diff --git a/PROMS/DotNetBar Source Code/AdvPropertyGrid.ico b/PROMS/DotNetBar Source Code/AdvPropertyGrid.ico
new file mode 100644
index 00000000..3c3bd614
Binary files /dev/null and b/PROMS/DotNetBar Source Code/AdvPropertyGrid.ico differ
diff --git a/PROMS/DotNetBar Source Code/AdvTree.ico b/PROMS/DotNetBar Source Code/AdvTree.ico
new file mode 100644
index 00000000..32a570b6
Binary files /dev/null and b/PROMS/DotNetBar Source Code/AdvTree.ico differ
diff --git a/PROMS/DotNetBar Source Code/AdvTree/AdvTree.cs b/PROMS/DotNetBar Source Code/AdvTree/AdvTree.cs
new file mode 100644
index 00000000..1433f472
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/AdvTree.cs
@@ -0,0 +1,9872 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.AdvTree.Display;
+using DevComponents.AdvTree.Layout;
+using System.Xml;
+using System.IO;
+using DevComponents.DotNetBar;
+using System.Runtime.Serialization;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+#if FRAMEWORK20
+using System.Collections.Generic;
+using System.Text;
+using System.Globalization;
+using System.Security;
+#endif
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents advanced multi-column Tree control.
+ ///
+ [ToolboxItem(true), DefaultEvent("Click"), System.Runtime.InteropServices.ComVisible(false), Designer("DevComponents.AdvTree.Design.AdvTreeDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), ToolboxBitmap(typeof(ToolboxIconResFinder), "AdvTree.ico")]
+ public class AdvTree : System.Windows.Forms.ScrollableControl, INodeNotify, ISupportInitialize
+ {
+ #region Private Variables
+ private bool _DisposeNodes = true;
+ private ElementStyleCollection m_Styles = new ElementStyleCollection();
+ private ColumnHeaderCollection m_Columns = new ColumnHeaderCollection();
+ private NodeCollection m_Nodes = new NodeCollection();
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.Container components = null;
+
+ private ElementStyle m_CellStyleDefault = null;
+ private ElementStyle m_CellStyleMouseDown = null;
+ private ElementStyle m_CellStyleMouseOver = null;
+ private ElementStyle m_CellStyleSelected = null;
+ private ElementStyle m_CellStyleDisabled = null;
+ private ElementStyle m_NodeStyleExpanded = null;
+ private ElementStyle m_NodeStyle = null;
+ private ElementStyle m_NodeStyleSelected = null;
+ private ElementStyle m_NodeStyleMouseOver = null;
+
+ private ElementStyle m_ColumnStyleNormal = null;
+ private ElementStyle m_ColumnStyleMouseOver = null;
+ private ElementStyle m_ColumnStyleMouseDown = null;
+
+ private Layout.NodeLayout m_NodeLayout = null;
+ private NodeDisplay m_NodeDisplay = null;
+
+ private HeadersCollection m_Headers = null;
+
+ private string m_PathSeparator = System.IO.Path.PathSeparator.ToString();
+
+ private int m_UpdateSuspended = 0;
+ private bool m_PendingLayout = false;
+ private bool m_SuspendPaint = false;
+
+ private Node m_SelectedNode = null;
+ private SelectedNodesCollection m_SelectedNodes = new SelectedNodesCollection();
+ //private Cell m_SelectedCell=null;
+ private Node m_MouseOverNode = null;
+ private Cell m_MouseOverCell = null;
+ private int m_CellMouseDownCounter = 0;
+
+ private ImageList m_ImageList = null;
+ private int m_ImageIndex = -1;
+ private bool m_AntiAlias = true;
+
+ //private NodeConnector m_RootConnector=null;
+ private NodeConnector m_NodesConnector = null;
+ private NodeConnector m_LinkConnector = null;
+ private NodeConnector m_SelectedPathConnector = null;
+ private eCellLayout m_CellLayout = eCellLayout.Default;
+ private eCellPartLayout m_CellPartLayout = eCellPartLayout.Default;
+ private Cursor m_OriginalCursor = null;
+ private Cursor m_DefaultCellCursor = null;
+ private ColorScheme m_ColorScheme = null;
+ private bool m_CenterContent = true;
+
+ // Selection box properties
+ private bool m_SelectionBox = true;
+ private int m_SelectionBoxSize = 4;
+ //private Color m_SelectionBoxBorderColor=Color.Empty;
+ //private Color m_SelectionBoxFillColor=Color.Empty;
+
+ // Expand Part Properties
+ private Size m_DefaultExpandPartSize = new Size(8, 8);
+ private Size m_ExpandButtonSize = Size.Empty;
+ private Color m_ExpandBorderColor = Color.Empty;
+ private eColorSchemePart m_ExpandBorderColorSchemePart = eColorSchemePart.None;
+ private Color m_ExpandBackColor = Color.Empty;
+ private eColorSchemePart m_ExpandBackColorSchemePart = eColorSchemePart.None;
+ private Color m_ExpandBackColor2 = Color.Empty;
+ private eColorSchemePart m_ExpandBackColor2SchemePart = eColorSchemePart.None;
+ private int m_ExpandBackColorGradientAngle = 0;
+ private Color m_ExpandLineColor = Color.Empty;
+ private eColorSchemePart m_ExpandLineColorSchemePart = eColorSchemePart.None;
+ private Image m_ExpandImage = null;
+ private Image m_ExpandImageCollapse = null;
+ private eExpandButtonType m_ExpandButtonType = eExpandButtonType.Rectangle;
+
+ private Node m_DisplayRootNode = null;
+
+ // Command button properties
+ private int m_CommandWidth = 10;
+ private Color m_CommandBackColor = Color.Empty;
+ private eColorSchemePart m_CommandBackColorSchemePart = eColorSchemePart.CustomizeBackground;
+ private Color m_CommandBackColor2 = Color.Empty;
+ private eColorSchemePart m_CommandBackColor2SchemePart = eColorSchemePart.CustomizeBackground2;
+ private Color m_CommandForeColor = Color.Empty;
+ private eColorSchemePart m_CommandForeColorSchemePart = eColorSchemePart.CustomizeText;
+ private int m_CommandBackColorGradientAngle = 90;
+ private Color m_CommandMouseOverBackColor = Color.Empty;
+ private eColorSchemePart m_CommandMouseOverBackColorSchemePart = eColorSchemePart.ItemHotBackground;
+ private Color m_CommandMouseOverBackColor2 = Color.Empty;
+ private eColorSchemePart m_CommandMouseOverBackColor2SchemePart = eColorSchemePart.ItemHotBackground2;
+ private Color m_CommandMouseOverForeColor = Color.Empty;
+ private eColorSchemePart m_CommandMouseOverForeColorSchemePart = eColorSchemePart.ItemHotText;
+ private int m_CommandMouseOverBackColorGradientAngle = 90;
+
+ // Cell editing support
+ private bool m_CellEdit = false;
+ private bool m_CellEditing = false;
+ private Cell m_EditedCell = null;
+ private TextBoxEx m_EditTextBox = null;
+
+ // Drag & Drop
+ private bool m_DragDropEnabled = true;
+ private Node m_DragNode = null;
+ private Point m_MouseDownLocation = Point.Empty;
+
+ // Layout
+ private eNodeLayout m_Layout = eNodeLayout.Map;
+ private int m_NodeHorizontalSpacing = 32;
+ private int m_NodeVerticalSpacing = 32;
+ private eDiagramFlow m_DiagramLayoutFlow = eDiagramFlow.LeftToRight;
+ private eMapFlow m_MapLayoutFlow = eMapFlow.Spread;
+
+ private ElementStyle m_BackgroundStyle = new ElementStyle();
+ private eNodeRenderMode m_RenderMode = eNodeRenderMode.Default;
+ private TreeRenderer m_NodeRenderer = null;
+
+ private ArrayList m_HostedControlCells = new ArrayList();
+ private float m_ZoomFactor = 1f;
+ private object m_DotNetBarManager = null;
+
+ private DevComponents.DotNetBar.VScrollBarAdv _VScrollBar = null;
+ private DevComponents.DotNetBar.ScrollBar.HScrollBarAdv _HScrollBar = null;
+ private Control _Thumb = null;
+ private ColumnHeaderControl _ColumnHeader = null;
+ private ArrayList _FullRowBackgroundNodes = null;
+ private DevComponents.AdvTree.Layout.LayoutSettings _LayoutSettings = new DevComponents.AdvTree.Layout.LayoutSettings();
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs just before cell editor is released for editing. It allows you to customize any properties on edit control.
+ ///
+ [Description(" Occurs just before cell editor is released for editing. It allows you to customize any properties on edit control.")]
+ public event PrepareCellEditorEventHandler PrepareCellEditorControl;
+ ///
+ /// Occurs when mouse button is pressed over the column header.
+ ///
+ public event MouseEventHandler ColumnHeaderMouseDown;
+ ///
+ /// Occurs when mouse button is released over the column header.
+ ///
+ public event MouseEventHandler ColumnHeaderMouseUp;
+ ///
+ /// Occurs after the cell check box is checked.
+ ///
+ public event AdvTreeCellEventHandler AfterCheck;
+
+ ///
+ /// Occurs before the cell check box is checked and provides opportunity to cancel the event.
+ ///
+ public event AdvTreeCellBeforeCheckEventHandler BeforeCheck;
+
+ ///
+ /// Occurs after the tree node is collapsed.
+ ///
+ public event AdvTreeNodeEventHandler AfterCollapse;
+
+ ///
+ /// Occurs before the tree node is collapsed.
+ ///
+ public event AdvTreeNodeCancelEventHandler BeforeCollapse;
+
+ ///
+ /// Occurs after the tree node is expanded.
+ ///
+ public event AdvTreeNodeEventHandler AfterExpand;
+
+ ///
+ /// Occurs before the tree node is expanded.
+ ///
+ public event AdvTreeNodeCancelEventHandler BeforeExpand;
+
+ ///
+ /// Occurs when command button on node is clicked.
+ ///
+ public event CommandButtonEventHandler CommandButtonClick;
+
+ ///
+ /// Occurs before cell is edited. The order of the cell editing events is as follows:
+ /// BeforeCellEdit, CellEditEnding, AfterCellEdit, AfterCellEditComplete.
+ ///
+ public event CellEditEventHandler BeforeCellEdit;
+ ///
+ /// Occurs just before the cell editing is ended. The text box for editing is still visible and you can cancel
+ /// the exit out of editing mode at this point. The order of the cell editing events is as follows:
+ /// BeforeCellEdit, CellEditEnding, AfterCellEdit, AfterCellEditComplete.
+ ///
+ public event CellEditEventHandler CellEditEnding;
+ ///
+ /// Occurs after cell editing has ended and before the new text entered by the user is assigned to the cell. You can abort the edits in this event.
+ /// The order of the cell editing events is as follows:
+ /// BeforeCellEdit, CellEditEnding, AfterCellEdit, AfterCellEditComplete.
+ ///
+ public event CellEditEventHandler AfterCellEdit;
+
+ ///
+ /// Occurs after cell editing has been completed. This event cannot be canceled.
+ ///
+ public event CellEditEventHandler AfterCellEditComplete;
+ ///
+ /// Occurs after node selection has changed.
+ ///
+ public event EventHandler SelectionChanged;
+ ///
+ /// Occurs before Node has been selected by user or through the SelectedNode property. Event can be cancelled.
+ ///
+ public event AdvTreeNodeCancelEventHandler BeforeNodeSelect;
+
+ ///
+ /// Occurs after node has been selected by user or through the SelectedNode property.
+ ///
+ public event AdvTreeNodeEventHandler AfterNodeSelect;
+
+ ///
+ /// Occurs after node has been deselected by user or through the SelectedNode or SelectedNodes properties.
+ ///
+ public event AdvTreeNodeEventHandler AfterNodeDeselect;
+
+ ///
+ /// Occurs before node has been removed from its parent.
+ ///
+ public event TreeNodeCollectionEventHandler BeforeNodeRemove;
+
+ ///
+ /// Occurs after node has been removed from its parent.
+ ///
+ public event TreeNodeCollectionEventHandler AfterNodeRemove;
+
+ ///
+ /// Occurs before node is inserted or added as child node to parent node.
+ ///
+ public event TreeNodeCollectionEventHandler BeforeNodeInsert;
+
+ ///
+ /// Occurs after node is inserted or added as child node.
+ ///
+ public event TreeNodeCollectionEventHandler AfterNodeInsert;
+
+ ///
+ /// Occurs when node drag & drop operation is initiated.
+ ///
+ [Description("Occurs when node drag & drop operation is initiated.")]
+ public event EventHandler NodeDragStart;
+ ///
+ /// Occurs before internal node drag & drop support is initiated and allows you to cancel the drag & drop.
+ ///
+ public event AdvTreeNodeCancelEventHandler BeforeNodeDragStart;
+ ///
+ /// Occurs before Drag-Drop of a node is completed and gives you information about new parent of the node that is being dragged
+ /// as well as opportunity to cancel the operation.
+ ///
+ public event TreeDragDropEventHandler BeforeNodeDrop;
+
+ ///
+ /// Occurs while node is being dragged. You can handle this event to disable the drop at specific nodes or to even change the
+ /// drop location for the node by modifying event arguments.
+ ///
+ public event TreeDragFeedbackEventHander NodeDragFeedback;
+
+ ///
+ /// Occurs after Drag-Drop of a node is completed. This operation cannot be cancelled.
+ ///
+ public event TreeDragDropEventHandler AfterNodeDrop;
+
+ ///
+ /// Occurs when the mouse pointer is over the node and a mouse button is pressed.
+ ///
+ public event TreeNodeMouseEventHandler NodeMouseDown;
+
+ ///
+ /// Occurs when the mouse pointer is over the node and a mouse button is released.
+ ///
+ public event TreeNodeMouseEventHandler NodeMouseUp;
+
+ ///
+ /// Occurs when the mouse pointer is moved over the node.
+ ///
+ public event TreeNodeMouseEventHandler NodeMouseMove;
+
+ ///
+ /// Occurs when the mouse enters the node.
+ ///
+ public event TreeNodeMouseEventHandler NodeMouseEnter;
+
+ ///
+ /// Occurs when the mouse leaves the node.
+ ///
+ public event TreeNodeMouseEventHandler NodeMouseLeave;
+
+ ///
+ /// Occurs when the mouse hovers over the node.
+ ///
+ public event TreeNodeMouseEventHandler NodeMouseHover;
+
+ ///
+ /// Occurs when the node is clicked with left mouse button. If you need to know more information like if another mouse button is clicked etc. use
+ /// NodeMouseDown event.
+ ///
+ public event TreeNodeMouseEventHandler NodeClick;
+
+ ///
+ /// Occurs when the node is double-clicked.
+ ///
+ public event TreeNodeMouseEventHandler NodeDoubleClick;
+
+ ///
+ /// Occurs after an node has been serialized to XmlElement and provides you with opportunity to add any custom data
+ /// to serialized XML. This allows you to serialize any data associated with the node and load it back up in DeserializeNode event.
+ ///
+ ///
+ /// To serialize custom data to XML definition control creates handle this event and use CustomXmlElement
+ /// property on SerializeNodeEventArgs to add new nodes or set attributes with custom data you want saved.
+ ///
+ public event SerializeNodeEventHandler SerializeNode;
+
+ ///
+ /// Occurs after an node has been de-serialized (loaded) from XmlElement and provides you with opportunity to load any custom data
+ /// you have serialized during SerializeItem event.
+ ///
+ ///
+ /// To de-serialize custom data from XML definition handle this event and use CustomXmlElement
+ /// property on SerializeItemEventArgs to retrieve any data you saved in SerializeNode event.
+ ///
+ public event SerializeNodeEventHandler DeserializeNode;
+
+ ///
+ /// Occurs when hyperlink in text-markup is clicked.
+ ///
+ public event MarkupLinkClickEventHandler MarkupLinkClick;
+
+ ///
+ /// Occurs when cell with custom editor type is about to be edited by user. Handle this event to provide
+ /// custom editors.
+ ///
+ public event CustomCellEditorEventHandler ProvideCustomCellEditor;
+
+#if FRAMEWORK20
+ ///
+ /// Occurs when the DataSource changes.
+ ///
+ [Description("Occurs when the DataSource changes.")]
+ public event EventHandler DataSourceChanged;
+ ///
+ /// Occurs when the DisplayMembers property changes.
+ ///
+ [Description("Occurs when the DisplayMembers property changes")]
+ public event EventHandler DisplayMembersChanged;
+ ///
+ /// Occurs when the control is bound to a data value that need to be converted.
+ ///
+ [Description("Occurs when the control is bound to a data value that need to be converted.")]
+ public event DevComponents.DotNetBar.Controls.TreeConvertEventHandler Format;
+ ///
+ /// Occurs when FormattingEnabled property changes.
+ ///
+ [Description("Occurs when FormattingEnabled property changes.")]
+ public event EventHandler FormattingEnabledChanged;
+ ///
+ /// Occurs when FormatString property changes.
+ ///
+ [Description("Occurs when FormatString property changes.")]
+ public event EventHandler FormatStringChanged;
+ ///
+ /// Occurs when FormatInfo property has changed.
+ ///
+ [Description("Occurs when FormatInfo property has changed.")]
+ public event EventHandler FormatInfoChanged;
+ ///
+ /// Occurs when a Node for an data-bound object item has been created and provides you with opportunity to modify the node.
+ ///
+ [Description("Occurs when a Node for an data-bound object item has been created and provides you with opportunity to modify the node")]
+ public event DevComponents.DotNetBar.Controls.DataNodeEventHandler DataNodeCreated;
+ ///
+ /// Occurs when a group Node is created as result of GroupingMembers property setting and provides you with opportunity to modify the node.
+ ///
+ [Description("Occurs when a group Node is created as result of GroupingMembers property setting and provides you with opportunity to modify the node")]
+ public event DevComponents.DotNetBar.Controls.DataNodeEventHandler GroupNodeCreated;
+ ///
+ /// Occurs when value of ValueMember property has changed.
+ ///
+ [Description("Occurs when value of ValueMember property has changed.")]
+ public event EventHandler ValueMemberChanged;
+ ///
+ /// Occurs when value of SelectedValue property has changed.
+ ///
+ [Description("Occurs when value of SelectedValue property has changed.")]
+ public event EventHandler SelectedValueChanged;
+ ///
+ /// Occurs when value of SelectedIndex property has changed.
+ ///
+ [Description("Occurs when value of SelectedValue property has changed.")]
+ public event EventHandler SelectedIndexChanged;
+ ///
+ /// Occurs when ColumnHeader is automatically created by control as result of data binding and provides you with opportunity to modify it.
+ ///
+ [Description("Occurs when ColumnHeader is automatically created by control as result of data binding and provides you with opportunity to modify it.")]
+ public event DevComponents.DotNetBar.Controls.DataColumnEventHandler DataColumnCreated;
+#endif
+ ///
+ /// Occurs after column has been resized by end-user.
+ ///
+ [Description("Occurs after column has been resized by end-user")]
+ public event EventHandler ColumnResized;
+ ///
+ /// Occurs while column is being resized by end-user.
+ ///
+ [Description("Occurs while column is being resized by end-user.")]
+ public event EventHandler ColumnResizing;
+
+ ///
+ /// Occurs after cell has been selected.
+ ///
+ [Description("Occurs after cell has been selected.")]
+ public event AdvTreeCellEventHandler CellSelected;
+ ///
+ /// Occurs after cell has been unselected.
+ ///
+ [Description("Occurs after cell has been unselected.")]
+ public event AdvTreeCellEventHandler CellUnselected;
+ ///
+ /// Occurs after users has moved the column.
+ ///
+ [Description("Occurs after users has moved the column.")]
+ public event ColumnMovedHandler ColumnMoved;
+ ///
+ /// Occurs while tree control is being rendered.
+ ///
+ [Description("Occurs while tree control is being rendered.")]
+ public event AdvTreeRenderEventHandler Render;
+ ///
+ /// Raises Render event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnRender(AdvTreeRenderEventArgs e)
+ {
+ AdvTreeRenderEventHandler handler = Render;
+ if (handler != null)
+ handler(this, e);
+ }
+ internal void InvokeRenderEvent(AdvTreeRenderEventArgs e)
+ {
+ OnRender(e);
+ }
+ #endregion
+
+ #region Constructor/Dispose
+ /// Creates new instance of the class.
+ public AdvTree()
+ {
+ if (!ColorFunctions.ColorsLoaded)
+ {
+ NativeFunctions.RefreshSettings();
+ NativeFunctions.OnDisplayChange();
+ ColorFunctions.LoadColors();
+ }
+ m_SelectedNodes.TreeSelectionControl = this;
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(ControlStyles.DoubleBuffer, true);
+ this.SetStyle(ControlStyles.Selectable, true);
+
+ // This call is required by the Windows.Forms Form Designer.
+ InitializeComponent();
+
+ m_BackgroundStyle.StyleChanged += new EventHandler(ElementStyleChanged);
+ m_BackgroundStyle.TreeControl = this;
+
+ m_Columns.Parent = this;
+
+ // Setup layout helper
+ m_NodeLayout = new NodeTreeLayout(this, this.ClientRectangle, _LayoutSettings);
+ _LayoutSettings.NodeVerticalSpacing = _NodeSpacing;
+
+ m_NodeLayout.LeftRight = this.RtlTranslateLeftRight(LeftRightAlignment.Left);
+
+#if TRIAL
+ NodeOperations.ColorExpAlt();
+#endif
+ // Setup display helper
+ m_NodeDisplay = new NodeTreeDisplay(this);
+
+ m_Headers = new HeadersCollection();
+
+ m_Nodes.TreeControl = this;
+ m_Styles.TreeControl = this;
+
+ m_ColorScheme = new ColorScheme(eColorSchemeStyle.Office2007);
+
+ //m_SelectionBoxBorderColor=GetDefaultSelectionBoxBorderColor();
+ //m_SelectionBoxFillColor=GetDefaultSelectionBoxFillColor();
+
+ m_ExpandButtonSize = GetDefaultExpandButtonSize();
+
+ this.AllowDrop = true;
+ this.IsAccessible = true;
+
+ if (BarFunctions.IsWindows7 && DevComponents.DotNetBar.Touch.TouchHandler.IsTouchEnabled)
+ {
+ _TouchHandler = new DevComponents.DotNetBar.Touch.TouchHandler(this, DevComponents.DotNetBar.Touch.eTouchHandlerType.Gesture);
+ _TouchHandler.PanBegin += new EventHandler(TouchHandlerPanBegin);
+ _TouchHandler.Pan += new EventHandler(TouchHandlerPan);
+ _TouchHandler.PanEnd += new EventHandler(TouchHandlerPanEnd);
+ }
+ }
+
+ private bool _Disposed = false;
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ _Disposed = true;
+ if (disposing)
+ {
+ if (components != null)
+ components.Dispose();
+
+ System.Windows.Forms.Timer timer = _SearchBufferExpireTimer;
+ _SearchBufferExpireTimer = null;
+ if (timer != null)
+ {
+ timer.Stop();
+ timer.Dispose();
+ }
+ }
+
+ if (BarUtilities.DisposeItemImages && !this.DesignMode)
+ {
+ BarUtilities.DisposeImage(ref _CheckBoxImageChecked);
+ BarUtilities.DisposeImage(ref _CheckBoxImageIndeterminate);
+ BarUtilities.DisposeImage(ref _CheckBoxImageUnChecked);
+ BarUtilities.DisposeImage(ref m_ExpandImage);
+ BarUtilities.DisposeImage(ref m_ExpandImageCollapse);
+ }
+
+ if (m_Nodes != null && disposing && _DisposeNodes)
+ {
+ Node[] nodes = new Node[m_Nodes.Count];
+ m_Nodes.CopyTo(nodes);
+ foreach (Node node in nodes)
+ node.Dispose();
+ //m_Nodes.Clear();
+ }
+
+ base.Dispose(disposing);
+ }
+ ///
+ /// Indicates whether nodes are disposed when control is disposed.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool DisposeNodes
+ {
+ get { return _DisposeNodes; }
+ set
+ {
+ _DisposeNodes = value;
+ }
+ }
+
+ #endregion
+
+ #region Component Designer generated code
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+ #endregion
+
+ #region Properties
+ [DefaultValue(true)]
+ public override bool AllowDrop {
+ get { return base.AllowDrop; }
+ set { base.AllowDrop = value; }
+ }
+
+ private bool _DeepSort = false;
+ ///
+ /// Indicates whether sorting of node collection sorts child nodes as well. Default value is false.
+ ///
+ [Browsable(false), DefaultValue(false), Category("Behavior"), Description("Indicates whether sorting of node collection sorts child nodes as well. Default value is false.")]
+ public bool DeepSort
+ {
+ get { return _DeepSort; }
+ set
+ {
+ _DeepSort = value;
+ }
+ }
+
+ private bool _ShowToolTips = true;
+ ///
+ /// Gets or sets whether tooltips are shown when mouse is over the cell when Tooltip property is set.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether tooltips are shown when mouse is over the cell when Tooltip property is set.")]
+ public bool ShowToolTips
+ {
+ get { return _ShowToolTips; }
+ set
+ {
+ _ShowToolTips = value;
+ }
+ }
+
+ ///
+ /// Gets the column header control which renderes the columns.
+ ///
+ internal ColumnHeaderControl ColumnHeaderControl
+ {
+ get { return _ColumnHeader; }
+ }
+ private eScrollBarAppearance _ScrollBarAppearance = eScrollBarAppearance.Default;
+ ///
+ /// Gets or sets the scroll-bar visual style.
+ ///
+ [DefaultValue(eScrollBarAppearance.Default), Category("Appearance"), Description("Gets or sets the scroll-bar visual style.")]
+ public eScrollBarAppearance ScrollBarAppearance
+ {
+ get { return _ScrollBarAppearance; }
+ set
+ {
+ _ScrollBarAppearance = value;
+ OnScrollBarAppearanceChanged();
+ }
+ }
+ private void OnScrollBarAppearanceChanged()
+ {
+ if (_VScrollBar != null) _VScrollBar.Appearance = _ScrollBarAppearance;
+ if (_HScrollBar != null) _HScrollBar.Appearance = _ScrollBarAppearance;
+ }
+
+ private Size _TileSize = new Size(184, 30);
+ ///
+ /// Gets or sets the proposed size of the tile in Tile view. The size of the tile might be larger than specified if Style assigned to node, cells adds padding, margins etc. or if Node.Image or font is greater than width or height specified here.
+ ///
+ [Category("Appearance"), Description("Indicates size of the tile in Tile view.")]
+ public Size TileSize
+ {
+ get { return _TileSize; }
+ set
+ {
+ if (value != _TileSize)
+ {
+ Size oldValue = _TileSize;
+ _TileSize = value;
+ OnTileSizeChanged(oldValue, value);
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTileSize()
+ {
+ return _TileSize.Width != 184 || _TileSize.Height != 30;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTileSize()
+ {
+ TileSize = new Size(184, 30);
+ }
+ private void OnTileSizeChanged(Size oldValue, Size newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("TileSize"));
+ if (_View == eView.Tile)
+ {
+ InvalidateNodesSize();
+ this.RecalcLayout();
+ }
+ }
+
+ private bool _HideSelection = false;
+ ///
+ /// Gets or sets a value indicating whether the selected tree node remains highlighted even when the tree control has lost the focus.
+ ///
+ [DefaultValue(false), Category("Selection"), Description("Indicates whether the selected tree node remains highlighted even when the tree control has lost the focus.")]
+ public bool HideSelection
+ {
+ get { return _HideSelection; }
+ set
+ {
+ _HideSelection = value;
+ if (this.SelectedNode != null && !this.IsKeyboardFocusWithin)
+ this.Invalidate();
+ }
+ }
+
+ private bool _IsKeyboardFocusWithin = false;
+ ///
+ /// Gets whether keyboard focus is within the control.
+ ///
+ [Browsable(false)]
+ public bool IsKeyboardFocusWithin
+ {
+ get { return _IsKeyboardFocusWithin; }
+#if FRAMEWORK20
+ internal set
+#else
+ set
+#endif
+ {
+ _IsKeyboardFocusWithin = value;
+ OnIsKeyboardFocusWithinChanged();
+ }
+ }
+ protected virtual void OnIsKeyboardFocusWithinChanged()
+ {
+ if (_IsKeyboardFocusWithin)
+ {
+ if (_MultiSelect)
+ {
+ foreach (Node node in m_SelectedNodes)
+ {
+ InvalidateNode(node);
+ }
+ }
+ else if (this.SelectedNode != null)
+ InvalidateNode(this.SelectedNode);
+ }
+ else
+ {
+ if (_MultiSelect)
+ {
+ foreach (Node node in m_SelectedNodes)
+ {
+ InvalidateNode(node);
+ }
+ }
+ else if (this.SelectedNode != null)
+ InvalidateNode(this.SelectedNode);
+
+ if (m_CellEditing && _EndCellEditingOnLostFocus)
+ EndCellEditing(eTreeAction.Keyboard);
+ }
+ }
+
+ private bool _EndCellEditingOnLostFocus = true;
+ ///
+ /// Gets or sets whether cell editing is completed when control loses input focus. Default value is true.
+ ///
+ [DefaultValue(true), Category("Editing"), Description("Indicates whether cell editing is completed when control loses input focus. Default value is true.")]
+ public bool EndCellEditingOnLostFocus
+ {
+ get { return _EndCellEditingOnLostFocus; }
+ set
+ {
+ _EndCellEditingOnLostFocus = value;
+ }
+ }
+
+ protected override void OnEnter(EventArgs e)
+ {
+ this.IsKeyboardFocusWithin = true;
+ base.OnEnter(e);
+ }
+ protected override void OnLeave(EventArgs e)
+ {
+ this.IsKeyboardFocusWithin = false;
+ base.OnLeave(e);
+ }
+
+ internal ArrayList FullRowBackgroundNodes
+ {
+ get
+ {
+ return _FullRowBackgroundNodes;
+ }
+ set
+ {
+ _FullRowBackgroundNodes = value;
+ }
+ }
+
+ private ContextMenuBar _ContextMenuBar = null;
+ ///
+ /// Gets or sets the reference to DotNetBar ContextMenuBar component which is used to provide context menu for nodes. This property
+ /// is automatically maintained by AdvTree.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), DefaultValue(null), Browsable(false)]
+ public ContextMenuBar ContextMenuBar
+ {
+ get { return _ContextMenuBar; }
+ set { _ContextMenuBar = value; }
+ }
+
+ ///
+ /// Gets or sets zoom factor for the control. Default value is 1. To zoom display of the nodes for 20% set zoom factor to 1.2
+ /// To zoom view 2 times set zoom factor to 2. Value must be greater than 0. Zoom is supported only when non-column tree setup is used.
+ /// Please note that Zoom functionality is designed only for very special use cases and only for
+ /// plain tree control setup which does not use editing, alternating row colors, drag & drop or any other
+ /// advanced functionality.
+ ///
+ [Browsable(false), DefaultValue(1f), Category("Layout"), Description("Indicates zoom factor for the control.")]
+ public float Zoom
+ {
+ get { return m_ZoomFactor; }
+ set
+ {
+ if (value <= 0.1)
+ return;
+ m_ZoomFactor = value;
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets the size of the tree.
+ ///
+ [Browsable(false)]
+ public Size TreeSize
+ {
+ get
+ {
+ return new Size(m_NodeLayout.Width, m_NodeLayout.Height);
+ }
+ }
+
+ ///
+ /// Gets or sets custom node renderer. You can set this property to your custom renderer. When set the RenderMode should be set to Custom to enable
+ /// your custom renderer. To choose one of the system renderer use RenderMode property. Default value is null.
+ ///
+ [Browsable(false), Category("Style"), DefaultValue(null), Description("Indicates render mode used to render the node.")]
+ internal TreeRenderer NodeRenderer
+ {
+ get { return m_NodeRenderer; }
+ set
+ {
+ m_NodeRenderer = value;
+ OnDisplayChanged();
+ }
+ }
+ ///
+ /// Gets or sets the render mode used to render all nodes. Default value is eNodeRenderMode.Default which indicates that system default renderer is used.
+ /// Note that if you specify custom renderer you need to set AdvTree.NodeRenderer property to your custom renderer.
+ ///
+ [Browsable(true), Category("Style"), DefaultValue(eNodeRenderMode.Default), Description("Indicates render mode used to render the node.")]
+ internal eNodeRenderMode RenderMode
+ {
+ get { return m_RenderMode; }
+ set
+ {
+ m_RenderMode = value;
+ OnDisplayChanged();
+ }
+ }
+
+ ///
+ /// Gets the style for the background of the control.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Gets the style for the background of the control."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return m_BackgroundStyle; }
+ }
+
+ ///
+ /// Gets the current renderer used by the control.
+ ///
+ /// Reference to the TreeRenderer used by the control.
+ public TreeRenderer GetRenderer()
+ {
+ if (m_RenderMode == eNodeRenderMode.Default)
+ {
+ if (m_NodeDisplay is NodeTreeDisplay)
+ return ((NodeTreeDisplay)m_NodeDisplay).SystemRenderer;
+ return null;
+ }
+ else
+ return m_NodeRenderer;
+ }
+
+ ///
+ /// Gets or sets internal layout cell horizontal spacing. This property is for advanced internal use and you should not set it.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Advanced)]
+ public int CellHorizontalSpacing
+ {
+ get
+ {
+ return _LayoutSettings.CellHorizontalSpacing;
+ }
+ set
+ {
+ _LayoutSettings.CellHorizontalSpacing = value;
+ }
+ }
+
+ /////
+ ///// Gets or sets the flow of nodes when Diagram layout is used. Note that this setting applies only to Diagram layout type.
+ /////
+ //[Browsable(true),Category("Layout"),DefaultValue(eDiagramFlow.LeftToRight),Description("Indicates flow of nodes when Diagram layout is used.")]
+ //public eDiagramFlow DiagramLayoutFlow
+ //{
+ // get {return m_DiagramLayoutFlow;}
+ // set
+ // {
+ // m_DiagramLayoutFlow=value;
+ // OnLayoutChanged();
+ // }
+ //}
+
+ /////
+ ///// Gets or sets the flow of nodes when Map layout is used. Note that this setting applies only to Map layout type.
+ /////
+ //[Browsable(true),Category("Layout"),DefaultValue(eMapFlow.Spread),Description("Indicates flow of nodes when Map layout is used.")]
+ //public eMapFlow MapLayoutFlow
+ //{
+ // get {return m_MapLayoutFlow;}
+ // set
+ // {
+ // m_MapLayoutFlow=value;
+ // OnLayoutChanged();
+ // }
+ //}
+
+ /////
+ ///// Gets or sets the horizontal spacing in pixels between nodes. Default value is 32.
+ /////
+ //[Browsable(true),Category("Layout"),DefaultValue(32),Description("Indicates horizontal spacing in pixels between nodes.")]
+ //public int NodeHorizontalSpacing
+ //{
+ // get {return m_NodeHorizontalSpacing;}
+ // set
+ // {
+ // m_NodeHorizontalSpacing=value;
+ // OnLayoutChanged();
+ // }
+ //}
+
+ /////
+ ///// Gets or sets the vertical spacing in pixels between nodes. Default value is 16.
+ /////
+ //[Browsable(true),Category("Layout"),DefaultValue(32),Description("Indicates vertical spacing in pixels between nodes.")]
+ //public int NodeVerticalSpacing
+ //{
+ // get {return m_NodeVerticalSpacing;}
+ // set
+ // {
+ // m_NodeVerticalSpacing=value;
+ // OnLayoutChanged();
+ // }
+ //}
+
+ /////
+ ///// Gets or sets the layout type for the nodes.
+ /////
+ //[Browsable(true),Category("Layout"),DefaultValue(eNodeLayout.Map),Description("Indicates layout type for the nodes.")]
+ //public eNodeLayout LayoutType
+ //{
+ // get {return m_Layout;}
+ // set
+ // {
+ // if(m_Layout!=value)
+ // {
+ // SetLayout(value);
+ // }
+ // }
+ //}
+
+ ///
+ /// Gets or sets whether automatic drag and drop is enabled. Default value is true.
+ ///
+ [Browsable(true), Category("Behavior"), Description("Indicates whether automatic drag and drop is enabled."), DefaultValue(true)]
+ public bool DragDropEnabled
+ {
+ get { return m_DragDropEnabled; }
+ set { m_DragDropEnabled = value; }
+ }
+
+ ///
+ /// Creates the Graphics object for the control.
+ ///
+ /// The Graphics object for the control.
+ public new Graphics CreateGraphics()
+ {
+ Graphics g = base.CreateGraphics();
+ if (m_AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+#if FRAMEWORK20
+ if (!SystemInformation.IsFontSmoothingEnabled)
+#endif
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+ return g;
+ }
+
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting the tree.
+ ///
+ [DefaultValue(true), Browsable(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting the tree.")]
+ public bool AntiAlias
+ {
+ get { return m_AntiAlias; }
+ set
+ {
+ if (m_AntiAlias != value)
+ {
+ m_AntiAlias = value;
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the delimiter string that the tree node path uses.
+ ///
+ [DefaultValue("\\"), Browsable(false), Description("Indicates the delimiter string that the tree node path uses.")]
+ public string PathSeparator
+ {
+ get { return m_PathSeparator; }
+ set { m_PathSeparator = value; }
+ }
+
+ private bool _AllowUserToResizeColumns = true;
+ ///
+ /// Gets or sets whether user can resize the columns. Default value is true.
+ ///
+ [DefaultValue(true), Category("Columns"), Description("Indicates whether user can resize the columns.")]
+ public bool AllowUserToResizeColumns
+ {
+ get { return _AllowUserToResizeColumns; }
+ set
+ {
+ _AllowUserToResizeColumns = value;
+ }
+ }
+
+ private bool _AllowUserToReorderColumns = false;
+ ///
+ /// Gets or sets whether user can reorder the columns. Default value is false.
+ ///
+ [DefaultValue(false), Category("Columns"), Description("Indicates whether user can reorder the columns.")]
+ public bool AllowUserToReorderColumns
+ {
+ get { return _AllowUserToReorderColumns; }
+ set
+ {
+ _AllowUserToReorderColumns = value;
+ }
+ }
+
+
+ ///
+ /// Gets the collection of column headers that appear in the tree.
+ ///
+ ///
+ /// By default there are no column headers defined. In that case tree control
+ /// functions as regular tree control where text has unrestricted width.
+ /// If you want to restrict the horizontal width of the text but not display
+ /// column header you can create one column and set its width to the width desired and
+ /// set its Visible property to false.
+ ///
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Columns"), Description("Gets collection of column headers that appear in the tree.")]
+ public ColumnHeaderCollection Columns
+ {
+ get
+ {
+ return m_Columns;
+ }
+ }
+
+ private bool _ColumnsVisible = true;
+ ///
+ /// Gets or sets whether column headers are visible if they are defined through Columns collection. Default value is true.
+ ///
+ [DefaultValue(true), Category("Columns"), Description("Indicates whether column headers are visible if they are defined through Columns collection.")]
+ public bool ColumnsVisible
+ {
+ get { return _ColumnsVisible; }
+ set
+ {
+ if (_ColumnsVisible != value)
+ {
+ _ColumnsVisible = value;
+ if (m_Columns.Count > 0) RecalcLayout();
+ }
+ }
+ }
+
+ internal void SetColumnHeaderControlVisibility(bool visible)
+ {
+ if (visible)
+ {
+ if (_ColumnHeader == null)
+ {
+ _ColumnHeader = new ColumnHeaderControl();
+ _ColumnHeader.Columns = this.Columns;
+ this.Controls.Add(_ColumnHeader);
+ }
+ }
+ else if (_ColumnHeader != null)
+ {
+ _ColumnHeader.Columns = null;
+ this.Controls.Remove(_ColumnHeader);
+ _ColumnHeader.Dispose();
+ _ColumnHeader = null;
+ }
+ RepositionColumnHeader();
+ }
+
+ internal bool CanResizeColumnAt(int x, int y)
+ {
+ if (!m_Columns.Bounds.Contains(x, y)) return false;
+
+ ColumnHeader col = GetColumnForResizeAt(x, y, m_Columns, false);
+ return col != null;
+ }
+
+ internal ColumnHeader GetColumnAt(int x, int y, ColumnHeaderCollection columns)
+ {
+ Point p = new Point(x, y);
+ Point offset = Point.Empty;
+ if (AutoScroll)
+ {
+ offset = GetAutoScrollPositionOffset();
+ if (columns.ParentNode == null)
+ offset.Y = 0;
+ }
+
+ Rectangle columnsBounds = columns.Bounds;
+ columnsBounds.Offset(offset);
+ if (!columnsBounds.Contains(p)) return null;
+
+ foreach (ColumnHeader item in columns)
+ {
+ if (!item.Visible) continue;
+ Rectangle r = item.Bounds;
+ r.Offset(offset);
+ if (r.Contains(p))
+ return item;
+ }
+ return null;
+ }
+
+ private ColumnHeader GetColumnForResizeAt(int x, int y, ColumnHeaderCollection columns, bool ignoreY)
+ {
+ return GetColumnForResizeAt(x, y, columns, ignoreY, false);
+ }
+ private ColumnHeader GetColumnForResizeAt(int x, int y, ColumnHeaderCollection columns, bool ignoreY, bool ignoreLastColumn)
+ {
+ Point p = new Point(x, y);
+ Point offset = Point.Empty;
+ if (AutoScroll)
+ {
+ offset = GetAutoScrollPositionOffset();
+ if (columns.ParentNode == null)
+ offset.Y = 0;
+ }
+
+ Rectangle columnsBounds = columns.Bounds;
+ columnsBounds.Offset(offset);
+ if (!columnsBounds.Contains(p) && !ignoreY) return null;
+
+ int count = columns.Count - (ignoreLastColumn ? 1 : 0);
+ for (int i = 0; i < count; i++)
+ {
+ ColumnHeader item = columns[i];
+ Rectangle r = new Rectangle(item.Bounds.Right - 4, item.Bounds.Y, 6, item.Bounds.Height);
+ r.Offset(offset);
+ if (r.Contains(p) || ignoreY && p.X >= r.X && p.X <= r.Right)
+ return item;
+ }
+ return null;
+ }
+
+ private ColumnHeader _ColumnReorder = null;
+ private Cursor _OldCursor = null;
+ private int _ColumnMoveMarkerIndex = -1;
+ private int ColumnMoveMarkerIndex
+ {
+ get
+ {
+ return _ColumnMoveMarkerIndex;
+ }
+ set
+ {
+ if (_ColumnReorder == null) throw new ArgumentException("Column is not being reordered");
+ _ColumnMoveMarkerIndex = value;
+ if (_ColumnReorder.Parent == m_Columns)
+ _ColumnHeader.ColumnMoveMarkerIndex = value;
+ else
+ {
+ this.Invalidate(_ColumnReorder.Parent.Bounds);
+ }
+ }
+ }
+ internal void StartColumnReorder(int x, int y)
+ {
+ StartColumnReorder(x, y, m_Columns);
+ }
+ private void StartColumnReorder(int x, int y, ColumnHeaderCollection columns)
+ {
+ ColumnHeader col = GetColumnAt(x, y, columns);
+ if (col == null) return;
+ EndCellEditing(eTreeAction.Mouse);
+ _OldCursor = this.Cursor;
+ this.Cursor = Cursors.Hand;
+ this.Capture = true;
+ _ColumnReorder = col;
+ this.ColumnMoveMarkerIndex = columns.IndexOf(col);
+ this.Invalidate();
+ }
+
+ private ColumnHeader _ColumnResize = null;
+ internal void StartColumnResize(int x, int y)
+ {
+ StartColumnResize(x, y, m_Columns);
+ }
+
+ private void StartColumnResize(int x, int y, ColumnHeaderCollection columns)
+ {
+ ColumnHeader col = GetColumnForResizeAt(x, y, columns, _GridColumnLineResizeEnabled, false);
+ if (col == null) return;
+
+ this.Capture = true;
+ _ColumnResize = col;
+ }
+
+ ///
+ /// Gets the collection of all style elements created for the tree.
+ ///
+ [Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyleCollection Styles
+ {
+ get { return m_Styles; }
+ }
+
+ ///
+ /// Gets or sets default style for the node cell.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates default style for the node cell.")]
+ public ElementStyle CellStyleDefault
+ {
+ get { return m_CellStyleDefault; }
+ set
+ {
+ if (m_CellStyleDefault != value)
+ {
+ if (m_CellStyleDefault != null)
+ m_CellStyleDefault.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_CellStyleDefault = value;
+ this.OnCellStyleChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets default style for the node cell when mouse is pressed.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates default style for the node cell when mouse is pressed.")]
+ public ElementStyle CellStyleMouseDown
+ {
+ get { return m_CellStyleMouseDown; }
+ set
+ {
+ if (m_CellStyleMouseDown != value)
+ {
+ if (m_CellStyleMouseDown != null)
+ m_CellStyleMouseDown.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_CellStyleMouseDown = value;
+ this.OnCellStyleChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets default style for the node cell when mouse is over the cell.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates default style for the node cell when mouse is over the cell.")]
+ public ElementStyle CellStyleMouseOver
+ {
+ get { return m_CellStyleMouseOver; }
+ set
+ {
+ if (m_CellStyleMouseOver != value)
+ {
+ if (m_CellStyleMouseOver != null)
+ m_CellStyleMouseOver.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_CellStyleMouseOver = value;
+ this.OnCellStyleChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets default style for the node cell when cell is selected.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates default style for the node cell when cell is selected.")]
+ public ElementStyle CellStyleSelected
+ {
+ get { return m_CellStyleSelected; }
+ set
+ {
+ if (m_CellStyleSelected != value)
+ {
+ if (m_CellStyleSelected != null)
+ m_CellStyleSelected.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_CellStyleSelected = value;
+ this.OnCellStyleChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets default style for the node cell when cell is disabled.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates default style for the node cell when cell is disabled.")]
+ public ElementStyle CellStyleDisabled
+ {
+ get { return m_CellStyleDisabled; }
+ set
+ {
+ if (m_CellStyleDisabled != value)
+ {
+ if (m_CellStyleDisabled != null)
+ m_CellStyleDisabled.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_CellStyleDisabled = value;
+ this.OnCellStyleChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets default style for the node when node is expanded.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Gets or sets default style for the node cell when node that cell belongs to is expanded.")]
+ public ElementStyle NodeStyleExpanded
+ {
+ get { return m_NodeStyleExpanded; }
+ set
+ {
+ if (m_NodeStyleExpanded != value)
+ {
+ if (m_NodeStyleExpanded != null)
+ m_NodeStyleExpanded.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_NodeStyleExpanded = value;
+ this.OnCellStyleChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets default style for all nodes where style is not specified
+ /// explicity.
+ ///
+ ///
+ /// Name of the style assigned or null value indicating that no style is used.
+ /// Default value is null.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Gets or sets default style for the node.")]
+ public ElementStyle NodeStyle
+ {
+ get { return m_NodeStyle; }
+ set
+ {
+ if (m_NodeStyle != value)
+ {
+ if (m_NodeStyle != null)
+ m_NodeStyle.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_NodeStyle = value;
+ this.OnCellStyleChanged();
+ }
+ }
+ }
+ ///
+ /// Gets or sets style for the node when node is selected. Note that this style is applied to the default node style.
+ ///
+ ///
+ /// Reference to the style assigned or null value indicating that no style is used.
+ /// Default value is null.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Gets or sets style of the node when node is selected.")]
+ public ElementStyle NodeStyleSelected
+ {
+ get { return m_NodeStyleSelected; }
+ set
+ {
+ if (m_NodeStyleSelected != value)
+ {
+ if (m_NodeStyleSelected != null)
+ m_NodeStyleSelected.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_NodeStyleSelected = value;
+ this.OnCellStyleChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets style for the node when mouse is over node. Note that this style is applied to the default node style.
+ ///
+ ///
+ /// Reference to the style assigned or null value indicating that no style is used.
+ /// Default value is null.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Gets or sets style of the node when mouse is over node.")]
+ public ElementStyle NodeStyleMouseOver
+ {
+ get { return m_NodeStyleMouseOver; }
+ set
+ {
+ if (m_NodeStyleMouseOver != value)
+ {
+ if (m_NodeStyleMouseOver != null)
+ m_NodeStyleMouseOver.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_NodeStyleMouseOver = value;
+ this.OnCellStyleChanged();
+ }
+ }
+ }
+
+
+ ///
+ /// Gets the collection of tree nodes that are assigned to the tree view control.
+ ///
+ ///
+ /// A NodeCollection that represents the tree nodes
+ /// assigned to the tree control.
+ ///
+ ///
+ /// The Nodes property holds a collection of Node objects, each of which has a
+ /// Nodes property that can contain its own NodeCollection.
+ ///
+ [Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Description("Gets the collection of tree nodes that are assigned to the tree control.")]
+ public NodeCollection Nodes
+ {
+ get { return m_Nodes; }
+ }
+
+ private int _NodeSpacing = 3;
+ ///
+ /// Gets or sets the vertical spacing between nodes in pixels. Default value is 3.
+ ///
+ [DefaultValue(3), Description("Indicates vertical spacing between nodes in pixels."), Category("Layout")]
+ public int NodeSpacing
+ {
+ get { return _NodeSpacing; }
+ set
+ {
+ _NodeSpacing = value;
+ _LayoutSettings.NodeVerticalSpacing = value;
+ this.InvalidateNodesSize();
+ this.RecalcLayout();
+ }
+ }
+ ///
+ /// Gets or sets the horizontal spacing between nodes in pixels when control is in Tile layout. Default value is 4.
+ ///
+ [DefaultValue(4), Description("Indicates horizontal spacing between nodes in pixels when control is in Tile layout."), Category("Layout")]
+ public int NodeHorizontalSpacing
+ {
+ get { return _LayoutSettings.NodeHorizontalSpacing; }
+ set
+ {
+ if (value != _LayoutSettings.NodeHorizontalSpacing)
+ {
+ _LayoutSettings.NodeHorizontalSpacing = value;
+ this.InvalidateNodesSize();
+ this.RecalcLayout();
+ }
+ }
+ }
+
+ private bool _GridRowLines = false;
+ ///
+ /// Gets or sets whether horizontal grid lines between each row are displayed. Default value is false.
+ ///
+ [DefaultValue(false), Category("Columns"), Description("")]
+ public bool GridRowLines
+ {
+ get { return _GridRowLines; }
+ set
+ {
+ if (_GridRowLines != value)
+ {
+ _GridRowLines = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ private bool _GridColumnLineResizeEnabled = false;
+ ///
+ /// Gets or sets whether column can be resized when mouse is over the column grid line and outside of the column header.
+ /// GridColumnLines must be set to true to make column lines visible.
+ ///
+ [DefaultValue(false), Category("Columns"), Description("Indicates whether column can be resized when mouse is over the column grid line and outside of the column header.")]
+ public bool GridColumnLineResizeEnabled
+ {
+ get { return _GridColumnLineResizeEnabled; }
+ set
+ {
+ _GridColumnLineResizeEnabled = value;
+ }
+ }
+
+ private bool _GridLines = true;
+ ///
+ /// Gets or sets whether grid lines are displayed when columns are defined. Default value is true.
+ ///
+ [DefaultValue(true), Category("Columns"), Description("Indicates whether grid lines are displayed when columns are defined.")]
+ public bool GridColumnLines
+ {
+ get { return _GridLines; }
+ set
+ {
+ if (_GridLines != value)
+ {
+ _GridLines = value;
+ if (m_Columns.Count > 0 && _ColumnsVisible)
+ this.Invalidate();
+ }
+ }
+ }
+
+ private Color _GridLinesColor = Color.Empty;
+ ///
+ /// Gets or sets the grid lines color.
+ ///
+ [Category("Columns"), Description("Indicates grid lines color.")]
+ public Color GridLinesColor
+ {
+ get { return _GridLinesColor; }
+ set { _GridLinesColor = value; this.Invalidate(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeGridLinesColor()
+ {
+ return !_GridLinesColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetGridLinesColor()
+ {
+ this.GridLinesColor = Color.Empty;
+ }
+
+ private Color _AlternateRowColor = Color.Empty;
+ ///
+ /// Gets or sets the alternate row color applied to every other row. Default value is Color.Empty.
+ ///
+ [Category("Columns"), Description("Indicates alternate row color applied to every other row.")]
+ public Color AlternateRowColor
+ {
+ get { return _AlternateRowColor; }
+ set
+ {
+ _AlternateRowColor = value;
+ this.Invalidate();
+ }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAlternateRowColor()
+ {
+ return !_AlternateRowColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAlternateRowColor()
+ {
+ this.AlternateRowColor = Color.Empty;
+ }
+
+ private ElementStyle _NodesColumnsBackgroundStyle = null;
+ ///
+ /// Gets or sets the background style for the child nodes columns. Background style defines the appearance of the column header background.
+ ///
+ ///
+ /// Reference to the style assigned to the column header.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Column Header Style"), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the style class assigned to the child nodes columns.")]
+ public ElementStyle NodesColumnsBackgroundStyle
+ {
+ get { return _NodesColumnsBackgroundStyle; }
+ set
+ {
+ if (_NodesColumnsBackgroundStyle != null)
+ _NodesColumnsBackgroundStyle.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ _NodesColumnsBackgroundStyle = value;
+ }
+ }
+
+ private ElementStyle _ColumnsBackgroundStyle = null;
+ ///
+ /// Gets or sets the background style for the columns. Background style defines the appearance of the column header background.
+ ///
+ ///
+ /// Reference to the style assigned to the column header.
+ ///
+ /// ColumnStyleNormal Property
+ /// ColumnStyleMouseDown Property
+ /// ColumnStyleMouseOver Property
+ [Browsable(true), DefaultValue(null), Category("Column Header Style"), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the style class assigned to the column.")]
+ public ElementStyle ColumnsBackgroundStyle
+ {
+ get { return _ColumnsBackgroundStyle; }
+ set
+ {
+ if (_ColumnsBackgroundStyle != null)
+ _ColumnsBackgroundStyle.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ _ColumnsBackgroundStyle = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the default style class assigned to the column headers.
+ ///
+ ///
+ /// Reference to the style assigned to the column header.
+ ///
+ ///
+ /// When style is not set on ColumnHeader objects then style setting from this property is used instead.
+ ///
+ /// ColumnStyleMouseDown Property
+ /// ColumnStyleMouseOver Property
+ [Browsable(true), DefaultValue(null), Category("Column Header Style"), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the style class assigned to the column.")]
+ public ElementStyle ColumnStyleNormal
+ {
+ get { return m_ColumnStyleNormal; }
+ set
+ {
+ if (m_ColumnStyleNormal != null)
+ m_ColumnStyleNormal.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_ColumnStyleNormal = value;
+ }
+ }
+
+ ///
+ /// Gets or sets default style class assigned to the column which is applied when mouse
+ /// button is pressed over the header.
+ ///
+ ///
+ /// Name of the style assigned to the column.
+ ///
+ ///
+ /// When style is not set on ColumnHeader objects then style setting from this property is used instead.
+ ///
+ /// ColumnStyleNormal Property
+ /// ColumnStyleMouseOver Property
+ [Browsable(true), DefaultValue(null), Category("Column Header Style"), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the style class assigned to the column when mouse is down.")]
+ public ElementStyle ColumnStyleMouseDown
+ {
+ get { return m_ColumnStyleMouseDown; }
+ set
+ {
+ if (m_ColumnStyleMouseDown != null)
+ m_ColumnStyleMouseDown.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_ColumnStyleMouseDown = value;
+ }
+ }
+
+ ///
+ /// Gets or sets default style class assigned to the column which is applied when mouse is
+ /// over the column.
+ ///
+ ///
+ /// Name of the style assigned to the column.
+ ///
+ ///
+ /// When style is not set on ColumnHeader objects then style setting from this property is used instead.
+ ///
+ /// ColumnStyleNormal Property
+ /// ColumnStyleMouseDown Property
+ [Browsable(true), DefaultValue(null), Category("Column Header Style"), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the style class assigned to the cell when mouse is over the column.")]
+ public ElementStyle ColumnStyleMouseOver
+ {
+ get { return m_ColumnStyleMouseOver; }
+ set
+ {
+ if (m_ColumnStyleMouseOver != null)
+ m_ColumnStyleMouseOver.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_ColumnStyleMouseOver = value;
+ }
+ }
+
+ ///
+ /// Gets collection that holds definition of column headers associated with nodes.
+ ///
+ [Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Description("Collection that holds definition of column headers associated with nodes.")]
+ internal HeadersCollection Headers
+ {
+ get { return m_Headers; }
+ }
+
+ ///
+ /// Gets or sets the tree node that is currently selected in the tree control.
+ ///
+ ///
+ /// If no Node is currently selected, the
+ /// SelectedNode property is a null reference (Nothing in Visual
+ /// Basic).
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Node SelectedNode
+ {
+ get
+ {
+ if (_MultiSelect && m_SelectedNodes.Count > 0)
+ return m_SelectedNodes[m_SelectedNodes.Count - 1];
+ return m_SelectedNode;
+ }
+ set
+ {
+ if (m_SelectedNode != value)
+ {
+ SelectNode(value, eTreeAction.Code);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the collection of currently selected nodes in tree control.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public NodeCollection SelectedNodes
+ {
+ get
+ {
+ return m_SelectedNodes;
+ }
+ }
+
+ private bool _MultiSelect = false;
+ ///
+ /// Gets or sets whether multi-node selection is enabled. Default value is false. When
+ /// multi-selection is enabled use SelectedNodes property to retrive collection of selected nodes.
+ /// Use MultiSelectRule property to change the multi-node selection rule.
+ ///
+ [DefaultValue(false), Category("Selection"), Description("Indicates whether multi-node selection is enabled.")]
+ public bool MultiSelect
+ {
+ get { return _MultiSelect; }
+ set
+ {
+ if (_MultiSelect != value)
+ {
+ if (_MultiSelect)
+ m_SelectedNodes.Clear();
+ _MultiSelect = value;
+ }
+ }
+ }
+
+ private eMultiSelectRule _MultiSelectRule = eMultiSelectRule.SameParent;
+ ///
+ /// Gets or sets the rule that governs the multiple node selection. Default value indicates that only nodes
+ /// belonging to same parent can be multi-selected.
+ ///
+ [DefaultValue(eMultiSelectRule.SameParent), Category("Selection"), Description("Indicates rule that governs the multiple node selection.")]
+ public eMultiSelectRule MultiSelectRule
+ {
+ get { return _MultiSelectRule; }
+ set { _MultiSelectRule = value; }
+ }
+
+ ///
+ /// Invalidates node bounds on canvas.
+ ///
+ /// Reference node.
+ internal void InvalidateNode(Node[] nodes)
+ {
+ foreach (Node node in nodes)
+ {
+ InvalidateNode(node);
+ }
+ }
+
+ ///
+ /// Invalidates node bounds on canvas.
+ ///
+ /// Reference node.
+ internal void InvalidateNode(Node node)
+ {
+ if (node == null)
+ return;
+
+ Rectangle r;
+ if (node == m_DragNode && m_DragNode.Parent == null)
+ r = m_DragNode.BoundsRelative;
+ else
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, node, m_NodeDisplay.Offset);
+ if (node.FullRowBackground)
+ {
+ r.Width = this.Width;
+ r.X = 0;
+ }
+
+ //if (m_SelectionBox)
+ {
+ r.Inflate(m_SelectionBoxSize, m_SelectionBoxSize);
+ if (_SelectionBoxStyle == eSelectionStyle.FullRowSelect)
+ {
+ r.X = this.ClientRectangle.X;
+ r.Width = this.ClientRectangle.Width;
+ }
+ }
+
+ if (this.NodeStyleMouseOver != null || this.CellStyleMouseOver != null || node.StyleMouseOver != null || this.NodeStyleMouseOver != null || _HotTracking)
+ r.Inflate(1, 1);
+
+ r = GetScreenRectangle(r);
+
+ this.Invalidate(r);
+ }
+
+ ///
+ /// Finds the node based on the Node.Name property.
+ ///
+ /// Name of the node to find.
+ /// Reference to a node with given name or null if node cannot be found.
+ public Node FindNodeByName(string name)
+ {
+ return NodeOperations.FindNodeByName(this, name);
+ }
+
+ ///
+ /// Finds the node based on the Node.DataKey property.
+ ///
+ /// Data key to look for.
+ /// Reference to a node with given key or null if node cannot be found.
+ public Node FindNodeByDataKey(object key)
+ {
+ return NodeOperations.FindNodeByDataKey(this, key);
+ }
+
+ ///
+ /// Finds the node based on the Node.BindingIndex property.
+ ///
+ /// Index to look for.
+ /// Reference to a node with given key or null if node cannot be found.
+ public Node FindNodeByBindingIndex(int bindingIndex)
+ {
+ return NodeOperations.FindNodeByBindingIndex(this, bindingIndex);
+ }
+
+ ///
+ /// Finds the first node that starts with the specified text. Node.Text property is searched.
+ ///
+ /// Partial text to look for
+ /// Reference to a node or null if no node is found.
+ public Node FindNodeByText(string text)
+ {
+ return NodeOperations.FindNodeByText(this, text, null, true);
+ }
+
+ ///
+ /// Finds the first node where each Node.Cell[0:n].Text value starts with the
+ /// respective value found in the comma delimited 'text' string.
+ ///
+ /// Comma delimited partial text to look for
+ /// Reference to a node or null if no node is found.
+ public Node FindNodeByCellText(string text)
+ {
+ return NodeOperations.FindNodeByCellText(this, text, null, true);
+ }
+
+ ///
+ /// Finds the first node that starts with the specified text. Node.Text property is searched.
+ ///
+ /// Partial text to look for
+ /// Controls whether case insensitive search is performed
+ /// Reference to a node or null if no node is found.
+ public Node FindNodeByText(string text, bool ignoreCase)
+ {
+ return NodeOperations.FindNodeByText(this, text, null, ignoreCase);
+ }
+
+ ///
+ /// Finds the first node where each Node.Cell[0:n].Text value starts with the
+ /// respective value found in the comma delimited 'text' string.
+ ///
+ /// Comma delimited partial text to look for
+ /// Controls whether case insensitive search is performed
+ /// Reference to a node or null if no node is found.
+ public Node FindNodeByCellText(string text, bool ignoreCase)
+ {
+ return NodeOperations.FindNodeByCellText(this, text, null, ignoreCase);
+ }
+
+ ///
+ /// Finds the first node that starts with the specified text. Node.Text property is searched.
+ ///
+ /// Partial text to look for
+ /// Reference node to start searching from
+ /// Controls whether case insensitive search is performed
+ /// Reference to a node or null if no node is found.
+ public Node FindNodeByText(string text, Node startFromNode, bool ignoreCase)
+ {
+ return NodeOperations.FindNodeByText(this, text, startFromNode, ignoreCase);
+ }
+
+ ///
+ /// Finds the first node where each Node.Cell[0:n].Text value starts with the
+ /// respective value found in the comma delimited 'text' string.
+ ///
+ /// Comma delimited partial text to look for
+ /// Reference node to start searching from
+ /// Controls whether case insensitive search is performed
+ /// Reference to a node or null if no node is found.
+ public Node FindNodeByCellText(string text, Node startFromNode, bool ignoreCase)
+ {
+ return NodeOperations.FindNodeByCellText(this, text, startFromNode, ignoreCase);
+ }
+
+ ///
+ /// Returns reference to node layout object.
+ ///
+ internal Layout.NodeLayout NodeLayout
+ {
+ get { return m_NodeLayout; }
+ }
+
+ ///
+ /// Returns reference to node display object.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
+ public NodeDisplay NodeDisplay
+ {
+ get { return m_NodeDisplay; }
+ }
+
+ ///
+ /// Gets whether layout is suspended for tree control. Layout is suspended after
+ /// call to BeginUpdate method and it is resumed after the
+ /// call to EndUpdate method.
+ ///
+ [Browsable(false)]
+ public bool IsUpdateSuspended
+ {
+ get { return (m_UpdateSuspended > 0); }
+ }
+
+ internal void SetPendingLayout()
+ {
+ m_PendingLayout = true;
+ }
+
+ ///
+ /// Gets whether control has layout operation pending on next paint or update.
+ ///
+ [Browsable(false)]
+ public bool IsLayoutPending
+ {
+ get { return m_PendingLayout; }
+ }
+
+
+ ///
+ /// Gets or sets whether paint operations are suspended for the control. You should use this method
+ /// if you need the RecalcLayout operations to proceed but you want to stop painting of the control.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool SuspendPaint
+ {
+ get { return m_SuspendPaint; }
+ set { m_SuspendPaint = value; }
+ }
+
+ ///
+ /// Gets or sets the ImageList that contains the Image objects used by the tree nodes.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Images"), Description("Indicates the ImageList that contains the Image objects used by the tree nodes.")]
+ public ImageList ImageList
+ {
+ get
+ {
+ return m_ImageList;
+ }
+ set
+ {
+ if (m_ImageList != null)
+ m_ImageList.Disposed -= new EventHandler(this.ImageListDisposed);
+ m_ImageList = value;
+ if (m_ImageList != null)
+ m_ImageList.Disposed += new EventHandler(this.ImageListDisposed);
+ }
+ }
+
+ ///
+ /// Gets or sets the image-list index value of the default image that is displayed by the tree nodes.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image-list index value of the default image that is displayed by the tree nodes."), Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), TypeConverter(typeof(ImageIndexConverter)), DefaultValue(-1)]
+ public int ImageIndex
+ {
+ get { return m_ImageIndex; }
+ set
+ {
+ if (m_ImageIndex != value)
+ {
+ m_ImageIndex = value;
+ }
+ }
+ }
+
+ private Image _CheckBoxImageChecked = null;
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box in cell is checked.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box in cell is checked")]
+ public Image CheckBoxImageChecked
+ {
+ get { return _CheckBoxImageChecked; }
+ set
+ {
+ _CheckBoxImageChecked = value;
+ OnCheckBoxImageChanged();
+ }
+ }
+ private Image _CheckBoxImageUnChecked = null;
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box in cell is unchecked.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box in cell is unchecked")]
+ public Image CheckBoxImageUnChecked
+ {
+ get { return _CheckBoxImageUnChecked; }
+ set
+ {
+ _CheckBoxImageUnChecked = value;
+ OnCheckBoxImageChanged();
+ }
+ }
+ private Image _CheckBoxImageIndeterminate = null;
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box in cell is in indeterminate state.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box in cell is in indeterminate state")]
+ public Image CheckBoxImageIndeterminate
+ {
+ get { return _CheckBoxImageIndeterminate; }
+ set
+ {
+ _CheckBoxImageIndeterminate = value;
+ OnCheckBoxImageChanged();
+ }
+ }
+ private void OnCheckBoxImageChanged()
+ {
+ InvalidateNodesSize();
+ SetPendingLayout();
+ Invalidate();
+ }
+
+ /////
+ ///// Gets or sets the NodeConnector object that describes the type of the connector used for
+ ///// displaying connection between root node and it's nested nodes. The root node is defined as
+ ///// the top level node i.e. which belongs directly to AdvTree.Nodes collection. Default value is null.
+ /////
+ /////
+ ///// You can use
+ ///// Node.ParentConnector
+ ///// property to specify per node connectors.
+ /////
+ //[Browsable(true),Category("Connectors"),DefaultValue(null),Editor("DevComponents.AdvTree.Design.NodeConnectorTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf",typeof(System.Drawing.Design.UITypeEditor)),Description("Indicates the root node connector.")]
+ //public NodeConnector RootConnector
+ //{
+ // get {return m_RootConnector;}
+ // set
+ // {
+ // if(m_RootConnector!=value)
+ // {
+ // if(m_RootConnector!=null)
+ // m_RootConnector.AppearanceChanged-=new EventHandler(this.ConnectorAppearanceChanged);
+ // if(value!=null)
+ // value.AppearanceChanged+=new EventHandler(this.ConnectorAppearanceChanged);
+ // m_RootConnector=value;
+ // this.OnDisplayChanged();
+ // }
+ // }
+ //}
+
+ ///
+ /// Gets or sets the NodeConnector object that describes the type of the connector used for
+ /// displaying connection between nested nodes. RootConnector property specifies the connector
+ /// between root node and it's imidate nested nodes. This property specifies connector for all other nested levels.
+ /// Default value is null.
+ ///
+ ///
+ /// You can use
+ /// Node.ParentConnector
+ /// property to specify per node connectors.
+ ///
+ [Browsable(true), Category("Connectors"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.NodeConnectorTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the nested nodes connector.")]
+ public NodeConnector NodesConnector
+ {
+ get { return m_NodesConnector; }
+ set
+ {
+ if (m_NodesConnector != value)
+ {
+ if (m_NodesConnector != null)
+ m_NodesConnector.AppearanceChanged -= new EventHandler(this.ConnectorAppearanceChanged);
+ if (value != null)
+ value.AppearanceChanged += new EventHandler(this.ConnectorAppearanceChanged);
+ m_NodesConnector = value;
+ this.OnDisplayChanged();
+ }
+ }
+ }
+
+ /////
+ ///// Gets or sets the NodeConnector object that describes the type of the connector used for
+ ///// displaying connection between linked nodes. This property specifies connector for all linked nodes.
+ ///// Default value is null.
+ /////
+ //[Browsable(true),Category("Connectors"),DefaultValue(null),Editor("DevComponents.AdvTree.Design.NodeConnectorTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf",typeof(System.Drawing.Design.UITypeEditor)),Description("Indicates the linked nodes connector.")]
+ //public NodeConnector LinkConnector
+ //{
+ // get {return m_LinkConnector;}
+ // set
+ // {
+ // if(m_LinkConnector!=value)
+ // {
+ // if(m_LinkConnector!=null)
+ // m_LinkConnector.AppearanceChanged-=new EventHandler(this.ConnectorAppearanceChanged);
+ // if(value!=null)
+ // value.AppearanceChanged+=new EventHandler(this.ConnectorAppearanceChanged);
+ // m_LinkConnector=value;
+ // this.OnDisplayChanged();
+ // }
+ // }
+ //}
+
+ ///
+ /// Gets or sets the NodeConnector object that describes the type of the connector used for
+ /// displaying connection between linked nodes. Connector specified here is used to display the connection
+ /// between nodes that are on the path to the selected node. When set you can use it to visually indicate the path to the currently selected node.
+ /// Default value is null.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), Category("Connectors"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.NodeConnectorTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the linked nodes connector.")]
+ public NodeConnector SelectedPathConnector
+ {
+ get { return m_SelectedPathConnector; }
+ set
+ {
+ if (m_SelectedPathConnector != value)
+ {
+ if (m_SelectedPathConnector != null)
+ m_SelectedPathConnector.AppearanceChanged -= new EventHandler(this.ConnectorAppearanceChanged);
+ if (value != null)
+ value.AppearanceChanged += new EventHandler(this.ConnectorAppearanceChanged);
+ m_SelectedPathConnector = value;
+ this.OnDisplayChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the layout of the cells inside the node. Default value is Horizontal layout which
+ /// means that cell are positioned horizontally next to each other.
+ ///
+ ///
+ /// You can specify cell layout on each node by using
+ /// Node.CellLayout
+ /// property.
+ ///
+ [Browsable(true), DefaultValue(eCellLayout.Default), Category("Appearance"), Description("Indicates layout of the cells inside the node.")]
+ public eCellLayout CellLayout
+ {
+ get { return m_CellLayout; }
+ set
+ {
+ m_CellLayout = value;
+ InvalidateNodesSize();
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets the layout of the cells inside the node. Default value is Horizontal layout which
+ /// means that cell are positioned horizontally next to each other.
+ ///
+ ///
+ /// You can specify cell layout on each node by using
+ /// Node.CellLayout
+ /// property.
+ ///
+ [Browsable(true), DefaultValue(eCellPartLayout.Default), Category("Appearance"), Description("Indicates layout of the cells inside the node.")]
+ public eCellPartLayout CellPartLayout
+ {
+ get { return m_CellPartLayout; }
+ set
+ {
+ m_CellPartLayout = value;
+ InvalidateNodesSize();
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets the color scheme style. Color scheme provides predefined colors based on popular visual styles.
+ /// We recommend that you use "SchemePart" color settings since they maintain consistant look that is
+ /// based on target system color scheme setting.
+ ///
+ [Browsable(true), DefaultValue(eColorSchemeStyle.Office2007), Category("Appearance"), Description("Indicates the color scheme style.")]
+ public eColorSchemeStyle ColorSchemeStyle
+ {
+ get { return MapStyle(m_ColorScheme.Style); }
+ set
+ {
+ m_ColorScheme.Style = MapStyle(value);
+ if (this.DesignMode)
+ this.Refresh();
+ }
+ }
+
+ internal static eDotNetBarStyle MapStyle(eColorSchemeStyle style)
+ {
+ if (style == eColorSchemeStyle.Office2003)
+ return eDotNetBarStyle.Office2003;
+ else if (style == eColorSchemeStyle.VS2005)
+ return eDotNetBarStyle.VS2005;
+ return eDotNetBarStyle.Office2007;
+ }
+ internal static eColorSchemeStyle MapStyle(eDotNetBarStyle style)
+ {
+ if (style == eDotNetBarStyle.Office2003)
+ return eColorSchemeStyle.Office2003;
+ else if (style == eDotNetBarStyle.VS2005)
+ return eColorSchemeStyle.VS2005;
+
+ return eColorSchemeStyle.Office2007;
+ }
+
+ ///
+ /// Gets the reference to the color scheme object.
+ ///
+ internal ColorScheme ColorScheme
+ {
+ get
+ {
+ if (ColorSchemeStyle == eColorSchemeStyle.Office2007 && DevComponents.DotNetBar.Rendering.GlobalManager.Renderer is DevComponents.DotNetBar.Rendering.Office2007Renderer)
+ {
+ return ((DevComponents.DotNetBar.Rendering.Office2007Renderer)DevComponents.DotNetBar.Rendering.GlobalManager.Renderer).ColorTable.LegacyColors;
+ }
+ return m_ColorScheme;
+ }
+ }
+
+ ///
+ /// Gets or sets whether the content of the control is centered within the bounds of control. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Description("Indicates whether the content of the control is centered within the bounds of control."), Category("Layout")]
+ internal bool CenterContent
+ {
+ get { return m_CenterContent; }
+ set
+ {
+ m_CenterContent = value;
+ OnLayoutChanged();
+ }
+ }
+
+ private bool _SelectionPerCell = false;
+ ///
+ /// Gets or sets whether per cell selection mode is enabled. In cell selection mode the selection box is drawn over selected cell only
+ /// instead of all cells in the node.
+ /// Default value is false.
+ ///
+ [DefaultValue(false), Category("Selection"), Description("Indicates whether selection is drawn for selected cell only instead of all cells inside of node")]
+ public bool SelectionPerCell
+ {
+ get { return _SelectionPerCell; }
+ set
+ {
+ if (_SelectionPerCell != value)
+ {
+ _SelectionPerCell = value;
+ if (this.SelectedNode != null)
+ {
+ InvalidateNode(this.SelectedNode);
+ }
+ }
+ }
+ }
+
+ private bool _SelectionFocusAware = true;
+ ///
+ /// Gets or sets whether selection appearance changes depending on whether control has input focus. Default value is true. Setting this value to false causes selection box to be rendered as if control has focus all the time.
+ ///
+ [DefaultValue(true), Category("Selection"), Description("Indicates whether selection appearance changes depending on whether control has input focus.")]
+ public bool SelectionFocusAware
+ {
+ get { return _SelectionFocusAware; }
+ set
+ {
+ if (_SelectionFocusAware != value)
+ {
+ _SelectionFocusAware = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+
+ private eSelectionStyle _SelectionBoxStyle = eSelectionStyle.HighlightCells;
+ ///
+ /// Gets or sets the node selection box style.
+ ///
+ /// SelectionBox Property
+ /// SelectionBoxSize Property
+ /// SelectionBoxFillColor Property
+ /// SelectionBoxBorderColor Property
+ [DefaultValue(eSelectionStyle.HighlightCells), Category("Selection"), Description("Indicates node selection box style.")]
+ public eSelectionStyle SelectionBoxStyle
+ {
+ get { return _SelectionBoxStyle; }
+ set { _SelectionBoxStyle = value; }
+ }
+
+ ///
+ /// Gets or sets the value that indicates whether selection box is drawn around the
+ /// selected node. Default value is true. Another way to provide the visual indication that
+ /// node is selected is by using selected state style properties like
+ /// NodeStyleSelected
+ /// and
+ /// CellStyleSelected.
+ ///
+ /// CellStyleSelected Property
+ /// NodeStyleSelected Property
+ [Browsable(true), DefaultValue(true), Category("Selection"), Description("Indicates whether selection box is drawn around selected node.")]
+ public bool SelectionBox
+ {
+ get { return m_SelectionBox; }
+ set
+ {
+ if (m_SelectionBox != value)
+ {
+ m_SelectionBox = value;
+ this.OnSelectionBoxChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the size/thickness in pixel of the selection box drawn around selected
+ /// node.
+ ///
+ [Browsable(true), DefaultValue(4), Category("Selection"), Description("Indicates the size in pixels of the selection box drawn around selected node.")]
+ internal int SelectionBoxSize
+ {
+ get { return m_SelectionBoxSize; }
+ set
+ {
+ if (m_SelectionBoxSize != value)
+ {
+ m_SelectionBoxSize = value;
+ this.OnSelectionBoxChanged();
+ }
+ }
+ }
+
+ private bool _FullRowSelect = true;
+ ///
+ /// Gets or sets whether node is selected when mouse is pressed anywhere within node vertical bounds. Default value is true.
+ ///
+ ///
+ /// When set to false the node is selected only when mouse is pressed over the node content.
+ ///
+ [DefaultValue(true), Description("Indicates whether node is selected when mouse is pressed anywhere within node vertical bounds."), Category("Selection")]
+ public bool FullRowSelect
+ {
+ get { return _FullRowSelect; }
+ set
+ {
+ _FullRowSelect = value;
+ }
+ }
+
+
+ /////
+ ///// Gets or sets the selection box border color.
+ /////
+ //[Browsable(true),Category("Selection"),Description("Indicates the selection box border color.")]
+ //public Color SelectionBoxBorderColor
+ //{
+ // get {return m_SelectionBoxBorderColor;}
+ // set
+ // {
+ // if(m_SelectionBoxBorderColor!=value)
+ // {
+ // m_SelectionBoxBorderColor=value;
+ // this.OnSelectionBoxChanged();
+ // }
+ // }
+
+ //}
+ /////
+ ///// Indicates whether SelectionBoxBorderColor should be serialized. Used by windows forms designer design-time support.
+ /////
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public bool ShouldSerializeSelectionBoxBorderColor()
+ //{return (m_SelectionBoxBorderColor!=GetDefaultSelectionBoxBorderColor());}
+ /////
+ ///// Resets SelectionBoxBorderColor to it's default value. Used by windows forms designer design-time support.
+ /////
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public void ResetSelectionBoxBorderColor()
+ //{
+ // m_SelectionBoxBorderColor=GetDefaultSelectionBoxBorderColor();
+ //}
+
+ /////
+ ///// Gets or sets the selection box fill color.
+ /////
+ //[Browsable(true),Category("Selection"),Description("Indicates the selection box fill color.")]
+ //public Color SelectionBoxFillColor
+ //{
+ // get {return m_SelectionBoxFillColor;}
+ // set
+ // {
+ // if(m_SelectionBoxFillColor!=value)
+ // {
+ // m_SelectionBoxFillColor=value;
+ // this.OnSelectionBoxChanged();
+ // }
+ // }
+
+ //}
+ /////
+ ///// Indicates whether SelectionBoxFillColor should be serialized. Used by windows forms designer design-time support.
+ /////
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public bool ShouldSerializeSelectionBoxFillColor()
+ //{return (m_SelectionBoxFillColor!=GetDefaultSelectionBoxFillColor());}
+ /////
+ ///// Resets SelectionBoxFillColor to it's default value. Used by windows forms designer design-time support.
+ /////
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public void ResetSelectionBoxFillColor()
+ //{
+ // m_SelectionBoxFillColor=GetDefaultSelectionBoxFillColor();
+ //}
+
+ private int _ExpandWidth = 24;
+ ///
+ /// Gets or sets the total node expand area width in pixels. The expand button with ExpandButtonSize is fitted into this area. Default value is 24.
+ ///
+ [DefaultValue(24), Category("Expand Button"), Description("Indicates total node expand area width in pixels.")]
+ public int ExpandWidth
+ {
+ get { return _ExpandWidth; }
+ set
+ {
+ if (_ExpandWidth != value)
+ {
+ _ExpandWidth = value;
+ _LayoutSettings.ExpandAreaWidth = value;
+ this.InvalidateNodesSize();
+ this.Invalidate();
+ }
+ }
+ }
+
+
+ ///
+ /// Gets or sets the size of the expand button that is used to expand/collapse node. Default value is 8,8.
+ ///
+ [Browsable(true), Category("Expand Button"), Description("Indicates size of the expand button that is used to expand/collapse node.")]
+ public Size ExpandButtonSize
+ {
+ get { return m_ExpandButtonSize; }
+ set
+ {
+ if (m_ExpandButtonSize != value)
+ {
+ m_ExpandButtonSize = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+ }
+ ///
+ /// Indicates whether SelectionBoxFillColor should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeExpandButtonSize()
+ { return (m_ExpandButtonSize != GetDefaultExpandButtonSize()); }
+ ///
+ /// Resets SelectionBoxFillColor to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetExpandButtonSize()
+ {
+ this.ExpandButtonSize = GetDefaultExpandButtonSize();
+ }
+
+ ///
+ /// Gets or sets expand button border color. Note that setting ExpandBorderColorSchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Expand Button"), Description("Indicates expand button border color.")]
+ public Color ExpandBorderColor
+ {
+ get { return m_ExpandBorderColor; }
+ set
+ {
+ m_ExpandBorderColor = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether ExpandBorderColor should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeExpandBorderColor()
+ { return (!m_ExpandBorderColor.IsEmpty && m_ExpandBorderColorSchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets ExpandBorderColor to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetExpandBorderColor()
+ {
+ this.ExpandBorderColor = Color.Empty;
+ }
+ ///
+ /// Gets or sets expand button color scheme border color. Setting
+ /// this property overrides the setting of the corresponding ExpandBorderColor property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through ExpandBorderColor property.
+ ///
+ [Browsable(true), Category("Expand Button"), DefaultValue(eColorSchemePart.None), Description("Indicates expand button border color.")]
+ public eColorSchemePart ExpandBorderColorSchemePart
+ {
+ get { return m_ExpandBorderColorSchemePart; }
+ set
+ {
+ m_ExpandBorderColorSchemePart = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets expand button back color. Note that setting ExpandBackColorSchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Expand Button"), Description("Indicates expand button back color.")]
+ public Color ExpandBackColor
+ {
+ get { return m_ExpandBackColor; }
+ set
+ {
+ m_ExpandBackColor = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether ExpandBackColor should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeExpandBackColor()
+ { return (!m_ExpandBackColor.IsEmpty && m_ExpandBackColorSchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets ExpandBackColor to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetExpandBackColor()
+ {
+ this.ExpandBackColor = Color.Empty;
+ }
+ ///
+ /// Gets or sets expand button color scheme back color. Setting
+ /// this property overrides the setting of the corresponding ExpandBackColor property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through ExpandBackColor property.
+ ///
+ [Browsable(true), Category("Expand Button"), DefaultValue(eColorSchemePart.None), Description("Indicates expand button back color.")]
+ public eColorSchemePart ExpandBackColorSchemePart
+ {
+ get { return m_ExpandBackColorSchemePart; }
+ set
+ {
+ m_ExpandBackColorSchemePart = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets expand button target gradientback color. Note that setting ExpandBackColor2SchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Expand Button"), Description("Indicates expand button target gradient back color.")]
+ public Color ExpandBackColor2
+ {
+ get { return m_ExpandBackColor2; }
+ set
+ {
+ m_ExpandBackColor2 = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether ExpandBackColor2 should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeExpandBackColor2()
+ { return (!m_ExpandBackColor2.IsEmpty && m_ExpandBackColor2SchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets ExpandBackColor2 to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetExpandBackColor2()
+ {
+ this.ExpandBackColor2 = Color.Empty;
+ }
+ ///
+ /// Gets or sets expand button color scheme target gradient back color. Setting
+ /// this property overrides the setting of the corresponding ExpandBackColor2 property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through ExpandBackColor2 property.
+ ///
+ [Browsable(true), Category("Expand Button"), DefaultValue(eColorSchemePart.None), Description("Indicates expand button target gradient back color.")]
+ public eColorSchemePart ExpandBackColor2SchemePart
+ {
+ get { return m_ExpandBackColor2SchemePart; }
+ set
+ {
+ m_ExpandBackColor2SchemePart = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets expand button line color. Note that setting ExpandLineColorSchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Expand Button"), Description("Indicates expand button line color.")]
+ public Color ExpandLineColor
+ {
+ get { return m_ExpandLineColor; }
+ set
+ {
+ m_ExpandLineColor = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether ExpandLineColor should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeExpandLineColor()
+ { return (!m_ExpandLineColor.IsEmpty && m_ExpandLineColorSchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets ExpandLineColor to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetExpandLineColor()
+ {
+ this.ExpandLineColor = Color.Empty;
+ }
+ ///
+ /// Gets or sets expand button color scheme line color. Setting
+ /// this property overrides the setting of the corresponding ExpandLineColor property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through ExpandLineColor property.
+ ///
+ [Browsable(true), Category("Expand Button"), DefaultValue(eColorSchemePart.None), Description("Indicates expand button line color.")]
+ public eColorSchemePart ExpandLineColorSchemePart
+ {
+ get { return m_ExpandLineColorSchemePart; }
+ set
+ {
+ m_ExpandLineColorSchemePart = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the expand button background gradient angle.
+ ///
+ [Browsable(true), Category("Expand Button"), DefaultValue(0), Description("Indicates expand button background gradient angle.")]
+ public int ExpandBackColorGradientAngle
+ {
+ get
+ {
+ return m_ExpandBackColorGradientAngle;
+ }
+ set
+ {
+ if (m_ExpandBackColorGradientAngle != value)
+ {
+ m_ExpandBackColorGradientAngle = value;
+ this.OnExpandButtonChanged();
+
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the expand button image which is used to indicate that node will be expanded. To use images as expand buttons you also need to set ExpandButtonType=eExpandButtonType.Image.
+ ///
+ [Browsable(true), DefaultValue(null), Description("Indicates expand button image which is used to indicate that node will be expanded."), Category("Expand Button")]
+ public Image ExpandImage
+ {
+ get { return m_ExpandImage; }
+ set
+ {
+ if (m_ExpandImage != value)
+ {
+ m_ExpandImage = value;
+ if (m_ExpandButtonType == eExpandButtonType.Image)
+ this.OnExpandButtonChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the expand button image which is used to indicate that node will be collapsed. To use images as expand buttons you also need to set ExpandButtonType=eExpandButtonType.Image.
+ ///
+ [Browsable(true), DefaultValue(null), Description("Indicates expand button image which is used to indicate that node will be collapsed."), Category("Expand Button")]
+ public Image ExpandImageCollapse
+ {
+ get { return m_ExpandImageCollapse; }
+ set
+ {
+ if (m_ExpandImageCollapse != value)
+ {
+ m_ExpandImageCollapse = value;
+ if (m_ExpandButtonType == eExpandButtonType.Image)
+ this.OnExpandButtonChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the type of the expand button used to expand/collapse nodes.
+ ///
+ [Browsable(true), DefaultValue(eExpandButtonType.Rectangle), Category("Expand Button"), Description("Indicates type of the expand button used to expand/collapse nodes.")]
+ public eExpandButtonType ExpandButtonType
+ {
+ get { return m_ExpandButtonType; }
+ set
+ {
+ if (m_ExpandButtonType != value)
+ {
+ m_ExpandButtonType = value;
+ this.OnExpandButtonChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the display root node. Setting this property allows you to use any
+ /// Node as root display node. Default value is Null which means that first node from
+ /// AdvTree.Nodes collection is used as display root node.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Appearance"), Description("Indicates display root node.")]
+ public Node DisplayRootNode
+ {
+ get { return m_DisplayRootNode; }
+ set
+ {
+ if (m_DisplayRootNode != value)
+ {
+ m_DisplayRootNode = value;
+ if (m_NodeDisplay != null) m_NodeDisplay.PaintedNodes.Clear();
+ InvalidateNodesSize();
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the width of the command button. Default value is 10 pixels.
+ ///
+ [Browsable(true), Category("Command Button"), DefaultValue(10), Description("Indicates width of the command button.")]
+ internal int CommandWidth
+ {
+ get { return m_CommandWidth; }
+ set
+ {
+ m_CommandWidth = value;
+ OnCommandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets command button back color. Note that setting CommandBackColorSchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Command Button"), Description("Indicates command button back color.")]
+ internal Color CommandBackColor
+ {
+ get { return m_CommandBackColor; }
+ set
+ {
+ m_CommandBackColor = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether CommandBackColor should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal bool ShouldSerializeCommandBackColor()
+ { return (!m_CommandBackColor.IsEmpty && m_CommandBackColorSchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets CommandBackColor to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void ResetCommandBackColor()
+ {
+ this.CommandBackColor = Color.Empty;
+ }
+ ///
+ /// Gets or sets command button color scheme back color. Setting
+ /// this property overrides the setting of the corresponding CommandBackColor property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through CommandBackColor property.
+ ///
+ [Browsable(true), Category("Command Button"), DefaultValue(eColorSchemePart.CustomizeBackground), Description("Indicates command button back color.")]
+ internal eColorSchemePart CommandBackColorSchemePart
+ {
+ get { return m_CommandBackColorSchemePart; }
+ set
+ {
+ m_CommandBackColorSchemePart = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets command button target gradient back color. Note that setting CommandBackColor2SchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Command Button"), Description("Indicates command button target gradient back color.")]
+ internal Color CommandBackColor2
+ {
+ get { return m_CommandBackColor2; }
+ set
+ {
+ m_CommandBackColor2 = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether CommandBackColor2 should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal bool ShouldSerializeCommandBackColor2()
+ { return (!m_CommandBackColor2.IsEmpty && m_CommandBackColor2SchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets CommandBackColor2 to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void ResetCommandBackColor2()
+ {
+ this.CommandBackColor2 = Color.Empty;
+ }
+ ///
+ /// Gets or sets command button color scheme target gradient back color. Setting
+ /// this property overrides the setting of the corresponding CommandBackColor2 property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through CommandBackColor2 property.
+ ///
+ [Browsable(true), Category("Command Button"), DefaultValue(eColorSchemePart.CustomizeBackground2), Description("Indicates command button target gradient back color.")]
+ internal eColorSchemePart CommandBackColor2SchemePart
+ {
+ get { return m_CommandBackColor2SchemePart; }
+ set
+ {
+ m_CommandBackColor2SchemePart = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets command button foreground color. Note that setting CommandForeColorSchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Command Button"), Description("Indicates command button fore color.")]
+ internal Color CommandForeColor
+ {
+ get { return m_CommandForeColor; }
+ set
+ {
+ m_CommandForeColor = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether CommandForeColor should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal bool ShouldSerializeCommandForeColor()
+ { return (!m_CommandForeColor.IsEmpty && m_CommandForeColorSchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets CommandForeColor to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void ResetCommandForeColor()
+ {
+ this.CommandForeColor = Color.Empty;
+ }
+ ///
+ /// Gets or sets command button color scheme foreground color. Setting
+ /// this property overrides the setting of the corresponding CommandForeColor property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through CommandForeColor property.
+ ///
+ [Browsable(true), Category("Command Button"), DefaultValue(eColorSchemePart.CustomizeText), Description("Indicates command button foreground color.")]
+ internal eColorSchemePart CommandForeColorSchemePart
+ {
+ get { return m_CommandForeColorSchemePart; }
+ set
+ {
+ m_CommandForeColorSchemePart = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the command button background gradient angle.
+ ///
+ [Browsable(true), Category("Expand Button"), DefaultValue(0), Description("Indicates command button background gradient angle.")]
+ internal int CommandBackColorGradientAngle
+ {
+ get
+ {
+ return m_CommandBackColorGradientAngle;
+ }
+ set
+ {
+ if (m_CommandBackColorGradientAngle != value)
+ {
+ m_CommandBackColorGradientAngle = value;
+ this.OnExpandButtonChanged();
+
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets command button mouse over back color. Note that setting CommandMouseOverBackColorSchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Command Button"), Description("Indicates command button mouse over back color.")]
+ internal Color CommandMouseOverBackColor
+ {
+ get { return m_CommandMouseOverBackColor; }
+ set
+ {
+ m_CommandMouseOverBackColor = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether CommandMouseOverBackColor should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal bool ShouldSerializeCommandMouseOverBackColor()
+ { return (!m_CommandMouseOverBackColor.IsEmpty && m_CommandMouseOverBackColorSchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets CommandMouseOverBackColor to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void ResetCommandMouseOverBackColor()
+ {
+ this.CommandMouseOverBackColor = Color.Empty;
+ }
+ ///
+ /// Gets or sets command button color scheme mouse over back color. Setting
+ /// this property overrides the setting of the corresponding CommandMouseOverBackColor property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through CommandMouseOverBackColor property.
+ ///
+ [Browsable(true), Category("Command Button"), DefaultValue(eColorSchemePart.ItemHotBackground), Description("Indicates command button mouse over back color.")]
+ internal eColorSchemePart CommandMouseOverBackColorSchemePart
+ {
+ get { return m_CommandMouseOverBackColorSchemePart; }
+ set
+ {
+ m_CommandMouseOverBackColorSchemePart = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets command button mouse over target gradient back color. Note that setting CommandMouseOverBackColor2SchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Command Button"), Description("Indicates command button mouse over target gradient back color.")]
+ internal Color CommandMouseOverBackColor2
+ {
+ get { return m_CommandMouseOverBackColor2; }
+ set
+ {
+ m_CommandMouseOverBackColor2 = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether CommandMouseOverBackColor2 should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal bool ShouldSerializeCommandMouseOverBackColor2()
+ { return (!m_CommandMouseOverBackColor2.IsEmpty && m_CommandMouseOverBackColor2SchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets CommandMouseOverBackColor2 to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void ResetCommandMouseOverBackColor2()
+ {
+ this.CommandMouseOverBackColor2 = Color.Empty;
+ }
+ ///
+ /// Gets or sets command button mouse over color scheme target gradient back color. Setting
+ /// this property overrides the setting of the corresponding CommandMouseOverBackColor2 property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through CommandMouseOverBackColor2 property.
+ ///
+ [Browsable(true), Category("Command Button"), DefaultValue(eColorSchemePart.ItemPressedBackground2), Description("Indicates command button mouse over target gradient back color.")]
+ internal eColorSchemePart CommandMouseOverBackColor2SchemePart
+ {
+ get { return m_CommandMouseOverBackColor2SchemePart; }
+ set
+ {
+ m_CommandMouseOverBackColor2SchemePart = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets command button mouse over foreground color. Note that setting CommandMouseOverForeColorSchemePart property will override the value that you set here.
+ ///
+ [Browsable(true), Category("Command Button"), Description("Indicates command button mouse over fore color.")]
+ internal Color CommandMouseOverForeColor
+ {
+ get { return m_CommandMouseOverForeColor; }
+ set
+ {
+ m_CommandMouseOverForeColor = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+ ///
+ /// Indicates whether CommandMouseOverForeColor should be serialized. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal bool ShouldSerializeCommandMouseOverForeColor()
+ { return (!m_CommandMouseOverForeColor.IsEmpty && m_CommandMouseOverForeColorSchemePart == eColorSchemePart.None); }
+ ///
+ /// Resets CommandMouseOverForeColor to it's default value. Used by windows forms designer design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void ResetCommandMouseOverForeColor()
+ {
+ this.CommandMouseOverForeColor = Color.Empty;
+ }
+ ///
+ /// Gets or sets command button mouse over color scheme foreground color. Setting
+ /// this property overrides the setting of the corresponding CommandMouseOverForeColor property.
+ /// Color scheme colors are automatically managed and are based on current system colors.
+ /// That means if colors on the system change the color scheme will ensure that it's colors
+ /// are changed as well to fit in the color scheme of target system. Set this property to
+ /// eColorSchemePart.None to
+ /// specify explicit color to use through CommandMouseOverForeColor property.
+ ///
+ [Browsable(true), Category("Command Button"), DefaultValue(eColorSchemePart.ItemHotText), Description("Indicates command button mouse over foreground color.")]
+ internal eColorSchemePart CommandMouseOverForeColorSchemePart
+ {
+ get { return m_CommandMouseOverForeColorSchemePart; }
+ set
+ {
+ m_CommandMouseOverForeColorSchemePart = value;
+ this.OnCommandButtonChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the command button mouse over background gradient angle.
+ ///
+ [Browsable(true), Category("Expand Button"), DefaultValue(0), Description("Indicates command button mouse over background gradient angle.")]
+ internal int CommandMouseOverBackColorGradientAngle
+ {
+ get
+ {
+ return m_CommandMouseOverBackColorGradientAngle;
+ }
+ set
+ {
+ if (m_CommandMouseOverBackColorGradientAngle != value)
+ {
+ m_CommandMouseOverBackColorGradientAngle = value;
+ this.OnExpandButtonChanged();
+
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the label text of the node cells can be edited. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Description("Indicates whether the label text of the node cells can be edited."), Category("Editing")]
+ public bool CellEdit
+ {
+ get { return m_CellEdit; }
+ set { m_CellEdit = value; }
+ }
+
+ ///
+ /// Returns whether cell editing is in progress.
+ ///
+ [Browsable(false)]
+ public bool IsCellEditing
+ {
+ get { return m_CellEditing; }
+ }
+
+ ///
+ /// Returns the zero based flat index of the node. Flat index is the index of the node as if tree structure
+ /// has been flattened into the list.
+ ///
+ /// Reference to the node to return index for.
+ /// Zero based node index or -1 if index cannot be determined.
+ public int GetNodeFlatIndex(Node node)
+ {
+ return NodeOperations.GetNodeFlatIndex(this, node);
+ }
+
+ ///
+ /// Returns node based on the flat index. Flat index is the index of the node as if tree structure
+ /// has been flattened into the list.
+ ///
+ /// Index to return node for.
+ /// Reference to a node or null if node at specified index cannot be found.
+ public Node GetNodeByFlatIndex(int index)
+ {
+ return NodeOperations.GetNodeByFlatIndex(this, index);
+ }
+ #endregion
+
+ #region Private implementation
+ private bool _AccessibleObjectCreated = false;
+ protected override AccessibleObject CreateAccessibilityInstance()
+ {
+ _AccessibleObjectCreated = true;
+ return new AdvTreeAccessibleObject(this);
+ }
+
+ protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
+ {
+ if (Dpi.RecordScalePerControl)
+ Dpi.SetScaling(factor);
+ ScaleHostedControls(factor);
+ this.InvalidateNodesSize();
+ if (_VScrollBar != null) _VScrollBar.UpdateScaling(factor);
+ if (_HScrollBar != null) _HScrollBar.UpdateScaling(factor);
+ base.ScaleControl(factor, specified);
+ }
+
+ private void ScaleHostedControls(SizeF factor)
+ {
+ foreach (Cell cell in m_HostedControlCells)
+ {
+ System.Windows.Forms.Control cellHostedControl = cell.HostedControl;
+ if (cellHostedControl == null) continue;
+ cellHostedControl.Scale(factor);
+ }
+ }
+
+ protected override bool ScaleChildren
+ {
+ get { return false; }
+ }
+
+ ///
+ /// Returns color scheme part color if set otherwise returns color passed in.
+ ///
+ /// Color.
+ /// Color scheme part.
+ /// Color.
+ internal Color GetColor(Color color, eColorSchemePart p)
+ {
+ if (p == eColorSchemePart.None || p == eColorSchemePart.Custom)
+ return color;
+ ColorScheme cs = this.ColorScheme;
+ if (cs == null)
+ return color;
+ return (Color)cs.GetType().GetProperty(p.ToString()).GetValue(cs, null);
+ }
+ private void OnExpandButtonChanged()
+ {
+ _LayoutSettings.ExpandPartSize = m_ExpandButtonSize;
+ this.InvalidateNodesSize();
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ private Size GetDefaultExpandButtonSize()
+ {
+ return m_DefaultExpandPartSize;
+ }
+ private void ElementStyleChanged(object sender, EventArgs e)
+ {
+ this.InvalidateNodesSize();
+ if (this.DesignMode)
+ this.RecalcLayout();
+ this.OnDisplayChanged();
+ }
+ private void OnDisplayChanged()
+ {
+ if (this.DesignMode)
+ this.Refresh();
+ }
+ private void OnLayoutChanged()
+ {
+ _LayoutSettings.NodeHorizontalSpacing = m_NodeHorizontalSpacing;
+ _LayoutSettings.NodeVerticalSpacing = m_NodeVerticalSpacing;
+
+ //// Layout specific properties
+ //if (m_Layout == eNodeLayout.Diagram)
+ //{
+ // Layout.NodeDiagramLayout nd = m_NodeLayout as Layout.NodeDiagramLayout;
+ // nd.DiagramFlow = m_DiagramLayoutFlow;
+ //}
+ //else if (m_Layout == eNodeLayout.Map)
+ //{
+ // NodeMapLayout nd = m_NodeLayout as NodeMapLayout;
+ // nd.MapFlow = m_MapLayoutFlow;
+ //}
+
+ this.RecalcLayout();
+ OnDisplayChanged();
+ }
+ private void ConnectorAppearanceChanged(object sender, EventArgs e)
+ {
+ OnDisplayChanged();
+ }
+ //private void SetLayout(eNodeLayout layout)
+ //{
+ // m_Layout=layout;
+ // if(m_Layout==eNodeLayout.Map)
+ // {
+ // m_NodeLayout=new NodeMapLayout(this,this.ClientRectangle);
+ // }
+ // else if(m_Layout==eNodeLayout.Diagram)
+ // {
+ // m_NodeLayout=new Layout.NodeDiagramLayout(this,this.ClientRectangle);
+ // }
+ // InvalidateNodesSize();
+ // OnLayoutChanged();
+ //}
+
+ ///
+ /// Collapses all nodes in a tree.
+ ///
+ public void CollapseAll()
+ {
+ this.BeginUpdate();
+ try
+ {
+ foreach (Node item in this.Nodes)
+ {
+ item.CollapseAll();
+ }
+ }
+ finally
+ {
+ this.EndUpdate(true);
+ }
+ }
+
+ ///
+ /// Expands all the tree nodes.
+ ///
+ public void ExpandAll()
+ {
+ this.BeginUpdate();
+ try
+ {
+ foreach (Node item in this.Nodes)
+ {
+ item.Expand();
+ item.ExpandAll();
+ }
+ }
+ finally
+ {
+ this.EndUpdate(true);
+ }
+ }
+
+ private void PaintStyleBackground(Graphics g)
+ {
+ Display.TreeRenderer renderer = this.NodeRenderer;
+ if (renderer != null)
+ {
+ this.NodeRenderer.DrawTreeBackground(new TreeBackgroundRendererEventArgs(g, this));
+ return;
+ }
+
+ if (!this.BackColor.IsEmpty)
+ {
+ using (SolidBrush brush = new SolidBrush(this.BackColor))
+ g.FillRectangle(brush, this.DisplayRectangle);
+ }
+
+ ElementStyleDisplayInfo info = new ElementStyleDisplayInfo();
+ info.Bounds = this.DisplayRectangle;
+ info.Graphics = g;
+ bool disposeStyle = false;
+ ElementStyle style = ElementStyleDisplay.GetElementStyle(m_BackgroundStyle, out disposeStyle);
+ info.Style = style;
+ ElementStyleDisplay.Paint(info);
+ if (disposeStyle)
+ style.Dispose();
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (this.SuspendPaint)
+ return;
+
+ try
+ {
+ if (m_PendingLayout)
+ {
+ this.RecalcLayout();
+ }
+
+ if (this.BackColor.A < 255)
+ {
+ base.OnPaintBackground(e);
+ }
+
+ Graphics g = e.Graphics;
+
+ PaintStyleBackground(g);
+ Point offset = Point.Empty;
+ bool setOffset = false;
+ if (this.AutoScroll)
+ {
+ offset = GetAutoScrollPositionOffset();
+ setOffset = true;
+ }
+ else if (this.SelectionBoxStyle == eSelectionStyle.NodeMarker)
+ {
+ offset.X += this.SelectionBoxSize;
+ offset.Y += this.SelectionBoxSize;
+ setOffset = true;
+ }
+
+ SmoothingMode sm = g.SmoothingMode;
+ TextRenderingHint th = g.TextRenderingHint;
+ if (m_AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ Rectangle clipRect = GetInnerRectangle();
+ if (_VScrollBar != null) clipRect.Width -= _VScrollBar.Width;
+ if (_HScrollBar != null) clipRect.Height -= _HScrollBar.Height;
+ g.SetClip(clipRect);
+
+ PaintTree(g, e.ClipRectangle, offset, setOffset, m_ZoomFactor);
+
+ if (_ColumnMoveMarkerIndex >= 0 && _ColumnReorder != null && _ColumnReorder.Parent != m_Columns)
+ DevComponents.AdvTree.Display.ColumnHeaderDisplay.PaintColumnMoveMarker(g, this, _ColumnMoveMarkerIndex, _ColumnReorder.Parent);
+
+ if (m_AntiAlias)
+ {
+ g.SmoothingMode = sm;
+ g.TextRenderingHint = th;
+ }
+ }
+ finally
+ {
+ base.OnPaint(e);
+ }
+ }
+
+ internal Rectangle GetInnerRectangle()
+ {
+ Rectangle r = ElementStyleLayout.GetInnerRect(this.BackgroundStyle, this.ClientRectangle);
+ return r;
+ }
+
+ internal Point GetAutoScrollPositionOffset()
+ {
+ Point p = this.AutoScrollPosition;
+ if (this.SelectionBoxStyle == eSelectionStyle.NodeMarker)
+ {
+ p.Y += this.SelectionBoxSize;
+ p.X += this.SelectionBoxSize;
+ }
+ return p;
+ }
+
+ private void PaintTree(Graphics g, Rectangle clipRectangle, Point offset, bool setOffset, float zoomFactor)
+ {
+
+#if TRIAL
+ if(NodeOperations.ColorExpAlt())
+ {
+ StringFormat format=new StringFormat(StringFormat.GenericDefault);
+ format.Alignment=StringAlignment.Center;
+ format.FormatFlags=format.FormatFlags & ~(format.FormatFlags & StringFormatFlags.NoWrap);
+ g.DrawString("Thank you very much for trying AdvTree. Unfortunately your trial period is over. To continue using AdvTree you should purchase license at http://www.devcomponents.com",new Font(this.Font.FontFamily,12),SystemBrushes.Highlight,this.ClientRectangle,format);
+ format.Dispose();
+ return;
+ }
+#else
+ if (NodeOperations.keyValidated2 != 114)
+ {
+ Font trial = new Font(this.Font.FontFamily, 7);
+ SolidBrush brushTrial = new SolidBrush(Color.FromArgb(200, SystemColors.Highlight));
+ StringFormat format = new StringFormat(StringFormat.GenericDefault);
+ format.Alignment = StringAlignment.Center;
+ g.DrawString("DotNetBar AdvTree license not found. Please purchase license at http://www.devcomponents.com",
+ trial, brushTrial, this.DisplayRectangle.X + this.DisplayRectangle.Width / 2, this.DisplayRectangle.Bottom - 14, format);
+ brushTrial.Dispose();
+ format.Dispose();
+ trial.Dispose();
+ }
+#endif
+
+ //Creates the drawing matrix with the right zoom;
+ if (zoomFactor != 1)
+ {
+ System.Drawing.Drawing2D.Matrix mx = GetTranslationMatrix(zoomFactor);
+ //use it for drawing
+ g.Transform = mx;
+
+ // Translate ClipRectangle
+ clipRectangle = GetLayoutRectangle(clipRectangle);
+ }
+
+ if (setOffset)
+ {
+ m_NodeDisplay.Offset = offset;
+ }
+ OnRender(new AdvTreeRenderEventArgs(eAdvTreeRenderType.Background, g));
+ m_NodeDisplay.Paint(g, clipRectangle);
+
+#if TRIAL
+ Font trial=new Font(this.Font.FontFamily,7);
+ SolidBrush brushTrial = new SolidBrush(Color.FromArgb(220, SystemColors.Highlight));
+ StringFormat formatTrial=new StringFormat(StringFormat.GenericDefault);
+ formatTrial.Alignment=StringAlignment.Center;
+ g.DrawString("Thank you for trying AdvTree. Please purchase license at http://www.devcomponents.com",
+ trial, brushTrial, this.DisplayRectangle.X+this.DisplayRectangle.Width/2, this.DisplayRectangle.Bottom - 14, formatTrial);
+ brushTrial.Dispose();
+ formatTrial.Dispose();
+ trial.Dispose();
+#endif
+ }
+
+ ///
+ /// Paints control to canvas. This method might be used for print output.
+ ///
+ /// Graphics object to paint control to.
+ /// Indicates whether to paint control background.
+ public void PaintTo(Graphics g, bool background)
+ {
+ PaintTo(g, background, Rectangle.Empty);
+ }
+
+ ///
+ /// Paints control to canvas. This method might be used for print output.
+ ///
+ /// Graphics object to paint control to.
+ /// Indicates whether to paint control background.
+ /// Indicates clipping rectangle. Nodes outside of clipping rectangle will not be painted. You can pass Rectangle.Empty and all nodes will be painted.
+ public void PaintTo(Graphics g, bool background, Rectangle clipRectangle)
+ {
+ if (background)
+ PaintStyleBackground(g);
+ Point lockedOffset = m_NodeDisplay.GetLockedOffset();
+ Point offsetDisplay = m_NodeDisplay.Offset;
+ Point offset = Point.Empty;
+
+ m_NodeLayout.Graphics = g;
+ try
+ {
+ m_NodeLayout.PerformLayout();
+ }
+ finally
+ {
+ m_NodeLayout.Graphics = null;
+ }
+
+ Node displayNode = this.GetDisplayRootNode();
+
+ //if(displayNode!=null)
+ //{
+ // if(this.NodeLayout is NodeMapLayout)
+ // {
+ // offset = new Point(Math.Abs(displayNode.ChildNodesBounds.Left),Math.Abs(displayNode.ChildNodesBounds.Top));
+ // }
+ //}
+
+ m_NodeDisplay.SetLockedOffset(offset);
+
+ try
+ {
+ PaintTree(g, clipRectangle, Point.Empty, true, 1f);
+ }
+ finally
+ {
+ m_NodeLayout.PerformLayout();
+ m_NodeDisplay.SetLockedOffset(lockedOffset);
+ if (lockedOffset.IsEmpty)
+ m_NodeDisplay.Offset = offsetDisplay;
+ }
+ }
+
+ protected override void OnRightToLeftChanged(EventArgs e)
+ {
+ this.RecalcLayout();
+ base.OnRightToLeftChanged(e);
+ }
+
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ base.OnHandleCreated(e);
+#if TRIAL
+ if(!this.DesignMode)
+ {
+ RemindForm f = new RemindForm();
+ //Design.ComponentNotLicensed f = new Design.ComponentNotLicensed();
+ f.ShowDialog();
+ f.Dispose();
+ }
+#endif
+ }
+
+ protected override void OnHandleDestroyed(EventArgs e)
+ {
+ DestroyDragScrollTimer();
+ base.OnHandleDestroyed(e);
+ }
+
+ private int _IsLayoutOrResize = 0;
+ protected override void OnResize(EventArgs e)
+ {
+ _IsLayoutOrResize++;
+ try
+ {
+ base.OnResize(e);
+ if (this.Size.Width == 0 || this.Size.Height == 0)
+ return;
+ RepositionScrollBars(); // Reposition scrollbars for appearance reasons so the do not "lag" behind when resizing
+ if ((m_Columns.Count > 0 && m_Columns.UsesRelativeSize || _View == eView.Tile) && !_FirstLayout)
+ {
+ this.InvalidateNodesSize();
+ if (this.Nodes.Count == 0 && m_Columns.UsesRelativeSize)
+ SetPendingLayout();
+ }
+ else
+ SetPendingLayout();
+
+ //this.RecalcLayout();
+ UpdateControlBorderPanel();
+ }
+ finally
+ {
+ _IsLayoutOrResize--;
+ }
+
+ }
+
+ protected override void OnLayout(LayoutEventArgs levent)
+ {
+ try
+ {
+ _IsLayoutOrResize++;
+ base.OnLayout(levent);
+ }
+ finally
+ {
+ _IsLayoutOrResize--;
+ }
+ }
+
+ protected override void OnKeyPress(KeyPressEventArgs e)
+ {
+ if (_KeyboardSearchEnabled && char.IsLetterOrDigit(e.KeyChar))
+ {
+ Node node = this.SelectedNode;
+ if (!(node != null && node.CheckBoxVisible && node.Enabled && e.KeyChar == ' ') || node == null)
+ e.Handled = ProcessKeyboardCharacter(e.KeyChar);
+ }
+ base.OnKeyPress(e);
+ }
+
+ private bool _KeyboardSearchEnabled = true;
+ ///
+ /// Gets or sets whether keyboard incremental search through Node.Text property is enabled. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether keyboard incremental search is enabled.")]
+ public bool KeyboardSearchEnabled
+ {
+ get { return _KeyboardSearchEnabled; }
+ set
+ {
+ _KeyboardSearchEnabled = value;
+ }
+ }
+
+ private System.Windows.Forms.Timer _SearchBufferExpireTimer = null;
+ ///
+ /// Processes the keyboard character and executes the search through the nodes.
+ ///
+ /// Character to process.
+ ///
+ public virtual bool ProcessKeyboardCharacter(char p)
+ {
+ string searchString = UpdateSearchBuffer(p.ToString());
+ Node node = FindNodeByText(searchString, SelectedNode, true);
+ if (node == null && SelectedNode != null)
+ {
+ // Try from top searching
+ node = FindNodeByText(searchString, true);
+ }
+ else
+ {
+ while (node != null && !node.Selectable)
+ {
+ node = FindNodeByText(searchString, node, true);
+ }
+ }
+ if (node != null)
+ SelectNode(node, eTreeAction.Keyboard);
+ else
+ {
+ if (searchString.Length > 1 && _SearchBufferAutoClearNotFound)
+ {
+ searchString = p.ToString();
+ _SearchBuffer = searchString;
+ node = FindNodeByText(searchString, SelectedNode, true);
+ if (node == null && SelectedNode != null)
+ node = FindNodeByText(searchString, true);
+ if (node != null)
+ SelectNode(node, eTreeAction.Keyboard);
+ }
+ }
+
+ return false;
+ }
+
+ private int _SearchBufferExpireTimeout = 1000;
+ ///
+ /// Gets or sets the keyboard search buffer expiration timeout. Default value is 1000 which indicates that
+ /// key pressed within 1 second will add to the search buffer and control will be searched for node text
+ /// that begins with resulting string. Setting this value to 0 will disable the search buffer.
+ ///
+ [DefaultValue(1000), Category("Behavior"), Description("Indicates keyboard search buffer expiration timeout.")]
+ public int SearchBufferExpireTimeout
+ {
+ get { return _SearchBufferExpireTimeout; }
+ set
+ {
+ if (value < 0) value = 0;
+ _SearchBufferExpireTimeout = value;
+ }
+ }
+ private bool _SearchBufferAutoClearNotFound = true;
+ ///
+ /// Indicates whether search buffer is auto-cleared regardless of the expiration timeout if node is not found using current buffer content.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether search buffer is auto-cleared regardless of the expiration timeout if node is not found using current buffer content.")]
+ public bool SearchBufferAutoClearNotFound
+ {
+ get { return _SearchBufferAutoClearNotFound; }
+ set
+ {
+ _SearchBufferAutoClearNotFound = value;
+ }
+ }
+
+
+ private string _SearchBuffer = "";
+ private string UpdateSearchBuffer(string s)
+ {
+ if (_SearchBufferExpireTimeout <= 0)
+ return s;
+
+ if (_SearchBufferExpireTimer == null)
+ {
+ _SearchBufferExpireTimer = new System.Windows.Forms.Timer();
+ _SearchBufferExpireTimer.Interval = _SearchBufferExpireTimeout;
+ _SearchBufferExpireTimer.Tick += new EventHandler(SearchBufferExpireTimerTick);
+ _SearchBufferExpireTimer.Start();
+ }
+ else
+ _SearchBufferExpireTimer.Start();
+ _SearchBuffer += s;
+ return _SearchBuffer;
+ }
+
+ private void SearchBufferExpireTimerTick(object sender, EventArgs e)
+ {
+ _SearchBufferExpireTimer.Stop();
+ _SearchBuffer = "";
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ base.OnKeyDown(e);
+ if (!e.Handled)
+ KeyNavigation.KeyDown(this, e);
+ }
+
+ protected override bool IsInputChar(char charCode)
+ {
+ if (char.IsLetterOrDigit(charCode))
+ return true;
+ return base.IsInputChar(charCode);
+ }
+
+
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+ {
+ if (this.IsKeyboardFocusWithin && !this.Focused)
+ {
+ foreach (Cell item in m_HostedControlCells)
+ {
+ if (item.HostedControl != null && (item.HostedControl.Focused || item.HostedControl.ContainsFocus))
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+ }
+
+ if (!m_CellEditing)
+ {
+ if (this.AutoScroll && this.AutoScrollMinSize.Height > this.ClientRectangle.Height && _VScrollBar != null)
+ {
+ if (keyData == (Keys.Down | Keys.Control))
+ {
+ // Scroll UP
+ AutoScrollPosition = new Point(AutoScrollPosition.X, Math.Max(AutoScrollPosition.Y - _VScrollBar.SmallChange, -(_VScrollBar.Maximum - _VScrollBar.LargeChange)));
+ return true;
+ }
+ else if (keyData == (Keys.Up | Keys.Control))
+ {
+ // Scroll Down
+ AutoScrollPosition = new Point(AutoScrollPosition.X, Math.Min(0, AutoScrollPosition.Y + _VScrollBar.SmallChange));
+ return true;
+ }
+ }
+
+ if (keyData == Keys.Left || keyData == Keys.Right ||
+ keyData == Keys.Up || keyData == (Keys.Up | Keys.Shift) ||
+ keyData == Keys.Down || keyData == (Keys.Down | Keys.Shift) || keyData == Keys.End || keyData == Keys.Home ||
+ keyData == Keys.PageDown || keyData == Keys.PageUp)
+ {
+ return KeyNavigation.NavigateKeyDown(this, new KeyEventArgs(keyData));
+ }
+ }
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+
+ private ColumnHeader _MouseDownColumnHeader = null;
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+
+ if (!this.Focused)
+ this.Focus();
+
+ _AutoScrollPositionChange = Point.Empty; // Reset scroll change tracking see notes elsewhere in code for what this does
+
+ Point mousePos = GetLayoutPosition(e);
+ if (m_CellEditing)
+ {
+ m_CellMouseDownCounter = 0;
+ if (!EndCellEditing(eTreeAction.Mouse))
+ return;
+ }
+
+ NodeHitTestInfo info = e.Button == MouseButtons.Left && _FullRowSelect && _View != eView.Tile ? NodeOperations.GetNodeAt(this, mousePos.Y, false, true) : NodeOperations.GetNodeAt(this, mousePos.X, mousePos.Y, false, true);
+
+ if (_MouseOverColumnHeader != null && e.Button == MouseButtons.Left && AllowUserToResizeColumns)
+ {
+ if (info.ColumnsAt != null)
+ {
+ StartColumnResize(mousePos.X, mousePos.Y, info.ColumnsAt);
+ }
+ else if (_GridColumnLineResizeEnabled)
+ {
+ StartColumnResize(mousePos.X, mousePos.Y, m_Columns);
+ }
+ }
+ else if (info.ColumnsAt != null)
+ {
+ ColumnHeader ch = GetColumnAt(mousePos.X, mousePos.Y, info.ColumnsAt);
+ if (ch != null)
+ {
+ _MouseDownColumnHeader = ch;
+ ch.OnMouseDown(e);
+ }
+ }
+
+ Node node = info.NodeAt; // e.Button == MouseButtons.Left && _FullRowSelect ? this.GetNodeAt(mousePos.Y) : this.GetNodeAt(mousePos.X, mousePos.Y);
+ if (node != null)
+ OnNodeMouseDown(node, e, m_NodeDisplay.Offset);
+ else if (_MultiSelect && this.SelectedNodes.Count > 1 && (Control.ModifierKeys & (Keys.Control | Keys.Shift)) == Keys.None)
+ SelectNode(null, eTreeAction.Mouse);
+ m_MouseDownLocation = mousePos;
+
+#if !TRIAL
+ if (NodeOperations.keyValidated2 != 114 && !m_DialogDisplayed)
+ {
+ RemindForm f = new RemindForm();
+ f.ShowDialog();
+ f.Dispose();
+ m_DialogDisplayed = true;
+ }
+#endif
+ }
+
+ private DateTime _LastMouseUpTime = DateTime.MinValue;
+ private DateTime _IgnoreDoubleClickTime = DateTime.MinValue;
+ private bool _MovingColumn = false;
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+
+ if (_MouseDownColumnHeader != null)
+ _MouseDownColumnHeader.OnMouseUp(e);
+ _MouseDownColumnHeader = null;
+
+ if (_ColumnResize != null)
+ {
+ DateTime now = DateTime.Now;
+ ColumnHeader header = _ColumnResize;
+ _ColumnResize = null;
+ this.Capture = false;
+ if (_LastMouseUpTime == DateTime.MinValue || now.Subtract(_LastMouseUpTime).TotalMilliseconds > SystemInformation.DoubleClickTime)
+ _LastMouseUpTime = DateTime.Now;
+ else if (now.Subtract(_LastMouseUpTime).TotalMilliseconds <= SystemInformation.DoubleClickTime)
+ {
+ _LastMouseUpTime = DateTime.MinValue;
+ header.OnDoubleClick(EventArgs.Empty);
+ if (header.DoubleClickAutoSize) header.AutoSize();
+ if (header.Parent != null && header.Parent.ParentNode == null)
+ {
+ if (_ColumnHeader != null)
+ _ColumnHeader.IgnoreDoubleClickTime = now;
+ }
+ else if (header.Parent != null && header.Parent.Parent != null)
+ _IgnoreDoubleClickTime = now;
+ else
+ _IgnoreDoubleClickTime = DateTime.MinValue;
+
+ }
+ else
+ _LastMouseUpTime = DateTime.MinValue;
+ OnColumnResized(header, EventArgs.Empty);
+ InvalidateNodesSize();
+ return;
+ }
+ else
+ {
+ ColumnHeader columnToMove = _ColumnReorder;
+ if (columnToMove != null)
+ {
+ this.Cursor = _OldCursor;
+ _OldCursor = null;
+ ColumnHeaderCollection columnsCollection = columnToMove.Parent;
+ if (columnToMove.Parent == columnsCollection)
+ {
+ int moveToPosition = this.ColumnMoveMarkerIndex;
+ int newDisplayIndex = -1;
+ this.ColumnMoveMarkerIndex = -1;
+ if (moveToPosition >= -1)
+ {
+ _MovingColumn = true;
+ this.EndCellEditing(eTreeAction.Mouse);
+ if (moveToPosition == columnsCollection.Count)
+ newDisplayIndex = columnsCollection.GetDisplayIndex(columnsCollection.LastVisibleColumn) + 1;
+ else if (moveToPosition >= 0)
+ {
+ int displayIndex = columnsCollection.GetDisplayIndex(columnsCollection[moveToPosition]);
+ if (displayIndex >= 0)
+ newDisplayIndex = displayIndex;
+ else
+ newDisplayIndex = 0;
+ }
+ List displayIndexMap = columnsCollection.DisplayIndexMap;
+ int oldDisplayIndex = columnsCollection.GetDisplayIndex(columnToMove);
+ displayIndexMap.RemoveAt(oldDisplayIndex);
+ if (oldDisplayIndex < newDisplayIndex) newDisplayIndex--;
+ displayIndexMap.Insert(newDisplayIndex, columnsCollection.IndexOf(columnToMove));
+ columnsCollection.UpdatingDisplayIndexes = true;
+ for (int i = 0; i < displayIndexMap.Count; i++)
+ {
+ columnsCollection[displayIndexMap[i]].DisplayIndex = i;
+ }
+ columnsCollection.UpdatingDisplayIndexes = false;
+ _MovingColumn = false;
+ OnColumnMoved(new ColumnMovedEventArgs(columnToMove, oldDisplayIndex, newDisplayIndex));
+ InvalidateNodesSize();
+ Invalidate();
+ this.RecalcLayout();
+ }
+ }
+ _ColumnReorder = null;
+ }
+ }
+
+ _LastMouseUpTime = DateTime.MinValue;
+
+ ReleaseMouseOverColumnHeader();
+
+ OnNodeMouseUp(e);
+ }
+ ///
+ /// Raises ColumnResized event.
+ ///
+ /// ColumnHeader that was resized.
+ /// Event arguments
+ protected virtual void OnColumnResized(ColumnHeader header, EventArgs e)
+ {
+ EventHandler handler = ColumnResized;
+ if (handler != null)
+ handler(header, e);
+ }
+
+ ///
+ /// Raises ColumnMoved event.
+ ///
+ /// ColumnHeader that was moved.
+ /// Provides event arguments.
+ protected virtual void OnColumnMoved(ColumnMovedEventArgs e)
+ {
+ ColumnMovedHandler handler = ColumnMoved;
+ if (handler != null)
+ handler(this, e);
+ }
+ protected override void OnClick(EventArgs e)
+ {
+ base.OnClick(e);
+
+ OnNodeMouseClick(e);
+ }
+
+ protected override void OnDoubleClick(EventArgs e)
+ {
+ base.OnDoubleClick(e);
+ MouseEventArgs sourceArgs = e as MouseEventArgs;
+
+ Node selectedNode = this.SelectedNode;
+ if (selectedNode != null)
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ p = GetLayoutPosition(p);
+ if (selectedNode.Bounds.Contains(p) || _SelectionBoxStyle == eSelectionStyle.FullRowSelect && p.Y>=selectedNode.Bounds.Y && p.Y<=selectedNode.Bounds.Bottom)
+ {
+ Cell cell = GetCellAt(p);
+ bool toggle = true;
+ if (cell != null)
+ {
+ Rectangle r = NodeDisplay.GetCellRectangle(eCellRectanglePart.CheckBoxBounds, cell, m_NodeDisplay.Offset);
+ if (!r.IsEmpty && r.Contains(p))
+ toggle = false;
+ }
+ Node node = selectedNode;
+ if (_DoubleClickTogglesNode && toggle && (node.HasChildNodes || node.ExpandVisibility == eNodeExpandVisibility.Visible))
+ node.Toggle(eTreeAction.Mouse);
+
+ InvokeNodeDoubleClick(new TreeNodeMouseEventArgs(node,
+ (sourceArgs != null ? sourceArgs.Button : MouseButtons.Left),
+ 2,
+ 0,
+ p.X,
+ p.Y));
+ }
+
+ if (selectedNode.HasColumns && selectedNode.NodesColumnsHeaderVisible && selectedNode.CommandBounds.Contains(p))
+ {
+ ColumnHeader ch = GetColumnAt(p.X, p.Y, selectedNode.NodesColumns);
+ if (ch != null)
+ {
+ DateTime now = DateTime.Now;
+ if (_IgnoreDoubleClickTime != DateTime.MinValue && now.Subtract(_IgnoreDoubleClickTime).TotalMilliseconds <= SystemInformation.DoubleClickTime)
+ {
+ _IgnoreDoubleClickTime = DateTime.MinValue;
+ return;
+ }
+ _IgnoreDoubleClickTime = DateTime.MinValue;
+ ch.OnDoubleClick(e);
+ }
+ }
+ }
+ }
+
+ private bool _DoubleClickTogglesNode = true;
+ ///
+ /// Gets or sets whether double-clicking the node will toggle its expanded state. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether double-clicking the node will toggle its expanded state.")]
+ public bool DoubleClickTogglesNode
+ {
+ get { return _DoubleClickTogglesNode; }
+ set
+ {
+ _DoubleClickTogglesNode = value;
+ }
+ }
+
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+
+ if (m_MouseOverNode != null)
+ this.SetMouseOverNode(null);
+ }
+
+ protected override void OnMouseHover(EventArgs e)
+ {
+ base.OnMouseHover(e);
+ if (m_MouseOverNode != null && (FireHoverEvent || m_MouseOverNode.FireHoverEvent))
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ p = GetLayoutPosition(p);
+ InvokeNodeMouseHover(new TreeNodeMouseEventArgs(m_MouseOverNode, Control.MouseButtons, 0, 0, p.X, p.Y));
+ }
+ }
+
+ private ColumnHeader _MouseOverColumnHeader = null;
+ private ColumnHeaderCollection _MouseOverColumsHeaderCollection = null;
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ bool bUpdate = false;
+
+ if (m_MouseOverNode != null && m_MouseOverNode.Parent == null && m_MouseOverNode.TreeControl == null) // Node has been removed
+ SetMouseOverNode(null);
+
+ Point mousePos = GetLayoutPosition(e);
+
+ if (_MouseDownColumnHeader != null && _ColumnReorder == null && Math.Abs(mousePos.X - m_MouseDownLocation.X) >= 2 && _AllowUserToReorderColumns)
+ {
+ StartColumnReorder(e.X, e.Y, _MouseDownColumnHeader.Parent);
+ return;
+ }
+
+ if (_ColumnResize != null)
+ {
+ Point offset = Point.Empty;
+ if (AutoScroll)
+ {
+ offset = GetAutoScrollPositionOffset();
+ if (_MouseOverColumsHeaderCollection == null) // Main column header resize
+ offset.Y = 0;
+ }
+ Rectangle columnBounds = _ColumnResize.Bounds;
+ if (m_BackgroundStyle.PaddingLeft > 0 || m_BackgroundStyle.MarginLeft > 0)
+ columnBounds.X += m_BackgroundStyle.PaddingLeft + m_BackgroundStyle.MarginLeft;
+ columnBounds.Offset(offset);
+ columnBounds = GetScreenRectangle(columnBounds);
+ int columnWidth = Math.Max(Math.Max(2, _ColumnResize.MinimumWidth), mousePos.X - columnBounds.X);
+
+ if (columnWidth != _ColumnResize.Width.Absolute)
+ {
+ _ColumnResize.Width.AutoSize = false;
+ _ColumnResize.Width.Absolute = columnWidth;
+ OnColumnResizing(_ColumnResize, EventArgs.Empty);
+ if (_MouseOverColumsHeaderCollection != null) InvalidateNodeSize(_MouseOverColumsHeaderCollection.ParentNode);
+ this.Update();
+ if (_ColumnHeader != null) _ColumnHeader.Refresh();
+ if (m_CellEditing && _CellEditControl is Control)
+ {
+ Control editControl = (Control)_CellEditControl;
+ Rectangle rCell = NodeDisplay.GetCellRectangle(eCellRectanglePart.TextBounds, m_EditedCell, m_NodeDisplay.Offset);
+ rCell = GetScreenRectangle(rCell);
+ editControl.Bounds = rCell;
+ }
+ }
+ return;
+ }
+ else if (_ColumnReorder != null)
+ {
+ ColumnHeader col = GetColumnAt(mousePos.X, mousePos.Y, _ColumnReorder.Parent);
+ int columnIndex = -1;
+ if (col != null)
+ columnIndex = col.Parent.IndexOf(col);
+ else if (col == null)
+ {
+ ColumnHeader lastVisible = _ColumnReorder.Parent.LastVisibleColumn;
+ if (lastVisible != null && mousePos.X >= lastVisible.Bounds.Right)
+ columnIndex = _ColumnReorder.Parent.Count;
+ }
+ if (columnIndex >= 0)
+ {
+ this.ColumnMoveMarkerIndex = columnIndex;
+ }
+ return;
+ }
+
+ if (e.Button == MouseButtons.Left && !m_CellEditing && m_DragDropEnabled && m_MouseOverNode != null && m_DragNode == null && m_MouseOverNode.DragDropEnabled && m_MouseOverNode.IsSelected &&
+ (Math.Abs(m_MouseDownLocation.X - mousePos.X) > SystemInformation.DragSize.Width || Math.Abs(m_MouseDownLocation.Y - mousePos.Y) > SystemInformation.DragSize.Height))
+ {
+ StartDragDrop();
+ }
+
+ Rectangle r = Rectangle.Empty;
+ if (m_MouseOverNode != null)
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, m_MouseOverNode, m_NodeDisplay.Offset);
+
+ bool checkColumns = true;
+ if (_AllowUserToResizeColumns && _GridLines && _GridColumnLineResizeEnabled && m_Columns.Count > 0)
+ {
+ ColumnHeader mouseOverHeader = GetColumnForResizeAt(mousePos.X, mousePos.Y, m_Columns, true, false);
+ if (mouseOverHeader != null)
+ {
+ if (_MouseOverColumnHeader == null)
+ {
+ m_OriginalCursor = this.Cursor;
+ this.Cursor = Cursors.VSplit;
+ }
+ _MouseOverColumnHeader = mouseOverHeader;
+ checkColumns = false;
+ }
+ else
+ ReleaseMouseOverColumnHeader();
+ }
+
+ if (!r.IsEmpty && r.Contains(mousePos))
+ bUpdate = OnNodeMouseMove(m_MouseOverNode, e, m_NodeDisplay.Offset);
+ else
+ {
+ Node node = null;
+ NodeHitTestInfo info = null;
+ if (_FullRowSelect && _View == eView.Tree)
+ info = NodeOperations.GetNodeAt(this, mousePos.Y, true);
+ else
+ info = NodeOperations.GetNodeAt(this, mousePos.X, mousePos.Y, true);
+ node = info.NodeAt;
+ if (node != m_MouseOverNode)
+ bUpdate = SetMouseOverNode(node);
+
+ if (checkColumns)
+ {
+ // Check for mouse over Columns
+ if (node == null && info.ColumnsAt != null && _AllowUserToResizeColumns)
+ {
+ ColumnHeader mouseOverHeader = GetColumnForResizeAt(mousePos.X, mousePos.Y, info.ColumnsAt, false);
+ if (mouseOverHeader != null)
+ {
+ if (_MouseOverColumnHeader == null)
+ {
+ m_OriginalCursor = this.Cursor;
+ this.Cursor = Cursors.VSplit;
+ }
+ _MouseOverColumnHeader = mouseOverHeader;
+ _MouseOverColumsHeaderCollection = info.ColumnsAt;
+ }
+ else
+ ReleaseMouseOverColumnHeader();
+ }
+ else
+ ReleaseMouseOverColumnHeader();
+ }
+
+ if (m_MouseOverNode != null)
+ bUpdate = bUpdate | OnNodeMouseMove(m_MouseOverNode, e, m_NodeDisplay.Offset);
+ }
+
+ if (bUpdate)
+ this.Update();
+ }
+ ///
+ /// Raises ColumnResizing event.
+ ///
+ /// Column being resized
+ /// Event arguments
+ protected virtual void OnColumnResizing(ColumnHeader column, EventArgs e)
+ {
+ EventHandler handler = ColumnResizing;
+ if (handler != null) handler(column, e);
+ }
+ private void ReleaseMouseOverColumnHeader()
+ {
+ if (_MouseOverColumnHeader != null)
+ {
+ _MouseOverColumnHeader = null;
+ if (m_OriginalCursor != null)
+ this.Cursor = m_OriginalCursor;
+ else
+ this.Cursor = null;
+ m_OriginalCursor = null;
+ }
+ _MouseOverColumsHeaderCollection = null;
+ }
+
+ protected override void OnMouseWheel(MouseEventArgs e)
+ {
+ if (this.AutoScroll && _VScrollBar != null && !this.IsCellEditing)
+ {
+ if (e.Delta < 0)
+ {
+ AutoScrollPosition = new Point(AutoScrollPosition.X, Math.Max(AutoScrollPosition.Y - _VScrollBar.SmallChange * SystemInformation.MouseWheelScrollLines, -(_VScrollBar.Maximum - _VScrollBar.LargeChange)));
+ }
+ else
+ {
+ AutoScrollPosition = new Point(AutoScrollPosition.X, Math.Min(0, AutoScrollPosition.Y + _VScrollBar.SmallChange * SystemInformation.MouseWheelScrollLines));
+
+ }
+ }
+ base.OnMouseWheel(e);
+ }
+
+ ///
+ /// Deselect specified node. Use this method when multiple node selection is enabled to deselect single node or all nodes.
+ ///
+ /// Reference to node to select or null to deselect all selected nodes.
+ /// Action that is selecting the node.
+ public void DeselectNode(Node node, eTreeAction action)
+ {
+ if (!_MultiSelect || node == null)
+ {
+ SelectNode(null, action);
+ return;
+ }
+
+ if (!node.IsSelected) return;
+ m_SelectedNodes.Remove(node, action);
+ }
+
+ internal void InvokeSelectionChanged(EventArgs e)
+ {
+ OnSelectionChanged(e);
+ }
+
+ ///
+ /// Raises SelectionChanged event.
+ ///
+ /// Event arguments
+ protected virtual void OnSelectionChanged(EventArgs e)
+ {
+ EventHandler handler = SelectionChanged;
+ if (handler != null) handler(this, e);
+ }
+
+ internal void InvokeCellSelected(AdvTreeCellEventArgs e)
+ {
+ OnCellSelected(e);
+ }
+ ///
+ /// Raises CellSelected event.
+ ///
+ /// Event arguments.
+ protected virtual void OnCellSelected(AdvTreeCellEventArgs e)
+ {
+ AdvTreeCellEventHandler handler = CellSelected;
+ if (handler != null) handler(this, e);
+ }
+ internal void InvokeCellUnselected(AdvTreeCellEventArgs e)
+ {
+ OnCellUnselected(e);
+ }
+ ///
+ /// Raises CellUnselected event.
+ ///
+ /// Event arguments.
+ protected virtual void OnCellUnselected(AdvTreeCellEventArgs e)
+ {
+ AdvTreeCellEventHandler handler = CellUnselected;
+ if (handler != null) handler(this, e);
+ }
+
+ ///
+ /// Selected specified node.
+ ///
+ /// Node to select.
+ /// Action that is selecting the node.
+ public void SelectNode(Node node, eTreeAction action)
+ {
+ if (node != null && !node.Selectable && !this.DesignMode) return;
+ if (!_MultiSelect && node == m_SelectedNode) return;
+
+ AdvTreeNodeCancelEventArgs cancelArgs = new AdvTreeNodeCancelEventArgs(action, node);
+ OnBeforeNodeSelect(cancelArgs);
+ if (cancelArgs.Cancel)
+ return;
+
+ // Reset change tracking since if node is partially covered by scroll-bars and is scrolled into the view
+ // the NodeClick event does not get fired since mouse at that time points to different node due to scrolling.
+ // This offset is used to offset mouse position so correct node is found and NodeClick event is fired.
+ _AutoScrollPositionChange = Point.Empty;
+ if (_MultiSelect && !this.DesignMode)
+ {
+ if (m_SelectedNodes.Count > 0)
+ {
+ //m_SelectedNodes.SuspendClearEvents = true;
+ m_SelectedNodes.SourceAction = action;
+ m_SelectedNodes.Clear();
+ m_SelectedNodes.SourceAction = eTreeAction.Code;
+ //m_SelectedNodes.SuspendClearEvents = false;
+ }
+ bool fireSelection = false;
+ if (node != null)
+ {
+ m_SelectedNodes.SuspendEvents = true;
+ try
+ {
+ if (m_SelectedNodes.Add(node, action) != -1)
+ {
+ node.EnsureVisible();
+ fireSelection = true;
+ }
+ }
+ finally
+ {
+ m_SelectedNodes.SuspendEvents = false;
+ }
+ }
+ else
+ OnSelectionChanged(EventArgs.Empty);
+ this.Invalidate();
+ //OnSelectionChanged(EventArgs.Empty); // Fired from SelectedNodes collection
+ return;
+ }
+
+ //bool bUpdate=false;
+
+ if (m_CellEditing)
+ {
+ if (!EndCellEditing(eTreeAction.Code))
+ return;
+ }
+
+#if !TRIAL
+ if (NodeOperations.keyValidated2 < 114)
+ {
+ NodeDisplay.keyInvalid = true;
+ NodeOperations.keyValidated2 = NodeOperations.keyValidated2 + 124;
+ }
+ else if (NodeOperations.keyValidated2 > 114)
+ return;
+#endif
+ Node oldSelected = m_SelectedNode;
+ m_SelectedNode = node;
+
+ if (oldSelected != null)
+ {
+ oldSelected.IsSelected = false;
+ InvalidateNode(oldSelected);
+ //bUpdate = true;
+ if (oldSelected.GetSelectedCell() != null && oldSelected != node)
+ oldSelected.SetSelectedCell(null, action); // SelectedCell.SetSelected(false);
+ if (m_SelectedNodes.Contains(oldSelected))
+ m_SelectedNodes.Remove(oldSelected);
+ OnAfterNodeDeselect(new AdvTreeNodeEventArgs(action, oldSelected));
+ oldSelected.InternalDeselected(action);
+ }
+
+ if (m_SelectedNode != null)
+ {
+ m_SelectedNode.IsSelected = true;
+ m_SelectedNodes.Add(m_SelectedNode);
+ InvalidateNode(m_SelectedNode);
+ //bUpdate = true;
+ if (m_SelectedNode.SelectedCell == null)
+ {
+ m_SelectedNode.SelectFirstCell(action);
+ }
+ m_SelectedNode.EnsureVisible();
+ }
+
+ if (this.SelectedPathConnector != null)
+ this.Invalidate();
+
+ if (_DataManager != null && _EnableDataPositionChange)
+ {
+ if (node != null && node.BindingIndex > -1 && _DataManager.Position != node.BindingIndex)
+ {
+ _DataManager.Position = node.BindingIndex;
+ }
+ //else if (node == null && !_LoadingDataSource)
+ // _DataManager.Position = -1;
+ }
+
+ AdvTreeNodeEventArgs args = new AdvTreeNodeEventArgs(action, node);
+ OnAfterNodeSelect(args);
+
+ if (m_SelectedNode != null)
+ {
+ m_SelectedNode.InternalSelected(action);
+ }
+
+ OnSelectedIndexChanged(EventArgs.Empty);
+ if (!string.IsNullOrEmpty(this.ValueMember))
+ this.OnSelectedValueChanged(EventArgs.Empty);
+ OnSelectionChanged(EventArgs.Empty);
+ }
+
+ private void OnCellStyleChanged()
+ {
+ InvalidateNodesSize();
+ if (this.DesignMode)
+ {
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+
+ private void SetSizeChanged(Node node)
+ {
+ node.SizeChanged = true;
+ foreach (Node c in node.Nodes)
+ SetSizeChanged(c);
+ }
+
+
+ ///
+ /// Invalidates the size for all top-level nodes and their sub-nodes.
+ ///
+ public void InvalidateNodesSize()
+ {
+ if (_ColumnResize != null)
+ {
+ // To optimize perormace when resizing columns just invalidate visible columns
+ ArrayList paintedNodes = this.NodeDisplay.PaintedNodes;
+ foreach (Node paintedNode in paintedNodes)
+ {
+ SetSizeChanged(paintedNode);
+ }
+ }
+ else
+ {
+ foreach (Node node in m_Nodes)
+ SetSizeChanged(node);
+ }
+ }
+
+ ///
+ /// Invalidates the size for a node and its sub-nodes.
+ ///
+ /// Node to invalidate size for.
+ public void InvalidateNodeSize(Node node)
+ {
+ SetSizeChanged(node);
+ }
+
+ private void ImageListDisposed(object sender, EventArgs e)
+ {
+ if (sender == m_ImageList)
+ {
+ this.ImageList = null;
+ }
+ }
+
+ ///
+ /// Ensures that selected node is visible i.e. that all parents of the selected node are expanded. If not selects the first parent node not expanded.
+ ///
+ internal void ValidateSelectedNode()
+ {
+ Node node = this.SelectedNode;
+ Node nodeSelected = node;
+ if (node == null)
+ return;
+ if (node.TreeControl != this)
+ {
+ nodeSelected = null;
+ }
+ else
+ {
+ while (node != null)
+ {
+ node = node.Parent;
+ if (node != null && !node.Expanded && node.Selectable)
+ nodeSelected = node;
+ }
+ }
+ if (nodeSelected == null || !nodeSelected.IsVisible)
+ {
+ if (!SelectFirstNode(eTreeAction.Code))
+ this.SelectedNode = null;
+ }
+ else
+ {
+ if (_MultiSelect)
+ {
+ if (!this.SelectedNodes.Contains(nodeSelected))
+ this.SelectedNode = nodeSelected;
+ }
+ else
+ {
+ if (this.SelectedNode != nodeSelected)
+ this.SelectedNode = nodeSelected;
+ }
+ }
+ }
+
+ private bool SetMouseOverCell(Cell mouseOverCell)
+ {
+ bool bUpdate = false;
+ if (mouseOverCell == m_MouseOverCell)
+ return bUpdate;
+
+ if (m_MouseOverCell != null && m_MouseOverCell != mouseOverCell)
+ {
+ if (this.CellStyleMouseOver != null || m_MouseOverCell.StyleMouseOver != null || m_RenderMode != eNodeRenderMode.Default || m_MouseOverCell.Parent != null && m_MouseOverCell.Parent.RenderMode != eNodeRenderMode.Default)
+ bUpdate = true;
+ m_MouseOverCell.SetMouseOver(false);
+ if (m_MouseOverCell.Tooltip != null)
+ Interop.WinApi.ResetHover(this);
+ }
+
+ m_MouseOverCell = mouseOverCell;
+ if (m_MouseOverCell != null)
+ {
+ m_MouseOverCell.SetMouseOver(true);
+ if (this.CellStyleMouseOver != null || m_MouseOverCell.StyleMouseOver != null || m_RenderMode != eNodeRenderMode.Default || m_MouseOverCell.Parent != null && m_MouseOverCell.Parent.RenderMode != eNodeRenderMode.Default)
+ bUpdate = true;
+ }
+
+ UpdateTreeCursor();
+
+ return bUpdate;
+ }
+
+ private bool SetMouseOverNode(Node mouseOverNode)
+ {
+ bool bUpdate = false;
+ if (m_MouseOverNode != null)
+ {
+ bUpdate = bUpdate | SetMouseOverCell(null);
+ if (m_MouseOverNode.MouseOverNodePart == eMouseOverNodePart.Expand)
+ bUpdate = true;
+ m_MouseOverNode.MouseOverNodePart = eMouseOverNodePart.None;
+ if (this.NodeStyleMouseOver != null || this.CellStyleMouseOver != null || m_MouseOverNode.StyleMouseOver != null || this.NodeStyleMouseOver != null ||
+ m_RenderMode != eNodeRenderMode.Default || m_MouseOverNode.RenderMode != eNodeRenderMode.Default || m_MouseOverNode.CommandButton || bUpdate || _HotTracking)
+ {
+ InvalidateNode(m_MouseOverNode);
+ bUpdate = true;
+ }
+
+ if (m_MouseOverNode != mouseOverNode && m_MouseOverNode != null)
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ InvokeNodeMouseLeave(new TreeNodeMouseEventArgs(m_MouseOverNode, Control.MouseButtons, 0, 0, p.X, p.Y));
+ }
+ }
+
+ bool mouseOverNodeChanged = m_MouseOverNode != mouseOverNode;
+ m_MouseOverNode = mouseOverNode;
+
+ if (mouseOverNode != null)
+ {
+ mouseOverNode.MouseOverNodePart = eMouseOverNodePart.Node;
+ if (mouseOverNode.StyleMouseOver != null || this.NodeStyleMouseOver != null ||
+ m_RenderMode != eNodeRenderMode.Default || mouseOverNode.RenderMode != eNodeRenderMode.Default || mouseOverNode.CommandButton || _HotTracking)
+ {
+ InvalidateNode(mouseOverNode);
+ bUpdate = true;
+ }
+
+ Point p = this.PointToClient(Control.MousePosition);
+ InvokeNodeMouseEnter(new TreeNodeMouseEventArgs(mouseOverNode, Control.MouseButtons, 0, 0, p.X, p.Y));
+
+ if (mouseOverNodeChanged && (FireHoverEvent || mouseOverNode.FireHoverEvent))
+ {
+ Interop.WinApi.ResetHover(this);
+ }
+ }
+
+ return bUpdate;
+ }
+ private static readonly string DotNetBarPrefix = "DotNetBar.";
+ private void OnNodeMouseDown(Node node, MouseEventArgs e, Point offset)
+ {
+ Point mousePos = GetLayoutPosition(e);
+
+ InvokeNodeMouseDown(new TreeNodeMouseEventArgs(node, e.Button, e.Clicks, e.Delta, mousePos.X, mousePos.Y));
+
+ if (e.Button == MouseButtons.Left)
+ {
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandHitTestBounds, node, offset);
+
+ if (r.Contains(mousePos) && e.Clicks == 1 && node.ExpandVisibility != eNodeExpandVisibility.Hidden)
+ {
+ m_CellMouseDownCounter = 0;
+ node.Toggle(eTreeAction.Mouse);
+ return;
+ }
+
+ if (node.CommandButton)
+ {
+ m_CellMouseDownCounter = 0;
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.CommandBounds, node, offset);
+ if (r.Contains(mousePos))
+ {
+ InvokeCommandButtonClick(node, new CommandButtonEventArgs(eTreeAction.Mouse, node));
+ return;
+ }
+ }
+
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, offset);
+ if ((r.Contains(mousePos) || _FullRowSelect && mousePos.Y >= r.Y && mousePos.Y <= r.Bottom) && node.TreeControl != null)
+ {
+ if (node.TreeControl.SelectedNode != node)
+ m_CellMouseDownCounter = 0;
+
+ if (node.Selectable)
+ {
+ if (_MultiSelect && m_SelectedNodes.Count > 0 && Control.ModifierKeys == Keys.None && e.Button == MouseButtons.Left) // Deselect all
+ _SelectOnMouseUp = true;
+ else
+ _SelectOnMouseUp = false;
+
+ if (_MultiSelect && m_SelectedNodes.Count > 0 && (Control.ModifierKeys == Keys.Shift || Control.ModifierKeys == Keys.Control))
+ {
+ m_CellMouseDownCounter = 0;
+ if (_MultiSelectRule == eMultiSelectRule.SameParent && m_SelectedNodes[0].Parent != node.Parent) return;
+ if (Control.ModifierKeys == Keys.Shift && m_SelectedNodes.Count > 0)
+ {
+ // Range selection
+ Node startNode = m_SelectedNodes[0];
+ Node currentNode = node;
+ bool selectionChanged = false;
+ m_SelectedNodes.MultiNodeOperation = true;
+ try
+ {
+ while (m_SelectedNodes.Count > 1)
+ {
+ m_SelectedNodes.Remove(m_SelectedNodes[m_SelectedNodes.Count - 1], eTreeAction.Mouse);
+ selectionChanged = true;
+ }
+ }
+ finally
+ {
+ m_SelectedNodes.MultiNodeOperation = false;
+ }
+ if (currentNode != startNode)
+ {
+ if (currentNode.Bounds.Y > startNode.Bounds.Y)
+ {
+ // Selecting down
+ m_SelectedNodes.MultiNodeOperation = true;
+ try
+ {
+ do
+ {
+ if (!currentNode.IsSelected && currentNode.Selectable)
+ {
+ if (_MultiSelectRule == eMultiSelectRule.AnyNode ||
+ _MultiSelectRule == eMultiSelectRule.SameParent && m_SelectedNodes.Count > 0 && m_SelectedNodes[0].Parent == currentNode.Parent)
+ m_SelectedNodes.Add(currentNode, eTreeAction.Mouse);
+ }
+ currentNode = NodeOperations.GetPreviousVisibleNode(currentNode);
+
+ } while (startNode != currentNode && currentNode != null);
+ }
+ finally
+ {
+ m_SelectedNodes.MultiNodeOperation = false;
+ InvokeSelectionChanged(EventArgs.Empty);
+ }
+ }
+ else
+ {
+ // Selecting upwards
+ m_SelectedNodes.MultiNodeOperation = true;
+ try
+ {
+ do
+ {
+ if (!currentNode.IsSelected && currentNode.Selectable)
+ {
+ if (_MultiSelectRule == eMultiSelectRule.AnyNode ||
+ _MultiSelectRule == eMultiSelectRule.SameParent && m_SelectedNodes.Count > 0 && m_SelectedNodes[0].Parent == currentNode.Parent)
+ m_SelectedNodes.Add(currentNode, eTreeAction.Mouse);
+ }
+ currentNode = NodeOperations.GetNextVisibleNode(currentNode);
+
+ } while (startNode != currentNode && currentNode != null);
+ }
+ finally
+ {
+ m_SelectedNodes.MultiNodeOperation = false;
+ InvokeSelectionChanged(EventArgs.Empty);
+ }
+ }
+ }
+ else if (selectionChanged)
+ InvokeSelectionChanged(EventArgs.Empty);
+ }
+ else
+ {
+ if (node.IsSelected)
+ m_SelectedNodes.Remove(node, eTreeAction.Mouse);
+ else
+ m_SelectedNodes.Add(node, eTreeAction.Mouse);
+ }
+ //OnSelectionChanged(EventArgs.Empty);
+ return;
+ }
+ else if (!node.IsSelected)
+ {
+ SelectNode(node, eTreeAction.Mouse);
+ if (node.TreeControl == null || node.TreeControl.SelectedNode != node) // Action cancelled
+ return;
+ }
+ }
+
+ Cell cell = GetCellAt(node, mousePos.X, mousePos.Y, offset);
+ if (cell != null)
+ {
+ bool checkBoxSelection = false;
+ if (cell.CheckBoxVisible && cell.GetEnabled())
+ {
+ Rectangle rCheckBox = cell.CheckBoxBoundsRelative;
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, node, offset);
+ rCheckBox.Offset(r.Location);
+ if (rCheckBox.Contains(mousePos))
+ {
+
+ if (cell.CheckBoxThreeState)
+ {
+ if (cell.CheckState == CheckState.Checked)
+ cell.SetChecked(CheckState.Indeterminate, eTreeAction.Mouse);
+ else if (cell.CheckState == CheckState.Unchecked)
+ cell.SetChecked(CheckState.Checked, eTreeAction.Mouse);
+ else if (cell.CheckState == CheckState.Indeterminate)
+ cell.SetChecked(CheckState.Unchecked, eTreeAction.Mouse);
+ }
+ else
+ cell.SetChecked(!cell.Checked, eTreeAction.Mouse);
+ checkBoxSelection = true;
+ m_CellMouseDownCounter = 0;
+ }
+ }
+ if (node.SelectedCell != cell)
+ {
+ m_CellMouseDownCounter = 1;
+ }
+ else if (!checkBoxSelection)
+ m_CellMouseDownCounter++;
+ node.SetSelectedCell(cell, eTreeAction.Mouse);
+ cell.SetMouseDown(true);
+ }
+ }
+ else
+ m_CellMouseDownCounter = 0;
+ }
+ else if (e.Button == MouseButtons.Right)
+ {
+ if (node.TreeControl == null) return;
+ if (!node.IsSelected)
+ SelectNode(node, eTreeAction.Mouse);
+ if (!this.MultiSelect && node.TreeControl.SelectedNode != node) // Action cancelled
+ return;
+ if (node.ContextMenu != null)
+ {
+ if (node.ContextMenu is ContextMenu)
+ {
+ ContextMenu cm = node.ContextMenu as ContextMenu;
+ cm.Show(this, new Point(e.X, e.Y));
+ }
+ else if (node.ContextMenu.GetType().FullName == "System.Windows.Forms.ContextMenuStrip")
+ {
+ node.ContextMenu.GetType().InvokeMember("Show", System.Reflection.BindingFlags.InvokeMethod, null,
+ node.ContextMenu, new object[] { this, new Point(e.X, e.Y) });
+ }
+ else if (node.ContextMenu.GetType().FullName == "DevComponents.DotNetBar.ButtonItem")
+ {
+ Point p = this.PointToScreen(new Point(e.X, e.Y));
+ ((PopupItem)node.ContextMenu).SetSourceControl(this);
+ node.ContextMenu.GetType().InvokeMember("Popup", System.Reflection.BindingFlags.InvokeMethod,
+ null, node.ContextMenu, new object[] { p });
+ }
+ else if (node.ContextMenu.ToString().StartsWith(DotNetBarPrefix) && m_DotNetBarManager != null)
+ {
+ string menuName = node.ContextMenu.ToString().Substring(DotNetBarPrefix.Length);
+ object contextMenus = m_DotNetBarManager.GetType().InvokeMember("ContextMenus",
+ System.Reflection.BindingFlags.GetProperty, null, m_DotNetBarManager, null);
+ int index = (int)contextMenus.GetType().InvokeMember("IndexOf", System.Reflection.BindingFlags.InvokeMethod,
+ null, contextMenus, new string[] { menuName });
+ if (index >= 0)
+ {
+ IList list = contextMenus as IList;
+ object popup = list[index];
+ // Older version of DotNetBar do not have this method exposed so ignore the error...
+ try
+ {
+ popup.GetType().InvokeMember("SetSourceControl", System.Reflection.BindingFlags.InvokeMethod,
+ null, popup, new object[] { this });
+ }
+ catch { }
+
+ Point p = this.PointToScreen(new Point(e.X, e.Y));
+ popup.GetType().InvokeMember("Popup", System.Reflection.BindingFlags.InvokeMethod,
+ null, popup, new object[] { p });
+ }
+ }
+ }
+ }
+ }
+
+ private bool _SelectOnMouseUp = false;
+ private void OnNodeMouseUp(MouseEventArgs e)
+ {
+ bool bUpdate = false;
+ Point mousePos = GetLayoutPosition(e);
+
+ if (this.SelectedNode != null)
+ {
+ if (this.SelectedNode.SelectedCell != null && this.SelectedNode.SelectedCell.IsMouseDown)
+ {
+ this.SelectedNode.SelectedCell.SetMouseDown(false);
+ this.InvalidateNode(this.SelectedNode);
+ bUpdate = true;
+ }
+ }
+
+ if (bUpdate)
+ this.Update();
+
+ Node node = null;
+ if (this.SelectedNode != null && this.SelectedNode.Bounds.Contains(mousePos))
+ node = this.SelectedNode;
+ else
+ node = NodeOperations.GetNodeAt(this, mousePos.X, mousePos.Y, true).NodeAt; //this.GetNodeAt(mousePos);
+
+ if (_SelectOnMouseUp && node != null && node.IsSelected && _MultiSelect && m_SelectedNodes.Count > 1 && Control.ModifierKeys == Keys.None) // Deselect all
+ SelectNode(node, eTreeAction.Mouse);
+ _SelectOnMouseUp = false;
+ if (node != null)
+ {
+ InvokeNodeMouseUp(new TreeNodeMouseEventArgs(node, e.Button, e.Clicks, e.Delta, mousePos.X, mousePos.Y));
+ }
+ }
+
+ private void OnNodeMouseClick(EventArgs e)
+ {
+ if (this.SelectedNode == null)
+ return;
+ MouseEventArgs me = e as MouseEventArgs;
+ if (me == null)
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ me = new MouseEventArgs(MouseButtons.Left, 1, p.X, p.Y, 0);
+ }
+
+ Point mousePos = GetLayoutPosition(me);
+ NodeHitTestInfo info = (me.Button == MouseButtons.Left && _FullRowSelect && _View == eView.Tree) ? NodeOperations.GetNodeAt(this, mousePos.Y + _AutoScrollPositionChange.Y, true, true) : NodeOperations.GetNodeAt(this, mousePos.X, mousePos.Y, true, true);
+ _AutoScrollPositionChange = Point.Empty;
+ if (info.NodeAt != null && (info.NodeAt == this.SelectedNode || info.NodeAt.IsSelected && me.Button == System.Windows.Forms.MouseButtons.Right) && !info.NodeAt.ExpandPartRectangle.Contains(mousePos))
+ {
+ InvokeNodeClick(new TreeNodeMouseEventArgs(this.SelectedNode, me.Button, me.Clicks, me.Delta, me.X, me.Y));
+ if (m_CellMouseDownCounter > 1 && me.Button == MouseButtons.Left)
+ EditSelectedCell(eTreeAction.Mouse);
+ }
+
+ if (info.ColumnsAt != null)
+ {
+ ColumnHeader ch = GetColumnAt(mousePos.X, mousePos.Y, info.ColumnsAt);
+ if (ch != null)
+ {
+ ch.OnClick(e);
+ }
+ }
+
+ }
+
+ internal bool EditSelectedCell(eTreeAction actionSource)
+ {
+ // Start editing if allowed
+ if (this.CellEdit && this.SelectedNode != null && this.SelectedNode.SelectedCell != null && this.SelectedNode.SelectedCell.IsEditable)
+ {
+ EditCell(this.SelectedNode.SelectedCell, actionSource);
+ return true;
+ }
+ return false;
+ }
+
+ private bool _HotTracking = false;
+ ///
+ /// Gets or sets whether node is highlighted when mouse enters the node. Default value is false.
+ ///
+ ///
+ /// There are two ways to enable the node hot-tracking. You can set the HotTracking property to true in which case the
+ /// mouse tracking is enabled using system colors specified in TreeColorTable. You can also define the NodeStyleMouseOver
+ /// style which gets applied to the node when mouse is over the node.
+ ///
+ [DefaultValue(false), Category("Appearance"), Description("Indicates whether node is highlighted when mouse enters the node.")]
+ public bool HotTracking
+ {
+ get { return _HotTracking; }
+ set
+ {
+ _HotTracking = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Starts editing specified cell, places the cell into the edit mode.
+ ///
+ /// Cell to start editing.
+ /// Action that is a cause for the edit.
+ internal void EditCell(Cell cell, eTreeAction action)
+ {
+ EditCell(cell, action, null);
+ }
+
+ private ICellEditControl _CellEditControl = null;
+ ///
+ /// Starts editing specified cell, places the cell into the edit mode.
+ ///
+ /// Cell to start editing.
+ /// Action that is a cause for the edit.
+ /// Specifies the text to be edited instead of the text of the cell. Passing the NULL value will edit the text of the cell.
+ internal void EditCell(Cell cell, eTreeAction action, string initialText)
+ {
+ if (cell == null || !cell.GetEnabled()) return;
+
+ if (m_CellEditing)
+ {
+ if (!EndCellEditing(action))
+ return;
+ }
+
+ if (_MovingColumn)
+ throw new InvalidOperationException("Cannot initiate cell edit while column is being moved.");
+
+ CellEditEventArgs e = new CellEditEventArgs(cell, action, "");
+ OnBeforeCellEdit(e);
+ if (e.Cancel)
+ return;
+ // No editing on non-data nodes
+ if (_DataManager != null && cell.Parent.DataKey == null) return;
+
+ ICellEditControl editControl = GetCellEditor(cell);
+ if (editControl == null) return;
+
+ NodeOperations.EnsureVisible(cell);
+ this.Update();
+
+ TextBoxEx textBox = editControl as TextBoxEx;
+ Control control = editControl as Control;
+
+ Rectangle rCell = NodeDisplay.GetCellRectangle(eCellRectanglePart.TextBounds, cell, m_NodeDisplay.Offset);
+ if (rCell.IsEmpty)
+ {
+ rCell = NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds, cell, m_NodeDisplay.Offset);
+ if (string.IsNullOrEmpty(cell.Text)) // Move edit box so its next to the actual cell
+ rCell.X += rCell.Width;
+ }
+ rCell = GetScreenRectangle(rCell);
+ // It is important that text is assigned first or textbox will be resized to different size otherwise
+ editControl.CurrentValue = cell.Text;
+ editControl.EditWordWrap = cell.WordWrap;
+
+ Font font = CellDisplay.GetCellFont(this, cell);
+ if (m_ZoomFactor != 1 && font != null)
+ {
+ font = new Font(font.FontFamily, font.SizeInPoints * m_ZoomFactor);
+ }
+
+ control.Font = font;
+ control.Location = rCell.Location;
+ control.Size = rCell.Size;
+ control.Visible = true;
+ control.Focus();
+
+ if (textBox != null)
+ {
+ //if initial text is null then follow default behaviour of selecting all text
+ //if initial text is not null, set that as the default text and set the caret to the end of the text
+ if (initialText == null)
+ {
+ textBox.SelectAll();
+ }
+ else
+ {
+ textBox.Text = initialText;
+ textBox.Select(textBox.Text.Length, 0);
+ }
+ }
+
+ PrepareCellEditor(cell, editControl);
+
+ cell.Parent.SetEditing(true);
+ m_EditedCell = cell;
+ m_CellEditing = true;
+ _CellEditControl = editControl;
+ editControl.BeginEdit();
+ }
+
+ ///
+ /// Gets whether tree is in process of moving the column in response to user finishing the column move action.
+ ///
+ [Browsable(false)]
+ public bool IsMovingColumn
+ {
+ get { return _MovingColumn; }
+ }
+
+ ///
+ /// Called just before cell editor is released for editing.
+ ///
+ /// Reference to the cell being edited.
+ /// Reference to the editor control.
+ protected virtual void PrepareCellEditor(Cell cell, ICellEditControl editControl)
+ {
+ OnPrepareCellEditorControl(new PrepareCellEditorEventArgs(cell, editControl));
+ }
+
+ protected virtual void OnPrepareCellEditorControl(PrepareCellEditorEventArgs e)
+ {
+ PrepareCellEditorEventHandler h = PrepareCellEditorControl;
+ if (h != null) h(this, e);
+ }
+
+ ///
+ /// Raises the ProvideCustomCellEditor event.
+ ///
+ /// Event arguments.
+ protected virtual void OnProvideCustomCellEditor(CustomCellEditorEventArgs e)
+ {
+ CustomCellEditorEventHandler handler = ProvideCustomCellEditor;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Ends cell editing.
+ ///
+ /// Specifies which action is cause for end of the editing.
+ /// Returns true if edits were applied to the cell or false otherwise.
+ internal bool EndCellEditing(eTreeAction action)
+ {
+ return EndCellEditing(action, false);
+ }
+
+ private bool _CellEditEnding = false;
+ ///
+ /// Ends cell editing.
+ ///
+ /// Specifies which action is cause for end of the editing.
+ /// Returns true if edits were applied to the cell or false otherwise.
+ internal bool EndCellEditing(eTreeAction action, bool cancelEdit)
+ {
+ Cell editedCell = m_EditedCell;
+ if (editedCell == null || _CellEditControl == null)
+ {
+ m_CellEditing = false;
+ return true;
+ }
+ ICellEditControl editControl = _CellEditControl;
+ Control control = editControl as Control;
+
+ string text = editControl.CurrentValue.ToString();
+
+ CellEditEventArgs e = new CellEditEventArgs(editedCell, action, text, cancelEdit, editControl);
+ InvokeCellEditEnding(e);
+ if (e.Cancel)
+ return false;
+ this.Focus();
+ control.Visible = false;
+
+ text = e.NewText;
+ InvokeAfterCellEdit(e);
+ text = e.NewText;
+
+ if (!e.Cancel && editedCell.Text != text && !cancelEdit)
+ {
+ if (this.DesignMode && editedCell.Parent.Cells[0] == editedCell)
+ TypeDescriptor.GetProperties(editedCell.Parent)["Text"].SetValue(editedCell.Parent, text);
+ else
+ TypeDescriptor.GetProperties(editedCell)["Text"].SetValue(editedCell, text);
+ this.BeginUpdate();
+ this.RecalcLayout();
+ this.EndUpdate();
+ }
+
+ editedCell.Parent.SetEditing(false);
+
+ // Try to apply to data-binding
+ if (_DataSource != null)
+ {
+ object item = editedCell.Parent.DataKey;
+ string fieldName = this.Columns[editedCell.Parent.Cells.IndexOf(editedCell)].DataFieldName;
+ if (item != null)
+ {
+ IEditableObject editableObject = item as IEditableObject;
+ PropertyDescriptor descriptor;
+ if (_DataManager != null)
+ descriptor = _DataManager.GetItemProperties().Find(fieldName, true);
+ else
+ descriptor = TypeDescriptor.GetProperties(item).Find(fieldName, true);
+
+ if (descriptor != null)
+ {
+ if (_EnableDataPositionChange && _DataManager != null && _DataManager.Position != editedCell.Parent.BindingIndex)
+ _DataManager.Position = editedCell.Parent.BindingIndex;
+ if (editableObject != null)
+ editableObject.BeginEdit();
+
+ descriptor.SetValue(item, text);
+
+ if (editableObject != null)
+ editableObject.EndEdit();
+ }
+ }
+ }
+
+ m_EditedCell = null;
+ m_CellEditing = false;
+
+ OnAfterCellEditComplete(e);
+
+ if (editControl != m_EditTextBox)
+ {
+ this.Controls.Remove(control);
+ editControl.EditComplete -= new EventHandler(EditControlEndEdit);
+ editControl.CancelEdit -= new EventHandler(EditControlCancelEdit);
+ }
+ editControl.EndEdit();
+
+ return true;
+ }
+
+ ///
+ /// Raises the AfterCellEditComplete event.
+ ///
+ /// Provides information about event.
+ protected virtual void OnAfterCellEditComplete(CellEditEventArgs e)
+ {
+ CellEditEventHandler eh = AfterCellEditComplete;
+ if (eh != null) eh(this, e);
+ }
+
+ ///
+ /// Cancels the cell editing if it is in progress.
+ ///
+ /// Specifies which action is cause for canceling of editing.
+ internal void CancelCellEdit(eTreeAction action)
+ {
+ if (m_EditedCell == null)
+ return;
+
+ if (m_EditTextBox != null)
+ m_EditTextBox.Text = m_EditedCell.Text;
+ else
+ {
+ ICellEditControl editControl = _CellEditControl;
+ if (editControl != null)
+ editControl.CurrentValue = m_EditedCell.Text;
+ }
+ this.EndCellEditing(action, true);
+ }
+
+ private ICellEditControl GetCellEditor(Cell cell)
+ {
+ eCellEditorType editorType = cell.GetEffectiveEditorType();
+ ICellEditControl editor = null;
+
+ if (editorType == eCellEditorType.Default)
+ {
+ editor = GetTextBoxEditor();
+ if (editor is TextBox)
+ {
+ ColumnHeader header = NodeOperations.GetCellColumnHeader(this, cell);
+ if (header != null)
+ ((TextBox)editor).MaxLength = header.MaxInputLength;
+ else
+ ((TextBox)editor).MaxLength = 0;
+ }
+ }
+#if FRAMEWORK20
+ else if (editorType == eCellEditorType.NumericInteger)
+ {
+ IntegerCellEditor edit = new IntegerCellEditor();
+ edit.ShowUpDown = true;
+ editor = edit;
+ }
+ else if (editorType == eCellEditorType.NumericDouble)
+ {
+ DoubleCellEditor edit = new DoubleCellEditor();
+ edit.ShowUpDown = true;
+ editor = edit;
+ }
+ else if (editorType == eCellEditorType.NumericCurrency)
+ {
+ DoubleCellEditor edit = new DoubleCellEditor();
+ edit.DisplayFormat = "C";
+ edit.ShowUpDown = true;
+ editor = edit;
+ }
+ else if (editorType == eCellEditorType.Date)
+ {
+ DateTimeCellEditor edit = new DateTimeCellEditor();
+ edit.Format = DevComponents.Editors.eDateTimePickerFormat.Short;
+ edit.ButtonDropDown.Visible = true;
+ editor = edit;
+ }
+ else if (editorType == eCellEditorType.Time)
+ {
+ DateTimeCellEditor edit = new DateTimeCellEditor();
+ edit.Format = DevComponents.Editors.eDateTimePickerFormat.ShortTime;
+ edit.ButtonDropDown.Visible = true;
+ editor = edit;
+ }
+ else if (editorType == eCellEditorType.DateTime)
+ {
+ DateTimeCellEditor edit = new DateTimeCellEditor();
+ edit.Format = DevComponents.Editors.eDateTimePickerFormat.Custom;
+ CultureInfo currentCulture = DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture();
+ edit.CustomFormat = currentCulture.DateTimeFormat.ShortDatePattern + " " + currentCulture.DateTimeFormat.ShortTimePattern;
+ edit.DateTimeSelectorVisibility = DevComponents.Editors.DateTimeAdv.eDateTimeSelectorVisibility.Both;
+ edit.ButtonDropDown.Visible = true;
+ editor = edit;
+ }
+#endif
+ else if (editorType == eCellEditorType.Custom)
+ {
+ CustomCellEditorEventArgs e = new CustomCellEditorEventArgs(cell);
+ OnProvideCustomCellEditor(e);
+ if (e.EditControl == null)
+ throw new ArgumentNullException("CustomCellEditorEventArgs.EditControl must be set to the custom cell editor.");
+
+ editor = e.EditControl;
+ }
+
+ if (editor == null)
+ throw new NotImplementedException("Editor type " + editorType.ToString() + " not implemented.");
+
+ if (((Control)editor).Parent != this)
+ {
+ this.Controls.Add((Control)editor);
+ editor.EditComplete += new EventHandler(EditControlEndEdit);
+ editor.CancelEdit += new EventHandler(EditControlCancelEdit);
+ }
+
+ return editor;
+ }
+
+ private TextBoxEx GetTextBoxEditor()
+ {
+ if (m_EditTextBox == null)
+ {
+ m_EditTextBox = new TextBoxEx();
+ m_EditTextBox.Name = "DefaultCellEditor";
+ m_EditTextBox.AutoSize = false;
+ m_EditTextBox.PreventEnterBeep = true;
+ this.Controls.Add(m_EditTextBox);
+ m_EditTextBox.EditComplete += new EventHandler(EditControlEndEdit);
+ m_EditTextBox.CancelEdit += new EventHandler(EditControlCancelEdit);
+ }
+ return m_EditTextBox;
+ }
+
+ private void EditControlEndEdit(object sender, EventArgs e)
+ {
+ if (m_EditedCell == null)
+ return;
+
+ this.EndCellEditing(eTreeAction.Keyboard);
+ }
+
+ private void EditControlCancelEdit(object sender, EventArgs e)
+ {
+ CancelCellEdit(eTreeAction.Keyboard);
+ }
+
+ private void UpdateTreeCursor()
+ {
+ if (m_MouseOverCell != null)
+ {
+ if (m_MouseOverCell.Cursor != null && this.Cursor != m_MouseOverCell.Cursor)
+ {
+ if (m_OriginalCursor == null)
+ m_OriginalCursor = this.Cursor;
+ this.Cursor = m_MouseOverCell.Cursor;
+ }
+ else if (m_DefaultCellCursor != null && this.Cursor != m_DefaultCellCursor)
+ {
+ if (m_OriginalCursor == null)
+ m_OriginalCursor = this.Cursor;
+ this.Cursor = m_DefaultCellCursor;
+ }
+ }
+ else if (m_OriginalCursor != null)
+ {
+ this.Cursor = m_OriginalCursor;
+ m_OriginalCursor = null;
+ }
+ }
+
+ private Cell GetCellAt(Node node, int x, int y, Point offset)
+ {
+ Cell cellAt = null;
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, node, offset);
+ foreach (Cell cell in node.Cells)
+ {
+ if (!cell.IsVisible) continue;
+ Rectangle rCell = cell.BoundsRelative;
+ //rCell.Offset(offset);
+ rCell.Offset(r.Location);
+ if (rCell.Contains(x, y))
+ {
+ cellAt = cell;
+ break;
+ }
+ }
+ return cellAt;
+ }
+
+ private bool OnNodeMouseMove(Node node, MouseEventArgs e, Point offset)
+ {
+ Point mousePos = GetLayoutPosition(e);
+ InvokeNodeMouseMove(new TreeNodeMouseEventArgs(node, e.Button, e.Clicks, e.Delta, mousePos.X, mousePos.Y));
+
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandHitTestBounds, node, offset);
+ bool bUpdate = false;
+ if (r.Contains(mousePos) && node.ExpandVisibility != eNodeExpandVisibility.Hidden)
+ {
+ node.MouseOverNodePart = eMouseOverNodePart.Expand;
+ if (m_MouseOverCell != null)
+ {
+ bUpdate |= SetMouseOverCell(null);
+ }
+ bUpdate = true;
+ }
+ else if (node.MouseOverNodePart == eMouseOverNodePart.Expand)
+ {
+ node.MouseOverNodePart = eMouseOverNodePart.Node;
+ bUpdate = true;
+ }
+
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.CommandBounds, node, offset);
+ if (r.Contains(mousePos))
+ {
+ node.MouseOverNodePart = eMouseOverNodePart.Command;
+ if (m_MouseOverCell != null)
+ {
+ bUpdate |= SetMouseOverCell(null);
+ }
+ bUpdate = true;
+ }
+ else if (node.MouseOverNodePart != eMouseOverNodePart.Expand)
+ {
+ if (node.MouseOverNodePart != eMouseOverNodePart.Node)
+ {
+ node.MouseOverNodePart = eMouseOverNodePart.Node;
+ bUpdate = true;
+ }
+ Cell cell = GetCellAt(node, mousePos.X, mousePos.Y, offset);
+
+ if (cell != null)
+ {
+ bUpdate |= SetMouseOverCell(cell);
+ }
+ }
+
+ if (bUpdate)
+ InvalidateNode(node);
+ return bUpdate;
+ }
+ //
+ // private class MouseOverInfo
+ // {
+ // public DevComponents.AdvTree.Node Node=null;
+ // public DevComponents.AdvTree.Cell Cell=null;
+ // MouseOverInfo()
+ // {
+ // this.Node=null;
+ // this.Cell=null;
+ // }
+ // }
+
+ private void OnSelectionBoxChanged()
+ {
+ if (this.SelectedNode != null)
+ {
+ InvalidateNode(this.SelectedNode);
+ this.Update();
+ }
+ }
+
+ //private Color GetDefaultSelectionBoxBorderColor()
+ //{
+ // return Color.FromArgb(96,SystemColors.Highlight);
+ //}
+
+ //private Color GetDefaultSelectionBoxFillColor()
+ //{
+ // return Color.FromArgb(64,SystemColors.Highlight);
+ //}
+
+ private void OnCommandButtonChanged()
+ {
+ _LayoutSettings.CommandAreaWidth = m_CommandWidth;
+ this.RecalcLayout();
+ }
+
+ private void InvokeCellEditEnding(CellEditEventArgs e)
+ {
+ if (CellEditEnding != null)
+ CellEditEnding(this, e);
+ }
+
+ private void InvokeAfterCellEdit(CellEditEventArgs e)
+ {
+ if (AfterCellEdit != null)
+ AfterCellEdit(this, e);
+ }
+
+ ///
+ /// Raises BeforeNodeInsert event
+ ///
+ /// Node that is about to be inserted
+ /// Source of the event
+ internal protected virtual void InvokeBeforeNodeInsert(eTreeAction action, Node node, Node parentNode)
+ {
+ if (BeforeNodeInsert != null)
+ {
+ TreeNodeCollectionEventArgs e = new TreeNodeCollectionEventArgs(action, node, parentNode);
+ BeforeNodeInsert(this, e);
+ }
+ }
+
+ ///
+ /// Raises AfterNodeInsert event
+ ///
+ /// Node that is inserted
+ /// Source of the event
+ internal protected virtual void InvokeAfterNodeInsert(eTreeAction action, Node node, Node parentNode)
+ {
+ if (AfterNodeInsert != null)
+ {
+ TreeNodeCollectionEventArgs e = new TreeNodeCollectionEventArgs(action, node, parentNode);
+ AfterNodeInsert(this, e);
+ }
+ }
+
+ ///
+ /// Raises BeforeNodeRemove event
+ ///
+ /// Node that is about to be removed
+ /// Source of the event
+ internal protected virtual void InvokeBeforeNodeRemove(eTreeAction action, Node node, Node parentNode)
+ {
+ if (BeforeNodeRemove != null)
+ {
+ TreeNodeCollectionEventArgs e = new TreeNodeCollectionEventArgs(action, node, parentNode);
+ BeforeNodeRemove(this, e);
+ }
+ }
+
+ ///
+ /// Raises AfterNodeRemove event
+ ///
+ /// Node that is removed
+ /// Source of the event
+ internal protected virtual void InvokeAfterNodeRemove(eTreeAction action, Node node, Node parentNode)
+ {
+ if (AfterNodeRemove != null)
+ {
+ TreeNodeCollectionEventArgs e = new TreeNodeCollectionEventArgs(action, node, parentNode);
+ AfterNodeRemove(this, e);
+ }
+ }
+
+ ///
+ /// Called after node has been removed
+ ///
+ /// Node that is removed
+ /// Source of the event
+ internal protected virtual void NodeRemoved(eTreeAction action, Node node, Node parentNode, int indexOfRemovedNode)
+ {
+ InvokeAfterNodeRemove(action, node, parentNode);
+
+ if (m_NodeDisplay != null) m_NodeDisplay.PaintedNodes.Clear();
+
+ if (!this.IsDisposed)
+ RecalcLayout();
+
+ if (!this.IsUpdateSuspended)
+ {
+ bool updateSelection = false;
+ if (node.IsSelected)
+ updateSelection = true;
+ else
+ {
+ Node n = this.SelectedNode;
+ while (n != null)
+ {
+ if (n != null && n == node)
+ {
+ updateSelection = true;
+ break;
+ }
+ n = n.Parent;
+ }
+ }
+
+ if (updateSelection)
+ {
+ Node refNode = parentNode;
+ bool selectFirst = true;
+ if (parentNode != null)
+ {
+ if (parentNode.Nodes.Count > 0)
+ {
+ if (indexOfRemovedNode >= parentNode.Nodes.Count)
+ indexOfRemovedNode = parentNode.Nodes.Count - 1;
+ refNode = parentNode.Nodes[indexOfRemovedNode];
+ if (refNode.CanSelect)
+ {
+ this.SelectNode(refNode, action);
+ selectFirst = false;
+ refNode = null;
+ }
+ }
+ else
+ {
+ if (refNode.CanSelect)
+ {
+ this.SelectNode(refNode, action);
+ selectFirst = false;
+ refNode = null;
+ }
+ }
+
+ if (refNode != null)
+ {
+ while (refNode != null)
+ {
+ refNode = NodeOperations.GetPreviousVisibleNode(refNode);
+ if (refNode != null && refNode.CanSelect)
+ {
+ this.SelectNode(refNode, action);
+ selectFirst = false;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ int startIndex = indexOfRemovedNode;
+ if (this.Nodes.Count == indexOfRemovedNode) startIndex--;
+ if (startIndex > 0 && this.Nodes.Count > startIndex)
+ {
+ for (int i = startIndex; i >= 0; i--)
+ {
+ refNode = this.Nodes[i];
+ if (refNode.CanSelect && refNode.Visible && refNode.Enabled)
+ {
+ this.SelectNode(refNode, action);
+ selectFirst = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (selectFirst && !SelectFirstNode(action))
+ this.SelectNode(null, action);
+ }
+ this.Invalidate();
+ }
+ else
+ {
+ if (node.IsSelected)
+ {
+ if (MultiSelect)
+ this.SelectedNodes.Remove(node, action);
+ else
+ this.SelectNode(null, action);
+ }
+ }
+ }
+
+ private bool SelectFirstNode(eTreeAction action)
+ {
+ bool selected = false;
+ foreach (Node node in this.Nodes)
+ {
+ if (node.Selectable && node.Visible && node.Enabled)
+ {
+ this.SelectNode(node, action);
+ if (this.SelectedNode == node)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ ///
+ /// Invokes BeforeNodeDrop event. If overriden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeBeforeNodeDrop(TreeDragDropEventArgs e)
+ {
+ if (BeforeNodeDrop != null)
+ BeforeNodeDrop(this, e);
+ }
+
+ ///
+ /// Invokes AfterNodeDrop event. If overridden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeAfterNodeDrop(TreeDragDropEventArgs e)
+ {
+ if (AfterNodeDrop != null)
+ AfterNodeDrop(this, e);
+ }
+
+ ///
+ /// Invokes NodeMouseDown event. If overridden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeNodeMouseDown(TreeNodeMouseEventArgs e)
+ {
+ if (e.Node != null)
+ e.Node.InvokeNodeMouseDown(this, new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
+
+ if (NodeMouseDown != null)
+ NodeMouseDown(this, e);
+ }
+
+ ///
+ /// Invokes NodeMouseUp event. If overridden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeNodeMouseUp(TreeNodeMouseEventArgs e)
+ {
+ if (e.Node != null)
+ e.Node.InvokeNodeMouseUp(this, new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
+
+ if (NodeMouseUp != null)
+ NodeMouseUp(this, e);
+ }
+
+ ///
+ /// Invokes NodeMouseMove event. If overridden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeNodeMouseMove(TreeNodeMouseEventArgs e)
+ {
+ if (e.Node != null)
+ e.Node.InvokeNodeMouseMove(this, new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
+
+ if (NodeMouseMove != null)
+ NodeMouseMove(this, e);
+ }
+
+ internal void InternalInvokeNodeClick(TreeNodeMouseEventArgs e)
+ {
+ InvokeNodeClick(e);
+ }
+ ///
+ /// Invokes NodeClick event. If overridden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeNodeClick(TreeNodeMouseEventArgs e)
+ {
+ if (e.Node != null)
+ e.Node.InvokeNodeClick(this, e);
+
+ if (NodeClick != null)
+ NodeClick(this, e);
+ }
+
+ ///
+ /// Invokes NodeDoubleClick event. If overridden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeNodeDoubleClick(TreeNodeMouseEventArgs e)
+ {
+ if (e.Node != null)
+ e.Node.InvokeNodeDoubleClick(this, e);
+
+ if (NodeDoubleClick != null)
+ NodeDoubleClick(this, e);
+ }
+
+ ///
+ /// Invokes NodeMouseEnter event. If overriden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeNodeMouseEnter(TreeNodeMouseEventArgs e)
+ {
+ if (e.Node != null)
+ e.Node.InvokeNodeMouseEnter(this, e);
+
+ if (NodeMouseEnter != null)
+ NodeMouseEnter(this, e);
+ }
+
+ ///
+ /// Invokes NodeMouseLeave event. If overriden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeNodeMouseLeave(TreeNodeMouseEventArgs e)
+ {
+ if (e.Node != null)
+ e.Node.InvokeNodeMouseLeave(this, e);
+
+ if (NodeMouseLeave != null)
+ NodeMouseLeave(this, e);
+ }
+
+ ///
+ /// Invokes NodeMouseHover event. If overriden base implementation must be called in order for event to fire.
+ ///
+ /// Provides information about event
+ protected virtual void InvokeNodeMouseHover(TreeNodeMouseEventArgs e)
+ {
+ if (e.Node != null)
+ e.Node.InvokeNodeMouseHover(this, e);
+
+ if (NodeMouseHover != null)
+ NodeMouseHover(this, e);
+ }
+
+ private bool FireHoverEvent
+ {
+ get { return NodeMouseHover != null; }
+ }
+ #endregion
+
+ #region INodeNotify
+ void INodeNotify.ExpandedChanged(Node node)
+ {
+ if (!node.Expanded)
+ ValidateSelectedNode();
+ if (!this.IsUpdateSuspended)
+ {
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+
+ #endregion
+
+ #region Public Interface
+ private eView _View = eView.Tree;
+ ///
+ /// Gets or sets how control positions the items. Default value is standard TreeView layout.
+ ///
+ [DefaultValue(eView.Tree), Category("Appearance"), Description("Indicates how control positions the items.")]
+ public eView View
+ {
+ get { return _View; }
+ set
+ {
+ if (value != _View)
+ {
+ eView oldValue = _View;
+ _View = value;
+ OnViewChanged(oldValue, value);
+ }
+ }
+ }
+ private void OnViewChanged(eView oldValue, eView newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("View"));
+ if (newValue == eView.Tree)
+ {
+ m_NodeLayout = new NodeTreeLayout(this, this.ClientRectangle, _LayoutSettings);
+ //m_NodeLayout.NodeVerticalSpacing = _NodeSpacing;
+ }
+ else if (newValue == eView.Tile)
+ {
+ m_NodeLayout = new NodeTileLayout(this, this.ClientRectangle, _LayoutSettings);
+ //m_NodeLayout.NodeHorizontalSpacing = 8;
+ //m_NodeLayout.NodeVerticalSpacing = 8;
+ //m_NodeLayout.NodeVerticalSpacing = _NodeSpacing;
+ }
+ InvalidateNodesSize();
+ RecalcLayout();
+ }
+
+ private static readonly Color DefaultTileGroupLineColor = ColorScheme.GetColor(0xE2E2E2);
+ private Color _TileGroupLineColor = DefaultTileGroupLineColor;
+ ///
+ /// Gets or sets the color of the group divider line when in tile view.
+ ///
+ [Category("Columns"), Description("Indicates color of the group divider line when in tile view.")]
+ public Color TileGroupLineColor
+ {
+ get { return _TileGroupLineColor; }
+ set
+ {
+ _TileGroupLineColor = value;
+ if (_View == eView.Tile)
+ this.Invalidate();
+ }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTileGroupLineColor()
+ {
+ return !ColorFunctions.IsEqual(DefaultTileGroupLineColor, _TileGroupLineColor);
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTileGroupLineColor()
+ {
+ this.TileGroupLineColor = DefaultTileGroupLineColor;
+ }
+
+ ///
+ /// Save nodes to XmlDocument. New Node AdvTree is created and nodes are serialized into it.
+ ///
+ /// Reference to an instance of XmlDocument object
+ public void Save(XmlDocument document)
+ {
+ TreeSerializer.Save(this, document);
+ }
+
+ ///
+ /// Saves nodes to a file.
+ ///
+ /// File name to save nodes to.
+ public void Save(string fileName)
+ {
+ TreeSerializer.Save(this, fileName);
+ }
+
+ ///
+ /// Saves nodes to specified stream.
+ ///
+ /// Stream to save nodes to.
+ public void Save(Stream outStream)
+ {
+ TreeSerializer.Save(this, outStream);
+ }
+
+ ///
+ /// Saves nodes to specified writer.
+ ///
+ /// Writer to save nodes to.
+ public void Save(TextWriter writer)
+ {
+ TreeSerializer.Save(this, writer);
+ }
+
+ ///
+ /// Saves nodes to specified writer.
+ ///
+ /// Writer to save nodes to.
+ public void Save(XmlWriter writer)
+ {
+ TreeSerializer.Save(this, writer);
+ }
+
+ ///
+ /// Load nodes from file.
+ ///
+ /// File to load nodes from
+ public void Load(string fileName)
+ {
+ TreeSerializer.Load(this, fileName);
+ }
+
+ ///
+ /// Load nodes from stream.
+ ///
+ /// Stream to load from
+ public void Load(Stream inStream)
+ {
+ TreeSerializer.Load(this, inStream);
+ }
+
+ ///
+ /// Load nodes from reader.
+ ///
+ /// Reader to load from.
+ public void Load(XmlReader reader)
+ {
+ TreeSerializer.Load(this, reader);
+ }
+
+ ///
+ /// Load nodes from reader.
+ ///
+ /// Reader to load from.
+ public void Load(TextReader reader)
+ {
+ TreeSerializer.Load(this, reader);
+ }
+
+ ///
+ /// Load nodes from an XmlDocument object.
+ ///
+ /// Document to load Nodes from.
+ public void Load(XmlDocument document)
+ {
+ TreeSerializer.Load(this, document);
+ }
+
+ ///
+ /// Forces the control to invalidate its client area and immediately redraw itself
+ /// and any child controls. Note however that this method will node do anything if refresh
+ /// is suspended as result of call to BeginUpdate method without corresponding EndUpdate
+ /// call or if SuspendPaint property is set to true.
+ ///
+ public override void Refresh()
+ {
+ if (!this.IsUpdateSuspended && !this.SuspendPaint)
+ base.Refresh();
+ }
+
+ /////
+ ///// Sets the node map position when tree is in Map layout mode. The node's position
+ ///// can be set only for the sub-root nodes, i.e. nodes that are parented directly to
+ ///// top-level root node. Setting map position for any other node does not have any effect.
+ /////
+ /////
+ ///// Note that setting map position explicitly can change the position for other
+ ///// nodes that are on the same level as the node that you pass into this method. Since
+ ///// Map mode layouts the nodes clock-wise, setting the node position to Near will cause
+ ///// all nodes that are in collection after the reference node to be
+ ///// positioned Near as well.
+ ///// Similarly, setting the node position to Far will cause all nodes that are in
+ ///// collection before the reference node to be positioned Far as
+ ///// well.
+ /////
+ ///// Sub-root node to set layout position for.
+ ///// The position relative to the root node should take
+ //public void SetNodeMapPosition(Node node, eMapPosition position)
+ //{
+ // if(node==null || node.Parent==null)
+ // return;
+
+ // if(position==eMapPosition.Default)
+ // {
+ // node.SetMapSubRootPosition(position);
+ // }
+ // else if(position==eMapPosition.Near)
+ // {
+ // int start=node.Parent.Nodes.IndexOf(node);
+ // int end=node.Parent.Nodes.Count;
+ // for(int i=start;i=0;i--)
+ // node.Parent.Nodes[i].SetMapSubRootPosition(position);
+ // }
+ //}
+
+ private bool _ProcessingSortRequests = false;
+ private void ProcessSortRequests()
+ {
+ if (_ProcessingSortRequests) return;
+ _ProcessingSortRequests = true;
+ try
+ {
+ if (_TopLevelSortRequest)
+ {
+ _TopLevelSortRequest = false;
+ if (m_Columns.IsSorted)
+ m_Columns.UpdateSort();
+ }
+ if (_SortRequestNodes.Count > 0)
+ {
+ foreach (Node sortRequestNode in _SortRequestNodes)
+ {
+ if (sortRequestNode.NodesColumns.IsSorted)
+ sortRequestNode.NodesColumns.UpdateSort();
+ }
+ _SortRequestNodes.Clear();
+ }
+ }
+ finally
+ {
+ _ProcessingSortRequests = false;
+ }
+ }
+
+ private List _SortRequestNodes = new List();
+ private bool _TopLevelSortRequest = false;
+ internal void PushSortRequest()
+ {
+ PushSortRequest(null);
+ }
+ internal void PushSortRequest(Node parentNode)
+ {
+ if (parentNode == null)
+ _TopLevelSortRequest = true;
+ else if (!_SortRequestNodes.Contains(parentNode))
+ _SortRequestNodes.Add(parentNode);
+ }
+
+ ///
+ /// Disables any redrawing of the tree control. To maintain performance while items
+ /// are added one at a time to the control, call the BeginUpdate method. The BeginUpdate
+ /// method prevents the control from painting until the
+ /// EndUpdate method is called.
+ ///
+ public void BeginUpdate()
+ {
+ m_UpdateSuspended++;
+ }
+
+ ///
+ /// Enables the redrawing of the tree view. To maintain performance while items are
+ /// added one at a time to the control, call the BeginUpdate
+ /// method. The BeginUpdate method prevents the control from painting until the EndUpdate
+ /// method is called.
+ ///
+ ///
+ /// Call to EndUpdate will enable the layout and painting in tree control. If there
+ /// are any pending layouts the EndUpdate will call
+ /// RecalcLayout method to perform the layout and it will
+ /// repaint the control.
+ ///
+ public void EndUpdate()
+ {
+ EndUpdate(true);
+ }
+
+ ///
+ /// Enables the redrawing of the tree view. To maintain performance while items are
+ /// added one at a time to the control, call the BeginUpdate
+ /// method. The BeginUpdate method prevents the control from painting until the EndUpdate
+ /// method is called.
+ ///
+ /// Gets or sets whether layout and refresh of control is performed if there are no other update blocks pending.
+ public void EndUpdate(bool performLayoutAndRefresh)
+ {
+ if (m_UpdateSuspended > 0) m_UpdateSuspended--;
+ if (m_UpdateSuspended == 0 && performLayoutAndRefresh)
+ {
+ this.RecalcLayout();
+ this.Invalidate(true);
+ }
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified location.
+ ///
+ /// The Node at the specified point, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// The Point to evaluate and retrieve the node from.
+ public Node GetNodeAt(Point p)
+ {
+ return GetNodeAt(p.X, p.Y);
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified location.
+ ///
+ /// The TreeNode at the specified location, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// The X position to evaluate and retrieve the node from.
+ /// The Y position to evaluate and retrieve the node from.
+ public Node GetNodeAt(int x, int y)
+ {
+ return NodeOperations.GetNodeAt(this, x, y).NodeAt;
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified location.
+ ///
+ /// The TreeNode at the specified location, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// The X position to evaluate and retrieve the node from.
+ /// The Y position to evaluate and retrieve the node from.
+ /// Whether to enumerated displayed nodes only.
+ public Node GetNodeAt(int x, int y, bool displayedOnly)
+ {
+ return NodeOperations.GetNodeAt(this, x, y, displayedOnly).NodeAt;
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified vertical location.
+ ///
+ /// The TreeNode at the specified location, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the y parameter.
+ ///
+ /// The Y position to evaluate and retrieve the node from.
+ public Node GetNodeAt(int y)
+ {
+ return NodeOperations.GetNodeAt(this, y).NodeAt;
+ }
+
+ ///
+ /// Retrieves the node cell that is at the specified location.
+ ///
+ /// The Point to evaluate and retrieve the cell from.
+ /// The Cell at the specified point, in tree view coordinates.
+ public Cell GetCellAt(Point p)
+ {
+ return GetCellAt(p.X, p.Y);
+ }
+
+ ///
+ /// Retrieves the node cell that is at the specified location.
+ ///
+ /// The X position to evaluate and retrieve the cell from.
+ /// The Y position to evaluate and retrieve the cell from.
+ /// The Cell at the specified point, in tree view coordinates.
+ public Cell GetCellAt(int x, int y)
+ {
+ return GetCellAt(x, y, false);
+ }
+
+ ///
+ /// Retrieves the node cell that is at the specified location.
+ ///
+ /// The X position to evaluate and retrieve the cell from.
+ /// The Y position to evaluate and retrieve the cell from.
+ /// Whether to enumerated displayed nodes only.
+ /// The Cell at the specified point, in tree view coordinates.
+ public Cell GetCellAt(int x, int y, bool displayedOnly)
+ {
+ Node node = GetNodeAt(x, y, displayedOnly);
+ if (node != null)
+ {
+ return GetCellAt(node, x, y, m_NodeDisplay.Offset);
+ }
+ return null;
+ }
+
+ ///
+ /// Returns the reference to the node mouse is currently over or null (Nothing) if mouse is not over any node in tree.
+ ///
+ [Browsable(false)]
+ public Node MouseOverNode
+ {
+ get
+ {
+ return m_MouseOverNode;
+ }
+ }
+
+ ///
+ /// Specifies the mouse cursor displayed when mouse is over the cell. Default value
+ /// is null which means that default control cursor is used.
+ ///
+ ///
+ /// To specify cursor for each individual cell use
+ /// Cell.Cursor property.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Appearance"), Description("Specifies the default mouse cursor displayed when mouse is over the cell.")]
+ public Cursor DefaultCellCursor
+ {
+ get
+ {
+ return m_DefaultCellCursor;
+ }
+ set
+ {
+ if (m_DefaultCellCursor != value)
+ {
+ m_DefaultCellCursor = value;
+ }
+ }
+ }
+
+ /// Applies any layout changes to the tree control.
+ ///
+ /// Layout will not be performed if BeginUpdate is called. Any calls to the
+ /// RecalcLayout will return without executing requested layout operation.
+ ///
+ public void RecalcLayout()
+ {
+ if (this.IsUpdateSuspended)
+ {
+ m_PendingLayout = true;
+ return;
+ }
+ RecalcLayoutInternal();
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ InvalidateNodesSize();
+ RecalcLayout();
+ base.OnFontChanged(e);
+ }
+
+ ///
+ /// Gets reference to array of Cell objects that have HostedControl property set.
+ ///
+ internal ArrayList HostedControlCells
+ {
+ get { return m_HostedControlCells; }
+ }
+
+ private bool _FirstLayout = true;
+ private delegate void NoArgumentsDelegate();
+ ///
+ /// Recalculates layout for the tree control. Not affected by BeginUpdate call.
+ ///
+ internal void RecalcLayoutInternal()
+ {
+ if (this.Bounds.IsEmpty || this.IsDisposed) return;
+ if (this.InvokeRequired)
+ {
+ this.Invoke(new NoArgumentsDelegate(RecalcLayoutInternal));
+ return;
+ }
+
+ _FirstLayout = false;
+
+ // Process any pending sorting requests first
+ ProcessSortRequests();
+
+ Rectangle clientArea = Rectangle.Empty, controlRect = Rectangle.Empty;
+ GetClientAndControlRectangles(ref clientArea, ref controlRect);
+
+ m_NodeLayout.ClientArea = clientArea;
+ m_NodeLayout.LeftRight = this.RtlTranslateLeftRight(LeftRightAlignment.Left);
+ m_NodeLayout.PerformLayout();
+ m_PendingLayout = false;
+
+ UpdateScrollState(clientArea, controlRect);
+
+ if (_InvalidControlBorder)
+ UpdateControlBorderPanel();
+ RepositionHostedControls(true);
+ RepositionColumnHeader();
+ UpdateScrollBars();
+ this.Invalidate(true);
+ }
+ private void GetClientAndControlRectangles(ref Rectangle clientArea, ref Rectangle controlRect)
+ {
+ clientArea = GetInnerRectangle();
+ if ((m_Columns.Count > 0 && m_Columns.UsesRelativeSize || _View == eView.Tile) && _VScrollBar != null)
+ clientArea.Width -= _VScrollBar.Width;
+ controlRect = clientArea;
+
+ if (this.SelectionBoxStyle == eSelectionStyle.NodeMarker)
+ clientArea.Inflate(-this.SelectionBoxSize, -this.SelectionBoxSize);
+ else
+ {
+ if (this.DisplayRootNode != null && !this.DisplayRootNode.Selectable || this.Nodes.Count > 0 && !this.Nodes[0].Selectable)
+ clientArea.Height -= 2;
+ else
+ clientArea.Inflate(-1, -2);
+ }
+ }
+ private void UpdateScrollState()
+ {
+ Rectangle clientArea = Rectangle.Empty, controlRect = Rectangle.Empty;
+ GetClientAndControlRectangles(ref clientArea, ref controlRect);
+ UpdateScrollState(clientArea, controlRect);
+ }
+ private void UpdateScrollState(Rectangle clientArea, Rectangle controlRect)
+ {
+ Rectangle screenRect = GetScreenRectangle(new Rectangle(0, 0, m_NodeLayout.Width, m_NodeLayout.Height));
+ Size nodeLayoutSize = screenRect.Size;
+ if (nodeLayoutSize.Width > controlRect.Width || nodeLayoutSize.Height > controlRect.Height)
+ {
+ Size autoScrollMinSize = nodeLayoutSize;
+ if (this.SelectionBoxStyle == eSelectionStyle.NodeMarker)
+ {
+ autoScrollMinSize.Width += this.SelectionBoxSize * 2;
+ autoScrollMinSize.Height += this.SelectionBoxSize * 2;
+ }
+ else
+ {
+ //autoScrollMinSize.Width += 2;
+ autoScrollMinSize.Height += 2;
+ }
+ Rectangle inner = clientArea; //GetInnerRectangle();
+
+ if (nodeLayoutSize.Height > inner.Height && _VScrollBarVisible ||
+ nodeLayoutSize.Width > inner.Width && nodeLayoutSize.Height > inner.Height - SystemInformation.HorizontalScrollBarHeight)
+ autoScrollMinSize.Width += SystemInformation.VerticalScrollBarWidth;
+
+ if (_HScrollBarVisible)
+ autoScrollMinSize.Height += SystemInformation.HorizontalScrollBarHeight;
+
+ if (!this.AutoScroll)
+ {
+ this.BeginUpdate();
+ this.Invalidate();
+ this.AutoScroll = true;
+ this.AutoScrollMinSize = autoScrollMinSize;
+ this.AutoScrollPosition = m_NodeDisplay.DefaultOffset;
+ if (m_Columns.Count > 0 && m_Columns.UsesRelativeSize || _View == eView.Tile)
+ {
+ InvalidateNodesSize();
+ SetPendingLayout();
+ }
+ this.EndUpdate(false);
+ }
+ else if (this.AutoScrollMinSize != autoScrollMinSize)
+ {
+ this.BeginUpdate();
+ this.AutoScrollMinSize = autoScrollMinSize;
+ if (nodeLayoutSize.Width <= this.Bounds.Width && this.AutoScrollPosition.X != 0)
+ {
+ this.AutoScrollPosition = new Point(0, this.AutoScrollPosition.Y);
+ }
+ Point asp = this.AutoScrollPosition;
+ if (Math.Abs(asp.Y) > autoScrollMinSize.Height)
+ {
+ if (autoScrollMinSize.Height > inner.Height)
+ asp.Y = -(autoScrollMinSize.Height - inner.Height);
+ else
+ asp.Y = 0;
+ }
+ else if (nodeLayoutSize.Height <= this.Bounds.Height)
+ asp.Y = 0;
+ else if (asp.Y<0 && autoScrollMinSize.Height - Math.Abs(asp.Y) < clientArea.Height) // Overscroll test
+ {
+ asp.Y = -(autoScrollMinSize.Height - inner.Height);
+ }
+
+ if (Math.Abs(asp.X) > autoScrollMinSize.Width)
+ {
+ asp.X = -(autoScrollMinSize.Width - inner.Width);
+ }
+ else if (nodeLayoutSize.Width <= this.Bounds.Width)
+ asp.X = 0;
+ if (this.AutoScrollPosition != asp) this.AutoScrollPosition = asp;
+ this.EndUpdate(false);
+ }
+ else if(_AutoScrollPosition.X != 0 && nodeLayoutSize.Width <= controlRect.Width)
+ this.AutoScrollPosition = new Point(0, this.AutoScrollPosition.Y);
+ }
+ else if (this.AutoScroll)
+ {
+ this.BeginUpdate();
+ bool updateColumnsWidth = false;
+ if (m_Columns.Count > 0 && _VScrollBar != null)
+ {
+ if (m_Columns.UsesRelativeSize)
+ InvalidateNodesSize();
+ else
+ updateColumnsWidth = true;
+ }
+
+ this.AutoScroll = false;
+ m_NodeDisplay.Offset = m_NodeDisplay.DefaultOffset;
+ if (updateColumnsWidth) m_NodeLayout.UpdateTopLevelColumnsWidth();
+ this.EndUpdate(false);
+ }
+ else
+ m_NodeDisplay.Offset = m_NodeDisplay.DefaultOffset;
+ }
+ private bool _ClipHostedControls = true;
+ ///
+ /// Gets or sets whether hosted controls are clipped so they don't overlap the control borders. Default value is true.
+ ///
+ [Browsable(false), DefaultValue(true)]
+ public bool ClipHostedControls
+ {
+ get { return _ClipHostedControls; }
+ set
+ {
+ _ClipHostedControls = value;
+ UpdateControlBorderPanel();
+ }
+ }
+
+ internal bool IsRepositioningControls
+ {
+ get
+ {
+ return _IsRepositioningControls;
+ }
+ }
+ private bool _IsRepositioningControls = false;
+ private PanelControl _ControlBorderPanel = null;
+ private void RemoveControlBorderPanel()
+ {
+ if (_ControlBorderPanel == null) return;
+
+ if (_IsLayoutOrResize > 0)
+ {
+ if (_IsUpdateControlBorderPanelPending) return;
+
+ // Delay this due to http://support.microsoft.com/kb/949458 bug in WinForms and MDI-Child Forms
+ _IsUpdateControlBorderPanelPending = true;
+ InvokeDelayed(new MethodInvoker(delegate { this.RemoveControlBorderPanel(); }));
+ return;
+ }
+ _IsUpdateControlBorderPanelPending = false;
+
+ PanelControl control = _ControlBorderPanel;
+ _ControlBorderPanel = null;
+ this.Controls.Remove(control);
+ control.Dispose();
+ }
+
+ private bool _InvalidControlBorder = true;
+ ///
+ /// Gets or sets whether control border needs to be updated by calling UpdateControlBorderPanel()
+ ///
+ internal bool InvalidControlBorder
+ {
+ get { return _InvalidControlBorder; }
+ set
+ {
+ _InvalidControlBorder = value;
+ }
+ }
+ private bool _IsUpdateControlBorderPanelPending = false;
+ private void UpdateControlBorderPanel()
+ {
+ if (!_ClipHostedControls)
+ {
+ RemoveControlBorderPanel();
+ return;
+ }
+ if (m_HostedControlCells.Count > 0)
+ {
+ Rectangle innerRect = GetInnerRectangle();
+ Rectangle cr = this.ClientRectangle;
+ if (cr.Contains(innerRect) && innerRect != cr &&
+ innerRect.X > cr.X && innerRect.Right < cr.Right && innerRect.Y > cr.Y && innerRect.Bottom < cr.Bottom)
+ {
+ if (_ControlBorderPanel == null)
+ {
+ if (_IsLayoutOrResize > 0)
+ {
+ if (_IsUpdateControlBorderPanelPending) return;
+
+ // Delay this due to http://support.microsoft.com/kb/949458 bug in WinForms and MDI-Child Forms
+ _IsUpdateControlBorderPanelPending = true;
+ InvokeDelayed(new MethodInvoker(delegate { this.UpdateControlBorderPanel(); }));
+ return;
+ }
+ _IsUpdateControlBorderPanelPending = false;
+ _ControlBorderPanel = new PanelControl();
+ _ControlBorderPanel.CanSetRegion = false;
+ _ControlBorderPanel.Style.ApplyStyle(this.BackgroundStyle);
+ _ControlBorderPanel.Style.Class = this.BackgroundStyle.Class;
+ this.Controls.Add(_ControlBorderPanel);
+ }
+ _ControlBorderPanel.Bounds = cr;
+ Region region = new Region(cr);
+ region.Exclude(innerRect);
+ _ControlBorderPanel.Region = region;
+ _ControlBorderPanel.BringToFront();
+ }
+ else
+ {
+ RemoveControlBorderPanel();
+ }
+ }
+ else
+ RemoveControlBorderPanel();
+ _InvalidControlBorder = false;
+ }
+ private void RepositionHostedControls(bool performLayout)
+ {
+ if (_IsRepositioningControls) return;
+ try
+ {
+ _IsRepositioningControls = true;
+ if (m_HostedControlCells.Count > 0)
+ {
+ this.SuspendLayout();
+ if (this.AutoScroll)
+ m_NodeDisplay.Offset = GetAutoScrollPositionOffset();
+ m_NodeDisplay.MoveHostedControls();
+
+ this.ResumeLayout(performLayout);
+ }
+ else if (_ControlBorderPanel != null)
+ {
+ RemoveControlBorderPanel();
+ }
+
+ if (m_CellEditing && _CellEditControl is Control && m_EditedCell != null)
+ {
+ Point offset = m_NodeDisplay.Offset;
+ if (this.AutoScroll)
+ offset = GetAutoScrollPositionOffset();
+ Control editControl = (Control)_CellEditControl;
+ Rectangle rCell = NodeDisplay.GetCellRectangle(eCellRectanglePart.TextBounds, m_EditedCell, offset);
+ rCell = GetScreenRectangle(rCell);
+ editControl.Location = rCell.Location;
+ }
+
+
+ }
+ finally
+ {
+ _IsRepositioningControls = false;
+ }
+ }
+
+ ///
+ /// Gets the reference to internal vertical scroll-bar control if one is created or null if no scrollbar is visible.
+ ///
+ [Browsable(false)]
+ public DevComponents.DotNetBar.VScrollBarAdv VScrollBar
+ {
+ get
+ {
+ return _VScrollBar;
+ }
+ }
+
+ private bool _VScrollBarVisible = true;
+ ///
+ /// Gets or sets whether Vertical Scroll-bar is shown if needed because content of the control exceeds available height. Default value is true.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether Vertical Scroll-bar is shown if needed because content of the control exceeds available height.")]
+ public bool VScrollBarVisible
+ {
+ get { return _VScrollBarVisible; }
+ set
+ {
+ _VScrollBarVisible = value;
+ if (!_VScrollBarVisible && _VScrollBar != null) _VScrollBar.Visible = false;
+ }
+ }
+
+ private bool _HScrollBarVisible = true;
+ ///
+ /// Gets or sets whether Horizontal Scroll-bar is shown if needed because content of the control exceeds available width. Default value is true.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether Vertical Scroll-bar is shown if needed because content of the control exceeds available height.")]
+ public bool HScrollBarVisible
+ {
+ get { return _HScrollBarVisible; }
+ set
+ {
+ _HScrollBarVisible = value;
+ if (!_HScrollBarVisible && _HScrollBar != null) _HScrollBar.Visible = false;
+ }
+ }
+
+
+ ///
+ /// Gets the reference to internal horizontal scroll-bar control if one is created or null if no scrollbar is visible.
+ ///
+ [Browsable(false)]
+ public DevComponents.DotNetBar.ScrollBar.HScrollBarAdv HScrollBar
+ {
+ get
+ {
+ return _HScrollBar;
+ }
+ }
+
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new Size AutoScrollMargin
+ {
+ get { return base.AutoScrollMargin; }
+ set { base.AutoScrollMargin = value; }
+ }
+
+ private bool _AutoScroll = false;
+ ///
+ /// Gets or sets a value indicating whether the tree control enables the user to scroll to any nodes placed outside of its visible boundaries.
+ /// This property is managed internally by AdvTree control and should not be modified.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new bool AutoScroll
+ {
+ get { return _AutoScroll; }
+ set
+ {
+ if (_AutoScroll != value)
+ {
+ _AutoScroll = value;
+ UpdateScrollBars();
+ }
+ }
+ }
+
+ private Size _AutoScrollMinSize = Size.Empty;
+ ///
+ /// Gets or sets the minimum size of the auto-scroll. Returns a Size that represents the minimum height and width of the scrolling area in pixels.
+ /// This property is managed internally by AdvTree control and should not be modified.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new Size AutoScrollMinSize
+ {
+ get { return _AutoScrollMinSize; }
+ set
+ {
+ _AutoScrollMinSize = value;
+ UpdateScrollBars();
+ }
+ }
+
+ private Point _AutoScrollPositionChange = Point.Empty;
+ private Point _AutoScrollPosition = Point.Empty;
+ ///
+ /// Gets or sets the location of the auto-scroll position.
+ ///
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false), Description("Indicates location of the auto-scroll position.")]
+ public new Point AutoScrollPosition
+ {
+ get
+ {
+ return _AutoScrollPosition;
+ }
+ set
+ {
+ //if (value.X > 0) value.X = -value.X;
+ //if (value.Y > 0) value.Y = -value.Y;
+ if (_AutoScrollPosition != value)
+ {
+ _AutoScrollPositionChange = new Point(value.X - _AutoScrollPosition.X, value.Y - _AutoScrollPosition.Y);
+ _AutoScrollPosition = value;
+ if (_AutoScroll)
+ {
+ if (_VScrollBar != null && _VScrollBar.Value != -_AutoScrollPosition.Y)
+ _VScrollBar.Value = Math.Min(_VScrollBar.Maximum, Math.Max(_VScrollBar.Minimum, -_AutoScrollPosition.Y));
+ if (_HScrollBar != null && _HScrollBar.Value != -_AutoScrollPosition.X)
+ _HScrollBar.Value = Math.Min(_HScrollBar.Maximum, Math.Max(_HScrollBar.Minimum, -_AutoScrollPosition.X));
+ RepositionHostedControls(false);
+ Invalidate();
+ m_NodeDisplay.Offset = Point.Empty; // Reset render offset
+ if (_ColumnHeader != null) _ColumnHeader.Invalidate();
+ }
+ }
+ }
+ }
+
+ private void InvokeDelayed(MethodInvoker method)
+ {
+ Timer delayedInvokeTimer = new Timer();
+ delayedInvokeTimer = new Timer();
+ delayedInvokeTimer.Tag = method;
+ delayedInvokeTimer.Interval = 10;
+ delayedInvokeTimer.Tick += new EventHandler(DelayedInvokeTimerTick);
+ delayedInvokeTimer.Start();
+ }
+ void DelayedInvokeTimerTick(object sender, EventArgs e)
+ {
+ Timer timer = (Timer)sender;
+ MethodInvoker method = (MethodInvoker)timer.Tag;
+ timer.Stop();
+ timer.Dispose();
+ method.Invoke();
+ }
+
+ private bool _IsUpdateScrollBarsPending = false;
+ private void UpdateScrollBars()
+ {
+ if (_IsLayoutOrResize > 0)
+ {
+ //Form form = this.FindForm();
+ //if (form != null && form.IsMdiChild)
+ {
+ if (_IsUpdateScrollBarsPending) return;
+
+ // Delay this due to http://support.microsoft.com/kb/949458 bug in WinForms and MDI-Child Forms
+ _IsUpdateScrollBarsPending = true;
+ InvokeDelayed(new MethodInvoker(delegate { this.UpdateScrollBars(); }));
+ return;
+ }
+ }
+
+ _IsUpdateScrollBarsPending = false;
+ if (!_AutoScroll)
+ {
+ bool update = _HScrollBar != null || _VScrollBar != null;
+ RemoveHScrollBar();
+ RemoveVScrollBar();
+ if (_Thumb != null)
+ {
+ this.Controls.Remove(_Thumb);
+ _Thumb.Dispose();
+ _Thumb = null;
+ }
+ if (update)
+ this.Update();
+ return;
+ }
+
+ //Node root = GetDisplayRootNode();
+ Rectangle innerBounds = ElementStyleLayout.GetInnerRect(this.BackgroundStyle, this.ClientRectangle);
+ // Check do we need vertical scrollbar
+ Size scrollSize = _AutoScrollMinSize;
+ if (_VScrollBarVisible && scrollSize.Height > innerBounds.Height)
+ {
+ if (_VScrollBar == null)
+ {
+ _VScrollBar = new DevComponents.DotNetBar.VScrollBarAdv();
+ _VScrollBar.Appearance = _ScrollBarAppearance;
+ _VScrollBar.Width = GetVerticalScrollBarWidth();
+ this.Controls.Add(_VScrollBar);
+ _VScrollBar.BringToFront();
+ _VScrollBar.Scroll += new ScrollEventHandler(VScrollBarScroll);
+ }
+ if (_VScrollBar.Minimum != 0)
+ _VScrollBar.Minimum = 0;
+ int innerHeight = innerBounds.Height - 12;
+ if (_ColumnHeader != null && _ColumnHeader.Visible)
+ innerHeight -= _ColumnHeader.Height + 2;
+ if (_VScrollBar.LargeChange != innerHeight && innerHeight > 0)
+ _VScrollBar.LargeChange = innerHeight;
+ //if (root != null && root.Bounds.Height > 0)
+ // _VScrollBar.SmallChange = root.Bounds.Height;
+ //else
+ // _VScrollBar.SmallChange = 22;
+ _VScrollBar.SmallChange = (int)Math.Ceiling(this.Font.GetHeight());
+ if (_VScrollBar.Maximum != _AutoScrollMinSize.Height)
+ _VScrollBar.Maximum = _AutoScrollMinSize.Height;
+ if (_VScrollBar.Value != -_AutoScrollPosition.Y)
+ _VScrollBar.Value = (Math.Min(_VScrollBar.Maximum, Math.Abs(_AutoScrollPosition.Y)));
+ }
+ else
+ RemoveVScrollBar();
+
+ // Check horizontal scrollbar
+ if (_HScrollBarVisible && scrollSize.Width > innerBounds.Width)
+ {
+ if (_HScrollBar == null)
+ {
+ _HScrollBar = new DevComponents.DotNetBar.ScrollBar.HScrollBarAdv();
+ _HScrollBar.Appearance = _ScrollBarAppearance;
+ _HScrollBar.Height = GetHorizontalScrollBarHeight();
+ this.Controls.Add(_HScrollBar);
+ _HScrollBar.BringToFront();
+ _HScrollBar.Scroll += new ScrollEventHandler(HScrollBarScroll);
+ }
+ if (_HScrollBar.Minimum != 0)
+ _HScrollBar.Minimum = 0;
+ if (_HScrollBar.LargeChange != innerBounds.Width && innerBounds.Width > 0)
+ _HScrollBar.LargeChange = innerBounds.Width;
+ if (_HScrollBar.Maximum != _AutoScrollMinSize.Width)
+ _HScrollBar.Maximum = _AutoScrollMinSize.Width;
+ if (_HScrollBar.Value != -_AutoScrollPosition.X)
+ _HScrollBar.Value = (Math.Min(_HScrollBar.Maximum, Math.Abs(_AutoScrollPosition.X)));
+ //if (root != null && root.Bounds.Height > 0)
+ // _HScrollBar.SmallChange = root.Bounds.Height;
+ //else
+ // _HScrollBar.SmallChange = 22;
+ _HScrollBar.SmallChange = (int)Math.Ceiling(this.Font.GetHeight());
+ }
+ else
+ RemoveHScrollBar();
+
+ RepositionScrollBars();
+
+ if (_Thumb != null)
+ _Thumb.BringToFront();
+ }
+
+ private static int GetHorizontalScrollBarHeight()
+ {
+ return SystemInformation.HorizontalScrollBarHeight;
+ }
+
+ private static int GetVerticalScrollBarWidth()
+ {
+ return SystemInformation.VerticalScrollBarWidth;
+ }
+
+ private void VScrollBarScroll(object sender, ScrollEventArgs e)
+ {
+ if (e.NewValue != e.OldValue)
+ {
+ _AutoScrollPosition.Y = -e.NewValue;
+ RepositionHostedControls(false);
+ this.Invalidate();
+ if (_ColumnHeader != null) _ColumnHeader.Invalidate();
+ if (e.Type == ScrollEventType.ThumbTrack && m_HostedControlCells.Count > 0)
+ this.Update();
+ }
+ OnScroll(new ScrollEventArgs(e.Type, e.OldValue, e.NewValue, ScrollOrientation.VerticalScroll));
+ }
+ private void HScrollBarScroll(object sender, ScrollEventArgs e)
+ {
+ _AutoScrollPosition.X = -e.NewValue;
+ RepositionHostedControls(false);
+ this.Invalidate();
+ if (_ColumnHeader != null) _ColumnHeader.Invalidate();
+ if (e.Type == ScrollEventType.ThumbTrack && m_HostedControlCells.Count > 0)
+ this.Update();
+
+ OnScroll(new ScrollEventArgs(e.Type, e.OldValue, e.NewValue, ScrollOrientation.HorizontalScroll));
+ }
+
+ private void RepositionScrollBars()
+ {
+ Rectangle innerBounds = ElementStyleLayout.GetInnerRect(this.BackgroundStyle, this.ClientRectangle);
+ if (_HScrollBar != null)
+ {
+ int width = innerBounds.Width;
+ if (_VScrollBar != null)
+ width -= _VScrollBar.Width;
+ _HScrollBar.Bounds = new Rectangle(innerBounds.X, innerBounds.Height - GetHorizontalScrollBarHeight() + 1, width, GetHorizontalScrollBarHeight());
+ }
+
+ if (_VScrollBar != null)
+ {
+ int height = innerBounds.Height;
+ if (_HScrollBar != null)
+ height -= _HScrollBar.Height;
+ _VScrollBar.Bounds = new Rectangle(innerBounds.Right - GetVerticalScrollBarWidth(), innerBounds.Y, GetVerticalScrollBarWidth(), height);
+ }
+
+ if (_VScrollBar != null && _HScrollBar != null)
+ {
+ if (_Thumb == null)
+ {
+ _Thumb = new Control();
+ _Thumb.BackColor = this.BackColor;
+ this.Controls.Add(_Thumb);
+ }
+ _Thumb.Bounds = new Rectangle(_HScrollBar.Bounds.Right, _VScrollBar.Bounds.Bottom, _VScrollBar.Width, _HScrollBar.Height);
+ }
+ else if (_Thumb != null)
+ {
+ this.Controls.Remove(_Thumb);
+ _Thumb.Dispose();
+ _Thumb = null;
+ }
+ RepositionColumnHeader();
+ }
+
+ internal int ColumnHeaderHeight
+ {
+ get
+ {
+ return _ColumnHeader != null ? _ColumnHeader.Height : 0;
+ }
+ }
+
+ private void RepositionColumnHeader()
+ {
+ Rectangle innerBounds = ElementStyleLayout.GetInnerRect(this.BackgroundStyle, this.ClientRectangle);
+ if (_ColumnHeader != null)
+ {
+ Rectangle r = GetScreenRectangle(new Rectangle(innerBounds.X, innerBounds.Y,
+ innerBounds.Width - (_VScrollBar != null ? _VScrollBar.Width : 0), _ColumnHeader.Columns.Bounds.Height));
+ r.X = innerBounds.X;
+ r.Y = innerBounds.Y;
+ r.Width = Math.Max(0, innerBounds.Width - (_VScrollBar != null ? _VScrollBar.Width : 0));
+ r.Height = Math.Max(0, r.Height);
+ _ColumnHeader.Bounds = r;
+ _ColumnHeader.BringToFront();
+ }
+ }
+
+ private void RemoveHScrollBar()
+ {
+ if (_HScrollBar != null)
+ {
+ Rectangle r = _HScrollBar.Bounds;
+ this.Controls.Remove(_HScrollBar);
+ _HScrollBar.Dispose();
+ _HScrollBar = null;
+ this.Invalidate(r);
+ }
+ }
+
+ private void RemoveVScrollBar()
+ {
+ if (_VScrollBar != null)
+ {
+ Rectangle r = _VScrollBar.Bounds;
+ this.Controls.Remove(_VScrollBar);
+ _VScrollBar.Dispose();
+ _VScrollBar = null;
+ this.Invalidate(r);
+ }
+ }
+
+ private System.Drawing.Drawing2D.Matrix GetTranslationMatrix(float zoom)
+ {
+ System.Drawing.Drawing2D.Matrix mx = new System.Drawing.Drawing2D.Matrix(zoom, 0, 0, zoom, 0, 0);
+ if (this.CenterContent)
+ {
+ float offsetX = 0, offsetY = 0;
+ if (this.AutoScroll)
+ {
+ if (this.Width > this.NodeLayout.Width)
+ {
+ if (this.Width < this.NodeLayout.Width * zoom)
+ offsetX = -(this.Width - this.NodeLayout.Width) / 2;
+ else
+ offsetX = (this.Width * (1.0f / zoom) - this.Width) / 2;
+ }
+
+ if (this.Height > this.NodeLayout.Height)
+ {
+ if (this.Height < this.NodeLayout.Height * zoom)
+ offsetY = -(this.Height - this.NodeLayout.Height) / 2;
+ else
+ offsetY = (this.Height * (1.0f / zoom) - this.Height) / 2;
+ }
+ }
+ else
+ {
+ offsetX = (this.Width * (1.0f / zoom) - this.Width) / 2;
+ offsetY = (this.Height * (1.0f / zoom) - this.Height) / 2;
+ }
+
+ mx.Translate(offsetX, offsetY);
+ }
+ return mx;
+ }
+
+ ///
+ /// Returns translation matrix for current Zoom. Translation matrix is used to translate internal node coordinates to screen
+ /// coordinates when Zoom is not set to 1.
+ ///
+ /// Returns new instance of Matrix object.
+ public System.Drawing.Drawing2D.Matrix GetTranslationMatrix()
+ {
+ return GetTranslationMatrix(m_ZoomFactor);
+ }
+
+ ///
+ /// Returns layout based rectangle from screen rectangle. Layout based rectangle will be different
+ /// from screen rectangle when Zoom is not set to 1. This method will translate the screen rectangle enlarged by Zoom
+ /// to layout rectangle which does not have Zoom applied.
+ ///
+ /// Screen rectangle
+ /// Layout rectangle
+ public virtual Rectangle GetLayoutRectangle(Rectangle r)
+ {
+ if (m_ZoomFactor == 1)
+ return r;
+
+ Point[] p = new Point[] { new Point(r.X, r.Y), new Point(r.Right, r.Bottom) };
+ using (System.Drawing.Drawing2D.Matrix mx = GetTranslationMatrix())
+ {
+ mx.Invert();
+ mx.TransformPoints(p);
+ }
+ return new Rectangle(p[0].X, p[0].Y, p[1].X - p[0].X, p[1].Y - p[0].Y);
+ }
+
+ ///
+ /// Returns mouse position which is translated if control Zoom is not equal 1
+ ///
+ /// Mouse event arguments
+ /// Returns translated position
+ protected virtual Point GetLayoutPosition(MouseEventArgs e)
+ {
+ return GetLayoutPosition(e.X, e.Y);
+ }
+
+ ///
+ /// Returns mouse position which is translated if control Zoom is not equal 1
+ ///
+ /// Mouse position
+ /// Returns translated position
+ public virtual Point GetLayoutPosition(Point mousePosition)
+ {
+ return GetLayoutPosition(mousePosition.X, mousePosition.Y);
+ }
+
+ ///
+ /// Returns mouse position which is translated if control Zoom is not equal 1
+ ///
+ /// X coordinate
+ /// Y coordinate
+ ///
+ public virtual Point GetLayoutPosition(int x, int y)
+ {
+ if (m_ZoomFactor == 1)
+ return new Point(x, y);
+ Point[] p = new Point[] { new Point(x, y) };
+ using (System.Drawing.Drawing2D.Matrix mx = GetTranslationMatrix())
+ {
+ mx.Invert();
+ mx.TransformPoints(p);
+ }
+ return p[0];
+ }
+
+ ///
+ /// Returns rectangle translated to screen rectangle if Zoom is not equal 1.
+ ///
+ /// Rectangle to translate
+ /// Screen Rectangle
+ public virtual Rectangle GetScreenRectangle(Rectangle r)
+ {
+ if (m_ZoomFactor == 1)
+ return r;
+ Point[] p = new Point[] { new Point(r.X, r.Y), new Point(r.Right, r.Bottom) };
+ using (System.Drawing.Drawing2D.Matrix mx = GetTranslationMatrix())
+ {
+ mx.TransformPoints(p);
+ }
+ return new Rectangle(p[0].X, p[0].Y, p[1].X - p[0].X, p[1].Y - p[0].Y);
+ }
+
+ ///
+ /// Returns size translated to screen dimension if Zoom is not equal 1.
+ ///
+ /// Size to translate
+ /// Screen Size
+ public virtual Size GetScreenSize(Size s)
+ {
+ return GetScreenRectangle(new Rectangle(Point.Empty, s)).Size;
+ }
+
+ internal void InvokeColumnHeaderMouseUp(object sender, MouseEventArgs e)
+ {
+ OnColumnHeaderMouseUp(sender, e);
+ }
+ ///
+ /// Raises ColumnHeaderMouseUp event.
+ ///
+ /// Reference to ColumnHeader
+ /// Event arguments
+ protected virtual void OnColumnHeaderMouseUp(object sender, MouseEventArgs e)
+ {
+ if (ColumnHeaderMouseUp != null)
+ ColumnHeaderMouseUp(sender, e);
+ }
+
+ internal void InvokeColumnHeaderMouseDown(object sender, MouseEventArgs e)
+ {
+ OnColumnHeaderMouseDown(sender, e);
+ }
+ ///
+ /// Raises ColumnHeaderMouseDown event.
+ ///
+ /// Reference to ColumnHeader
+ /// Event arguments
+ protected virtual void OnColumnHeaderMouseDown(object sender, MouseEventArgs e)
+ {
+ if (ColumnHeaderMouseDown != null)
+ ColumnHeaderMouseDown(sender, e);
+ }
+
+ ///
+ /// Gets the list of all checked nodes in tree including child nodes.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public System.Collections.Generic.List CheckedNodes
+ {
+ get
+ {
+ System.Collections.Generic.List items = new System.Collections.Generic.List();
+ NodeCollection itemsCollection = this.Nodes;
+ GetSelectedNodes(items, itemsCollection);
+ return items;
+ }
+ }
+
+ private static void GetSelectedNodes(System.Collections.Generic.List items, NodeCollection itemsCollection)
+ {
+ foreach (Node item in itemsCollection)
+ {
+ if (item.Checked)
+ items.Add(item);
+
+ if (item.HasChildNodes)
+ {
+ GetSelectedNodes(items, item.Nodes);
+ }
+ }
+ }
+ #endregion
+
+ #region Event Invocation
+ ///
+ /// Calls OnBeforeCheck method which fired
+ /// OnBeforeCheck event.
+ ///
+ /// Event arguments.
+ internal void InvokeBeforeCheck(AdvTreeCellBeforeCheckEventArgs e)
+ {
+ OnBeforeCheck(e);
+ }
+
+ /// Raises the BeforeCheck event.
+ ///
+ /// A AdvTreeCellBeforeCheckEventArgs that contains the event
+ /// data.
+ ///
+ protected virtual void OnBeforeCheck(AdvTreeCellBeforeCheckEventArgs e)
+ {
+ if (BeforeCheck != null)
+ BeforeCheck(this, e);
+ }
+
+ ///
+ /// Calls OnAfterCheck method which fired
+ /// AfterCheck event.
+ ///
+ /// Event arguments.
+ internal void InvokeAfterCheck(AdvTreeCellEventArgs e)
+ {
+ OnAfterCheck(e);
+ }
+
+ /// Raises the AfterCheck event.
+ ///
+ /// A AdvTreeEventArgs that contains the event
+ /// data.
+ ///
+ protected virtual void OnAfterCheck(AdvTreeCellEventArgs e)
+ {
+ if (AfterCheck != null)
+ AfterCheck(this, e);
+ }
+
+ ///
+ /// Invokes CommandButtonClick event.
+ ///
+ /// Context node.
+ /// Event arguments.
+ internal void InvokeCommandButtonClick(Node node, CommandButtonEventArgs e)
+ {
+ if (CommandButtonClick != null)
+ CommandButtonClick(node, e);
+ }
+
+ protected virtual void OnBeforeCellEdit(CellEditEventArgs e)
+ {
+ if (BeforeCellEdit != null)
+ BeforeCellEdit(this, e);
+ }
+
+ void INodeNotify.OnBeforeCollapse(AdvTreeNodeCancelEventArgs e)
+ {
+ if (BeforeCollapse != null)
+ BeforeCollapse(this, e);
+ }
+
+ void INodeNotify.OnAfterCollapse(AdvTreeNodeEventArgs e)
+ {
+ if (AfterCollapse != null)
+ AfterCollapse(this, e);
+ }
+
+ void INodeNotify.OnBeforeExpand(AdvTreeNodeCancelEventArgs e)
+ {
+ if (BeforeExpand != null)
+ BeforeExpand(this, e);
+ }
+
+ void INodeNotify.OnAfterExpand(AdvTreeNodeEventArgs e)
+ {
+ if (AfterExpand != null)
+ AfterExpand(this, e);
+ }
+
+ internal void InvokeOnAfterNodeDeselect(AdvTreeNodeEventArgs args)
+ {
+ OnAfterNodeDeselect(args);
+ }
+ protected virtual void OnAfterNodeDeselect(AdvTreeNodeEventArgs args)
+ {
+ if (AfterNodeDeselect != null)
+ AfterNodeDeselect(this, args);
+ }
+
+ internal void InvokeOnAfterNodeSelect(AdvTreeNodeEventArgs args)
+ {
+ OnAfterNodeSelect(args);
+ }
+ protected virtual void OnAfterNodeSelect(AdvTreeNodeEventArgs args)
+ {
+ if (AfterNodeSelect != null)
+ AfterNodeSelect(this, args);
+ }
+
+ internal void InvokeOnBeforeNodeSelect(AdvTreeNodeCancelEventArgs args)
+ {
+ OnBeforeNodeSelect(args);
+ }
+ protected virtual void OnBeforeNodeSelect(AdvTreeNodeCancelEventArgs args)
+ {
+ if (BeforeNodeSelect != null)
+ BeforeNodeSelect(this, args);
+ }
+
+ ///
+ /// Invokes DeserializeNode event.
+ ///
+ /// Provides more information about the event
+ protected virtual void OnDeserializeNode(SerializeNodeEventArgs e)
+ {
+ if (DeserializeNode != null)
+ DeserializeNode(this, e);
+ }
+
+ ///
+ /// Invokes SerializeNode event.
+ ///
+ /// Provides more information about the event
+ protected virtual void OnSerializeNode(SerializeNodeEventArgs e)
+ {
+ if (SerializeNode != null)
+ SerializeNode(this, e);
+ }
+
+ internal void InvokeSerializeNode(SerializeNodeEventArgs e)
+ {
+ OnSerializeNode(e);
+ }
+
+ internal void InvokeDeserializeNode(SerializeNodeEventArgs e)
+ {
+ OnDeserializeNode(e);
+ }
+
+ internal bool HasSerializeNodeHandlers
+ {
+ get { return (SerializeNode != null); }
+ }
+
+ internal bool HasDeserializeNodeHandlers
+ {
+ get { return (DeserializeNode != null); }
+ }
+
+ internal void InvokeMarkupLinkClick(object sender, MarkupLinkClickEventArgs e)
+ {
+ OnMarkupLinkClick(sender, e);
+ m_CellMouseDownCounter = 0;
+ }
+
+ ///
+ /// Invokes the MarkupLinkClick evcent.
+ ///
+ /// Sender of the event, usually instance Cell object.
+ /// Event arguments
+ protected virtual void OnMarkupLinkClick(object sender, MarkupLinkClickEventArgs e)
+ {
+ if (MarkupLinkClick != null)
+ MarkupLinkClick(sender, e);
+ }
+ #endregion
+
+ #region Drag & Drop Support
+ [DllImport("user32.dll", SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool SetCursorPos(int X, int Y);
+
+ protected override void OnDragDrop(DragEventArgs drgevent)
+ {
+ base.OnDragDrop(drgevent);
+ InternalDragDrop(drgevent);
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void InternalDragDrop(DragEventArgs drgevent)
+ {
+ ReleaseDragNode(true);
+ }
+
+ protected override void OnDragLeave(EventArgs e)
+ {
+ base.OnDragLeave(e);
+ InternalDragLeave();
+ }
+
+ private Timer _DragScrollTimer = null;
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void InternalDragLeave()
+ {
+ ReleaseDragNode(false);
+ if (AutoScroll && _DragScrollTimer == null)
+ {
+ _DragScrollTimer = new Timer();
+ _DragScrollTimer.Interval = 100;
+ _DragScrollTimer.Tick += new EventHandler(DragScrollTimerTick);
+ _DragScrollTimer.Start();
+ }
+ }
+
+ private void DestroyDragScrollTimer()
+ {
+ Timer t = _DragScrollTimer;
+ if (t == null) return;
+ _DragScrollTimer = null;
+ t.Stop();
+ t.Tick -= new EventHandler(DragScrollTimerTick);
+ t.Dispose();
+ }
+
+ private void DragScrollTimerTick(object sender, EventArgs e)
+ {
+ if (Control.MouseButtons == MouseButtons.Left && this.IsHandleCreated && this.AutoScroll)
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ Rectangle temp = this.ClientRectangle;
+ temp.Inflate(32, 32);
+ if (!temp.Contains(p)) return;
+
+ if (p.Y < 0 && this.AutoScrollPosition.Y != 0 && _VScrollBar != null)
+ this.AutoScrollPosition = new Point(this.AutoScrollPosition.X, Math.Min(0, this.AutoScrollPosition.Y + _VScrollBar.SmallChange));
+ else if (_VScrollBar != null && p.Y > this.ClientRectangle.Bottom && -(this.AutoScrollPosition.Y - _VScrollBar.SmallChange) < (_VScrollBar.Maximum - _VScrollBar.LargeChange))
+ {
+ this.AutoScrollPosition = new Point(this.AutoScrollPosition.X, Math.Min(0, this.AutoScrollPosition.Y - _VScrollBar.SmallChange));
+ }
+ }
+ else
+ DestroyDragScrollTimer();
+ }
+
+ protected override void OnDragEnter(DragEventArgs drgevent)
+ {
+ DestroyDragScrollTimer();
+ base.OnDragEnter(drgevent);
+ }
+
+ protected override void OnDragOver(DragEventArgs drgevent)
+ {
+ base.OnDragOver(drgevent);
+ InternalDragOver(drgevent);
+ }
+
+ ///
+ /// Raises the NodeDragFeedback event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnNodeDragFeedback(TreeDragFeedbackEventArgs e)
+ {
+ TreeDragFeedbackEventHander h = NodeDragFeedback;
+ if (h != null)
+ h(this, e);
+ }
+
+ private int _DropAsChildOffset = 24;
+ ///
+ /// Gets or sets the offset in pixels from node's X position that is used during drag & drop operation to indicate that
+ /// dragged node is dropped as child node of the parent's node.
+ ///
+ [DefaultValue(24), Category("Behavior"), Description("Indicates offset in pixels from node's X position that is used during drag & drop operation to indicate that dragged node is dropped as child node of the parent's node.")]
+ public int DropAsChildOffset
+ {
+ get { return _DropAsChildOffset; }
+ set
+ {
+ _DropAsChildOffset = value;
+ }
+ }
+
+ private bool _DragDropNodeCopyEnabled = true;
+ ///
+ /// Gets or sets whether drag & drop internal implementation allows the copying of the node being dragged when CTRL key is pressed.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether drag & drop internal implementation allows the copying of the node being dragged when CTRL key is pressed.")]
+ public bool DragDropNodeCopyEnabled
+ {
+ get { return _DragDropNodeCopyEnabled; }
+ set
+ {
+ _DragDropNodeCopyEnabled = value;
+ }
+ }
+
+ private bool GetNodesContain(Node[] nodes, Node nodeToLookFor)
+ {
+ foreach (Node node in nodes)
+ {
+ if (node == nodeToLookFor)
+ return true;
+ }
+ return false;
+ }
+
+ private bool _AllowExternalDrop = true;
+ ///
+ /// Gets or sets whether control accepts the dragged nodes from other AdvTree controls. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether control accepts the dragged nodes from other AdvTree controls.")]
+ public bool AllowExternalDrop
+ {
+ get { return _AllowExternalDrop; }
+ set { _AllowExternalDrop = value; }
+ }
+
+ private NodeDragInfo _DragInfo = null;
+ ///
+ /// Processes drag over event.
+ ///
+ /// Drag event arguments.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void InternalDragOver(DragEventArgs drgevent)
+ {
+ if (!m_DragDropEnabled)
+ return;
+
+ if (!_AllowExternalDrop && IsExternalTreeDrop(drgevent))
+ {
+ drgevent.Effect = DragDropEffects.None;
+ return;
+ }
+
+ if (m_DragNode == null)
+ CreateDragNode(drgevent);
+
+ if (m_DragNode == null)
+ {
+ drgevent.Effect = DragDropEffects.None;
+ return;
+ }
+
+ drgevent.Effect = (Control.ModifierKeys == Keys.Control && _DragDropNodeCopyEnabled) ? DragDropEffects.Copy : DragDropEffects.Move;
+
+ InvalidateNode(m_DragNode);
+ Point p = this.PointToClient(new Point(drgevent.X, drgevent.Y));
+ p = GetLayoutPosition(p);
+ TreeAreaInfo areaInfo = NodeOperations.GetTreeAreaInfo(this, p.X, p.Y);
+ Point insideNodeOffset = Point.Empty;
+
+ NodeDragInfo newDragInfo = null;
+ Node lastVisibleNode = null;
+ if (areaInfo != null && areaInfo.NodeAt == null && this.ClientRectangle.Contains(p.X, p.Y))
+ {
+ lastVisibleNode = NodeOperations.GetLastVisibleTopLevelNode(this);
+ if (lastVisibleNode != null && p.Y >= lastVisibleNode.Bounds.Y)
+ areaInfo.NodeAt = lastVisibleNode;
+ }
+
+ if (areaInfo != null && areaInfo.NodeAt != null && !GetNodesContain((Node[])m_DragNode.Tag, areaInfo.NodeAt) && !NodeOperations.IsChildOfAnyParent((Node[])m_DragNode.Tag, areaInfo.NodeAt))
+ {
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, areaInfo.NodeAt, m_NodeDisplay.Offset);
+ Rectangle rContent = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, areaInfo.NodeAt, m_NodeDisplay.Offset);
+
+ if (_View == eView.Tile)
+ {
+ if (areaInfo.NodeAt == lastVisibleNode)
+ {
+ // Drop at the end of the tree as new parent
+ MultiNodeTreeDragFeedbackEventArgs feedbackArgs = new MultiNodeTreeDragFeedbackEventArgs(null, this.Nodes.Count, (Node[])m_DragNode.Tag, drgevent.Effect);
+ OnNodeDragFeedback(feedbackArgs);
+ if (feedbackArgs.AllowDrop)
+ {
+ // Adding the drag node as child node
+ newDragInfo = new NodeDragInfo(feedbackArgs.ParentNode, feedbackArgs.InsertPosition);
+ if (feedbackArgs.EffectSet)
+ drgevent.Effect = feedbackArgs.Effect;
+ }
+ else
+ drgevent.Effect = DragDropEffects.None;
+ }
+ else if ((areaInfo.NodeAt.HasChildNodes || areaInfo.NodeAt.Parent == null))
+ {
+ // Drop as child
+ MultiNodeTreeDragFeedbackEventArgs feedbackArgs = new MultiNodeTreeDragFeedbackEventArgs(areaInfo.NodeAt, -1, (Node[])m_DragNode.Tag, drgevent.Effect);
+ OnNodeDragFeedback(feedbackArgs);
+ if (feedbackArgs.AllowDrop)
+ {
+ // Adding the drag node as child node
+ newDragInfo = new NodeDragInfo(feedbackArgs.ParentNode, feedbackArgs.InsertPosition);
+ if (feedbackArgs.EffectSet)
+ drgevent.Effect = feedbackArgs.Effect;
+ }
+ else
+ drgevent.Effect = DragDropEffects.None;
+ }
+ else
+ {
+ TreeDragFeedbackEventArgs feedbackArgs = null;
+ // Pick insert position based on X position within the mouse over node. X 0)
+ feedbackArgs = new MultiNodeTreeDragFeedbackEventArgs(areaInfo.NodeAt, -1, (Node[])m_DragNode.Tag);
+ else
+ feedbackArgs = new MultiNodeTreeDragFeedbackEventArgs(areaInfo.NodeAt.Parent, areaInfo.NodeAt.Index, (Node[])m_DragNode.Tag, drgevent.Effect);
+ }
+ OnNodeDragFeedback(feedbackArgs);
+ if (feedbackArgs.AllowDrop)
+ {
+ // Adding the drag node as child node
+ newDragInfo = new NodeDragInfo(feedbackArgs.ParentNode, feedbackArgs.InsertPosition);
+ if (feedbackArgs.EffectSet)
+ drgevent.Effect = feedbackArgs.Effect;
+ }
+ else
+ drgevent.Effect = DragDropEffects.None;
+ }
+ }
+ else
+ {
+ // Determine drag node insert position
+ if (p.X > rContent.X + _DropAsChildOffset)
+ {
+ MultiNodeTreeDragFeedbackEventArgs feedbackArgs = new MultiNodeTreeDragFeedbackEventArgs(areaInfo.NodeAt, -1, (Node[])m_DragNode.Tag, drgevent.Effect);
+ OnNodeDragFeedback(feedbackArgs);
+ if (feedbackArgs.AllowDrop)
+ {
+ // Adding the drag node as child node
+ newDragInfo = new NodeDragInfo(feedbackArgs.ParentNode, feedbackArgs.InsertPosition);
+ if (feedbackArgs.EffectSet)
+ drgevent.Effect = feedbackArgs.Effect;
+ }
+ else
+ drgevent.Effect = DragDropEffects.None;
+ }
+ else
+ {
+ TreeDragFeedbackEventArgs feedbackArgs = null;
+ // Pick insert position based on Y position within the mouse over node. y 0)
+ feedbackArgs = new MultiNodeTreeDragFeedbackEventArgs(areaInfo.NodeAt, -1, (Node[])m_DragNode.Tag);
+ else
+ feedbackArgs = new MultiNodeTreeDragFeedbackEventArgs(areaInfo.NodeAt.Parent, areaInfo.NodeAt.Index, (Node[])m_DragNode.Tag, drgevent.Effect);
+ }
+ OnNodeDragFeedback(feedbackArgs);
+ if (feedbackArgs.AllowDrop)
+ {
+ // Adding the drag node as child node
+ newDragInfo = new NodeDragInfo(feedbackArgs.ParentNode, feedbackArgs.InsertPosition);
+ if (feedbackArgs.EffectSet)
+ drgevent.Effect = feedbackArgs.Effect;
+ }
+ else
+ drgevent.Effect = DragDropEffects.None;
+ }
+ }
+ }
+ else if (m_Nodes.Count == 0) // Drop into empty tree
+ {
+ MultiNodeTreeDragFeedbackEventArgs feedbackArgs = new MultiNodeTreeDragFeedbackEventArgs(null, 0, (Node[])m_DragNode.Tag, drgevent.Effect);
+ OnNodeDragFeedback(feedbackArgs);
+ if (feedbackArgs.AllowDrop)
+ {
+ // Adding the drag node as child node
+ newDragInfo = new NodeDragInfo(null, 0);
+ if (feedbackArgs.EffectSet)
+ drgevent.Effect = feedbackArgs.Effect;
+ }
+ else
+ drgevent.Effect = DragDropEffects.None;
+ }
+ else
+ {
+ Rectangle temp = this.ClientRectangle;
+ temp.Inflate(32, 32);
+ if (AutoScroll && temp.Contains(p))
+ {
+ if (p.Y < 0)
+ {
+ if (_VScrollBar != null && _VScrollBar.Value > 0)
+ _VScrollBar.Value -= _VScrollBar.SmallChange;
+ }
+ else if (p.Y > this.ClientRectangle.Bottom)
+ {
+ if (_VScrollBar != null && _VScrollBar.Value + _VScrollBar.SmallChange < _VScrollBar.Maximum)
+ _VScrollBar.Value += _VScrollBar.SmallChange;
+ }
+
+ }
+ drgevent.Effect = DragDropEffects.None;
+ }
+
+ bool update = false;
+ if (newDragInfo != null)
+ {
+ if (_DragInfo == null)
+ {
+ _DragInfo = newDragInfo;
+ InvalidateDragInfo(_DragInfo);
+ update = true;
+ }
+ else if (_DragInfo.Parent != newDragInfo.Parent || _DragInfo.InsertIndex != newDragInfo.InsertIndex)
+ {
+ InvalidateDragInfo(_DragInfo);
+ InvalidateDragInfo(newDragInfo);
+ _DragInfo = newDragInfo;
+ update = true;
+ }
+ }
+ else if (newDragInfo != _DragInfo)
+ {
+ InvalidateDragInfo(_DragInfo);
+ _DragInfo = null;
+ update = true;
+ }
+
+ m_DragNode.SetBounds(new Rectangle(p.X, p.Y, m_DragNode.BoundsRelative.Width, m_DragNode.BoundsRelative.Height));
+ m_DragNode.Visible = true;
+ InvalidateNode(m_DragNode);
+
+ if (update)
+ {
+ if (this.DesignMode)
+ this.Refresh();
+ else
+ this.Update();
+ }
+ }
+
+
+ private void InvalidateDragInfo(NodeDragInfo dragInfo)
+ {
+ if (dragInfo == null) return;
+ Rectangle r = GetDragInsertionBounds(dragInfo);
+ if (!r.IsEmpty)
+ {
+ r.Inflate(1, 1);
+ Invalidate(r);
+ }
+ }
+
+ private Node GetDragInfoReferenceNode(NodeDragInfo dragInfo)
+ {
+ Node referenceNode = null;
+ NodeCollection col = null;
+ if (dragInfo.Parent != null)
+ {
+ col = dragInfo.Parent.Nodes;
+ }
+ else
+ {
+ col = this.Nodes;
+ }
+
+ if (col.Count > 0)
+ {
+ if (dragInfo.InsertIndex <= 0)
+ referenceNode = col[0];
+ else if (dragInfo.InsertIndex >= col.Count)
+ referenceNode = col[col.Count - 1];
+ else
+ referenceNode = col[dragInfo.InsertIndex];
+ }
+
+ return referenceNode;
+ }
+ internal static readonly int DragInsertMarkSize = 9;
+ internal Rectangle GetDragInsertionBounds(NodeDragInfo dragInfo)
+ {
+ if (dragInfo == null) return Rectangle.Empty;
+
+ Rectangle r = Rectangle.Empty;
+
+ Node referenceNode = GetDragInfoReferenceNode(dragInfo);
+
+ Node parentDragNode = dragInfo.Parent;
+ if (_View == eView.Tile)
+ {
+ //Console.WriteLine(dragInfo);
+ if (referenceNode != null)
+ {
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, referenceNode, m_NodeDisplay.Offset);
+ if (dragInfo.InsertIndex == -1)
+ r.X -= 4;
+ else
+ r.X = r.Right - DragInsertMarkSize;
+ r.Height = referenceNode.Bounds.Height;
+ r.Width = DragInsertMarkSize;
+ }
+ else if (parentDragNode != null)
+ {
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, parentDragNode, m_NodeDisplay.Offset);
+ r.X += this.Indent;
+ if (!parentDragNode.HasChildNodes)
+ r.Y = r.Bottom - DragInsertMarkSize;
+ r.Width = parentDragNode.Bounds.Width;
+ r.Height = DragInsertMarkSize;
+ }
+ }
+ else
+ {
+ if (referenceNode != null)
+ {
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, referenceNode, m_NodeDisplay.Offset);
+ r.Width = referenceNode.Bounds.Width;
+ if (referenceNode.Expanded && dragInfo.InsertIndex >= 0)
+ {
+ Rectangle childBounds = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ChildNodeBounds, referenceNode, m_NodeDisplay.Offset);
+ r.Y = childBounds.Bottom - r.Height;
+ }
+ }
+ else if (parentDragNode != null)
+ {
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, parentDragNode, m_NodeDisplay.Offset);
+ r.X += this.Indent;
+ r.Width = parentDragNode.Bounds.Width;
+ }
+
+ if (dragInfo.InsertIndex < 0 && referenceNode != null)
+ r.Y -= 4;
+ else
+ r.Y = r.Bottom - 2;
+ r.Height = DragInsertMarkSize;
+ }
+
+ return r;
+ }
+
+ private int _Indent = 16;
+ ///
+ /// Gets or sets the distance to indent each of the child tree node levels. Default value is 16.
+ ///
+ [DefaultValue(16), Description("Indicates distance to indent each of the child tree node levels."), Category("Appearance")]
+ public int Indent
+ {
+ get { return _Indent; }
+ set
+ {
+ if (_Indent != value)
+ {
+ _Indent = value;
+ if (m_NodeLayout is NodeTreeLayout)
+ ((NodeTreeLayout)m_NodeLayout).NodeLevelOffset = value;
+ InvalidateNodesSize();
+ RecalcLayout();
+ }
+ }
+ }
+
+ private bool _PaintDragDropInsertMarker = true;
+ ///
+ /// Indicates whether drop marker is displayed during drag-drop operation.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether drop marker is displayed during drag-drop operation.")]
+ public bool PaintDragDropInsertMarker
+ {
+ get { return _PaintDragDropInsertMarker; }
+ set
+ {
+ _PaintDragDropInsertMarker = value;
+ if (IsDragDropInProgress && _DragInfo != null)
+ InvalidateDragInfo(_DragInfo);
+ }
+ }
+
+ ///
+ /// Gets or sets whether drag and drop operation is in progress. This member supports
+ /// the AdvTree infrastructure and is not intended to be used directly from your
+ /// code.
+ ///
+ [Browsable(false)]
+ public bool IsDragDropInProgress
+ {
+ get { return (m_DragNode != null); }
+ }
+
+ private Node[] SortNodesByFlatIndex(Node[] dragNodes)
+ {
+ ArrayList nodes = new ArrayList(dragNodes);
+ nodes.Sort(new NodeFlatIndexComparer(this));
+ nodes.CopyTo(dragNodes);
+ return dragNodes;
+ }
+ private void ReleaseDragNode(bool drop)
+ {
+ if (m_DragNode == null)
+ return;
+ bool isCopy = (Control.ModifierKeys == Keys.Control && _DragDropNodeCopyEnabled);
+
+ this.BeginUpdate();
+ try
+ {
+ if (m_NodeDisplay.LockOffset)
+ m_NodeDisplay.LockOffset = false;
+
+ Node[] dragNodes = m_DragNode.Tag as Node[];
+ foreach (Node item in dragNodes)
+ {
+ if (!item.Visible) item.Visible = true;
+ }
+
+ if (drop && _DragInfo != null)
+ {
+ Node parent = _DragInfo.Parent;
+ // Fire off events and cancel processing if needed
+ TreeDragDropEventArgs e = new TreeDragDropEventArgs(eTreeAction.Mouse, dragNodes, dragNodes[0].Parent, parent, isCopy, _DragInfo.InsertIndex);
+ InvokeBeforeNodeDrop(e);
+ if (!e.Cancel && e.Nodes != null && e.Nodes.Length > 0)
+ {
+ isCopy = e.IsCopy;
+ dragNodes = e.Nodes;
+ int index = e.InsertPosition + 1;
+
+ if (dragNodes.Length > 1)
+ dragNodes = SortNodesByFlatIndex(dragNodes);
+ Node[] afterDragNodes = new Node[dragNodes.Length];
+ for (int i = 0; i < dragNodes.Length; i++)
+ {
+ Node childNode = dragNodes[i];
+ Node node = childNode;
+ if (NodeOperations.IsChildOfAnyParent(dragNodes, node)) continue;
+
+ if (isCopy)
+ {
+ node = node.DeepCopy();
+ }
+ else
+ {
+ if (parent != null)
+ {
+ if (node.Parent == parent && parent.Nodes.IndexOf(node) < index)
+ index--;
+ }
+ else
+ {
+ if (node.Parent == null && node.TreeControl == this && this.Nodes.IndexOf(node) < index)
+ index--;
+ }
+ node.Remove(eTreeAction.Mouse);
+ }
+ afterDragNodes[i] = node;
+
+ // Adjust index in case node was removed and flat indexes changed
+ if (index < 0)
+ index = 0;
+ else if (parent != null && index > parent.Nodes.Count)
+ index = parent.Nodes.Count;
+ else if (parent == null && index > this.Nodes.Count)
+ index = this.Nodes.Count;
+
+ if (parent == null)
+ this.Nodes.Insert(index, node, eTreeAction.Mouse);
+ else
+ {
+ parent.Nodes.Insert(index, node, eTreeAction.Mouse);
+ if (!parent.Expanded)
+ parent.Expanded = true;
+ }
+ index++;
+ }
+ e.Nodes = afterDragNodes;
+ InvokeAfterNodeDrop(e);
+ }
+ }
+ _DragInfo = null;
+ }
+ finally
+ {
+ m_DragNode = null;
+ if (!m_PendingLayout)
+ {
+ this.EndUpdate();
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ else
+ this.EndUpdate();
+ }
+ }
+
+ ///
+ /// Raises the NodeDragStart event.
+ ///
+ /// Reference to node being dragged.
+ /// Event parameters
+ protected virtual void OnNodeDragStart(object sender, EventArgs e)
+ {
+ EventHandler eh = NodeDragStart;
+ if (eh != null)
+ eh(sender, e);
+ }
+
+ private bool IsExternalTreeDrop(DragEventArgs e)
+ {
+ if (e.Data != null)
+ {
+ Node node = null;
+ Node[] nodes = null;
+ if (e.Data.GetDataPresent(typeof(Node)))
+ node = e.Data.GetData(typeof(Node)) as Node;
+ else if (e.Data.GetDataPresent(typeof(Node[])))
+ nodes = e.Data.GetData(typeof(Node[])) as Node[];
+ else if (e.Data.GetFormats().Length > 0)
+ {
+ node = e.Data.GetData(e.Data.GetFormats()[0]) as Node;
+ nodes = e.Data.GetData(e.Data.GetFormats()[0]) as Node[];
+ }
+
+ if (node != null && node.TreeControl != this)
+ return true;
+ else if (nodes != null && nodes.Length > 0)
+ {
+ if (nodes[0].TreeControl != this)
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private void CreateDragNode(DragEventArgs e)
+ {
+ if (e.Data != null)
+ {
+ Node node = null;
+ Node[] nodes = null;
+ if (e.Data.GetDataPresent(typeof(Node)))
+ node = e.Data.GetData(typeof(Node)) as Node;
+ else if (e.Data.GetDataPresent(typeof(Node[])))
+ nodes = e.Data.GetData(typeof(Node[])) as Node[];
+ else if (e.Data.GetFormats().Length > 0)
+ {
+ node = e.Data.GetData(e.Data.GetFormats()[0]) as Node;
+ nodes = e.Data.GetData(e.Data.GetFormats()[0]) as Node[];
+ }
+
+ if (node != null)
+ CreateDragNode(new Node[1] { node });
+ else if (nodes != null && nodes.Length > 0)
+ {
+ CreateDragNode(nodes);
+ }
+ }
+ }
+
+ private bool _MultiNodeDragCountVisible = true;
+ ///
+ /// Gets or sets whether number of nodes being dragged is displayed on drag node preview. Default value is true.
+ ///
+ [DefaultValue(true), Category("Selection"), Description("Indicates whether number of nodes being dragged is displayed on drag node preview.")]
+ public bool MultiNodeDragCountVisible
+ {
+ get
+ {
+ return _MultiNodeDragCountVisible;
+ }
+ set
+ {
+ _MultiNodeDragCountVisible = value;
+ }
+ }
+ private void CreateDragNode(Node[] nodes)
+ {
+ AdvTreeMultiNodeCancelEventArgs eventArgs = new AdvTreeMultiNodeCancelEventArgs(eTreeAction.Mouse, nodes);
+ OnBeforeNodeDragStart(eventArgs);
+ if (eventArgs.Cancel) return;
+
+ m_DragNode = nodes[0].Copy();
+ m_DragNode.Tag = nodes;
+ m_DragNode.IsDragNode = true;
+ PrepareDragNodeElementStyle(m_DragNode, nodes[0]);
+
+ if (nodes.Length > 1 && this.MultiNodeDragCountVisible)
+ {
+ Cell cell = new Cell();
+ cell.Text = nodes.Length.ToString();
+ cell.StyleNormal = new ElementStyle();
+ cell.StyleNormal.BackColor = ColorScheme.GetColor(0x40408C);
+ cell.StyleNormal.BackColor2 = ColorScheme.GetColor(0x0093F9);
+ cell.StyleNormal.BackColorGradientAngle = 90;
+ cell.StyleNormal.TextColor = Color.White;
+ cell.StyleNormal.Padding = 3;
+ cell.Name = "sysNodeCount";
+ cell.Tag = m_DragNode.Tag;
+ m_DragNode.Tag = null;
+ m_DragNode.Cells.Insert(0, cell);
+ }
+
+ m_DragNode.Visible = false;
+ m_NodeLayout.PerformSingleNodeLayout(m_DragNode);
+ this.Refresh();
+ OnNodeDragStart(nodes[0], new EventArgs());
+ }
+
+ ///
+ /// Raises BeforeNodeDragStart event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnBeforeNodeDragStart(AdvTreeNodeCancelEventArgs e)
+ {
+ if (BeforeNodeDragStart != null) BeforeNodeDragStart(this, e);
+ }
+
+ private void PrepareDragNodeElementStyle(Node dragNode, Node originalNode)
+ {
+ // Setup half transparent styles
+ int alpha = 128;
+ ElementStyle style = null;
+ if (originalNode.Style != null)
+ style = originalNode.Style.Copy();
+ else if (this.NodeStyle != null)
+ style = this.NodeStyle.Copy();
+ else
+ {
+ style = new ElementStyle();
+ style.TextColorSchemePart = eColorSchemePart.ItemText;
+ }
+ ElementStyle.SetColorsAlpha(style, alpha);
+ dragNode.Style = style;
+
+ if (this.CellStyleDefault != null)
+ style = this.CellStyleDefault.Copy();
+ else
+ style = ElementStyle.GetDefaultCellStyle(dragNode.Style);
+ ElementStyle.SetColorsAlpha(style, alpha);
+ foreach (Cell cell in dragNode.Cells)
+ {
+ cell.StyleNormal = style;
+ }
+
+ for (int i = 0; i < dragNode.Cells.Count; i++)
+ {
+ if (originalNode.Cells[i].StyleNormal != null)
+ {
+ ElementStyle cellStyle = originalNode.Cells[i].StyleNormal.Copy();
+ ElementStyle.SetColorsAlpha(style, alpha);
+ dragNode.Cells[i].StyleNormal = cellStyle;
+ }
+ else
+ dragNode.Cells[i].StyleNormal = style;
+ }
+ }
+
+ private bool _MultiNodeDragDropAllowed = true;
+ ///
+ /// Gets or sets whether multiple nodes drag & drop is enabled. Default value is true.
+ ///
+ [DefaultValue(true), Category("Selection"), Description("Indicates whether multiple nodes drag & drop is enabled.")]
+ public bool MultiNodeDragDropAllowed
+ {
+ get
+ {
+ return _MultiNodeDragDropAllowed;
+ }
+ set
+ {
+ _MultiNodeDragDropAllowed = value;
+ }
+ }
+ private bool StartDragDrop()
+ {
+ if (m_MouseOverNode == null)
+ return false;
+
+ if (this.MultiSelect && this.SelectedNodes.Count > 1 && this.MultiNodeDragDropAllowed)
+ {
+ Node[] nodes = new Node[this.SelectedNodes.Count];
+ this.SelectedNodes.CopyTo(nodes);
+ return StartDragDrop(nodes);
+ }
+
+ return StartDragDrop(m_MouseOverNode);
+ }
+
+ private bool StartDragDrop(Node[] nodes)
+ {
+ if (IsDragDropInProgress)
+ return false;
+
+ _SelectOnMouseUp = false;
+ foreach (Node node in nodes)
+ {
+ if (!node.DragDropEnabled || node == m_DisplayRootNode)
+ return false;
+ if (node.IsMouseDown)
+ OnNodeMouseUp(new MouseEventArgs(Control.MouseButtons, 0, 0, 0, 0));
+ }
+
+ this.EndCellEditing(eTreeAction.Mouse);
+
+ Point m_MouseDownPoint = Control.MousePosition;
+
+ if (this.DesignMode)
+ CreateDragNode(nodes);
+ else
+ this.DoDragDrop(nodes, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move | DragDropEffects.Scroll);
+
+ return true;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool StartDragDrop(Node node)
+ {
+ if (IsDragDropInProgress || !node.DragDropEnabled)
+ return false;
+
+ this.EndCellEditing(eTreeAction.Mouse);
+
+ if (node.IsMouseDown)
+ OnNodeMouseUp(new MouseEventArgs(Control.MouseButtons, 0, 0, 0, 0));
+
+ if (node == m_DisplayRootNode /*|| node.Parent==null*/) // Drag & drop in designer means that parent is null
+ return false;
+
+ Point m_MouseDownPoint = Control.MousePosition;
+
+ if (this.DesignMode)
+ CreateDragNode(new Node[1] { node });
+ else
+ this.DoDragDrop(node, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move | DragDropEffects.Scroll);
+
+ return true;
+ }
+
+ ///
+ /// Returns the display root node.
+ ///
+ /// Instance of node or null if there is no display root node.
+ internal Node GetDisplayRootNode()
+ {
+ if (m_DisplayRootNode != null)
+ return m_DisplayRootNode;
+ if (this.Nodes.Count > 0)
+ return this.Nodes[0];
+ return null;
+ }
+
+ ///
+ /// Returns reference to the node involved in drag-drop operation if any.
+ ///
+ /// Reference to node object or null if there is no drag node.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Node GetDragNode()
+ {
+ return m_DragNode;
+ }
+
+ ///
+ /// Returns the reference to node drag information class that gives information about node drag & drop.
+ ///
+ /// Reference to node drag info object or null if no drag information is available
+ internal NodeDragInfo GetNodeDragInfo()
+ {
+ return _DragInfo;
+ }
+ #endregion
+
+ #region ISupportInitialize
+ ///
+ /// This member supports the .NET Framework infrastructure and is not intended to be
+ /// used directly from your code.
+ ///
+ public void BeginInit()
+ {
+ this.BeginUpdate();
+ }
+
+ ///
+ /// This member supports the .NET Framework infrastructure and is not intended to be
+ /// used directly from your code.
+ ///
+ public void EndInit()
+ {
+ this.EndUpdate();
+ }
+ #endregion
+
+ #region Property Hiding
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new System.Windows.Forms.Padding Padding
+ {
+ get
+ {
+ return base.Padding;
+ }
+ set
+ {
+ //base.Padding = value;
+ }
+ }
+
+ [Browsable(false)]
+ public override Image BackgroundImage
+ {
+ get
+ {
+ return base.BackgroundImage;
+ }
+ set
+ {
+ base.BackgroundImage = value;
+ }
+ }
+#if FRAMEWORK20
+ [Browsable(false)]
+ public override ImageLayout BackgroundImageLayout
+ {
+ get
+ {
+ return base.BackgroundImageLayout;
+ }
+ set
+ {
+ base.BackgroundImageLayout = value;
+ }
+ }
+#endif
+ #endregion
+
+ #region Licensing
+#if !TRIAL
+ private string m_LicenseKey = "";
+ private bool m_DialogDisplayed = false;
+ [Browsable(false), DefaultValue("")]
+ public string LicenseKey
+ {
+ get { return m_LicenseKey; }
+ set
+ {
+ if (NodeOperations.ValidateLicenseKey(value))
+ return;
+ m_LicenseKey = (!NodeOperations.CheckLicenseKey(value) ? "9dsjkhds7" : value);
+ }
+ }
+#endif
+ #endregion
+
+ #region BarAccessibleObject
+ public class AdvTreeAccessibleObject : System.Windows.Forms.Control.ControlAccessibleObject
+ {
+ AdvTree _Owner = null;
+ public AdvTreeAccessibleObject(AdvTree owner)
+ : base(owner)
+ {
+ _Owner = owner;
+ }
+
+ internal void GenerateEvent(Node sender, System.Windows.Forms.AccessibleEvents e)
+ {
+ int iChild = _Owner.Nodes.IndexOf(sender);
+ if (iChild >= 0)
+ {
+ if (_Owner != null && !_Owner.IsDisposed)
+ _Owner.AccessibilityNotifyClients(e, iChild);
+ }
+ }
+
+ public override AccessibleRole Role
+ {
+ get
+ {
+ if (_Owner != null && !_Owner.IsDisposed)
+ return _Owner.AccessibleRole;
+ return System.Windows.Forms.AccessibleRole.None;
+ }
+ }
+
+ public override AccessibleObject Parent
+ {
+ get
+ {
+ if (_Owner != null && !_Owner.IsDisposed)
+ return _Owner.Parent.AccessibilityObject;
+ return null;
+ }
+ }
+
+ public override Rectangle Bounds
+ {
+ get
+ {
+ if (_Owner != null && !_Owner.IsDisposed && _Owner.Parent != null)
+ return this._Owner.Parent.RectangleToScreen(_Owner.Bounds);
+ return Rectangle.Empty;
+ }
+ }
+
+ public override int GetChildCount()
+ {
+ if (_Owner != null && !_Owner.IsDisposed && _Owner.Nodes != null)
+ return _Owner.Nodes.Count;
+ return 0;
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetChild(int iIndex)
+ {
+ if (_Owner != null && !_Owner.IsDisposed && _Owner.Nodes != null)
+ return _Owner.Nodes[iIndex].AccessibleObject;
+ return null;
+ }
+
+ public override AccessibleStates State
+ {
+ get
+ {
+ AccessibleStates state = AccessibleStates.Default;
+ if (_Owner == null || _Owner.IsDisposed)
+ return AccessibleStates.None;
+ if (_Owner.Focused)
+ state = AccessibleStates.Focused;
+
+ return state;
+ }
+ }
+ }
+ private bool _ResetAutoScrollPositionOnClearedNodes=true;
+ ///
+ /// Indicates whether AutoScrollPosition is reset to 0,0 when all nodes are cleared from the tree. Default value is true.
+ ///
+ [DefaultValue(true), Browsable(false)]
+ public bool ResetAutoScrollPositionOnClearedNodes
+ {
+ get { return _ResetAutoScrollPositionOnClearedNodes; }
+ set
+ {
+ _ResetAutoScrollPositionOnClearedNodes = value;
+ }
+ }
+
+ internal void OnNodesCleared()
+ {
+ if (m_NodeDisplay != null)
+ m_NodeDisplay.PaintedNodes.Clear();
+ if (_FullRowBackgroundNodes != null)
+ _FullRowBackgroundNodes.Clear();
+ if (this.MultiSelect && this.SelectedNodes.Count > 0) this.SelectedNodes.Clear();
+ if (_ResetAutoScrollPositionOnClearedNodes)
+ this.AutoScrollPosition = Point.Empty;
+ this.SelectedNode = null;
+ if (this.IsHandleCreated)
+ this.RecalcLayout();
+ else
+ SetPendingLayout();
+ }
+
+ internal Rectangle GetPaintRectangle()
+ {
+ Rectangle rect = this.ClientRectangle;
+ if (_ColumnHeader != null && _ColumnHeader.Visible)
+ {
+ rect.Y += _ColumnHeader.Height;
+ rect.Height -= _ColumnHeader.Height;
+ }
+ if (_VScrollBar != null && _VScrollBar.Visible)
+ {
+ rect.Width -= _VScrollBar.Width;
+ }
+ if (_HScrollBar != null && _HScrollBar.Visible)
+ {
+ rect.Height -= _HScrollBar.Height;
+ }
+ return rect;
+ }
+
+ #endregion
+
+ #region Data-binding
+#if FRAMEWORK20
+ private List _DisplayMembers = null;
+ ///
+ /// Gets or sets the comma separated list of property or column names to display on popup tree control.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates comma separated list of property or column names to display on popup tree control")]
+ [Editor("DevComponents.DotNetBar.Design.DataMembersSelector, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ public string DisplayMembers
+ {
+ get
+ {
+ if (_DisplayMembers == null || _DisplayMembers.Count == 0)
+ return "";
+ StringBuilder members = new StringBuilder();
+ for (int i = 0; i < _DisplayMembers.Count; i++)
+ {
+ BindingMemberInfo item = _DisplayMembers[i];
+ members.Append(item.BindingMember);
+ if (i + 1 < _DisplayMembers.Count)
+ members.Append(',');
+ }
+ return members.ToString();
+ }
+ set
+ {
+ List displayMembers = _DisplayMembers;
+
+ List newMembers = null;
+
+ if (!string.IsNullOrEmpty(value))
+ {
+ newMembers = new List();
+ // Parse the members comma separated list expected...
+ string[] members = value.Split(',');
+ for (int i = 0; i < members.Length; i++)
+ {
+ newMembers.Add(new BindingMemberInfo(members[i].Trim()));
+ }
+ }
+
+ try
+ {
+ this.SetDataConnection(_DataSource, newMembers, false);
+ }
+ catch
+ {
+ _DisplayMembers = displayMembers;
+ }
+ }
+ }
+
+ private object _DataSource = null;
+ ///
+ /// Gets or sets the data source for the ComboTree. Expected is an object that implements the IList or IListSource interfaces,
+ /// such as a DataSet or an Array. The default is null.
+ ///
+ [AttributeProvider(typeof(IListSource)), Description("Indicates data source for the ComboTree."), Category("Data"), DefaultValue(null), RefreshProperties(RefreshProperties.Repaint)]
+ public object DataSource
+ {
+ get
+ {
+ return _DataSource;
+ }
+ set
+ {
+ if (((value != null) && !(value is IList)) && !(value is IListSource))
+ {
+ throw new ArgumentException("Data type is not supported for complex data binding");
+ }
+ //if (_DataSource != value)
+ {
+ ClearDescriptorsCache();
+ try
+ {
+ this.SetDataConnection(value, _DisplayMembers, true);
+ }
+ catch
+ {
+ this.DisplayMembers = "";
+ }
+ if (value == null)
+ {
+ this.DisplayMembers = "";
+ }
+ }
+ }
+ }
+
+ private bool _FormattingEnabled = false;
+ ///
+ /// Gets or sets a value indicating whether formatting is applied to the DisplayMembers property of the control.
+ ///
+ [DefaultValue(false), Description("Indicates whether formatting is applied to the DisplayMembers property of the control.")]
+ public bool FormattingEnabled
+ {
+ get
+ {
+ return _FormattingEnabled;
+ }
+ set
+ {
+ if (value != _FormattingEnabled)
+ {
+ _FormattingEnabled = value;
+ RefreshItems();
+ OnFormattingEnabledChanged(EventArgs.Empty);
+ }
+ }
+ }
+ ///
+ /// Raises FormattingEnabledChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnFormattingEnabledChanged(EventArgs e)
+ {
+ EventHandler handler = FormattingEnabledChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ private string _FormatString = "";
+ ///
+ /// Gets or sets the format-specifier characters that indicate how a value is to be displayed.
+ ///
+ [MergableProperty(false), Editor("System.Windows.Forms.Design.FormatStringEditor, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor)), DefaultValue(""), Description("Indicates format-specifier characters that indicate how a value is to be displayed.")]
+ public string FormatString
+ {
+ get
+ {
+ return _FormatString;
+ }
+ set
+ {
+ if (value == null)
+ {
+ value = string.Empty;
+ }
+ if (!value.Equals(_FormatString))
+ {
+ _FormatString = value;
+ RefreshItems();
+ OnFormatStringChanged(EventArgs.Empty);
+ }
+ }
+ }
+ ///
+ /// Raises FormatStringChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnFormatStringChanged(EventArgs e)
+ {
+ EventHandler handler = FormatStringChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ private IFormatProvider _FormatInfo = null;
+ ///
+ /// Gets or sets the IFormatProvider that provides custom formatting behavior.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Advanced), Browsable(false), DefaultValue((string)null)]
+ public IFormatProvider FormatInfo
+ {
+ get
+ {
+ return _FormatInfo;
+ }
+ set
+ {
+ if (value != _FormatInfo)
+ {
+ _FormatInfo = value;
+ RefreshItems();
+ OnFormatInfoChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ ///
+ /// Raises FormatInfoChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnFormatInfoChanged(EventArgs e)
+ {
+ EventHandler handler = FormatInfoChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+
+ private bool _InSetDataConnection = false;
+ private void SetDataConnection(object newDataSource, List newDisplayMembers, bool force)
+ {
+ bool dataSourceChanged = _DataSource != newDataSource;
+ bool displayMemberChanged = _DisplayMembers != newDisplayMembers;
+
+ if (!_InSetDataConnection)
+ {
+ try
+ {
+ if ((force || dataSourceChanged) || displayMemberChanged)
+ {
+ _InSetDataConnection = true;
+ IList list = (this.DataManager != null) ? this.DataManager.List : null;
+ bool isDataManagerNull = this.DataManager == null;
+ this.UnwireDataSource();
+ _DataSource = newDataSource;
+ _DisplayMembers = newDisplayMembers;
+ this.WireDataSource();
+ if (_IsDataSourceInitialized)
+ {
+ CurrencyManager manager = null;
+ if (((newDataSource != null) && (this.BindingContext != null)) && (newDataSource != Convert.DBNull))
+ {
+ string bindingPath = "";
+ if (_DisplayMembers != null && _DisplayMembers.Count > 0)
+ bindingPath = newDisplayMembers[0].BindingPath;
+ manager = (CurrencyManager)this.BindingContext[newDataSource, bindingPath];
+ }
+
+ if (_DataManager != manager)
+ {
+ if (_DataManager != null)
+ {
+ _DataManager.ItemChanged -= new ItemChangedEventHandler(this.DataManager_ItemChanged);
+ _DataManager.PositionChanged -= new EventHandler(this.DataManager_PositionChanged);
+ }
+ _DataManager = manager;
+ if (_DataManager != null)
+ {
+ _DataManager.ItemChanged += new ItemChangedEventHandler(this.DataManager_ItemChanged);
+ _DataManager.PositionChanged += new EventHandler(this.DataManager_PositionChanged);
+ }
+ else if (newDataSource == null)
+ this.Nodes.Clear();
+ }
+ if (((_DataManager != null) && (displayMemberChanged || dataSourceChanged)) && !ValidateDisplayMembers(_DisplayMembers))
+ {
+ throw new ArgumentException("Wrong DisplayMembers parameter", "newDisplayMember");
+ }
+ if ((_DataManager != null && (dataSourceChanged || displayMemberChanged || force))
+ && (displayMemberChanged || dataSourceChanged || (force && ((list != _DataManager.List) || isDataManagerNull))))
+ {
+ DataManager_ItemChanged(_DataManager, null);
+ }
+ }
+ _Converters.Clear();
+ }
+ if (dataSourceChanged)
+ {
+ this.OnDataSourceChanged(EventArgs.Empty);
+ }
+ if (displayMemberChanged)
+ {
+ this.OnDisplayMembersChanged(EventArgs.Empty);
+ }
+ }
+ finally
+ {
+ _InSetDataConnection = false;
+ }
+ }
+ }
+
+ private bool ValidateDisplayMembers(List members)
+ {
+ if (members == null || members.Count == 0) return true;
+
+ foreach (BindingMemberInfo item in members)
+ {
+ if (item.BindingMember != null && !BindingMemberInfoInDataManager(item))
+ return false;
+ }
+ return true;
+ }
+ private bool BindingMemberInfoInDataManager(BindingMemberInfo bindingMemberInfo)
+ {
+ if (_DataManager != null)
+ {
+ PropertyDescriptorCollection itemProperties = _DataManager.GetItemProperties();
+ int count = itemProperties.Count;
+ for (int i = 0; i < count; i++)
+ {
+ if (!typeof(IList).IsAssignableFrom(itemProperties[i].PropertyType) && itemProperties[i].Name.Equals(bindingMemberInfo.BindingField))
+ {
+ return true;
+ }
+ }
+ for (int j = 0; j < count; j++)
+ {
+ if (!typeof(IList).IsAssignableFrom(itemProperties[j].PropertyType) && (string.Compare(itemProperties[j].Name, bindingMemberInfo.BindingField, true, CultureInfo.CurrentCulture) == 0))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ ///
+ /// Raises the DataSourceChanged event.
+ ///
+ /// An EventArgs that contains the event data.
+ protected virtual void OnDataSourceChanged(EventArgs e)
+ {
+ EventHandler handler = DataSourceChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+ ///
+ /// Raises the DisplayMemberChanged event.
+ ///
+ /// An EventArgs that contains the event data.
+ protected virtual void OnDisplayMembersChanged(EventArgs e)
+ {
+ EventHandler handler = DisplayMembersChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ private Hashtable _Converters = new Hashtable();
+ private TypeConverter GetFieldConverter(string fieldName)
+ {
+ if (_Converters.ContainsKey(fieldName))
+ return (TypeConverter)_Converters[fieldName];
+ if (this.DataManager != null)
+ {
+ PropertyDescriptorCollection itemProperties = this.DataManager.GetItemProperties();
+ if (itemProperties != null)
+ {
+ PropertyDescriptor descriptor = itemProperties.Find(fieldName, true);
+ if (descriptor != null)
+ {
+ _Converters.Add(fieldName, descriptor.Converter);
+ return descriptor.Converter;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private void DataManager_ItemChanged(object sender, ItemChangedEventArgs e)
+ {
+ if (this.InvokeRequired)
+ {
+ this.Invoke(new ItemChangedEventHandler(DataManager_ItemChanged), sender, e);
+ return;
+ }
+ if (_DataManager != null)
+ {
+ if (e == null || e.Index == -1)
+ {
+ this.SetItemsCore(_DataManager.List);
+ if (this.AllowSelection)
+ {
+ if (_DataManager.Position == -1)
+ this.SelectedNode = null;
+ else
+ this.SelectedNode = this.FindNodeByBindingIndex(_DataManager.Position);
+ }
+ }
+ else
+ {
+ this.SetItemCore(e.Index, _DataManager.List[e.Index]);
+ }
+ }
+ }
+ private void DataManager_PositionChanged(object sender, EventArgs e)
+ {
+ if ((_DataManager != null) && this.AllowSelection)
+ {
+ if (_DataManager.Position == -1)
+ this.SelectedNode = null;
+ else
+ this.SelectedNode = this.FindNodeByBindingIndex(_DataManager.Position);
+ //this.SelectedIndex = _DataManager.Position;
+ }
+ }
+
+ ///
+ /// When overridden in a derived class, resynchronizes the item data with the contents of the data source.
+ ///
+ public virtual void RefreshItems()
+ {
+ if (_DataManager != null)
+ {
+ SetItemsCore(_DataManager.List);
+ if (this.AllowSelection)
+ {
+ if (_DataManager.Position == -1)
+ this.SelectedNode = null;
+ else
+ this.SelectedNode = this.FindNodeByBindingIndex(_DataManager.Position);
+ }
+ }
+ }
+
+ private bool _LoadingDataSource = false;
+ ///
+ /// Disposes all nodes in Nodes collection and clears it.
+ ///
+ public void ClearAndDisposeAllNodes()
+ {
+ List disposeControls = new List();
+ if (m_HostedControlCells.Count > 0)
+ {
+ foreach (Cell cell in m_HostedControlCells)
+ {
+ Control c = cell.HostedControl;
+ if (c != null)
+ disposeControls.Add(c);
+ }
+ }
+ foreach (Node node in this.Nodes)
+ {
+ node.Dispose();
+ }
+ foreach (Control c in disposeControls)
+ {
+ this.Controls.Remove(c);
+ c.Dispose();
+ }
+ this.Nodes.Clear();
+ }
+ private bool IsSimpleType(object current)
+ {
+ if (current == null) return false;
+ return current is string || current.GetType().IsPrimitive;
+ }
+ ///
+ /// When overridden in a derived class, sets the specified array of objects in a collection in the derived class.
+ ///
+ /// An array of items.
+ protected virtual void SetItemsCore(IList items)
+ {
+ this.BeginUpdate();
+ this.SuspendPaint = true;
+ _LoadingDataSource = true;
+ try
+ {
+ ClearAndDisposeAllNodes();
+
+ //bool isGrouping = !string.IsNullOrEmpty(_GroupingMembers);
+
+ List fieldNames = new List();
+ // Create Columns
+ if (string.IsNullOrEmpty(this.DisplayMembers))
+ {
+ if (this.Columns.Count > 0)
+ {
+ foreach (DevComponents.AdvTree.ColumnHeader columnHeader in this.Columns)
+ {
+ if (!string.IsNullOrEmpty(columnHeader.DataFieldName))
+ fieldNames.Add(columnHeader.DataFieldName);
+ }
+ }
+ if (fieldNames.Count == 0)
+ {
+ this.Columns.Clear();
+ if (_DataManager.List is Array)
+ {
+ DevComponents.AdvTree.ColumnHeader ch = new DevComponents.AdvTree.ColumnHeader("Items");
+ ch.Width.Relative = 100;
+ this.Columns.Add(ch);
+ OnDataColumnCreated(new DevComponents.DotNetBar.Controls.DataColumnEventArgs(ch));
+ }
+ else if (_DataManager != null)
+ {
+ if (_DataManager.Position >= 0 && _DataManager.Current != null && IsSimpleType(_DataManager.Current))
+ {
+ DevComponents.AdvTree.ColumnHeader ch = new DevComponents.AdvTree.ColumnHeader();
+ ch.Width.Relative = 100;
+ this.Columns.Add(ch);
+ OnDataColumnCreated(new DevComponents.DotNetBar.Controls.DataColumnEventArgs(ch));
+ }
+ else
+ {
+ PropertyDescriptorCollection properties = _DataManager.GetItemProperties();
+ foreach (PropertyDescriptor prop in properties)
+ {
+ fieldNames.Add(prop.Name);
+ DevComponents.AdvTree.ColumnHeader ch = new DevComponents.AdvTree.ColumnHeader(StringHelper.GetFriendlyName(prop.Name));
+ ch.DataFieldName = prop.Name;
+ ch.Width.Relative = Math.Max(15, 100 / properties.Count);
+ this.Columns.Add(ch);
+ OnDataColumnCreated(new DevComponents.DotNetBar.Controls.DataColumnEventArgs(ch));
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ this.Columns.Clear();
+ if (_DisplayMembers != null && _DisplayMembers.Count > 0)
+ {
+ foreach (BindingMemberInfo item in _DisplayMembers)
+ {
+ DevComponents.AdvTree.ColumnHeader ch = new DevComponents.AdvTree.ColumnHeader(StringHelper.GetFriendlyName(item.BindingMember));
+ ch.DataFieldName = item.BindingMember;
+ ch.Tag = item;
+ ch.Width.Relative = Math.Max(15, 100 / _DisplayMembers.Count);
+ this.Columns.Add(ch);
+ fieldNames.Add(item.BindingMember);
+ OnDataColumnCreated(new DevComponents.DotNetBar.Controls.DataColumnEventArgs(ch));
+ }
+ }
+ }
+
+ if (string.IsNullOrEmpty(_GroupingMembers) && string.IsNullOrEmpty(_ParentFieldNames))
+ {
+ for (int i = 0; i < items.Count; i++)
+ {
+ object item = items[i];
+ Node node = CreateNode(this.Nodes, item, i, fieldNames);
+ }
+ }
+ else if (!string.IsNullOrEmpty(_ParentFieldNames))
+ {
+ //isGrouping = true;
+
+ Dictionary nodeParentCollection = new Dictionary();
+ Dictionary> nodeNeedsParentCollection = new Dictionary>();
+ string[] parentFields = _ParentFieldNames.Split(',');
+ int currentPosition = _DataManager.Position;
+ for (int i = 0; i < items.Count; i++)
+ {
+ object item = items[i];
+ string nodeKey = GetItemText(item, parentFields[0].Trim());
+ string parentKey = GetItemText(item, parentFields[1].Trim());
+ Node parentNode = null;
+ if (nodeParentCollection.TryGetValue(parentKey, out parentNode))
+ {
+ Node node = CreateNode(parentNode.Nodes, item, i, fieldNames);
+ nodeParentCollection.Add(nodeKey, node);
+ if (node.BindingIndex == currentPosition) SelectNode(node, eTreeAction.Code);
+ }
+ else
+ {
+ Node node = CreateNode(this.Nodes, item, i, fieldNames);
+ List list = null;
+ if (!nodeNeedsParentCollection.TryGetValue(parentKey, out list))
+ {
+ list = new List();
+ nodeNeedsParentCollection.Add(parentKey, list);
+ }
+ list.Add(node);
+ nodeParentCollection.Add(nodeKey, node);
+ }
+ }
+ // If there are nodes that needed a parent process them now
+ foreach (KeyValuePair> keyValue in nodeNeedsParentCollection)
+ {
+ Node parentNode = null;
+ if (nodeParentCollection.TryGetValue(keyValue.Key, out parentNode))
+ {
+ foreach (Node node in keyValue.Value)
+ {
+ node.Remove();
+ parentNode.Nodes.Add(node);
+ if (node.BindingIndex == currentPosition) SelectNode(node, eTreeAction.Code);
+ }
+ }
+ }
+ }
+ else
+ {
+ string[] groupFields = _GroupingMembers.Split(',');
+ for (int i = 0; i < groupFields.Length; i++)
+ {
+ groupFields[i] = groupFields[i].Trim();
+ }
+ Dictionary groupTable = new Dictionary();
+ for (int i = 0; i < items.Count; i++)
+ {
+ object item = items[i];
+ NodeCollection parentCollection = this.Nodes;
+
+ // Find the parent collection to add item to
+ string key = "";
+ for (int gi = 0; gi < groupFields.Length; gi++)
+ {
+ string text = GetItemText(item, groupFields[gi]);
+ key += text.ToLower() + "/";
+ Node groupNode = null;
+ if (!groupTable.TryGetValue(key, out groupNode))
+ {
+ groupNode = CreateGroupNode(parentCollection, text);
+ groupTable.Add(key, groupNode);
+ }
+ parentCollection = groupNode.Nodes;
+ }
+
+ Node node = CreateNode(parentCollection, item, i, fieldNames);
+ }
+ }
+
+ //// If not grouping then remove the expand part space on left-hand side
+ //if (isGrouping)
+ //{
+ // this.ExpandWidth = 24;
+ //}
+ //else
+ //{
+ // this.ExpandWidth = 0;
+ //}
+ }
+ finally
+ {
+ this.SuspendPaint = false;
+ this.EndUpdate();
+ _LoadingDataSource = false;
+ }
+ }
+
+ ///
+ /// Raises the DataColumnCreated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnDataColumnCreated(DevComponents.DotNetBar.Controls.DataColumnEventArgs args)
+ {
+ if (DataColumnCreated != null)
+ DataColumnCreated(this, args);
+ }
+
+ private Node CreateGroupNode(NodeCollection parentCollection, string text)
+ {
+ Node node = new Node();
+ node.Text = text;
+ node.Style = _GroupNodeStyle;
+ node.Expanded = true;
+ node.Selectable = false;
+ parentCollection.Add(node);
+ DevComponents.DotNetBar.Controls.DataNodeEventArgs eventArgs = new DevComponents.DotNetBar.Controls.DataNodeEventArgs(node, null);
+ OnGroupNodeCreated(eventArgs);
+ return node;
+ }
+ ///
+ /// Raises the DataNodeCreated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnGroupNodeCreated(DevComponents.DotNetBar.Controls.DataNodeEventArgs dataNodeEventArgs)
+ {
+ if (GroupNodeCreated != null) GroupNodeCreated(this, dataNodeEventArgs);
+ }
+
+ ///
+ /// Creates a new node for the data item.
+ ///
+ /// Item to create node for.
+ /// New instance of the node.
+ private Node CreateNode(NodeCollection parentCollection, object item, int itemIndex, List fieldNames)
+ {
+ Node node = new Node();
+ parentCollection.Add(node);
+
+ SetNodeData(node, item, fieldNames, itemIndex);
+
+ DevComponents.DotNetBar.Controls.DataNodeEventArgs eventArgs = new DevComponents.DotNetBar.Controls.DataNodeEventArgs(node, item);
+
+ OnDataNodeCreated(eventArgs);
+
+ return eventArgs.Node;
+ }
+
+ private void SetNodeData(Node node, object item, List fieldNames, int bindingIndex)
+ {
+ node.DataKey = item;
+ node.BindingIndex = bindingIndex;
+
+ node.CreateCells();
+
+ if (fieldNames.Count > 0)
+ {
+ for (int i = 0; i < fieldNames.Count; i++)
+ {
+ object propertyValue = GetPropertyValue(item, fieldNames[i]);
+ if (propertyValue is Image)
+ {
+ node.Cells[i].Images.Image = (Image)propertyValue;
+ //node.Cells[i].Images.AutoDispose = true;
+ }
+ else
+ node.Cells[i].Text = GetItemText(item, fieldNames[i]);
+ }
+ }
+ else if (item != null)
+ node.Text = item.ToString();
+ }
+
+
+ ///
+ /// Raises the DataNodeCreated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnDataNodeCreated(DevComponents.DotNetBar.Controls.DataNodeEventArgs dataNodeEventArgs)
+ {
+ if (DataNodeCreated != null) DataNodeCreated(this, dataNodeEventArgs);
+ }
+
+ ///
+ /// When overridden in a derived class, sets the object with the specified index in the derived class.
+ ///
+ /// The array index of the object.
+ /// The object.
+ protected virtual void SetItemCore(int index, object value)
+ {
+ Node node = this.FindNodeByBindingIndex(index);
+ if (node == null) return;
+
+ List fieldNames = new List();
+
+ foreach (DevComponents.AdvTree.ColumnHeader column in this.Columns)
+ {
+ if (!string.IsNullOrEmpty(column.DataFieldName))
+ fieldNames.Add(column.DataFieldName);
+ }
+
+ SetNodeData(node, value, fieldNames, index);
+ }
+
+ private string _ParentFieldNames = "";
+ ///
+ /// Gets or sets comma separated field or property names that holds the value that is used to identify node and parent node. Format expected is: FieldNodeId,ParentNodeFieldId. For example if your table represents departments, you have DepartmentId field which uniquely identifies a department and ParentDepartmentId field which identifies parent of the department if any you would set this property to DepartmentId,ParentDepartmentId.
+ /// Note that you can only use ParentFieldNames or GroupingMembers property but not both. If both are set ParentFieldName take precedence.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates comma separated field or property names that holds the value that is used to identify node and parent node. Format expected is: FieldNodeId,ParentNodeFieldId. For example if your table represents departments, you have DepartmentId field which uniquely identifies a department and ParentDepartmentId field which identifies parent of the department if any you would set this property to DepartmentId,ParentDepartmentId.")]
+ public string ParentFieldNames
+ {
+ get { return _ParentFieldNames; }
+ set
+ {
+ if (value == null) value = "";
+ if (!string.IsNullOrEmpty(value))
+ {
+ string[] fields = value.Split(',');
+ if (fields.Length != 2)
+ throw new ArgumentException("ParentFieldNames excepts two and only two fields/property names separated by comma character.");
+ if (string.IsNullOrEmpty(fields[0]))
+ throw new ArgumentException("ParentFieldNames excepts two and only two fields/property names separated by comma character. First field name is empty.");
+ if (string.IsNullOrEmpty(fields[1]))
+ throw new ArgumentException("ParentFieldNames excepts two and only two fields/property names separated by comma character. Second field name is empty.");
+ }
+ _ParentFieldNames = value;
+ OnParentFieldNamesChanged();
+ }
+ }
+
+ ///
+ /// Called when ParentFieldName property has changed.
+ ///
+ protected virtual void OnParentFieldNamesChanged()
+ {
+ RefreshItems();
+ }
+
+ private string _GroupingMembers = "";
+ ///
+ /// Gets or sets comma separated list of field or property names that are used for grouping when data-binding is used. Note that you can only use ParentFieldName or GroupingMembers property but not both. If both are set ParentFieldName take precedence.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates comma separated list of field or property names that are used for grouping when data-binding is used")]
+ public string GroupingMembers
+ {
+ get { return _GroupingMembers; }
+ set
+ {
+ if (value == null) value = "";
+ _GroupingMembers = value;
+ OnGroupingMembersChanged();
+ }
+ }
+
+ ///
+ /// Called when GroupingMembers property has changed.
+ ///
+ protected virtual void OnGroupingMembersChanged()
+ {
+ RefreshItems();
+ }
+
+ private ElementStyle _GroupNodeStyle = null;
+ ///
+ /// Gets or sets style for automatically created group nodes when data-binding is used and GroupingMembers property is set.
+ ///
+ ///
+ /// Name of the style assigned or null value indicating that no style is used.
+ /// Default value is null.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Gets or sets default style for the node.")]
+ public ElementStyle GroupNodeStyle
+ {
+ get { return _GroupNodeStyle; }
+ set
+ {
+ if (_GroupNodeStyle != value)
+ {
+ _GroupNodeStyle = value;
+ if (_DataManager != null && this.Nodes != null)
+ RefreshItems();
+ }
+ }
+ }
+
+ private bool AllowSelection
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+
+ private CurrencyManager _DataManager = null;
+ protected CurrencyManager DataManager
+ {
+ get
+ {
+ return _DataManager;
+ }
+ }
+ private bool _IsDataSourceInitEventHooked = false;
+ private void UnwireDataSource()
+ {
+ if (_DataSource is IComponent)
+ {
+ ((IComponent)_DataSource).Disposed -= new EventHandler(DataSourceDisposed);
+ }
+ ISupportInitializeNotification dataSource = _DataSource as ISupportInitializeNotification;
+ if ((dataSource != null) && _IsDataSourceInitEventHooked)
+ {
+ dataSource.Initialized -= new EventHandler(DataSourceInitialized);
+ _IsDataSourceInitEventHooked = false;
+ }
+ }
+ private void DataSourceDisposed(object sender, EventArgs e)
+ {
+ this.SetDataConnection(null, null, true);
+ }
+ private bool _IsDataSourceInitialized = false;
+ private void WireDataSource()
+ {
+ if (_DataSource is IComponent)
+ {
+ ((IComponent)_DataSource).Disposed += new EventHandler(DataSourceDisposed);
+ }
+ ISupportInitializeNotification dataSource = _DataSource as ISupportInitializeNotification;
+ if ((dataSource != null) && !dataSource.IsInitialized)
+ {
+ dataSource.Initialized += new EventHandler(DataSourceInitialized);
+ _IsDataSourceInitEventHooked = true;
+ _IsDataSourceInitialized = false;
+ }
+ else
+ {
+ _IsDataSourceInitialized = true;
+ }
+ }
+ private void DataSourceInitialized(object sender, EventArgs e)
+ {
+ this.SetDataConnection(_DataSource, _DisplayMembers, true);
+ }
+ ///
+ /// Raises the Format event.
+ ///
+ /// Event parameters
+ protected virtual void OnFormat(DevComponents.DotNetBar.Controls.TreeConvertEventArgs e)
+ {
+ DevComponents.DotNetBar.Controls.TreeConvertEventHandler handler = Format;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ private static TypeConverter stringTypeConverter;
+ public string GetItemText(object item, string fieldName)
+ {
+ object propertyValue = GetPropertyValue(item, fieldName);
+ if (!_FormattingEnabled)
+ {
+ if (item == null)
+ {
+ return string.Empty;
+ }
+ if (propertyValue == null)
+ {
+ return "";
+ }
+ return Convert.ToString(propertyValue, CultureInfo.CurrentCulture);
+ }
+
+ DevComponents.DotNetBar.Controls.TreeConvertEventArgs e = new DevComponents.DotNetBar.Controls.TreeConvertEventArgs(propertyValue, typeof(string), item, fieldName);
+ this.OnFormat(e);
+ if ((e.Value != item) && (e.Value is string))
+ {
+ return (string)e.Value;
+ }
+ if (stringTypeConverter == null)
+ {
+ stringTypeConverter = TypeDescriptor.GetConverter(typeof(string));
+ }
+ try
+ {
+ return (string)FormatHelper.FormatObject(propertyValue, typeof(string), GetFieldConverter(fieldName), stringTypeConverter, _FormatString, _FormatInfo, null, DBNull.Value);
+ }
+ catch (Exception ex)
+ {
+ if (ex is SecurityException || IsCriticalException(ex))
+ {
+ throw;
+ }
+ return ((propertyValue != null) ? Convert.ToString(item, CultureInfo.CurrentCulture) : "");
+ }
+ }
+ private static bool IsCriticalException(Exception ex)
+ {
+ return (((((ex is NullReferenceException) || (ex is StackOverflowException)) || ((ex is OutOfMemoryException) || (ex is System.Threading.ThreadAbortException))) || ((ex is ExecutionEngineException) || (ex is IndexOutOfRangeException))) || (ex is AccessViolationException));
+ }
+ Dictionary _DescriptorsCache = new Dictionary();
+ ///
+ /// Clears internal property descriptors cache when data-binding is used. In most cases it is not needed that you call this method. Do so only if instructed by DevComponents support.
+ ///
+ public void ClearDescriptorsCache()
+ {
+ _DescriptorsCache.Clear();
+ }
+ protected object GetPropertyValue(object item, string fieldName)
+ {
+ if ((item != null) && (fieldName.Length > 0))
+ {
+ try
+ {
+ PropertyDescriptor descriptor = null;
+ string key = item.GetType().ToString() + ":" + fieldName;
+ if (!_DescriptorsCache.TryGetValue(key, out descriptor))
+ {
+ if (_DataManager != null)
+ {
+ descriptor = _DataManager.GetItemProperties().Find(fieldName, true);
+ }
+ else
+ {
+ descriptor = TypeDescriptor.GetProperties(item).Find(fieldName, true);
+ }
+ if (descriptor != null)
+ _DescriptorsCache.Add(key, descriptor);
+ }
+ if (descriptor != null)
+ {
+ item = descriptor.GetValue(item);
+ }
+ }
+ catch
+ {
+ }
+ }
+ return item;
+ }
+ ///
+ /// Gets or sets the index specifying the currently selected item.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Description("Gets or sets the index specifying the currently selected item.")]
+ public int SelectedIndex
+ {
+ get
+ {
+ if (_DataManager != null)
+ {
+ if (this.SelectedNode == null || this.SelectedNode.BindingIndex < 0)
+ return -1;
+ return this.SelectedNode.BindingIndex;
+ }
+ if (this.SelectedNode == null) return -1;
+ return this.GetNodeFlatIndex(this.SelectedNode);
+ }
+ set
+ {
+ SetSelectedIndex(value);
+ }
+ }
+ private void SetSelectedIndex(int value)
+ {
+ if (value == -1)
+ {
+ this.SelectedNode = null;
+ return;
+ }
+ Node node = null;
+ if (_DataManager != null)
+ {
+ node = this.FindNodeByBindingIndex(value);
+ }
+ else
+ {
+ node = this.GetNodeByFlatIndex(value);
+ }
+ this.SelectedNode = node;
+ }
+ ///
+ /// Raises the SelectedIndexChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnSelectedIndexChanged(EventArgs e)
+ {
+ EventHandler handler = SelectedIndexChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+ private BindingMemberInfo _ValueMember = new BindingMemberInfo();
+ ///
+ /// Gets or sets the property to use as the actual value for the items in the control. Applies to data-binding scenarios. SelectedValue property will return the value of selected node as indicated by this property.
+ ///
+ [Category("Data"), DefaultValue(""), Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor)), Description("property to use as the actual value for the items in the control. Applies to data-binding scenarios. SelectedValue property will return the value of selected node as indicated by this property.")]
+ public string ValueMember
+ {
+ get
+ {
+ return _ValueMember.BindingMember;
+ }
+ set
+ {
+ if (value == null)
+ {
+ value = "";
+ }
+ BindingMemberInfo newValueMember = new BindingMemberInfo(value);
+ if (!newValueMember.Equals(_ValueMember))
+ {
+ if (this.DisplayMembers.Length == 0)
+ {
+ List list = new List();
+ list.Add(newValueMember);
+ this.SetDataConnection(this.DataSource, list, false);
+ }
+ if (((_DataManager != null) && (value != null)) && ((value.Length != 0) && !this.BindingMemberInfoInDataManager(newValueMember)))
+ {
+ throw new ArgumentException("Invalid value for ValueMember", "value");
+ }
+ _ValueMember = newValueMember;
+ this.OnValueMemberChanged(EventArgs.Empty);
+ this.OnSelectedValueChanged(EventArgs.Empty);
+ }
+ }
+ }
+ ///
+ /// Raises the ValueMemberChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnValueMemberChanged(EventArgs e)
+ {
+ EventHandler handler = ValueMemberChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+ ///
+ /// Raises the SelectedValueChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnSelectedValueChanged(EventArgs e)
+ {
+ EventHandler handler = SelectedValueChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+ ///
+ /// Gets or sets the value of the member property specified by the ValueMember property.
+ ///
+ [Browsable(false), DefaultValue(null), Bindable(true), Category("Data"), Description("Indicates value of the member property specified by the ValueMember property."), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public object SelectedValue
+ {
+ get
+ {
+ if (_DataManager != null && this.SelectedIndex != -1)
+ {
+ object item = _DataManager.List[this.SelectedIndex];
+ return this.GetPropertyValue(item, _ValueMember.BindingField);
+ }
+ return null;
+ }
+ set
+ {
+ if (_DataManager != null)
+ {
+ string bindingField = _ValueMember.BindingField;
+ if (string.IsNullOrEmpty(bindingField))
+ {
+ throw new InvalidOperationException("ValueMember property must be set to be able to set SelectedValue");
+ }
+ PropertyDescriptor property = _DataManager.GetItemProperties().Find(bindingField, true);
+ System.Reflection.MethodInfo mi = _DataManager.GetType().GetMethod("Find", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
+ int num = -1;
+ if (mi != null)
+ {
+ num = (int)mi.Invoke(_DataManager, new object[] { property, value, true });
+ }
+ else
+ {
+ //int num = _DataManager.Find(property, value, true);
+ // Provide an alternate implementation...
+ }
+ this.SelectedIndex = num;
+ }
+ }
+ }
+
+ private bool _EnableDataPositionChange = true;
+ ///
+ /// Indicates whether control changes the CurrencyManager.DataPosition when selected node is changed during data binding.
+ /// Default value is true.
+ ///
+ [Browsable(false), DefaultValue(true)]
+ public bool EnableDataPositionChange
+ {
+ get
+ {
+ return _EnableDataPositionChange;
+ }
+ set
+ {
+ _EnableDataPositionChange = value;
+ }
+ }
+#endif
+ #endregion
+
+ #region Touch Handling
+ private DevComponents.DotNetBar.Touch.TouchHandler _TouchHandler = null;
+
+ private bool _TouchEnabled = true;
+ ///
+ /// Indicates whether touch support for scrolling is enabled.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether touch support for scrolling is enabled.")]
+ public bool TouchEnabled
+ {
+ get { return _TouchEnabled; }
+ set
+ {
+ if (value != _TouchEnabled)
+ {
+ bool oldValue = _TouchEnabled;
+ _TouchEnabled = value;
+ OnTouchEnabledChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when TouchEnabled property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnTouchEnabledChanged(bool oldValue, bool newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("TouchEnabled"));
+ }
+ private int TriggerPageChangeOffset
+ {
+ get
+ {
+ return 32;
+ }
+ }
+ private int MaximumReversePageOffset
+ {
+ get
+ {
+ return 0; //Math.Min(32, this.Width / 6);
+ }
+ }
+ private bool _TouchDrag = false;
+ private Point _TouchStartLocation = Point.Empty;
+ private Point _TouchStartScrollPosition = Point.Empty;
+ private Rectangle _TouchInnerBounds = Rectangle.Empty;
+ private void TouchHandlerPanBegin(object sender, DevComponents.DotNetBar.Touch.GestureEventArgs e)
+ {
+ if (_TouchEnabled)
+ {
+ _TouchInnerBounds = GetInnerRectangle();
+ _TouchStartLocation = e.Location;
+ _TouchStartScrollPosition = _AutoScrollPosition;
+ _TouchDrag = true;
+ e.Handled = true;
+ }
+ }
+
+ private void TouchHandlerPanEnd(object sender, DevComponents.DotNetBar.Touch.GestureEventArgs e)
+ {
+ if (_TouchDrag)
+ {
+ EndTouchPan();
+ e.Handled = true;
+ }
+ }
+
+ private void EndTouchPan()
+ {
+ _TouchDrag = false;
+ Point autoScrollPosition = this.AutoScrollPosition;
+
+ if (_AutoScrollMinSize.Width > _TouchInnerBounds.Width)
+ {
+ if (_AutoScrollMinSize.Width - _TouchInnerBounds.Width < -_AutoScrollPosition.X)
+ autoScrollPosition = new Point(_AutoScrollMinSize.Width - _TouchInnerBounds.Width, autoScrollPosition.Y);
+ else if (-_AutoScrollPosition.X < 0)
+ autoScrollPosition = new Point(0, autoScrollPosition.Y);
+ }
+
+ if (_AutoScrollMinSize.Height > _TouchInnerBounds.Height)
+ {
+ if (_AutoScrollMinSize.Height - _TouchInnerBounds.Height < -_AutoScrollPosition.Y)
+ autoScrollPosition = new Point(autoScrollPosition.X, _AutoScrollMinSize.Height - _TouchInnerBounds.Height);
+ else if (-_AutoScrollPosition.Y < 0)
+ autoScrollPosition = new Point(autoScrollPosition.X, 0);
+ }
+
+ if (this.AutoScrollPosition != autoScrollPosition)
+ {
+ this.AutoScrollPosition = autoScrollPosition;
+ OnScroll(new ScrollEventArgs(ScrollEventType.EndScroll, autoScrollPosition.Y));
+ }
+ //ApplyScrollChange();
+
+ }
+
+ private void TouchHandlerPan(object sender, DevComponents.DotNetBar.Touch.GestureEventArgs e)
+ {
+ if (_TouchDrag)
+ {
+ Point autoScrollPosition = this.AutoScrollPosition;
+
+ int offset = (e.Location.X - _TouchStartLocation.X);
+ int offsetChange = offset + _TouchStartScrollPosition.X;
+
+ bool overflowH = false;
+
+ if (_AutoScrollMinSize.Width > _TouchInnerBounds.Width)
+ {
+ if (-offsetChange + MaximumReversePageOffset > _AutoScrollMinSize.Width - _TouchInnerBounds.Width)
+ {
+ autoScrollPosition.X = -(_AutoScrollMinSize.Width + MaximumReversePageOffset - _TouchInnerBounds.Width);
+ overflowH = true;
+ }
+ else if (offsetChange > MaximumReversePageOffset)
+ {
+ autoScrollPosition.X = MaximumReversePageOffset;
+ overflowH = true;
+ }
+ else
+ autoScrollPosition.X = offsetChange;
+ }
+
+ // Y Scroll
+ bool overflowV = false;
+ if (_AutoScrollMinSize.Height > _TouchInnerBounds.Height)
+ {
+ offset = (e.Location.Y - _TouchStartLocation.Y);
+ offsetChange = offset + _TouchStartScrollPosition.Y;
+
+ if (-offsetChange + MaximumReversePageOffset > _AutoScrollMinSize.Height - _TouchInnerBounds.Height)
+ {
+ autoScrollPosition.Y = -(_AutoScrollMinSize.Height + MaximumReversePageOffset - _TouchInnerBounds.Height);
+ overflowV = true;
+ }
+ else if (offsetChange > MaximumReversePageOffset)
+ {
+ autoScrollPosition.Y = MaximumReversePageOffset;
+ overflowV = true;
+ }
+ else
+ autoScrollPosition.Y = offsetChange;
+ }
+
+ if (this.AutoScrollPosition != autoScrollPosition)
+ {
+ this.AutoScrollPosition = autoScrollPosition;
+ Update();
+ OnScroll(new ScrollEventArgs(ScrollEventType.ThumbTrack, autoScrollPosition.Y));
+ }
+ if (overflowH && overflowV && e.IsInertia) EndTouchPan();
+
+
+ //if (_VScrollBar != null && _VScrollBar.Value != -_AutoScrollPosition.Y)
+ // _VScrollBar.Value = Math.Min(_VScrollBar.Maximum, Math.Max(0, -_AutoScrollPosition.Y));
+ //if (_HScrollBar != null && _HScrollBar.Value != -_AutoScrollPosition.X)
+ // _HScrollBar.Value = Math.Min(_HScrollBar.Maximum, Math.Max(0, -_AutoScrollPosition.X));
+ e.Handled = true;
+ }
+ }
+ #endregion
+ }
+
+ #region AdvTreeSettings
+ ///
+ /// Static class that holds AdvTree settings that are not commonly used.
+ ///
+ public class AdvTreeSettings
+ {
+ ///
+ /// Gets or sets whether tree control is scrolled horizontally so selected node is brought into the view. Default value is false.
+ /// You can set this property to false to disable the horizontal scrolling of tree control when selected node has changed.
+ ///
+ public static bool SelectedScrollIntoViewHorizontal = false;
+ ///
+ /// Gets or sets whether AdvTree node comparer that provides column sorting uses standard text comparer instead of default
+ /// hybrid alpha-numeric comparer. Default value is false.
+ ///
+ public static bool UseSortAlphaComparer = false;
+ }
+ #endregion
+
+ #region ICellEditControl
+ ///
+ /// Defines an interface for cell edit control that allows custom controls to be used as cell editors. AdvTree control
+ /// expects that editing control inherits from System.Windows.Forms.Control.
+ ///
+ public interface ICellEditControl
+ {
+ ///
+ /// Called when edit operation is started. The AdvTree control will first set CurrentValue, then call BeginEdit and will call EditComplete once
+ /// editing is completed.
+ ///
+ void BeginEdit();
+ ///
+ /// Called when edit operation is completed.
+ ///
+ void EndEdit();
+ ///
+ /// Gets or sets current edit value.
+ ///
+ object CurrentValue { get;set;}
+ ///
+ /// AdvTree control subscribes to this event to be notified when edit operation is completed. For example when Enter key is
+ /// pressed the edit control might raise this event to indicate the completion of editing operation.
+ ///
+ event EventHandler EditComplete;
+ ///
+ /// AdvTree control subscribes to this event to be notified that user has cancelled the editing. For example when Escape key is
+ /// pressed the edit control might raise this event to indicate that editing has been cancelled.
+ ///
+ event EventHandler CancelEdit;
+ ///
+ /// Gets or sets whether cell requests the word-wrap based on the current cell style. If your editor does not support
+ /// word-wrap functionality this can be ignored.
+ ///
+ bool EditWordWrap { get;set;}
+ }
+ #endregion
+
+ #region PrepareCellEditor
+ ///
+ /// Defines delegate for PrepareCellEditor event.
+ ///
+ ///
+ ///
+ public delegate void PrepareCellEditorEventHandler(object sender, PrepareCellEditorEventArgs e);
+ ///
+ /// Event arguments for PrepareCellEditor event.
+ ///
+ public class PrepareCellEditorEventArgs : EventArgs
+ {
+ ///
+ /// Gets reference to the cell being edited.
+ ///
+ public readonly Cell EditedCell;
+ ///
+ /// Gets reference to the cell editor control.
+ ///
+ public readonly ICellEditControl Editor;
+ ///
+ /// Initializes a new instance of the PrepareCellEditorEventArgs class.
+ ///
+ ///
+ ///
+ public PrepareCellEditorEventArgs(Cell editedCell, ICellEditControl editor)
+ {
+ EditedCell = editedCell;
+ Editor = editor;
+ }
+ }
+ #endregion
+
+ #region AdvTreeRender
+ ///
+ /// Defines delegate for PrepareCellEditor event.
+ ///
+ ///
+ ///
+ public delegate void AdvTreeRenderEventHandler(object sender, AdvTreeRenderEventArgs e);
+ ///
+ /// Event arguments for AdvTree.Render event.
+ ///
+ public class AdvTreeRenderEventArgs : EventArgs
+ {
+ ///
+ /// Indicates the rendering operation being performed.
+ ///
+ public readonly eAdvTreeRenderType RenderType;
+ ///
+ /// Indicates graphics canvas to render on.
+ ///
+ public Graphics Graphics;
+ ///
+ /// Initializes a new instance of the AdvTreeRenderEventArgs class.
+ ///
+ /// Specifies rendering type
+ /// Specifies graphics canvas to render on
+ public AdvTreeRenderEventArgs(eAdvTreeRenderType renderType, Graphics g)
+ {
+ RenderType = renderType;
+ Graphics = g;
+ }
+ }
+ ///
+ /// Specifies the rendering type being performed on AdvTree control Render event.
+ ///
+ public enum eAdvTreeRenderType
+ {
+ ///
+ /// Control background is being painted.
+ ///
+ Background
+ }
+ #endregion
+}
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/AdvTree/AdvTree.resx b/PROMS/DotNetBar Source Code/AdvTree/AdvTree.resx
new file mode 100644
index 00000000..7e323966
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/AdvTree.resx
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.0.0.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Cell.cs b/PROMS/DotNetBar Source Code/AdvTree/Cell.cs
new file mode 100644
index 00000000..1383dbb0
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Cell.cs
@@ -0,0 +1,1836 @@
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Windows.Forms;
+using DevComponents.AdvTree.Display;
+using DevComponents.DotNetBar;
+using System.Collections;
+
+namespace DevComponents.AdvTree
+{
+ /// Represents a cell assigned to the Node.
+ ///
+ /// The Cell with Index 0 (zero) always exists for a Node and it is a cell that
+ /// you can interact with through the properties on a node, which are forwarding to the
+ /// Cell(0), or you can go directly to the Cell(0).
+ /// When Node has multiple columns defined each column corresponds to Cell in
+ /// Node's Cells collection. The first Column has Index 0, second Column Index 1 and so
+ /// forth.
+ /// Note that there is always at least one Cell in a Node even if multiple
+ /// columns are not used.
+ ///
+ [DesignTimeVisible(false),ToolboxItem(false)]
+ public class Cell:Component
+ {
+ #region Private Variables
+ private ElementStyle m_StyleNormal=null;
+ private ElementStyle m_StyleDisabled=null;
+ private ElementStyle m_StyleMouseDown=null;
+ private ElementStyle m_StyleMouseOver=null;
+ private ElementStyle m_StyleSelected=null;
+ private bool m_Enabled=true;
+ private CellImages m_Images=null;
+ private Rectangle m_Bounds=Rectangle.Empty;
+ private Rectangle m_TextBounds=Rectangle.Empty;
+ private Rectangle m_TextContentBounds=Rectangle.Empty;
+ private Rectangle m_ImageBounds=Rectangle.Empty;
+ private Rectangle m_CheckBoxBounds=Rectangle.Empty;
+ private object m_Tag=null;
+ private string m_Text="";
+ private eCellPartAlignment m_ImageAlignment=eCellPartAlignment.Default;
+ private eCellPartAlignment m_CheckBoxAlignment=eCellPartAlignment.Default;
+ private bool m_CheckBoxVisible=false;
+ private bool m_Checked=false;
+ private bool m_MouseDown=false;
+ private bool m_MouseOver=false;
+ private bool m_Selected=false;
+ private Node m_Parent=null;
+ private bool m_Visible=true;
+ private eTreeAction m_ActionSource=eTreeAction.Code;
+ private eCellPartLayout m_Layout=eCellPartLayout.Default;
+ private System.Windows.Forms.Cursor m_Cursor=null;
+ private bool m_WordWrap=false;
+ private string m_Name="";
+ private Control m_HostedControl=null;
+ private Size m_HostedControlSize=Size.Empty;
+ private bool m_IgnoreHostedControlSizeChange=false;
+ #endregion
+
+ #region Constructor/Dispose
+ ///
+ /// Initializes new instance of Cell class.
+ ///
+ public Cell():this("")
+ {
+ }
+
+ ///
+ /// Initializes new instance of Cell class.
+ ///
+ /// Cell text.
+ public Cell(string text)
+ {
+ Text=text;
+ m_Images=new CellImages(this);
+ }
+
+ ///
+ /// Initializes new instance of Cell class.
+ ///
+ /// Cell text.
+ public Cell(string text, ElementStyle styleNormal)
+ : this(text)
+ {
+ this.StyleNormal = styleNormal;
+ }
+
+ ///
+ /// Initializes new instance of Cell class.
+ ///
+ /// Cell text.
+ public Cell(string text, string styleNormalName)
+ : this(text)
+ {
+ this.StyleNormalName = styleNormalName;
+ }
+
+ ///
+ /// Releases the resources used by the Component.
+ ///
+ /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
+ protected override void Dispose(bool disposing)
+ {
+ if(m_HostedControl!=null)
+ m_HostedControl.SizeChanged-=new EventHandler(this.HostedControlSizedChanged);
+ m_HostedControl=null;
+ if (m_Images != null)
+ {
+ m_Images.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+ #endregion
+
+ #region Properties
+ ///
+ /// Occurs after Tooltip text has changed.
+ ///
+ protected virtual void OnTooltipChanged() { }
+ private string _Tooltip = "";
+ ///
+ /// Gets/Sets informational text (tooltip) for the cell.
+ ///
+ [Browsable(true), DefaultValue(""), Category("Appearance"), Description("Indicates the text that is displayed when mouse hovers over the cell."), Localizable(true)]
+ public string Tooltip
+ {
+ get
+ {
+
+ return _Tooltip;
+ }
+ set
+ {
+ if (_Tooltip == value)
+ return;
+ if (value == null) value = "";
+ _Tooltip = value;
+
+ if (this.ToolTipVisible)
+ {
+ if (string.IsNullOrEmpty(_Tooltip))
+ this.HideToolTip();
+ else
+ {
+ DevComponents.DotNetBar.ToolTip tooltipWindow = _ToolTipWnd;
+ tooltipWindow.Text = _Tooltip;
+ tooltipWindow.ShowToolTip();
+ tooltipWindow.Invalidate();
+ }
+ }
+ OnTooltipChanged();
+ }
+ }
+ ///
+ /// Gets whether tooltip is visible or not.
+ ///
+ internal protected bool ToolTipVisible
+ {
+ get
+ {
+ return (_ToolTipWnd != null);
+ }
+ }
+ ///
+ /// Called when tooltip is shown and hidden.
+ ///
+ /// true if tooltip is being shown otherwise false.
+ protected virtual void OnTooltip(bool isShown)
+ {
+ }
+ private DevComponents.DotNetBar.ToolTip _ToolTipWnd = null;
+ ///
+ /// Shows tooltip for this item.
+ ///
+ public virtual void ShowToolTip()
+ {
+ if (this.DesignMode)
+ return;
+
+ if (IsVisible)
+ {
+ AdvTree tree = TreeControl;
+ if (tree != null && !tree.ShowToolTips || !this.ShowToolTips)
+ return;
+ OnTooltip(true);
+ if (_Tooltip != "")
+ {
+ if (_ToolTipWnd == null)
+ _ToolTipWnd = new DevComponents.DotNetBar.ToolTip();
+ _ToolTipWnd.Style = StyleManager.GetEffectiveStyle();
+ _ToolTipWnd.Text = _Tooltip;
+ _ToolTipWnd.ReferenceRectangle = ScreenRectangle;
+
+ OnToolTipVisibleChanged(new EventArgs());
+ _ToolTipWnd.ShowToolTip();
+ }
+ }
+ }
+ ///
+ /// Destroys tooltip window.
+ ///
+ internal protected void HideToolTip()
+ {
+ if (_ToolTipWnd != null)
+ {
+ System.Drawing.Rectangle tipRect = _ToolTipWnd.Bounds;
+ tipRect.Width += 5;
+ tipRect.Height += 6;
+
+ OnTooltip(false);
+ OnToolTipVisibleChanged(new EventArgs());
+ try
+ {
+ if (_ToolTipWnd != null)
+ {
+ _ToolTipWnd.Hide();
+ _ToolTipWnd.Dispose();
+ _ToolTipWnd = null;
+ }
+ }
+ catch { }
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ tree.Invalidate(tree.RectangleToClient(tipRect), false);
+ }
+ }
+ }
+ ///
+ /// Occurs when item's tooltip visibility has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when item's tooltip visibility has changed.")]
+ public event EventHandler ToolTipVisibleChanged;
+ private void OnToolTipVisibleChanged(EventArgs eventArgs)
+ {
+ EventHandler h = ToolTipVisibleChanged;
+ if (h != null)
+ ToolTipVisibleChanged(this, eventArgs);
+ }
+ private Rectangle ScreenRectangle
+ {
+ get
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree == null) return Rectangle.Empty;
+ return new Rectangle(tree.PointToScreen(this.Bounds.Location), this.Bounds.Size);
+ }
+ }
+
+ private bool _ShowToolTips = true;
+ ///
+ /// Gets or sets whether tooltips are shown when mouse is over the cell when Tooltip property is set.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether tooltips are shown when mouse is over the cell when Tooltip property is set.")]
+ public bool ShowToolTips
+ {
+ get { return _ShowToolTips; }
+ set
+ {
+ _ShowToolTips = value;
+ }
+ }
+
+
+ private bool _Editable = true;
+ ///
+ /// Gets or sets whether cell content is editable when cell editing is enabled on tree control. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether cell content is editable when cell editing is enabled on tree control.")]
+ public bool Editable
+ {
+ get { return _Editable; }
+ set
+ {
+ _Editable = value;
+ }
+ }
+
+ ///
+ /// Gets whether cell can be edited. Cell can be edited if both Editable property is set to true and ColumnHeader.Editable property is set to true.
+ ///
+ [Browsable(false)]
+ public bool IsEditable
+ {
+ get
+ {
+ ColumnHeader header = NodeOperations.GetCellColumnHeader(this.TreeControl, this);
+ if (header == null) return _Editable;
+ return _Editable && header.Editable;
+ }
+ }
+
+ private BaseItem _HostedItem = null;
+ ///
+ /// Gets or sets the item hosted inside of the cell. Only items that do not generate
+ /// popups are supported. Note that cell can only host either HostedItem or HostedControl but not both.
+ ///
+ [DefaultValue(null), Category("Appearance"), Editor("DevComponents.AdvTree.Design.HostedItemTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates item hosted inside of the cell. Only items that do not generate popups are supported. Note that cell can only host either HostedItem or HostedControl but not both.")]
+ public BaseItem HostedItem
+ {
+ get { return _HostedItem; }
+ set { SetHostedItem(value); }
+ }
+
+ ///
+ /// Gets or sets the control hosted inside of the cell. Note that cell can only host either HostedItem or HostedControl but not both.
+ ///
+ ///
+ /// When control is hosted inside of the cell, cell size is determined by the
+ /// size of the control hosted inside of it. The cell will not display its text but it will display any image assigned
+ /// or check box when control is hosted inside of it. The Style settings like Margin
+ /// and Padding will still apply.
+ ///
+ [Browsable(true),Category("Behavior"),Description("Indicates control hosted inside of the cell."),DefaultValue(null)]
+ public Control HostedControl
+ {
+ get {return m_HostedControl;}
+ set
+ {
+ SetHostedControl(value);
+ }
+ }
+
+ ///
+ /// Gets or sets whether hosted control size change event is ignored.
+ ///
+ internal bool IgnoreHostedControlSizeChange
+ {
+ get { return m_IgnoreHostedControlSizeChange;}
+ set { m_IgnoreHostedControlSizeChange=value; }
+ }
+
+ ///
+ /// Gets or sets the hosted control size. Property is used to correctly scale control when AdvTree.Zoom is used to zoom view.
+ ///
+ internal Size HostedControlSize
+ {
+ get { return m_HostedControlSize;}
+ set { m_HostedControlSize = value;}
+ }
+
+ ///
+ /// Returns name of the cell that can be used to identify it from the code.
+ ///
+ [Browsable(false),Category("Design"),Description("Indicates the name used to identify cell.")]
+ public string Name
+ {
+ get
+ {
+ if(this.Site!=null)
+ m_Name=this.Site.Name;
+ return m_Name;
+ }
+ set
+ {
+ if(this.Site!=null)
+ this.Site.Name=value;
+ if(value==null)
+ m_Name="";
+ else
+ m_Name=value;
+ }
+ }
+
+ ///
+ /// Gets the relative bounds of the cell.
+ ///
+ [Browsable(false)]
+ internal Rectangle BoundsRelative
+ {
+ get
+ {
+ return m_Bounds;
+ }
+ }
+
+ ///
+ /// Gets the bounds of the cell.
+ ///
+ [Browsable(false)]
+ public Rectangle Bounds
+ {
+ get
+ {
+ AdvTree tree=this.TreeControl;
+ if(tree!=null)
+ {
+ return NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds, this, tree.NodeDisplay.Offset);
+ }
+ return Rectangle.Empty;
+ }
+ }
+
+ ///
+ /// Sets the bounds of the cell.
+ ///
+ /// New cell bounds.
+ internal void SetBounds(Rectangle bounds)
+ {
+ m_Bounds=bounds;
+ }
+
+// ///
+// /// Gets the bounds of the text inside of cell.
+// ///
+// [Browsable(false)]
+// public Rectangle TextBounds
+// {
+// get
+// {
+// return m_TextBounds;
+// }
+// }
+
+// ///
+// /// Sets the bounds of the text inside of the cell.
+// ///
+// /// New cell bounds.
+// internal void SetTextBounds(Rectangle bounds)
+// {
+// m_TextBounds=bounds;
+// }
+
+ ///
+ /// Gets or sets the available content bounds for the text. Text will fitted into these bounds
+ /// but it's true location can be obtained only after it is displayed.
+ ///
+ internal Rectangle TextContentBounds
+ {
+ get {return m_TextContentBounds;}
+ set {m_TextContentBounds=value;}
+ }
+
+ ///
+ /// Gets the bounds of the text inside of cell.
+ ///
+ [Browsable(false)]
+ public Rectangle TextBounds
+ {
+ get
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ return NodeDisplay.GetCellRectangle(eCellRectanglePart.TextBounds, this, tree.NodeDisplay.Offset);
+ }
+ return Rectangle.Empty;
+ }
+ }
+
+ ///
+ /// Gets the relative bounds of the image inside of cell.
+ ///
+ [Browsable(false)]
+ internal Rectangle ImageBoundsRelative
+ {
+ get
+ {
+ return m_ImageBounds;
+ }
+ }
+
+ ///
+ /// Gets the bounds of the image inside of cell.
+ ///
+ [Browsable(false)]
+ public Rectangle ImageBounds
+ {
+ get
+ {
+ AdvTree tree=this.TreeControl;
+ if(tree!=null)
+ {
+ return NodeDisplay.GetCellRectangle(eCellRectanglePart.ImageBounds, this, tree.NodeDisplay.Offset);
+ }
+ return Rectangle.Empty;
+ }
+ }
+
+ ///
+ /// Sets the bounds of the image inside of the cell.
+ ///
+ /// New cell bounds.
+ internal void SetImageBounds(Rectangle bounds)
+ {
+ m_ImageBounds=bounds;
+ }
+
+ ///
+ /// Gets the bounds of the image inside of cell.
+ ///
+ [Browsable(false)]
+ internal Rectangle CheckBoxBoundsRelative
+ {
+ get
+ {
+ return m_CheckBoxBounds;
+ }
+ }
+
+ ///
+ /// Gets the bounds of the check box inside of cell.
+ ///
+ [Browsable(false)]
+ public Rectangle CheckBoxBounds
+ {
+ get
+ {
+ AdvTree tree=this.TreeControl;
+ if (tree != null)
+ {
+ return NodeDisplay.GetCellRectangle(eCellRectanglePart.CheckBoxBounds, this, tree.NodeDisplay.Offset);
+ }
+ return Rectangle.Empty;
+ }
+ }
+
+ ///
+ /// Sets the bounds of the check box inside of the cell.
+ ///
+ /// New cell bounds.
+ internal void SetCheckBoxBounds(Rectangle bounds)
+ {
+ m_CheckBoxBounds=bounds;
+ }
+
+ ///
+ /// Gets a value indicating whether the cell is in an editable state. true if the cell is in editable state; otherwise, false.
+ ///
+ [Browsable(false)]
+ public bool IsEditing
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether the cell is in the selected state. true if the cell is in the selected state; otherwise, false.
+ ///
+ [Browsable(false)]
+ public bool IsSelected
+ {
+ get
+ {
+ return m_Selected;
+ }
+ }
+
+ internal void SetSelected(bool selected, eTreeAction actionSource)
+ {
+ m_Selected = selected;
+ }
+
+ ///
+ /// Gets a value indicating whether the cell is visible. Cell is considered to be visible when it's parent column is visible.
+ ///
+ [Browsable(false)]
+ public bool IsVisible
+ {
+ get
+ {
+ return m_Visible;
+ }
+ }
+
+ ///
+ /// Sets whether cells is visible or not. This is set by node layout manager and it is based on column visibility.
+ ///
+ /// True if visible otherwise false.
+ internal void SetVisible(bool visible)
+ {
+ if(m_Visible!=visible)
+ {
+ m_Visible=visible;
+ OnVisibleChanged();
+ }
+ }
+
+ ///
+ /// Gets the parent node of the current cell.
+ ///
+ [Browsable(false)]
+ public Node Parent
+ {
+ get
+ {
+ return m_Parent;
+ }
+ }
+
+ ///
+ /// Sets the parent of the cell.
+ ///
+ /// Parent node.
+ internal void SetParent(Node parent)
+ {
+ m_Parent=parent;
+ }
+
+ ///
+ /// Gets or sets the object that contains data about the cell. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ ///
+ [Browsable(false),DefaultValue(null),Category("Data"),Description("Indicates text that contains data about the cell.")]
+ public object Tag
+ {
+ get
+ {
+ return m_Tag;
+ }
+ set
+ {
+ m_Tag=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the object that contains data about the cell. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ ///
+ [Browsable(true),DefaultValue(""),Category("Data"),Description("Indicates text that contains data about the cell."),DevCoSerialize()]
+ public string TagString
+ {
+ get
+ {
+ if(m_Tag==null)
+ return "";
+ return m_Tag.ToString();
+ }
+ set
+ {
+ m_Tag=value;
+ }
+ }
+
+ private string _TextDisplayFormat = "";
+ ///
+ /// Gets or sets the format that is applied to the value of Text property for display purposes. See "Formatting Overview" in MSDN
+ /// for description on available format strings. For example you can specify "C" to format text as currency, or "D" to format text as decimal number etc.
+ ///
+ ///
+ [Browsable(true), DefaultValue(""), Category("Appearance"), Description("Indicates format that is applied to the value of Text property for display purposes.")]
+ public string TextDisplayFormat
+ {
+ get { return _TextDisplayFormat; }
+ set
+ {
+ _TextDisplayFormat = value;
+ UpdateDisplayText();
+ this.OnSizeChanged();
+ }
+ }
+
+ private string _DisplayText = string.Empty;
+ ///
+ /// Gets the formatted display text.
+ ///
+ internal string DisplayText
+ {
+ get
+ {
+ return _DisplayText;
+ }
+ }
+ private void UpdateDisplayText()
+ {
+ if (string.IsNullOrEmpty(_TextDisplayFormat))
+ {
+ _DisplayText = m_Text;
+ return;
+ }
+
+ long longNumber = 0;
+ double number = 0;
+ DateTime date = DateTime.MinValue;
+ if (long.TryParse(m_Text, out longNumber))
+ {
+ _DisplayText = longNumber.ToString(_TextDisplayFormat);
+ }
+ else if (double.TryParse(m_Text, out number))
+ {
+ _DisplayText = number.ToString(_TextDisplayFormat);
+ }
+ else if (DateTime.TryParse(m_Text, out date))
+ {
+ _DisplayText = date.ToString(_TextDisplayFormat);
+ }
+ else
+ _DisplayText = m_Text;
+ }
+
+ ///
+ /// Gets or sets the text displayed in the cell.
+ ///
+ [Browsable(true), DefaultValue(""), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Category("Appearance"), Localizable(true), Description("Indicates text displayed in the cell."), DevCoSerialize()]
+ public string Text
+ {
+ get
+ {
+ return m_Text;
+ }
+ set
+ {
+ if (value == null) value = "";
+ if (m_Text != value)
+ {
+ m_Text = value;
+ UpdateDisplayText();
+ OnTextChanged();
+ this.OnSizeChanged();
+ }
+ }
+ }
+
+ ///
+ /// Occurs after text has changed.
+ ///
+ protected virtual void OnTextChanged()
+ {
+ MarkupTextChanged();
+ }
+
+ ///
+ /// Gets the parent tree control that the cell belongs to.
+ ///
+ [Browsable(false)]
+ public AdvTree TreeControl
+ {
+ get
+ {
+ if(this.Parent!=null)
+ return this.Parent.TreeControl;
+ return null;
+ }
+ }
+
+ ///
+ /// Gets or sets the style class assigned to the cell. Null value indicates that
+ /// default style is used as specified on cell's parent.
+ ///
+ ///
+ /// Reference to the style assigned to the cell or null (VB Nothing) indicating that default
+ /// style setting from tree control is applied. Default value is null.
+ ///
+ ///
+ /// When property is set to null (VB Nothing) the style setting from parent tree
+ /// controls is used. CellStyleNormal on AdvTree control is a root style for a cell.
+ ///
+ /// StyleDisabled Property
+ /// StyleMouseDown Property
+ /// StyleMouseOver Property
+ /// StyleSelected Property
+ [Browsable(true),DefaultValue(null),Category("Style"),Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf",typeof(System.Drawing.Design.UITypeEditor)),Description("Indicates the style class assigned to the cell.")]
+ public ElementStyle StyleNormal
+ {
+ get {return m_StyleNormal;}
+ set
+ {
+ m_StyleNormal=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the style name used by cell. This member is provided for internal use only. To set or get the style use StyleNormal property instead.
+ ///
+ [Browsable(false), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never) , DevCoSerialize()]
+ public string StyleNormalName
+ {
+ get
+ {
+ if(m_StyleNormal!=null)
+ return m_StyleNormal.Name;
+ return "";
+ }
+ set
+ {
+ if(value.Length==0)
+ {
+ TypeDescriptor.GetProperties(this)["StyleNormal"].SetValue(this, null);
+ return;
+ }
+
+ AdvTree tree=this.TreeControl;
+ if(tree!=null)
+ {
+ TypeDescriptor.GetProperties(this)["StyleNormal"].SetValue(this, tree.Styles[value]);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the style class that is to when cell is selected. Null value indicates that
+ /// default style is used as specified on cell's parent.
+ ///
+ ///
+ /// Reference to the style assigned to the cell or null value indicating that default
+ /// style setting from tree control is applied. Default is null value.
+ ///
+ ///
+ /// When property is set to null value the style setting from parent tree
+ /// controls is used. CellStyleSelected on AdvTree control is a root style for a cell.
+ ///
+ /// StyleNormal Property
+ /// StyleDisabled Property
+ /// StyleMouseDown Property
+ /// StyleMouseOver Property
+ [Browsable(true),DefaultValue(null),Category("Style"),Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf",typeof(System.Drawing.Design.UITypeEditor)),Description("Indicates the style class assigned to the cell.")]
+ public ElementStyle StyleSelected
+ {
+ get {return m_StyleSelected;}
+ set
+ {
+ m_StyleSelected=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the selected style name used by cell. This member is provided for internal use only. To set or get the style use StyleSelected property instead.
+ ///
+ [Browsable(false), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never) , DevCoSerialize()]
+ public string StyleSelectedName
+ {
+ get
+ {
+ if(m_StyleSelected!=null)
+ return m_StyleSelected.Name;
+ return "";
+ }
+ set
+ {
+ if(value.Length==0)
+ {
+ TypeDescriptor.GetProperties(this)["StyleSelected"].SetValue(this, null);
+ return;
+ }
+
+ AdvTree tree=this.TreeControl;
+ if(tree!=null)
+ {
+ TypeDescriptor.GetProperties(this)["StyleSelected"].SetValue(this, tree.Styles[value]);
+ }
+ }
+ }
+
+
+ ///
+ /// Gets or sets the disabled style class assigned to the cell. Null value indicates
+ /// that default style is used as specified on cell's parent.
+ ///
+ ///
+ /// Reference to the style assigned to the cell or null value indicating that default
+ /// style setting from tree control is applied. Default value is null.
+ ///
+ ///
+ /// When property is set to null value the style setting from parent tree
+ /// controls is used. CellStyleDisabled on AdvTree control is a root style for a
+ /// cell.
+ ///
+ /// StyleNormal Property
+ /// StyleMouseDown Property
+ /// StyleMouseOver Property
+ /// StyleSelected Property
+ [Browsable(true),DefaultValue(null),Category("Style"),Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf",typeof(System.Drawing.Design.UITypeEditor)),Description("Indicates the disabled style class assigned to the cell.")]
+ public ElementStyle StyleDisabled
+ {
+ get {return m_StyleDisabled;}
+ set
+ {
+ m_StyleDisabled=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the disabled style name used by cell. This member is provided for internal use only. To set or get the style use StyleDisabled property instead.
+ ///
+ [Browsable(false), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never) , DevCoSerialize()]
+ public string StyleDisabledName
+ {
+ get
+ {
+ if(m_StyleDisabled!=null)
+ return m_StyleDisabled.Name;
+ return "";
+ }
+ set
+ {
+ if(value.Length==0)
+ {
+ TypeDescriptor.GetProperties(this)["StyleDisabled"].SetValue(this, null);
+ return;
+ }
+
+ AdvTree tree=this.TreeControl;
+ if(tree!=null)
+ {
+ TypeDescriptor.GetProperties(this)["StyleDisabled"].SetValue(this, tree.Styles[value]);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the style class assigned to the cell which is applied when mouse
+ /// button is pressed while mouse is over the cell. Null value indicates that default
+ /// style is used as specified on cell's parent.
+ ///
+ ///
+ /// Reference to the style assigned to the cell or null value indicating that default
+ /// style setting from tree control is applied. Default value is null.
+ ///
+ ///
+ /// When property is set to null value style setting from parent tree
+ /// controls is used. CellStyleMouseDown on AdvTree control is a root style for a
+ /// cell.
+ ///
+ /// StyleNormal Property
+ /// StyleDisabled Property
+ /// StyleMouseOver Property
+ /// StyleSelected Property
+ [Browsable(true),DefaultValue(null),Category("Style"),Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf",typeof(System.Drawing.Design.UITypeEditor)),Description("Indicates the style class assigned to the cell when mouse is down.")]
+ public ElementStyle StyleMouseDown
+ {
+ get {return m_StyleMouseDown;}
+ set
+ {
+ m_StyleMouseDown=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the mouse down style name used by cell. This member is provided for internal use only. To set or get the style use StyleMouseDown property instead.
+ ///
+ [Browsable(false), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never) , DevCoSerialize()]
+ public string StyleMouseDownName
+ {
+ get
+ {
+ if(m_StyleMouseDown!=null)
+ return m_StyleMouseDown.Name;
+ return "";
+ }
+ set
+ {
+ if(value.Length==0)
+ {
+ TypeDescriptor.GetProperties(this)["StyleMouseDown"].SetValue(this, null);
+ return;
+ }
+
+ AdvTree tree=this.TreeControl;
+ if(tree!=null)
+ {
+ TypeDescriptor.GetProperties(this)["StyleMouseDown"].SetValue(this, tree.Styles[value]);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the style class assigned to the cell which is applied when mouse is
+ /// over the cell. Null value indicates that default style is used as specified on cell's
+ /// parent.
+ ///
+ ///
+ /// Reference to the style assigned to the cell or null value indicating that default
+ /// style setting from tree control is applied. Default value is null.
+ ///
+ ///
+ /// When property is set to null value the style setting from parent tree
+ /// controls is used. CellStyleMouseOver on AdvTree control is a root style for a
+ /// cell.
+ ///
+ /// StyleNormal Property
+ /// StyleDisabled Property
+ /// StyleMouseDown Property
+ /// StyleSelected Property
+ [Browsable(true),DefaultValue(""),Category("Style"),Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf",typeof(System.Drawing.Design.UITypeEditor)),Description("Indicates the style class assigned to the cell when mouse is over the cell.")]
+ public ElementStyle StyleMouseOver
+ {
+ get {return m_StyleMouseOver;}
+ set
+ {
+ m_StyleMouseOver=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the mouse over style name used by cell. This member is provided for internal use only. To set or get the style use StyleMouseOver property instead.
+ ///
+ [Browsable(false), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never) , DevCoSerialize()]
+ public string StyleMouseOverName
+ {
+ get
+ {
+ if(m_StyleMouseOver!=null)
+ return m_StyleMouseOver.Name;
+ return "";
+ }
+ set
+ {
+ if(value.Length==0)
+ {
+ TypeDescriptor.GetProperties(this)["StyleMouseOver"].SetValue(this, null);
+ return;
+ }
+
+ AdvTree tree=this.TreeControl;
+ if(tree!=null)
+ {
+ TypeDescriptor.GetProperties(this)["StyleMouseOver"].SetValue(this, tree.Styles[value]);
+ }
+ }
+ }
+
+
+ ///
+ /// Gets or sets whether cell is enabled or not.
+ ///
+ [Browsable(true),DefaultValue(true),Category("Behavior"),Description("Gets or sets whether cell is enabled or not."),DevCoSerialize()]
+ public bool Enabled
+ {
+ get {return m_Enabled;}
+ set
+ {
+ m_Enabled=value;
+ if (this.Parent != null)
+ {
+ this.Parent.OnDisplayChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets the reference to images associated with this cell.
+ ///
+ [Browsable(true),Category("Images"),Description("Gets the reference to images associated with this cell."),DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public CellImages Images
+ {
+ get {return m_Images;}
+ }
+ ///
+ /// Sets the Images to the new CellImages object.
+ ///
+ /// CellImages object.
+ internal void SetCellImages(CellImages ci)
+ {
+ m_Images=ci;
+ m_Images.Parent=this;
+ }
+ ///
+ /// Returns whether Images property should be serialized. Used internally for windows forms designer support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal bool ShouldSerializeImages()
+ {
+ return m_Images.ShouldSerialize;
+ }
+
+ ///
+ /// Gets or sets the image alignment in relation to the text displayed by cell.
+ ///
+ [Browsable(true),Category("Image Properties"),DefaultValue(eCellPartAlignment.Default),Description("Gets or sets the image alignment in relation to the text displayed by cell."),DevCoSerialize()]
+ public eCellPartAlignment ImageAlignment
+ {
+ get
+ {
+ return m_ImageAlignment;
+ }
+ set
+ {
+ if(m_ImageAlignment!=value)
+ {
+ m_ImageAlignment=value;
+ this.OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the checkbox alignment in relation to the text displayed by cell.
+ ///
+ [Browsable(true),Category("Check-box Properties"),DefaultValue(eCellPartAlignment.Default),Description("Indicates checkbox alignment in relation to the text displayed by cell.")]
+ public eCellPartAlignment CheckBoxAlignment
+ {
+ get
+ {
+ return m_CheckBoxAlignment;
+ }
+ set
+ {
+ if(m_CheckBoxAlignment!=value)
+ {
+ m_CheckBoxAlignment=value;
+ this.OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether check box is visible inside the cell.
+ ///
+ [Browsable(true),Category("Check-box Properties"),DefaultValue(false),Description("Indicates whether check box is visible inside the cell."),DevCoSerialize()]
+ public bool CheckBoxVisible
+ {
+ get
+ {
+ return m_CheckBoxVisible;
+ }
+ set
+ {
+ if(m_CheckBoxVisible!=value)
+ {
+ m_CheckBoxVisible=value;
+ this.OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or set a value indicating whether the check box is in the checked state.
+ ///
+ [Browsable(true),Category("Check-box Properties"),DefaultValue(false),Description("Indicates whether the check box is in the checked state."),DevCoSerialize()]
+ public bool Checked
+ {
+ get {return m_Checked;}
+ set
+ {
+ if(m_Checked!=value)
+ {
+ if (_ThreeState && value && _CheckState != CheckState.Unchecked) return;
+ SetChecked(value ? CheckState.Checked : CheckState.Unchecked, eTreeAction.Code);
+ }
+ }
+ }
+
+ private bool _ThreeState = false;
+ ///
+ /// Gets or sets a value indicating whether the CheckBox will allow three check states rather than two. If the ThreeState property is set to true
+ /// CheckState property should be used instead of Checked property to set the extended state of the control.
+ ///
+ [Browsable(true), Category("Check-box Properties"), DefaultValue(false), Description("Indicates whether the CheckBox will allow three check states rather than two.")]
+ public bool CheckBoxThreeState
+ {
+ get { return _ThreeState; }
+ set { _ThreeState = value; }
+ }
+
+ private CheckState _CheckState = CheckState.Unchecked;
+ ///
+ /// Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state.
+ ///
+ [Browsable(true), Category("Check-box Properties"), DefaultValue(CheckState.Unchecked), RefreshProperties(RefreshProperties.All), Description("Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state")]
+ public CheckState CheckState
+ {
+ get { return _CheckState; }
+ set
+ {
+ if (value != _CheckState)
+ SetChecked(value, eTreeAction.Code);
+ }
+ }
+
+ ///
+ /// Sets the Checked or CheckState properties.
+ ///
+ /// New value for checked state.
+ /// Action source.
+ public void SetChecked(bool value, eTreeAction actionSource)
+ {
+ SetChecked(value ? CheckState.Checked : CheckState.Unchecked, actionSource);
+ }
+
+ ///
+ /// Sets the Checked or CheckState properties.
+ ///
+ /// New value for checked state.
+ /// Action source.
+ public void SetChecked(CheckState value, eTreeAction actionSource)
+ {
+ AdvTreeCellBeforeCheckEventArgs beforeCheckArgs = new AdvTreeCellBeforeCheckEventArgs(actionSource, this, value);
+ InvokeBeforeCheck(beforeCheckArgs);
+ if (beforeCheckArgs.Cancel) return;
+
+ _CheckState = value;
+ m_Checked = value == CheckState.Checked;
+ OnAppearanceChanged();
+
+ if (this.CheckBoxStyle == eCheckBoxStyle.RadioButton && value == CheckState.Checked && this.Parent != null)
+ {
+ Node parent = this.Parent;
+ AdvTree tree = parent.TreeControl;
+ if (tree != null) tree.BeginUpdate();
+ bool processNodes = true;
+ foreach (Cell item in parent.Cells)
+ {
+ if (item == this) continue;
+ if (item.CheckBoxStyle == eCheckBoxStyle.RadioButton)
+ {
+ item.Checked = false;
+ processNodes = false;
+ }
+ }
+ if (processNodes)
+ {
+ if (parent.Parent != null)
+ {
+ foreach (Node item in parent.Parent.Nodes)
+ {
+ if (item != parent && item.CheckBoxStyle == eCheckBoxStyle.RadioButton)
+ item.Checked = false;
+ }
+ }
+ else
+ {
+ if (tree != null && NodeOperations.IsRootNode(tree, parent))
+ {
+ foreach (Node item in tree.Nodes)
+ {
+ if (item != parent && item.CheckBoxStyle == eCheckBoxStyle.RadioButton)
+ item.Checked = false;
+ }
+ }
+ }
+ }
+ if (tree != null) tree.EndUpdate();
+ }
+
+ InvokeAfterCheck(actionSource);
+ }
+
+ private eCheckBoxStyle _CheckBoxStyle = eCheckBoxStyle.CheckBox;
+ ///
+ /// Gets or sets the appearance style of the item. Default value is CheckBox. Item can also assume the style of radio-button.
+ ///
+ [Browsable(true), DefaultValue(eCheckBoxStyle.CheckBox), Category("Check-box Properties"), Description("Indicates appearance style of the item. Default value is CheckBox. Item can also assume the style of radio-button.")]
+ public eCheckBoxStyle CheckBoxStyle
+ {
+ get { return _CheckBoxStyle; }
+ set
+ {
+ _CheckBoxStyle = value;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Gets whether mouse is over the cell.
+ ///
+ [Browsable(false)]
+ public bool IsMouseOver
+ {
+ get{return m_MouseOver;}
+ }
+ ///
+ /// Sets the mouse over flag.
+ ///
+ /// true if mouse is over the cell otherwise false.
+ internal void SetMouseOver(bool over)
+ {
+ m_MouseOver=over;
+ }
+
+ ///
+ /// Gets whether left mouse button is pressed while over the cell.
+ ///
+ [Browsable(false)]
+ public bool IsMouseDown
+ {
+ get{return m_MouseDown;}
+ }
+ ///
+ /// Sets the mouse down flag.
+ ///
+ /// true if left mouse button is pressed while over the cell otherwise false.
+ internal void SetMouseDown(bool over)
+ {
+ m_MouseDown=over;
+ }
+
+ ///
+ /// Gets or sets the layout of the cell parts like check box, image and text. Layout can be horizontal (default)
+ /// where parts of the cell are positioned next to each other horizontally, or vertical where
+ /// parts of the cell are positioned on top of each other vertically.
+ /// Alignment of the each part is controlled by alignment properties.
+ ///
+ /// ImageAlignment Property
+ /// CheckBoxAlignment Property
+ [Browsable(true),DefaultValue(eCellPartLayout.Default),Category("Cells"),Description("Indicates the layout of the cell parts like check box, image and text."), DevCoSerialize()]
+ public eCellPartLayout Layout
+ {
+ get {return m_Layout;}
+ set
+ {
+ if(m_Layout!=value)
+ {
+ m_Layout=value;
+ this.OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Specifies the mouse cursor displayed when mouse is over the cell.
+ ///
+ [Browsable(true),DefaultValue(null),Category("Appearance"),Description("Specifies the mouse cursor displayed when mouse is over the cell.")]
+ public System.Windows.Forms.Cursor Cursor
+ {
+ get
+ {
+ return m_Cursor;
+ }
+ set
+ {
+ if(m_Cursor!=value)
+ {
+ m_Cursor=value;
+ }
+ }
+ }
+
+ internal bool GetEnabled()
+ {
+ return m_Enabled;
+ }
+
+ ///
+ /// Gets or sets whether cell wrapped the text during the layout.
+ ///
+ internal bool WordWrap
+ {
+ get {return m_WordWrap;}
+ set {m_WordWrap=value;}
+ }
+
+ private eCellEditorType _EditorType = eCellEditorType.Default;
+ ///
+ /// Gets or sets the editor type used to edit the cell. Setting this property to value other than Default
+ /// overrides the cell editor type specified on column cell belongs to.
+ ///
+ [DefaultValue(eCellEditorType.Default), Category("Behavior"), Description("Indicates editor type used to edit the cell.")]
+ public eCellEditorType EditorType
+ {
+ get { return _EditorType; }
+ set { _EditorType = value; }
+ }
+
+ ///
+ /// Returns effective editor type used for cell editing.
+ ///
+ /// Editor type.
+ internal eCellEditorType GetEffectiveEditorType()
+ {
+ if (_EditorType != eCellEditorType.Default) return _EditorType;
+ int index = -1;
+ if (this.Parent != null) index = this.Parent.Cells.IndexOf(this);
+ if (index == -1) return _EditorType;
+
+ if (this.Parent != null && this.Parent.Parent != null && this.Parent.Parent.NodesColumns.Count > 0 && index < this.Parent.Parent.NodesColumns.Count)
+ {
+ return this.Parent.Parent.NodesColumns[index].EditorType;
+ }
+
+ AdvTree tree=TreeControl;
+ if (tree != null && tree.Columns.Count > 0 && index < tree.Columns.Count)
+ return tree.Columns[index].EditorType;
+
+ return _EditorType;
+ }
+ #endregion
+
+ #region Methods
+ /// Makes a copy of a Cell.
+ public virtual Cell Copy()
+ {
+ // TODO: Make sure that new properties are copied
+ Cell c=new Cell();
+ c.CheckBoxAlignment=this.CheckBoxAlignment;
+ c.CheckBoxVisible=this.CheckBoxVisible;
+ c.CheckBoxStyle = this.CheckBoxStyle;
+ if (this.CheckBoxThreeState)
+ c.CheckState = this.CheckState;
+ else
+ c.Checked=this.Checked;
+ c.Cursor=this.Cursor;
+ c.Enabled=this.Enabled;
+ c.ImageAlignment=this.ImageAlignment;
+ c.SetCellImages(this.Images.Copy());
+ c.Layout=this.Layout;
+ c.StyleDisabled=this.StyleDisabled;
+ c.StyleMouseDown=this.StyleMouseDown;
+ c.StyleMouseOver=this.StyleMouseOver;
+ c.StyleNormal=this.StyleNormal;
+ c.StyleSelected=this.StyleSelected;
+ c.Tag=this.Tag;
+ c.Text=this.Text;
+ c.Editable = this.Editable;
+ c.EditorType = this.EditorType;
+
+
+ return c;
+ }
+
+ ///
+ /// Ensures that the cell is visible, expanding nodes and scrolling the control as necessary.
+ ///
+ public void EnsureVisible()
+ {
+ NodeOperations.EnsureVisible(this);
+ }
+
+ private void OnAppearanceChanged()
+ {
+ if(this.Parent!=null)
+ {
+ this.Parent.SizeChanged=true;
+ this.Parent.OnDisplayChanged();
+ }
+ }
+
+ private void OnSizeChanged()
+ {
+ if(this.Parent!=null)
+ {
+ this.Parent.SizeChanged=true;
+ this.Parent.OnDisplayChanged();
+ }
+ }
+
+ ///
+ /// Occurs when any image property for the cell has changed.
+ ///
+ internal void OnImageChanged()
+ {
+ if(m_Parent!=null)
+ m_Parent.OnImageChanged();
+ }
+
+ ///
+ /// Invokes AfterCheck event on AdvTree
+ /// control.
+ ///
+ protected virtual void InvokeAfterCheck(eTreeAction actionSource)
+ {
+ AdvTree tree=this.TreeControl;
+ if(tree!=null)
+ {
+ tree.InvokeAfterCheck(new AdvTreeCellEventArgs(actionSource, this));
+ }
+ m_ActionSource=eTreeAction.Code;
+ }
+
+ ///
+ /// Invokes BeforeCheck event on AdvTree
+ /// control.
+ ///
+ protected virtual void InvokeBeforeCheck(AdvTreeCellBeforeCheckEventArgs e)
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ tree.InvokeBeforeCheck(e);
+ }
+
+ if (this.Parent != null)
+ this.Parent.BeforeCellCheck(this, e);
+ }
+
+ ///
+ /// Called just before cell layout is to be performed.
+ ///
+ internal void OnLayoutCell()
+ {
+ if (m_HostedControl != null && !_HostedControlAdded)
+ {
+ AddHostedControlToTree();
+ }
+ else if (_HostedItem != null && !_HostedItemAdded)
+ AddHostedItemToTree();
+ }
+
+ private void SetHostedItem(BaseItem value)
+ {
+ // Note that hosted item when set is guided by the size of the text. So the TextContentBounds are actually bounds of the control.
+ if (m_HostedControl != null)
+ throw new InvalidOperationException("HostedItem cannot be set if HostedControl property is set to non-null value.");
+
+ if (_HostedItem != null)
+ {
+ RemoveHostedItemFromTree();
+ }
+
+ _HostedItem = value;
+ if (_HostedItem != null)
+ {
+ if (_HostedItem.Parent != null)
+ _HostedItem.Parent.SubItems.Remove(_HostedItem);
+ _HostedItem.Visible = true;
+ _HostedItem.Style = eDotNetBarStyle.StyleManagerControlled;
+ AddHostedItemToTree();
+ }
+
+ OnSizeChanged();
+ }
+
+ private void RemoveHostedItemFromTree()
+ {
+ if (_HostedItem != null)
+ _HostedItem.ContainerControl = null;
+ _HostedItemAdded = false;
+ }
+ private bool _HostedItemAdded = false;
+ private void AddHostedItemToTree()
+ {
+ if (_HostedItemAdded) return;
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ if (_HostedItem.ContainerControl != tree)
+ {
+ _HostedItem.ContainerControl = tree;
+ }
+ _HostedItemAdded = true;
+ }
+ }
+
+ private bool _HostedControlAdded = false;
+ internal void AddHostedControlToTree()
+ {
+ if (_HostedControlAdded) return;
+ AdvTree tree = this.TreeControl;
+ if(tree!=null)
+ {
+ if (m_HostedControl.Parent != tree)
+ {
+ if (m_HostedControl.Parent != null)
+ m_HostedControl.Parent.Controls.Remove(m_HostedControl);
+ tree.Controls.Add(m_HostedControl);
+ tree.InvalidControlBorder = true;
+ m_HostedControl.SendToBack();
+ }
+ tree.HostedControlCells.Add(this);
+ _HostedControlAdded = true;
+ }
+ }
+
+ internal void RemoveHostedControlFromTree()
+ {
+ AdvTree tree = m_HostedControl.Parent as AdvTree;
+ if (tree == null) tree = this.TreeControl;
+ if (tree != null)
+ {
+ tree.Controls.Remove(m_HostedControl);
+ tree.HostedControlCells.Remove(this);
+ _HostedControlAdded = false;
+ }
+ }
+
+ private void SetHostedControl(Control value)
+ {
+ // Note that hosted control when set is guided by the size of the text. So the TextContentBounds are actually bounds of the control.
+ if(value==this.TreeControl)
+ return;
+
+ if (_HostedItem != null)
+ throw new InvalidOperationException("HostedControl cannot be set when HostedItem is set to non-null value.");
+
+ if(m_HostedControl!=null)
+ {
+ m_HostedControl.SizeChanged-=new EventHandler(this.HostedControlSizedChanged);
+ m_HostedControl.Enter -= new EventHandler(HostedControlEnter);
+ RemoveHostedControlFromTree();
+ }
+
+ m_HostedControl=value;
+ if(m_HostedControl!=null)
+ {
+ m_HostedControl.SizeChanged+=new EventHandler(this.HostedControlSizedChanged);
+ m_HostedControl.Enter += new EventHandler(HostedControlEnter);
+ TypeDescriptor.GetProperties(m_HostedControl)["Dock"].SetValue(m_HostedControl,DockStyle.None);
+ if(m_HostedControl.Parent!=null)
+ m_HostedControl.Parent.Controls.Remove(m_HostedControl);
+
+ if(!this.DesignMode)
+ m_HostedControl.Visible = false;
+ if(this.DesignMode || this.Parent!=null && this.Parent.Site!=null && this.Parent.Site.DesignMode)
+ {
+ bool visible=GetVisible();
+ TypeDescriptor.GetProperties(m_HostedControl)["Visible"].SetValue(m_HostedControl,visible);
+ }
+
+ AddHostedControlToTree();
+ }
+
+ OnSizeChanged();
+ }
+
+ private void HostedControlEnter(object sender, EventArgs e)
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ tree.SelectedNode = this.Parent;
+ }
+ private void HostedControlSizedChanged(object sender, EventArgs e)
+ {
+ if(!m_HostedControlSize.IsEmpty && m_HostedControl!=null)
+ m_HostedControlSize = m_HostedControl.Size;
+ if (m_IgnoreHostedControlSizeChange)
+ return;
+
+ OnSizeChanged();
+ }
+
+ internal void OnVisibleChanged()
+ {
+ if(m_HostedControl!=null)
+ {
+ TypeDescriptor.GetProperties(m_HostedControl)["Visible"].SetValue(m_HostedControl,GetVisible());
+ }
+ }
+
+ private bool GetVisible()
+ {
+ if(m_Parent!=null && !NodeOperations.GetIsNodeVisible(m_Parent))
+ return false;
+ return m_Visible;
+ }
+
+ internal void OnParentExpandedChanged(bool expanded)
+ {
+ if(m_HostedControl!=null && m_HostedControl.Visible != expanded)
+ {
+ bool visible=GetVisible();
+ m_HostedControl.Visible = visible;
+ if(this.DesignMode || this.Parent!=null && this.Parent.Site!=null && this.Parent.Site.DesignMode)
+ TypeDescriptor.GetProperties(m_HostedControl)["Visible"].SetValue(m_HostedControl,visible);
+ }
+ }
+
+ private bool _Selectable = true;
+ ///
+ /// Gets or sets whether cell can be selected by user by clicking it with the mouse or using keyboard. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether cell can be selected by user by clicking it with the mouse or using keyboard.")]
+ public bool Selectable
+ {
+ get { return _Selectable; }
+ set
+ {
+ _Selectable = value;
+ }
+ }
+
+ ///
+ /// Gets whether cell can be selected. Cell must be Visible, Enabled and Selectable in order for it to be selected.
+ ///
+ [Browsable(false)]
+ public bool CanSelect
+ {
+ get
+ {
+ return this.Enabled & this.IsVisible & this.Selectable;
+ }
+ }
+
+ ///
+ /// Returns ColumnHeader cell is under if one is defined and cell is already parented to the tree. Otherwise it returns null/nothing.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public ColumnHeader ColumnHeader
+ {
+ get
+ {
+ AdvTree tree = this.TreeControl;
+ if (this.Parent == null || tree == null) return null;
+ int index = this.Parent.Cells.IndexOf(this);
+ if (this.Parent.HasColumns && this.Parent.NodesColumns.Count > index)
+ return this.Parent.NodesColumns[index];
+ if (tree.Columns.Count > index)
+ return tree.Columns[index];
+ return null;
+ }
+ }
+ #endregion
+
+ #region Markup Implementation
+ private DevComponents.DotNetBar.TextMarkup.BodyElement m_TextMarkup = null;
+
+ private void MarkupTextChanged()
+ {
+ if (!IsMarkupSupported)
+ return;
+
+ if(m_TextMarkup!=null)
+ m_TextMarkup.HyperLinkClick -= new EventHandler(this.TextMarkupLinkClick);
+
+ m_TextMarkup = null;
+
+ if (!DevComponents.DotNetBar.TextMarkup.MarkupParser.IsMarkup(ref m_Text))
+ return;
+
+ m_TextMarkup = DevComponents.DotNetBar.TextMarkup.MarkupParser.Parse(m_Text);
+
+ if (m_TextMarkup != null)
+ m_TextMarkup.HyperLinkClick += new EventHandler(TextMarkupLinkClick);
+ }
+
+ ///
+ /// Occurs when text markup link is clicked.
+ ///
+ protected virtual void TextMarkupLinkClick(object sender, EventArgs e)
+ {
+ DevComponents.DotNetBar.TextMarkup.HyperLink link = sender as DevComponents.DotNetBar.TextMarkup.HyperLink;
+
+ if(link!=null && this.Parent!=null)
+ this.Parent.InvokeMarkupLinkClick(this, new MarkupLinkClickEventArgs(link.Name, link.HRef));
+ }
+
+ ///
+ /// Gets reference to parsed markup body element if text was markup otherwise returns null.
+ ///
+ internal DevComponents.DotNetBar.TextMarkup.BodyElement TextMarkupBody
+ {
+ get { return m_TextMarkup; }
+ }
+
+ private bool _TextMarkupEnabled = true;
+ ///
+ /// Gets or sets whether cell supports and renders text markup. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Gets or sets whether cell supports and renders text markup.")]
+ public bool TextMarkupEnabled
+ {
+ get { return _TextMarkupEnabled; }
+ set
+ {
+ _TextMarkupEnabled = value;
+ }
+ }
+
+ ///
+ /// Gets whether item supports text markup. Default is false.
+ ///
+ protected virtual bool IsMarkupSupported
+ {
+ get { return _TextMarkupEnabled; }
+ }
+
+ private bool _HostedItemMouseEntered = false;
+ protected internal virtual void InvokeNodeMouseMove(object sender, MouseEventArgs e)
+ {
+ if(m_TextMarkup!=null)
+ m_TextMarkup.MouseMove(sender as Control, e);
+
+ if (_HostedItem != null)
+ {
+ if (_HostedItem.DisplayRectangle.Contains(e.X, e.Y))
+ {
+ if (!_HostedItemMouseEntered)
+ {
+ _HostedItem.InternalMouseEnter();
+ _HostedItemMouseEntered = true;
+ }
+ _HostedItem.InternalMouseMove(e);
+ }
+ else if(_HostedItemMouseEntered)
+ {
+ _HostedItem.InternalMouseLeave();
+ _HostedItemMouseEntered = false;
+ }
+ }
+
+ if (!IsMouseOver) HideToolTip();
+ }
+
+ private bool _HostedItemMouseDown = false;
+ protected internal virtual void InvokeNodeMouseDown(object sender, MouseEventArgs e)
+ {
+ HideToolTip();
+
+ if(m_TextMarkup!=null)
+ m_TextMarkup.MouseDown(sender as Control, e);
+
+ if (_HostedItem != null && _HostedItem.DisplayRectangle.Contains(e.X, e.Y))
+ {
+ _HostedItem.InternalMouseDown(e);
+ _HostedItemMouseDown = true;
+ }
+ }
+
+ protected internal virtual void InvokeNodeMouseUp(object sender, MouseEventArgs e)
+ {
+ if(m_TextMarkup!=null)
+ m_TextMarkup.MouseUp(sender as Control, e);
+
+ if (_HostedItem != null && _HostedItemMouseDown)
+ {
+ _HostedItem.InternalMouseUp(e);
+ _HostedItemMouseDown = false;
+ }
+ }
+
+ protected internal virtual void InvokeNodeMouseLeave(object sender, EventArgs e)
+ {
+ HideToolTip();
+
+ if(m_TextMarkup!=null)
+ m_TextMarkup.MouseLeave(sender as Control);
+ if (_HostedItem != null)
+ {
+ if (_HostedItemMouseEntered)
+ {
+ _HostedItem.InternalMouseLeave();
+ _HostedItemMouseEntered = false;
+ }
+ }
+ }
+
+ protected internal virtual void InvokeNodeClick(object sender, EventArgs e)
+ {
+ if(m_TextMarkup!=null)
+ m_TextMarkup.Click(sender as Control);
+ if (_HostedItem != null && e is TreeNodeMouseEventArgs)
+ {
+ TreeNodeMouseEventArgs me = (TreeNodeMouseEventArgs)e;
+ if (this.Bounds.Contains(me.X, me.Y))
+ _HostedItem.InternalClick(me.Button, new Point(me.X, me.Y));
+ }
+ }
+
+ protected internal virtual void InvokeNodeMouseHover(object sender, EventArgs e)
+ {
+ if (_HostedItem != null)
+ _HostedItem.InternalMouseHover();
+ if (System.Windows.Forms.Control.MouseButtons == System.Windows.Forms.MouseButtons.None)
+ this.ShowToolTip();
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Cell.resx b/PROMS/DotNetBar Source Code/AdvTree/Cell.resx
new file mode 100644
index 00000000..3f337e08
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Cell.resx
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.0.0.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
diff --git a/PROMS/DotNetBar Source Code/AdvTree/CellCollection.cs b/PROMS/DotNetBar Source Code/AdvTree/CellCollection.cs
new file mode 100644
index 00000000..85c4fd56
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/CellCollection.cs
@@ -0,0 +1,211 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// A strongly-typed collection of objects.
+ ///
+ public class CellCollection:CollectionBase
+ {
+ #region Private Variables
+ private Node m_ParentNode=null;
+ #endregion
+
+ #region Internal Implementation
+ /// Creates new instance of the class.
+ public CellCollection()
+ {
+ }
+ ///
+ /// Adds new object to the collection.
+ ///
+ /// Object to add.
+ /// Index of newly added object.
+ public int Add(Cell cell)
+ {
+ return List.Add(cell);
+ }
+ ///
+ /// Returns reference to the object in collection based on it's index.
+ ///
+ public Cell this[int index]
+ {
+ get {return (Cell)(List[index]);}
+ set {List[index] = value;}
+ }
+ ///
+ /// Returns reference to the object in collection based on it's name. Returns null/nothing if cell with given name is not found.
+ ///
+ public Cell this[string name]
+ {
+ get
+ {
+ foreach (Cell item in List)
+ {
+ if (item.Name == name) return item;
+ }
+ return null;
+ }
+ }
+
+ ///
+ /// Gets the cell based on the column name. Node must be able to reach AdvTree control for this method to work.
+ ///
+ /// Column name.
+ /// Cell object or null.
+ public Cell GetByColumnName(string columnName)
+ {
+ if (string.IsNullOrEmpty(columnName))
+ throw new ArgumentException("columnName argument must be non-empty non-null string with column name");
+ Node parentNode = this.ParentNode;
+ AdvTree tree = parentNode.TreeControl;
+ if (tree == null)
+ throw new NullReferenceException("AdvTree control cannot be reached. Node is not added to a tree.");
+ Cell cell = null;
+ if (parentNode.Parent != null && parentNode.Parent.NodesColumns.Count > 0)
+ {
+ int index= parentNode.Parent.NodesColumns.IndexOf(columnName);
+ if (index >= 0) cell = this[index];
+ }
+ else
+ {
+ int index = tree.Columns.IndexOf(columnName);
+ if (index >= 0) cell = this[index];
+ }
+ return cell;
+ }
+
+ ///
+ /// Inserts new object into the collection.
+ ///
+ /// Position of the object.
+ /// Object to insert.
+ public void Insert(int index, Cell value)
+ {
+ List.Insert(index, value);
+ }
+
+ ///
+ /// Returns index of the object inside of the collection.
+ ///
+ /// Reference to the object.
+ /// Index of the object.
+ public int IndexOf(Cell value)
+ {
+ return List.IndexOf(value);
+ }
+
+ ///
+ /// Returns whether collection contains specified object.
+ ///
+ /// Object to look for.
+ /// true if object is part of the collection, otherwise false.
+ public bool Contains(Cell value)
+ {
+ return List.Contains(value);
+ }
+
+ ///
+ /// Removes specified object from the collection.
+ ///
+ ///
+ public void Remove(Cell value)
+ {
+ List.Remove(value);
+ }
+
+ protected override void OnRemoveComplete(int index,object value)
+ {
+ base.OnRemoveComplete(index,value);
+ Cell cell=value as Cell;
+ cell.SetParent(null);
+ if(m_ParentNode!=null)
+ m_ParentNode.OnCellRemoved(cell);
+ }
+ protected override void OnInsertComplete(int index,object value)
+ {
+ base.OnInsertComplete(index,value);
+ Cell cell=value as Cell;
+ if(cell.Parent!=null && cell.Parent!=m_ParentNode)
+ cell.Parent.Cells.Remove(cell);
+ cell.SetParent(m_ParentNode);
+ if(m_ParentNode!=null)
+ m_ParentNode.OnCellInserted(cell);
+ }
+ protected override void OnInsert(int index, object value)
+ {
+ if (m_ParentNode != null && m_ParentNode.Site != null && m_ParentNode.Site.DesignMode && this.List.Count > 0)
+ {
+ Cell cell = value as Cell;
+ if (cell.Site == null && this.List.Contains(cell)) this.List.Remove(cell);
+ }
+
+ base.OnInsert(index, value);
+ }
+
+ ///
+ /// Copies collection into the specified array.
+ ///
+ /// Array to copy collection to.
+ /// Starting index.
+ public void CopyTo(Cell[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ ///
+ /// Copies contained items to the Cell array.
+ ///
+ /// Array to copy to.
+ internal void CopyTo(Cell[] array)
+ {
+ List.CopyTo(array,0);
+ }
+
+ private Cell _RootCell = null;
+ protected override void OnClear()
+ {
+ if (m_ParentNode != null && m_ParentNode.Site != null && m_ParentNode.Site.DesignMode && this.List.Count>0)
+ {
+ if (this[0].Site == null)
+ _RootCell = this[0];
+ }
+ base.OnClear();
+ }
+
+ protected override void OnClearComplete()
+ {
+ base.OnClearComplete();
+ if (_RootCell != null)
+ {
+ this.Add(_RootCell);
+ _RootCell = null;
+ }
+ }
+
+ protected override void OnSet(int index, object oldValue, object newValue)
+ {
+ base.OnSet(index, oldValue, newValue);
+ }
+
+ ///
+ /// Gets or sets the node this collection is associated with.
+ ///
+ [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Node ParentNode
+ {
+ get {return m_ParentNode;}
+ }
+ ///
+ /// Sets the node collection belongs to.
+ ///
+ /// Cell that is parent of this collection.
+ internal void SetParentNode(Node parent)
+ {
+ m_ParentNode=parent;
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/CellEditEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/CellEditEventArgs.cs
new file mode 100644
index 00000000..891b6bc4
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/CellEditEventArgs.cs
@@ -0,0 +1,105 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents event arguments for cell editing events.
+ ///
+ public class CellEditEventArgs : EventArgs
+ {
+ ///
+ /// Indicates the action that caused the event.
+ ///
+ public eTreeAction Action=eTreeAction.Code;
+ ///
+ /// Indicates the cell that is affected.
+ ///
+ public DevComponents.AdvTree.Cell Cell=null;
+ ///
+ /// Indicates new text that will be assigned to the cell if one is appropriate for given event.
+ ///
+ public string NewText="";
+
+ private ICellEditControl _Editor = null;
+ ///
+ /// Gets reference to the cell editor control.
+ ///
+ public ICellEditControl Editor
+ {
+ get
+ {
+ return _Editor;
+ }
+ }
+
+ ///
+ /// Indicates whether the current action is cancelled. For BeforeCellEdit event setting this
+ /// property to true will cancel the editing. For AfterCellEdit event setting this property to
+ /// true will cancel any changes made to the text and edits will not be accepted. For CellEditEnding
+ /// event setting this property to true will keep the cell in edit mode.
+ ///
+ public bool Cancel=false;
+
+ ///
+ /// Indicates whether editing operation was canceled by the end user, usually by pressing ESCAPE key.
+ ///
+ public readonly bool IsUserCanceled;
+
+ ///
+ /// Initializes new instance of CellEditEventArgs class.
+ ///
+ /// Reference to Cell this event is raised for.
+ /// Indicates the action that caused the event.
+ /// Indicates new text of the cell if it applies to given event.
+ public CellEditEventArgs(Cell cell, eTreeAction action, string newText)
+ {
+ this.Action=action;
+ this.Cell=cell;
+ this.NewText=newText;
+ this.IsUserCanceled = false;
+ }
+ ///
+ /// Initializes new instance of CellEditEventArgs class.
+ ///
+ /// Reference to Cell this event is raised for.
+ /// Indicates the action that caused the event.
+ /// Indicates new text of the cell if it applies to given event.
+ public CellEditEventArgs(Cell cell, eTreeAction action, string newText, ICellEditControl editor)
+ {
+ this.Action = action;
+ this.Cell = cell;
+ this.NewText = newText;
+ this.IsUserCanceled = false;
+ _Editor = editor;
+ }
+ ///
+ /// Initializes new instance of CellEditEventArgs class.
+ ///
+ /// Reference to Cell this event is raised for.
+ /// Indicates the action that caused the event.
+ /// Indicates new text of the cell if it applies to given event.
+ /// Indicates whether action is canceled by the end user.
+ public CellEditEventArgs(Cell cell, eTreeAction action, string newText, bool isUserCanceled)
+ {
+ this.Action = action;
+ this.Cell = cell;
+ this.NewText = newText;
+ this.IsUserCanceled = isUserCanceled;
+ }
+ ///
+ /// Initializes new instance of CellEditEventArgs class.
+ ///
+ /// Reference to Cell this event is raised for.
+ /// Indicates the action that caused the event.
+ /// Indicates new text of the cell if it applies to given event.
+ /// Indicates whether action is canceled by the end user.
+ public CellEditEventArgs(Cell cell, eTreeAction action, string newText, bool isUserCanceled, ICellEditControl editor)
+ {
+ this.Action = action;
+ this.Cell = cell;
+ this.NewText = newText;
+ this.IsUserCanceled = isUserCanceled;
+ _Editor = editor;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/CellImages.cs b/PROMS/DotNetBar Source Code/AdvTree/CellImages.cs
new file mode 100644
index 00000000..ab7910ea
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/CellImages.cs
@@ -0,0 +1,570 @@
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents class that holds images for a cell.
+ ///
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ [ToolboxItem(false), TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+ public class CellImages
+ {
+ // Image variables
+ private System.Drawing.Image m_Image=null;
+ private System.Drawing.Image m_DisabledImageGenerated = null;
+ private int m_ImageIndex=-1; // Image index if image from ImageList is used
+ private System.Drawing.Image m_ImageMouseOver=null;
+ private int m_ImageMouseOverIndex=-1; // Image index if image from ImageList is used
+ private System.Drawing.Image m_ImageDisabled=null;
+// private bool m_DisabledImageCustom=false;
+ private int m_ImageDisabledIndex=-1; // Image index if image from ImageList is used
+ private System.Drawing.Image m_ImageExpanded=null;
+ private int m_ImageExpandedIndex=-1;
+ private Cell m_ParentCell=null;
+ private Size m_LargestImageSize=Size.Empty;
+
+ ///
+ /// Initializes new instance of CellImages class.
+ ///
+ /// Reference to parent cell.
+ public CellImages(Cell parentCell)
+ {
+ m_ParentCell=parentCell;
+ }
+
+ #region Properties
+
+ internal System.Drawing.Image DisabledImageGenerated
+ {
+ get { return m_DisabledImageGenerated; }
+ set
+ {
+ m_DisabledImageGenerated = value;
+ }
+ }
+
+ ///
+ /// Gets or sets default cell image. Setting this property to valid image will
+ /// override any setting of ImageIndex property.
+ ///
+ ///
+ /// The image set through this property will be serialized with the cell. If you
+ /// plan to use ImageList then use ImageIndex
+ /// property.
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format
+ /// which supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1
+ /// do not support alpha-blending when used through Image class.
+ ///
+ ///
+ /// Image object or null (Nothing) if no image is assigned.
+ [Browsable(true),DefaultValue(null),Category("Images"),Description("Indicates default cell image"), DevCoSerialize()]
+ public System.Drawing.Image Image
+ {
+ get {return m_Image;}
+ set
+ {
+ ChangeImage(ref m_Image, value);
+ }
+ }
+
+ ///
+ /// Resets Image property to it's default value (null, VB nothing).
+ ///
+ public void ResetImage()
+ {
+ TypeDescriptor.GetProperties(this)["Image"].SetValue(this, null);
+ }
+
+ ///
+ /// Gets or sets the image that is displayed when mouse is over the cell. Setting
+ /// this property to valid image will override any setting of ImageMouseOverIndex
+ /// property.
+ ///
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writting .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ [Browsable(true),DefaultValue(null),Category("Images"),Description("Indicates cell image when mouse is over the cell"), DevCoSerialize()]
+ public System.Drawing.Image ImageMouseOver
+ {
+ get {return m_ImageMouseOver;}
+ set
+ {
+ ChangeImage(ref m_ImageMouseOver, value);
+ }
+ }
+
+ ///
+ /// Resets ImageMouseOver to it's default value (null, VB nothing).
+ ///
+ public void ResetImageMouseOver()
+ {
+ TypeDescriptor.GetProperties(this)["ImageMouseOver"].SetValue(this, null);
+ }
+
+ ///
+ /// Gets or sets the image that is displayed when cell is disabled. If not assigned
+ /// disabled image is created from default cell image. Setting this property to valid image
+ /// will override any setting of ImageDisabledIndex property.
+ ///
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Images"), Description("Indicates disabled cell image")]
+ public System.Drawing.Image ImageDisabled
+ {
+ get { return m_ImageDisabled; }
+ set
+ {
+ ChangeImage(ref m_ImageDisabled, value);
+ }
+ }
+
+ ///
+ /// Resets ImageDisabled to it's default value (null, VB nothing).
+ ///
+ public void ResetImageDisabled()
+ {
+ this.ImageDisabled = null;
+ }
+
+ ///
+ /// Gets or sets image that is displayed when Node that this cell belongs to is
+ /// expanded. Setting this property to valid image will override any setting of
+ /// ImageExpandedIndex property.
+ ///
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ [Browsable(true),DefaultValue(null),Category("Images"),Description("Indicates cell image when node associtaed with this cell is expanded"), DevCoSerialize()]
+ public System.Drawing.Image ImageExpanded
+ {
+ get {return m_ImageExpanded;}
+ set
+ {
+ ChangeImage(ref m_ImageExpanded, value);
+ }
+ }
+
+ ///
+ /// Resets ImageExpanded to it's default value (null, VB nothing).
+ ///
+ public void ResetImageExpanded()
+ {
+ TypeDescriptor.GetProperties(this)["ImageExpanded"].SetValue(this, null);
+ }
+
+ ///
+ /// Gets or sets the Index of default cell image from ImageList specified on AdvTree
+ /// control.
+ ///
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ [Browsable(true),DefaultValue(-1),Category("ImageList Images"),Description("Indicates default cell image"), DevCoSerialize()]
+ public int ImageIndex
+ {
+ get {return m_ImageIndex;}
+ set
+ {
+ m_ImageIndex=value;
+ this.OnImageChanged();
+ }
+ }
+
+ private string _ImageKey = "";
+ ///
+ /// Gets or sets the key of the default cell image from ImageList specified on AdvTree control.
+ ///
+ [DefaultValue(""), Category("ImageList Images"), Description("Indicates the default cell image key"), DevCoSerialize()]
+ public string ImageKey
+ {
+ get { return _ImageKey; }
+ set
+ {
+ _ImageKey = value;
+ this.OnImageChanged();
+ }
+ }
+
+
+ ///
+ /// Property Editor support for ImageIndex selection
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public System.Windows.Forms.ImageList ImageList
+ {
+ get
+ {
+ if(this.Parent!=null)
+ {
+ AdvTree tree=this.Parent.TreeControl;
+ if(tree!=null)
+ {
+ return tree.ImageList;
+ }
+ }
+
+ return null;
+ }
+ }
+
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ ///
+ /// Gets or sets the Index of cell image when mouse is over the cell from ImageList
+ /// specified on AdvTree control.
+ ///
+ [Browsable(true),DefaultValue(-1),Category("ImageList Images"),Description("Indicates cell image when mouse is over the cell"), DevCoSerialize()]
+ public int ImageMouseOverIndex
+ {
+ get {return m_ImageMouseOverIndex;}
+ set
+ {
+ m_ImageMouseOverIndex=value;
+ this.OnImageChanged();
+ }
+ }
+
+ private string _ImageMouseOverKey = "";
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ ///
+ /// Gets or sets the key of cell image when mouse is over the cell from ImageList
+ /// specified on AdvTree control.
+ ///
+ [Browsable(true), DefaultValue(""), Category("ImageList Images"), Description("Indicates cell image when mouse is over the cell"), DevCoSerialize()]
+ public string ImageMouseOverKey
+ {
+ get { return _ImageMouseOverKey; }
+ set
+ {
+ _ImageMouseOverKey = value;
+ this.OnImageChanged();
+ }
+ }
+
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ ///
+ /// Gets or sets the Index of disabled cell image from ImageList specified on AdvTree
+ /// control.
+ ///
+ [Browsable(true), DefaultValue(-1), Category("ImageList Images"), Description("Indicates disabled cell image")]
+ public int ImageDisabledIndex
+ {
+ get { return m_ImageDisabledIndex; }
+ set
+ {
+ m_ImageDisabledIndex = value;
+ this.OnImageChanged();
+ }
+ }
+
+ private string _ImageDisabledKey = "";
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ ///
+ /// Gets or sets the key of disabled cell image from ImageList specified on AdvTree
+ /// control.
+ ///
+ [Browsable(true), DefaultValue(""), Category("ImageList Images"), Description("Indicates disabled cell image")]
+ public string ImageDisabledKey
+ {
+ get { return _ImageDisabledKey; }
+ set
+ {
+ _ImageDisabledKey = value;
+ this.OnImageChanged();
+ }
+ }
+
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ ///
+ /// Gets or sets the Index of cell image from ImageList specified on AdvTree control
+ /// that is used when Node associated with this cell is expanded
+ ///
+ [Browsable(true),DefaultValue(-1),Category("ImageList Images"),Description("Indicates expanded cell image"), DevCoSerialize()]
+ public int ImageExpandedIndex
+ {
+ get {return m_ImageExpandedIndex;}
+ set
+ {
+ m_ImageExpandedIndex=value;
+ this.OnImageChanged();
+ }
+ }
+
+ private string _ImageExpandedKey = "";
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format which
+ /// supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1 do not support
+ /// alpha-blending when used through Image class.
+ ///
+ ///
+ /// Gets or sets the key of cell image from ImageList specified on AdvTree control
+ /// that is used when Node associated with this cell is expanded
+ ///
+ [Browsable(true), DefaultValue(""), Category("ImageList Images"), Description("Indicates expanded cell image"), DevCoSerialize()]
+ public string ImageExpandedKey
+ {
+ get { return _ImageExpandedKey; }
+ set
+ {
+ _ImageExpandedKey = value;
+ this.OnImageChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the parent node of the cell.
+ ///
+ [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Cell Parent
+ {
+ get {return m_ParentCell;}
+ set {m_ParentCell=value;}
+ }
+
+ ///
+ /// Gets whether CellImages object should be serialized or not. If object has all
+ /// default values then this property will return false.
+ ///
+ internal bool ShouldSerialize
+ {
+ get
+ {
+ if(m_Image==null && m_ImageDisabled==null && m_ImageDisabledIndex==-1 &&
+ m_ImageExpanded==null && m_ImageExpandedIndex==-1 && m_ImageIndex==-1 &&
+ m_ImageMouseOver==null && m_ImageMouseOverIndex==-1)
+ return false;
+ return true;
+ }
+ }
+
+ ///
+ /// Returns largest image size in this set of images.
+ ///
+ internal Size LargestImageSize
+ {
+ get
+ {
+ return m_LargestImageSize;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ /// Makes a copy of a CellImages object.
+ public virtual CellImages Copy()
+ {
+ CellImages ci=new CellImages(null);
+ ci.Image=this.Image;
+// ci.ImageDisabled=this.ImageDisabled;
+// ci.ImageDisabledIndex=this.ImageDisabledIndex;
+ ci.ImageExpanded = this.ImageExpanded == null ? null : (Image) this.ImageExpanded.Clone();
+ ci.ImageExpandedIndex=this.ImageExpandedIndex;
+ ci.ImageIndex=this.ImageIndex;
+ ci.ImageMouseOver=this.ImageMouseOver == null? null : (Image)this.ImageMouseOver.Clone();
+ ci.ImageMouseOverIndex=this.ImageMouseOverIndex;
+ ci.ImageDisabledKey = this.ImageDisabledKey;
+ ci.ImageExpandedKey = this.ImageExpandedKey;
+ ci.ImageKey = this.ImageKey;
+ ci.ImageMouseOverKey = this.ImageMouseOverKey;
+ return ci;
+ }
+
+ #endregion
+
+ #region Internals
+ ///
+ /// Changes the image and invokes largest image size calculation if the
+ /// image size truly changed.
+ ///
+ ///
+ ///
+ private void ChangeImage(ref System.Drawing.Image currentImage, System.Drawing.Image newImage)
+ {
+ // Early out if no real change
+ if (currentImage == newImage)
+ return;
+
+ // Hold onto previous image
+ System.Drawing.Image previousImage = currentImage;
+
+ // Assign new image
+ currentImage = newImage;
+
+ // If either current or previous is null, or the sizes don't match,
+ // we need to resize ourselves and the parent.
+ if (previousImage == null || currentImage == null || GetImageSize(previousImage) != GetImageSize(currentImage))
+ {
+ RefreshLargestImageSize();
+
+ if (this.Parent != null)
+ this.Parent.OnImageChanged();
+ }
+
+ // Dispose the generated disabled image, if applicable.
+ DisposeGeneratedDisabledImage();
+ }
+ private Size GetImageSize(Image image)
+ {
+ try
+ {
+ return image.Size;
+ }
+ catch
+ {
+ return Size.Empty;
+ }
+ }
+
+ private void OnImageChanged()
+ {
+ RefreshLargestImageSize();
+ if (this.Parent != null)
+ this.Parent.OnImageChanged();
+ DisposeGeneratedDisabledImage();
+ }
+
+ public void Dispose()
+ {
+ DisposeGeneratedDisabledImage();
+ if (BarUtilities.DisposeItemImages || _AutoDispose)
+ {
+ BarUtilities.DisposeImage(ref m_Image);
+ BarUtilities.DisposeImage(ref m_ImageDisabled);
+ BarUtilities.DisposeImage(ref m_ImageExpanded);
+ BarUtilities.DisposeImage(ref m_ImageMouseOver);
+ }
+ }
+
+ internal void DisposeGeneratedDisabledImage()
+ {
+ if (m_DisabledImageGenerated != null)
+ {
+ m_DisabledImageGenerated.Dispose();
+ m_DisabledImageGenerated = null;
+ }
+ }
+
+ internal void RefreshLargestImageSize()
+ {
+ m_LargestImageSize=Size.Empty;
+ AdjustSize(m_Image,ref m_LargestImageSize);
+ AdjustSize(m_ImageDisabled,ref m_LargestImageSize);
+ AdjustSize(m_ImageExpanded,ref m_LargestImageSize);
+ AdjustSize(m_ImageMouseOver,ref m_LargestImageSize);
+
+ AdjustSize(GetImageByIndex(m_ImageIndex),ref m_LargestImageSize);
+ AdjustSize(GetImageByIndex(m_ImageDisabledIndex),ref m_LargestImageSize);
+ AdjustSize(GetImageByIndex(m_ImageExpandedIndex),ref m_LargestImageSize);
+ AdjustSize(GetImageByIndex(m_ImageMouseOverIndex),ref m_LargestImageSize);
+
+ AdjustSize(GetImageByKey(_ImageKey), ref m_LargestImageSize);
+ AdjustSize(GetImageByKey(_ImageDisabledKey), ref m_LargestImageSize);
+ AdjustSize(GetImageByKey(_ImageExpandedKey), ref m_LargestImageSize);
+ AdjustSize(GetImageByKey(_ImageMouseOverKey), ref m_LargestImageSize);
+ }
+ private void AdjustSize(System.Drawing.Image image, ref Size size)
+ {
+ if(image!=null)
+ {
+ if(image.Width>size.Width)
+ size.Width=image.Width;
+ if(image.Height>size.Height)
+ size.Height=image.Height;
+ }
+ }
+ ///
+ /// Returns image from image list based on the image index.
+ ///
+ /// Index of the image to return.
+ /// Image object from image list.
+ internal System.Drawing.Image GetImageByIndex(int imageIndex)
+ {
+ if (imageIndex >= 0 && this.Parent != null && this.Parent.TreeControl != null && this.Parent.TreeControl.ImageList != null && this.Parent.TreeControl.ImageList.Images.Count > 0)
+ {
+ try
+ {
+ return this.Parent.TreeControl.ImageList.Images[imageIndex];
+ }
+ catch
+ {
+ return null;
+ }
+
+ }
+ else
+ return null;
+ }
+
+ ///
+ /// Returns image from image list based on the image key.
+ ///
+ /// Key of the image to return.
+ /// Image object from image list.
+ internal System.Drawing.Image GetImageByKey(string key)
+ {
+ if (string.IsNullOrEmpty(key)) return null;
+
+ Cell parent = this.Parent;
+ if (parent == null) return null;
+
+ AdvTree tree = parent.TreeControl;
+ if (tree == null || tree.ImageList == null || !tree.ImageList.Images.ContainsKey(key)) return null;
+
+ return tree.ImageList.Images[key];
+ }
+
+ private bool _AutoDispose = false;
+ ///
+ /// Indicates whether assigned images are automatically disposed when the cell and node are disposed. Default value is false.
+ ///
+ [Browsable(false), DefaultValue(false)]
+ public bool AutoDispose
+ {
+ get { return _AutoDispose; }
+ set
+ {
+ _AutoDispose = value;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/ColumnHeader.cs b/PROMS/DotNetBar Source Code/AdvTree/ColumnHeader.cs
new file mode 100644
index 00000000..980bf138
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/ColumnHeader.cs
@@ -0,0 +1,1183 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using DevComponents.DotNetBar;
+using System.Collections;
+
+namespace DevComponents.AdvTree
+{
+ /// Represents the node or tree ColumnHeader.
+ [ToolboxItem(false), Designer("DevComponents.AdvTree.Design.ColumnHeaderDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class ColumnHeader : Component
+ {
+ #region Private Variables
+ private string m_Text = "";
+ private ColumnWidth m_Width = null;
+ private bool m_Sortable = true;
+ private eStyleTextAlignment m_TextAlign = eStyleTextAlignment.Near;
+ private string m_StyleNormal = "";
+ private string m_StyleMouseDown = "";
+ private string m_StyleMouseOver = "";
+ private string m_ColumnName = "";
+ private bool m_Visible = true;
+ private Rectangle m_Bounds = Rectangle.Empty;
+ private bool m_SizeChanged = true;
+ private string m_Name = "";
+ ///
+ /// Occurs when header size has changed due to the user resizing the column.
+ ///
+ public event EventHandler HeaderSizeChanged;
+ internal event SortCellsEventHandler SortCells;
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs when mouse button is pressed over the column header.
+ ///
+ public event MouseEventHandler MouseDown;
+ ///
+ /// Occurs when mouse button is released over the column header.
+ ///
+ public event MouseEventHandler MouseUp;
+ ///
+ /// Occurs when header is double clicked.
+ ///
+ public event EventHandler DoubleClick;
+ ///
+ /// Occurs when header is clicked.
+ ///
+ public event EventHandler Click;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Creates new instance of the object.
+ ///
+ public ColumnHeader()
+ : this("")
+ {
+
+ }
+
+ ///
+ /// Creates new instance of the object and initializes it with text.
+ ///
+ /// Text to initialize object with.
+ public ColumnHeader(string text)
+ {
+ m_Text = text;
+ m_Width = new ColumnWidth();
+ m_Width.WidthChanged += new EventHandler(this.WidthChanged);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (BarUtilities.DisposeItemImages)
+ {
+ BarUtilities.DisposeImage(ref _Image);
+ }
+ base.Dispose(disposing);
+ }
+ #endregion
+
+ #region Methods
+ ///
+ /// Makes a copy of ColumnHeader object.
+ ///
+ /// Returns new instance of column header object.
+ public virtual ColumnHeader Copy()
+ {
+ ColumnHeader c = new ColumnHeader();
+ c.ColumnName = this.ColumnName;
+ c.StyleMouseDown = this.StyleMouseDown;
+ c.StyleMouseOver = this.StyleMouseOver;
+ c.StyleNormal = this.StyleNormal;
+ c.Text = this.Text;
+ c.Visible = this.Visible;
+ c.Width.Absolute = this.Width.Absolute;
+ c.Width.Relative = this.Width.Relative;
+ c.Width.AutoSize = this.Width.AutoSize;
+ c.Width.AutoSizeMinHeader = this.Width.AutoSizeMinHeader;
+ c.DisplayIndex = this.DisplayIndex;
+ c.SortDirection = this.SortDirection;
+ c.SortingEnabled = this.SortingEnabled;
+ c.StretchToFill = this.StretchToFill;
+ c.Tag = this.Tag;
+ c.DataFieldName = this.DataFieldName;
+ c.DoubleClickAutoSize = this.DoubleClickAutoSize;
+ c.Editable = this.Editable;
+ c.EditorType = this.EditorType;
+ c.Image = this.Image;
+ c.ImageAlignment = this.ImageAlignment;
+ c.MaxInputLength = this.MaxInputLength;
+ c.MinimumWidth = this.MinimumWidth;
+ c.SortComparer = this.SortComparer;
+ c.SortComparerReverse = this.SortComparerReverse;
+
+ return c;
+ }
+ #endregion
+
+ #region Properties
+ private ColumnHeaderCollection _Parent;
+ internal ColumnHeaderCollection Parent
+ {
+ get { return _Parent; }
+ set { _Parent = value; }
+ }
+
+ private bool _Editable = true;
+ ///
+ /// Gets or sets whether cells content in this column is editable when cell editing is enabled on tree control. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether cells content in this column is editable when cell editing is enabled on tree control.")]
+ public bool Editable
+ {
+ get { return _Editable; }
+ set
+ {
+ _Editable = value;
+ }
+ }
+
+ private int _MaxInputLength = 0;
+ ///
+ /// Gets or sets the maximum number of characters the user can type or paste when editing cells in this column.
+ ///
+ [DefaultValue(0), Category("Behavior"), Description("Indicates maximum number of characters the user can type or paste when editing cells in this column.")]
+ public int MaxInputLength
+ {
+ get { return _MaxInputLength; }
+ set
+ {
+ _MaxInputLength = value;
+ }
+ }
+
+ ///
+ /// Returns name of the column header that can be used to identify it from the code.
+ ///
+ [Browsable(false), Category("Design"), Description("Indicates the name used to identify column header.")]
+ public string Name
+ {
+ get
+ {
+ if (this.Site != null)
+ m_Name = this.Site.Name;
+ return m_Name;
+ }
+ set
+ {
+ if (this.Site != null)
+ this.Site.Name = value;
+ if (value == null)
+ m_Name = "";
+ else
+ m_Name = value;
+ }
+ }
+ ///
+ /// Returns rectangle that this column occupies. If the layout has not been performed on the column the return value will be Rectangle.Empty.
+ ///
+ [Browsable(false)]
+ public Rectangle Bounds
+ {
+ get { return m_Bounds; }
+ }
+ ///
+ /// Sets the column bounds.
+ ///
+ internal void SetBounds(Rectangle bounds)
+ {
+ m_Bounds = bounds;
+ }
+
+ ///
+ /// Gets the reference to the object that represents width of the column as either
+ /// absolute or relative value.
+ ///
+ ///
+ /// Set Width using Absolute or Relative properties of ColumnWidth object.
+ ///
+ /// Absolute Property (DevComponents.AdvTree.ColumnWidth)
+ /// Relative Property (DevComponents.AdvTree.ColumnWidth)
+ [Browsable(true), Category("Layout"), Description("Gets or sets the width of the column."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ColumnWidth Width
+ {
+ // TODO: Add Proper TypeConverter for ColumnWidth object and test design-time support
+ get { return m_Width; }
+ }
+
+ private int _MinimumWidth = 0;
+ ///
+ /// Gets or sets the minimum column width in pixels that is enforced when user is resizing the columns using mouse.
+ /// Default value is 0 which indicates that there is no minimum size constraint.
+ ///
+ [DefaultValue(0), Category("Layout"), Description("Indicates minimum column width in pixels that is enforced when user is resizing the columns using mouse")]
+ public int MinimumWidth
+ {
+ get { return _MinimumWidth; }
+ set
+ {
+ if (value < 0) value = 0;
+ _MinimumWidth = value;
+ }
+ }
+
+ private bool _StretchToFill = false;
+ ///
+ /// Gets or sets whether column is stretched to fill any empty space horizontally in tree when all columns consume less width than available.
+ /// Only one column in tree may have this property set to true and only last column with this property set will be stretched.
+ /// You should always set the Width for the column since Width will be used when columns consume more space in tree horizontally than available.
+ /// Applies to top-level columns only.
+ ///
+ [DefaultValue(false), Category("Layout"), Description("Indicates whether column is stretched to fill any empty space horizontally in tree when all columns consume less width than available. Only one column in tree may have this property set to true and only last column with this property set will be stretched. You should always set the Width for the column since Width will be used when columns consume more space in tree horizontally than available. Applies to top-level columns only.")]
+ public bool StretchToFill
+ {
+ get { return _StretchToFill; }
+ set
+ {
+ if (_StretchToFill != value)
+ {
+ _StretchToFill = value;
+ OnSizeChanged();
+ }
+ }
+ }
+
+
+ ///
+ /// Gets or sets the style class assigned to the column. Empty value indicates that
+ /// default style is used as specified on cell's parent's control.
+ ///
+ ///
+ /// Name of the style assigned to the cell or an empty string indicating that default
+ /// style setting from tree control is applied. Default is empty string.
+ ///
+ ///
+ /// When property is set to an empty string the style setting from parent tree
+ /// controls is used. ColumnStyleNormal on AdvTree control is a root style for a cell.
+ ///
+ /// StyleMouseDown Property
+ /// StyleMouseOver Property
+ [Browsable(true), DefaultValue(""), Category("Style"), Description("Indicates the style class assigned to the column.")]
+ public string StyleNormal
+ {
+ get { return m_StyleNormal; }
+ set
+ {
+ if (value == null) value = "";
+ m_StyleNormal = value;
+ this.OnSizeChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the style class assigned to the column which is applied when mouse
+ /// button is pressed over the header. Empty value indicates that default
+ /// style is used as specified on column's parent.
+ ///
+ ///
+ /// Name of the style assigned to the column or an empty string indicating that default
+ /// style setting from tree control is applied. Default is empty string.
+ ///
+ ///
+ /// When property is set to an empty string the style setting from parent tree
+ /// controls is used. ColumnStyleMouseDown on AdvTree control is a root style for a
+ /// cell.
+ ///
+ /// StyleNormal Property
+ /// StyleMouseOver Property
+ [Browsable(true), DefaultValue(""), Category("Style"), Description("Indicates the style class assigned to the column when mouse is down.")]
+ public string StyleMouseDown
+ {
+ get { return m_StyleMouseDown; }
+ set
+ {
+ if (value == null) value = "";
+ m_StyleMouseDown = value;
+ this.OnSizeChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the style class assigned to the column which is applied when mouse is
+ /// over the column. Empty value indicates that default style is used as specified on column's
+ /// parent control.
+ ///
+ ///
+ /// Name of the style assigned to the column or an empty string indicating that default
+ /// style setting from tree control is applied. Default is empty string.
+ ///
+ ///
+ /// When property is set to an empty string the style setting from parent tree
+ /// controls is used. ColumnStyleMouseOver on AdvTree control is a root style for a
+ /// cell.
+ ///
+ /// StyleNormal Property
+ /// StyleMouseDown Property
+ [Browsable(true), DefaultValue(""), Category("Style"), Description("Indicates the style class assigned to the cell when mouse is over the column.")]
+ public string StyleMouseOver
+ {
+ get { return m_StyleMouseOver; }
+ set
+ {
+ if (value == null) value = "";
+ m_StyleMouseOver = value;
+ this.OnSizeChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the name of the column in the ColumnHeaderCollection.
+ ///
+ [Browsable(true), DefaultValue(""), Category("Data"), Description("Indicates the name of the column in the ColumnHeaderCollection.")]
+ public string ColumnName
+ {
+ get { return m_ColumnName; }
+ set
+ {
+ m_ColumnName = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the column caption.
+ ///
+ [Browsable(true), DefaultValue(""), Category("Appearance"), Description("Indicates column caption."), Localizable(true)]
+ public string Text
+ {
+ get { return m_Text; }
+ set
+ {
+ m_Text = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether column is visible. Hiding the header column will also hide corresponding data column.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior"), Description("Indicates whether column is visible.")]
+ public bool Visible
+ {
+ get { return m_Visible; }
+ set
+ {
+ if (m_Visible != value)
+ {
+ m_Visible = value;
+ OnSizeChanged();
+ }
+ }
+ }
+
+ private Image _Image = null;
+ ///
+ /// Gets or sets column image.
+ ///
+ ///
+ /// The image set through this property will be serialized with the column.
+ ///
+ /// If you plan to use alpha-blended images we recommend using PNG-24 format
+ /// which supports alpha-blending. As of this writing .NET Framework 1.0 and 1.1
+ /// do not support alpha-blending when used through Image class.
+ ///
+ ///
+ /// Image object or null (Nothing) if no image is assigned.
+ [Browsable(true), DefaultValue(null), Category("Images"), Description("Indicates column image"), DevCoSerialize()]
+ public System.Drawing.Image Image
+ {
+ get { return _Image; }
+ set
+ {
+ _Image = value;
+ this.OnImageChanged();
+ }
+ }
+
+ private void OnImageChanged()
+ {
+ OnSizeChanged();
+ }
+ ///
+ /// Resets Image property to it's default value (null, VB nothing).
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetImage()
+ {
+ TypeDescriptor.GetProperties(this)["Image"].SetValue(this, null);
+ }
+
+ private eColumnImageAlignment _ImageAlignment = eColumnImageAlignment.Left;
+ ///
+ /// Gets or sets Image alignment inside of column. Default value is Left.
+ ///
+ [DefaultValue(eColumnImageAlignment.Left), Category("Images"), Description("Indicates image alignment."), DevCoSerialize()]
+ public eColumnImageAlignment ImageAlignment
+ {
+ get { return _ImageAlignment; }
+ set { _ImageAlignment = value; OnSizeChanged(); }
+ }
+
+ private string _DataFieldName = "";
+ ///
+ /// Gets or sets the data-field or property name that is used as source of data for this column when data-binding is used.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates data-field or property name that is used as source of data for this column when data-binding is used.")]
+ public string DataFieldName
+ {
+ get { return _DataFieldName; }
+ set
+ {
+ if (value == null) value = "";
+ if (_DataFieldName != value)
+ {
+ _DataFieldName = value;
+ OnDataFieldNameChanged();
+ }
+ }
+ }
+
+ ///
+ /// Called when DataFieldName property has changed.
+ ///
+ protected virtual void OnDataFieldNameChanged()
+ {
+
+ }
+
+ private object _Tag = null;
+ ///
+ /// Gets or sets additional custom data associated with the column.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public object Tag
+ {
+ get { return _Tag; }
+ set { _Tag = value; }
+ }
+
+ private Color _CellsBackColor = Color.Empty;
+ ///
+ /// Gets or sets the color of the cells background for this column.
+ ///
+ [Category("Columns"), Description("Indicates color of cells background for this column.")]
+ public Color CellsBackColor
+ {
+ get { return _CellsBackColor; }
+ set
+ {
+ if (_CellsBackColor != value)
+ {
+ _CellsBackColor = value;
+ if (_Parent != null && _Parent.Parent != null)
+ _Parent.Parent.Invalidate();
+ }
+ }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeCellsBackColor()
+ {
+ return !_CellsBackColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetCellsBackColor()
+ {
+ this.CellsBackColor = Color.Empty;
+ }
+
+ private int _DisplayIndex = -1;
+ ///
+ /// Gets or sets display index of the column. -1 indicates default value and is modified to actual display index when the column is added to a ColumnHeaderCollection.
+ ///
+ ///
+ /// A lower display index means a column will appear first (to the left) of columns with a higher display index.
+ /// Allowable values are from 0 to num columns - 1. (-1 is legal only as the default value and is modified to something else
+ /// when the column is added to a AdvTree's column collection). AdvTree enforces that no two columns have the same display index;
+ /// changing the display index of a column will cause the index of other columns to adjust as well.
+ ///
+ [DefaultValue(-1), Category("Appearance"), Description("Indicates display index of the column. -1 indicates default value and is modified to actual display index when the column is added to a ColumnHeaderCollection.")]
+ public int DisplayIndex
+ {
+ get { return _DisplayIndex; }
+ set
+ {
+ if (value != _DisplayIndex)
+ {
+ int oldValue = _DisplayIndex;
+ _DisplayIndex = value;
+ OnDisplayIndexChanged(oldValue, value);
+ }
+ }
+ }
+
+ private void OnDisplayIndexChanged(int oldValue, int newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("DisplayIndex"));
+ if (_Parent != null) _Parent.DisplayIndexChanged(this, newValue, oldValue);
+ }
+
+ private bool _SortingEnabled = true;
+ ///
+ /// Gets or sets whether user can sort by this column by clicking it.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether user can sort by this column by clicking it.")]
+ public bool SortingEnabled
+ {
+ get { return _SortingEnabled; }
+ set
+ {
+ if (value != _SortingEnabled)
+ {
+ bool oldValue = _SortingEnabled;
+ _SortingEnabled = value;
+ OnSortingEnabledChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when SortingEnabled property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnSortingEnabledChanged(bool oldValue, bool newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("SortingEnabled"));
+ }
+
+ private eSortDirection _SortDirection = eSortDirection.None;
+ ///
+ /// Gets or sets the sort direction. Sort direction can be changed by clicking the column header if SortingEnabled=true.
+ ///
+ [DefaultValue(eSortDirection.None), Category("Behavior"), Description("Indicates sort direction. Sort direction can be changed by clicking the column header if SortingEnabled=true.")]
+ public eSortDirection SortDirection
+ {
+ get { return _SortDirection; }
+ set
+ {
+ if (value != _SortDirection)
+ {
+ eSortDirection oldValue = _SortDirection;
+ _SortDirection = value;
+ OnSortDirectionChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when SortDirection property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnSortDirectionChanged(eSortDirection oldValue, eSortDirection newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("SortDirection"));
+ this.Invalidate();
+ if (_SortingEnabled)
+ {
+ if (_Parent != null) _Parent.SortDirectionUpdated(this);
+ if (newValue == eSortDirection.Ascending)
+ this.Sort(false);
+ else if (newValue == eSortDirection.Descending)
+ this.Sort(true);
+ }
+ }
+ ///
+ /// Invalidates the appearance of column header.
+ ///
+ private void Invalidate()
+ {
+ if (_Parent == null) return;
+ if (_Parent.Parent != null)
+ {
+ if (_Parent.Parent.ColumnHeaderControl != null)
+ {
+ Rectangle r = this.Bounds;
+ if (!this.IsFirstVisible)
+ {
+ int spacing = _Parent.Parent.CellHorizontalSpacing;
+ r.Width += spacing;
+ r.X -= spacing;
+ }
+ _Parent.Parent.ColumnHeaderControl.Invalidate(r);
+ }
+ }
+ else if (_Parent.ParentNode != null)
+ _Parent.ParentNode.Invalidate();
+ }
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Occurs after Tooltip text has changed.
+ ///
+ protected virtual void OnTooltipChanged() { }
+ private string _Tooltip = "";
+ ///
+ /// Gets/Sets informational text (tooltip) for the cell.
+ ///
+ [Browsable(true), DefaultValue(""), Category("Appearance"), Description("Indicates the text that is displayed when mouse hovers over the cell."), Localizable(true)]
+ public string Tooltip
+ {
+ get
+ {
+
+ return _Tooltip;
+ }
+ set
+ {
+ if (_Tooltip == value)
+ return;
+ if (value == null) value = "";
+ _Tooltip = value;
+
+ if (this.ToolTipVisible)
+ {
+ if (string.IsNullOrEmpty(_Tooltip))
+ this.HideToolTip();
+ else
+ {
+ DevComponents.DotNetBar.ToolTip tooltipWindow = _ToolTipWnd;
+ tooltipWindow.Text = _Tooltip;
+ tooltipWindow.ShowToolTip();
+ tooltipWindow.Invalidate();
+ }
+ }
+ OnTooltipChanged();
+ }
+ }
+ ///
+ /// Gets whether tooltip is visible or not.
+ ///
+ internal protected bool ToolTipVisible
+ {
+ get
+ {
+ return (_ToolTipWnd != null);
+ }
+ }
+ ///
+ /// Called when tooltip is shown and hidden.
+ ///
+ /// true if tooltip is being shown otherwise false.
+ protected virtual void OnTooltip(bool isShown)
+ {
+ }
+ private DevComponents.DotNetBar.ToolTip _ToolTipWnd = null;
+ ///
+ /// Shows tooltip for this item.
+ ///
+ public virtual void ShowToolTip()
+ {
+ if (this.DesignMode)
+ return;
+
+ if (Visible)
+ {
+ AdvTree tree = this.AdvTree;
+ if (tree != null && !tree.ShowToolTips || !this.ShowToolTips)
+ return;
+ OnTooltip(true);
+ if (_Tooltip != "")
+ {
+ if (_ToolTipWnd == null)
+ _ToolTipWnd = new DevComponents.DotNetBar.ToolTip();
+ _ToolTipWnd.Style = StyleManager.GetEffectiveStyle();
+ _ToolTipWnd.Text = _Tooltip;
+ _ToolTipWnd.ReferenceRectangle = ScreenRectangle;
+
+ OnToolTipVisibleChanged(new EventArgs());
+ _ToolTipWnd.ShowToolTip();
+ }
+ }
+ }
+ ///
+ /// Destroys tooltip window.
+ ///
+ internal protected void HideToolTip()
+ {
+ if (_ToolTipWnd != null)
+ {
+ System.Drawing.Rectangle tipRect = _ToolTipWnd.Bounds;
+ tipRect.Width += 5;
+ tipRect.Height += 6;
+
+ OnTooltip(false);
+ OnToolTipVisibleChanged(new EventArgs());
+ try
+ {
+ if (_ToolTipWnd != null)
+ {
+ _ToolTipWnd.Hide();
+ _ToolTipWnd.Dispose();
+ _ToolTipWnd = null;
+ }
+ }
+ catch { }
+ AdvTree tree = this.AdvTree;
+ if (tree != null)
+ {
+ tree.Invalidate(tree.RectangleToClient(tipRect), false);
+ }
+ }
+ }
+ ///
+ /// Occurs when item's tooltip visibility has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when item's tooltip visibility has changed.")]
+ public event EventHandler ToolTipVisibleChanged;
+ private void OnToolTipVisibleChanged(EventArgs eventArgs)
+ {
+ EventHandler h = ToolTipVisibleChanged;
+ if (h != null)
+ ToolTipVisibleChanged(this, eventArgs);
+ }
+ private Rectangle ScreenRectangle
+ {
+ get
+ {
+ AdvTree tree = this.AdvTree;
+ if (tree == null) return Rectangle.Empty;
+ return new Rectangle(tree.PointToScreen(this.Bounds.Location), this.Bounds.Size);
+ }
+ }
+
+ private bool _ShowToolTips = true;
+ ///
+ /// Gets or sets whether tooltips are shown when mouse is over the cell when Tooltip property is set.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether tooltips are shown when mouse is over the cell when Tooltip property is set.")]
+ public bool ShowToolTips
+ {
+ get { return _ShowToolTips; }
+ set
+ {
+ _ShowToolTips = value;
+ }
+ }
+
+ ///
+ /// Automatically sets the column width (Width.Absolute) property based on the content of the column.
+ /// This will perform the one-time auto sizing of the column. To make column auto-size all the time
+ /// set Width.AutoSize=true.
+ ///
+ public void AutoSize()
+ {
+ if (_Parent == null)
+ throw new InvalidOperationException("ColumnHeader is not parented.");
+ AdvTree tree = AdvTree;
+ if (tree == null)
+ throw new InvalidOperationException("Cannot obtain reference to parent tree control, column might not be parented.");
+ this.Width.AutoSize = true;
+ tree.RecalcLayout();
+ tree.Invalidate();
+ this.Width.SetAutoSize(false);
+ this.Width.SetAbsolute(this.Width.AutoSizeWidth);
+ OnHeaderSizeChanged(EventArgs.Empty);
+ }
+ private void OnHeaderSizeChanged(EventArgs e)
+ {
+ EventHandler h = HeaderSizeChanged;
+ if (h != null)
+ h(this, e);
+ }
+ ///
+ /// Returns reference to AdvTree control this column belongs to.
+ ///
+ [Browsable(false)]
+ public AdvTree AdvTree
+ {
+ get
+ {
+ if (_Parent == null) return null;
+ return _Parent.ParentNode == null ? _Parent.Parent : _Parent.ParentNode.TreeControl;
+ }
+ }
+
+ private bool _DoubleClickAutoSize = true;
+ ///
+ /// Gets or sets whether column is automatically sized to the content when user double-clicks the column
+ /// on the column resize line. Column resizing must be enabled in order for this property to function.
+ /// Default value is true which indicates that column will be auto-sized to content when user double-clicks the
+ /// column resize marker.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether column is automatically sized to content when user double-clicks the column resize marker.")]
+ public bool DoubleClickAutoSize
+ {
+ get { return _DoubleClickAutoSize; }
+ set
+ {
+ _DoubleClickAutoSize = value;
+ }
+ }
+
+
+ ///
+ /// Gets or sets whether column size has changed and it's layout needs to be recalculated.
+ ///
+ internal bool SizeChanged
+ {
+ get { return m_SizeChanged; }
+ set { m_SizeChanged = value; }
+ }
+
+ private void OnSizeChanged()
+ {
+ m_SizeChanged = true;
+ OnHeaderSizeChanged(EventArgs.Empty);
+ }
+
+ private void WidthChanged(object sender, EventArgs e)
+ {
+ this.OnSizeChanged();
+ }
+
+ private bool _IsMouseDown = false;
+ ///
+ /// Gets whether mouse left button is pressed on the column.
+ ///
+ [Browsable(false)]
+ public bool IsMouseDown
+ {
+ get { return _IsMouseDown; }
+#if FRAMEWORK20
+ internal set
+#else
+ set
+#endif
+
+ {
+ if (_IsMouseDown != value)
+ {
+ _IsMouseDown = value;
+ OnIsMouseDownChanged();
+ }
+ }
+ }
+
+ private void OnIsMouseDownChanged()
+ {
+ if (_Parent != null && _Parent.ParentNode != null)
+ {
+ AdvTree tree = _Parent.ParentNode.TreeControl;
+ if (tree != null) tree.Invalidate(this.Bounds);
+ }
+ }
+
+ private bool _IsMouseOver = false;
+ ///
+ /// Gets whether mouse is over the column.
+ ///
+ [Browsable(false)]
+ public bool IsMouseOver
+ {
+ get { return _IsMouseOver; }
+#if FRAMEWORK20
+ internal set
+#else
+ set
+#endif
+ {
+ _IsMouseOver = value;
+ this.Invalidate();
+ }
+ }
+
+ internal bool IsLastVisible = false;
+ internal bool IsFirstVisible = false;
+ ///
+ /// Occurs when mouse is moving over the column header.
+ ///
+ [Description("Occurs when mouse is moving over the column header")]
+ public event MouseEventHandler MouseMove;
+ ///
+ /// Raises MouseMove event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnMouseMove(MouseEventArgs e)
+ {
+ MouseEventHandler handler = MouseMove;
+ if (handler != null)
+ handler(this, e);
+ }
+ internal void InternalMouseMove(MouseEventArgs e)
+ {
+ OnMouseMove(e);
+ }
+ ///
+ /// Occurs when mouse enters column header.
+ ///
+ [Description("Occurs when mouse enters column header.")]
+ public event EventHandler MouseEnter;
+ ///
+ /// Raises MouseEnter event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnMouseEnter(EventArgs e)
+ {
+ EventHandler handler = MouseEnter;
+ if (handler != null)
+ handler(this, e);
+ }
+ internal void InternalMouseEnter(EventArgs e)
+ {
+ this.IsMouseOver = true;
+ OnMouseEnter(e);
+ }
+ ///
+ /// Occurs when mouse leaves the column header.
+ ///
+ [Description("Occurs when mouse leaves the column header.")]
+ public event EventHandler MouseLeave;
+ ///
+ /// Raises MouseLeave event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnMouseLeave(EventArgs e)
+ {
+ EventHandler handler = MouseLeave;
+ if (handler != null)
+ handler(this, e);
+ }
+ internal void InternalMouseLeave(EventArgs e)
+ {
+ HideToolTip();
+ this.IsMouseOver = false;
+ OnMouseLeave(e);
+ }
+ ///
+ /// Occurs when mouse hovers over the column.
+ ///
+ [Description("Occurs when mouse hovers over the column.")]
+ public event EventHandler MouseHover;
+ ///
+ /// Raises MouseHover event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnMouseHover(EventArgs e)
+ {
+ EventHandler handler = MouseHover;
+ if (handler != null)
+ handler(this, e);
+ }
+ internal void InternalMouseHover(EventArgs e)
+ {
+ ShowToolTip();
+ OnMouseHover(e);
+ }
+
+ internal virtual void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
+ {
+ HideToolTip();
+ if (e.Button == MouseButtons.Left) IsMouseDown = true;
+
+ MouseEventHandler eh = this.MouseDown;
+ if (eh != null)
+ eh(this, e);
+ }
+
+ internal virtual void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
+ {
+ bool wasMouseDown = IsMouseDown;
+ if (e.Button == MouseButtons.Left) IsMouseDown = false;
+
+ if (_SortingEnabled && wasMouseDown)
+ {
+ if (e.Button == MouseButtons.Middle && _SortDirection != eSortDirection.None)
+ SortDirection = eSortDirection.None;
+ else if (e.Button == MouseButtons.Left)
+ {
+ if (_SortDirection == eSortDirection.None || _SortDirection == eSortDirection.Descending)
+ SortDirection = eSortDirection.Ascending;
+ else
+ SortDirection = eSortDirection.Descending;
+ }
+ }
+
+ MouseEventHandler eh = this.MouseUp;
+ if (eh != null)
+ eh(this, e);
+ }
+
+ internal virtual void OnDoubleClick(EventArgs e)
+ {
+ EventHandler handler = DoubleClick;
+ if (handler != null) handler(this, e);
+ }
+
+ internal virtual void OnClick(EventArgs e)
+ {
+ EventHandler handler = Click;
+ if (handler != null) handler(this, e);
+ }
+
+ private eCellEditorType _EditorType = eCellEditorType.Default;
+ ///
+ /// Gets or sets the editor type used to edit the cell. Setting this property to value other than Default
+ /// overrides the cell editor type specified on column cell belongs to.
+ ///
+ [DefaultValue(eCellEditorType.Default), Category("Behavior"), Description("Indicates editor type used to edit the cell.")]
+ public eCellEditorType EditorType
+ {
+ get { return _EditorType; }
+ set { _EditorType = value; }
+ }
+
+ private bool _LastSortReverse = false;
+ ///
+ /// Sort first level nodes that belong directly to this column. Calling this method repeatedly will
+ /// alternate between A-Z and Z-A sorting.
+ ///
+ public void Sort()
+ {
+ Sort(_LastSortReverse);
+ _LastSortReverse = !_LastSortReverse;
+ }
+
+ ///
+ /// Sort first level nodes that belong directly to this column.
+ ///
+ /// true to use reverse Z-A sorting, false to sort from A-Z
+ public void Sort(bool reverse)
+ {
+ if (SortCells != null)
+ SortCells(this, new SortEventArgs(reverse, this));
+ }
+
+ private IComparer _SortComparer = null;
+ ///
+ /// Gets or sets ascending (A-Z) column comparer used to sort nodes when this column is clicked. Your comparer will be passed to NodeCollection.Sort method and should know how to sort by appropriate column.
+ ///
+ [Browsable(false), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public IComparer SortComparer
+ {
+ get { return _SortComparer; }
+ set
+ {
+ if (value != _SortComparer)
+ {
+ IComparer oldValue = _SortComparer;
+ _SortComparer = value;
+ OnSortComparerChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when SortComparer property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnSortComparerChanged(IComparer oldValue, IComparer newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("SortComparer"));
+ }
+
+ private IComparer _SortComparerReverse = null;
+ ///
+ /// Gets or sets descending (Z-A) column comparer used to sort nodes when this column is clicked. Your comparer will be passed to NodeCollection.Sort method and should know how to sort by appropriate column.
+ ///
+ [Browsable(false), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public IComparer SortComparerReverse
+ {
+ get { return _SortComparerReverse; }
+ set
+ {
+ if (value != _SortComparerReverse)
+ {
+ IComparer oldValue = _SortComparerReverse;
+ _SortComparerReverse = value;
+ OnSortComparerReverseChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when SortComparerReverse property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnSortComparerReverseChanged(IComparer oldValue, IComparer newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("SortComparerReverse"));
+ }
+ #endregion
+
+ }
+
+ public delegate void SortCellsEventHandler(object sender, SortEventArgs e);
+ public class SortEventArgs : EventArgs
+ {
+ public bool ReverseSort = false;
+ ///
+ /// Gets or sets whether to cancel internal sorting performed by AdvTree.
+ ///
+ public bool Cancel = false;
+ ///
+ /// Gets or sets the column header being sorted.
+ ///
+ public ColumnHeader ColumnHeader = null;
+ ///
+ /// Gets or sets the IComparer used for sorting.
+ ///
+ public IComparer Comparer = null;
+ public SortEventArgs(bool reverse, ColumnHeader columnHeader)
+ {
+ ReverseSort = reverse;
+ ColumnHeader = columnHeader;
+ }
+ }
+ ///
+ /// Defines column related event arguments.
+ ///
+ public class ColumnEventArgs : EventArgs
+ {
+ ///
+ /// Gets reference to the column.
+ ///
+ public readonly ColumnHeader Column;
+ ///
+ /// Initializes a new instance of the ColumnEventArgs class.
+ ///
+ ///
+ public ColumnEventArgs(ColumnHeader column)
+ {
+ Column = column;
+ }
+ }
+
+ ///
+ /// Defines delegate for ColumnMoved event.
+ ///
+ public delegate void ColumnMovedHandler(object sender, ColumnMovedEventArgs ea);
+ ///
+ /// Defines column moved event arguments.
+ ///
+ public class ColumnMovedEventArgs : ColumnEventArgs
+ {
+ ///
+ /// Gets the column display index before the column was moved.
+ ///
+ public readonly int OldColumnDisplayIndex;
+ ///
+ /// Gets the column display index before the column was moved.
+ ///
+ public readonly int NewColumnDisplayIndex;
+ ///
+ /// Initializes a new instance of the ColumnMovedEventArgs class.
+ ///
+ /// Column affected
+ /// Old display index
+ /// New display index
+ public ColumnMovedEventArgs(ColumnHeader column, int oldColumnDisplayIndex, int newColumnDisplayIndex)
+ : base(column)
+ {
+ OldColumnDisplayIndex = oldColumnDisplayIndex;
+ NewColumnDisplayIndex = newColumnDisplayIndex;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/ColumnHeaderCollection.cs b/PROMS/DotNetBar Source Code/AdvTree/ColumnHeaderCollection.cs
new file mode 100644
index 00000000..7d57b7c2
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/ColumnHeaderCollection.cs
@@ -0,0 +1,583 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Collections.Generic;
+using System.Windows.Forms;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents collection for ColumnHeader objects.
+ ///
+ public class ColumnHeaderCollection : CollectionBase
+ {
+ #region Private Variables
+ private Node _ParentNode = null;
+ private AdvTree _Parent = null;
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Default constructor.
+ ///
+ public ColumnHeaderCollection()
+ {
+ }
+ ///
+ /// Gets or sets the node this collection is associated with.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Node ParentNode
+ {
+ get { return _ParentNode; }
+ }
+ ///
+ /// Sets the node collection belongs to.
+ ///
+ /// ColumnHeader that is parent of this collection.
+ internal void SetParentNode(Node parent)
+ {
+ _ParentNode = parent;
+ }
+
+ internal AdvTree Parent
+ {
+ get { return _Parent; }
+ set { _Parent = value; }
+ }
+
+ ///
+ /// Adds new object to the collection.
+ ///
+ /// Object to add.
+ /// Index of newly added object.
+ public int Add(ColumnHeader ch)
+ {
+ return List.Add(ch);
+ }
+ ///
+ /// Returns reference to the object in collection based on it's index.
+ ///
+ public ColumnHeader this[int index]
+ {
+ get { return (ColumnHeader)(List[index]); }
+ set { List[index] = value; }
+ }
+
+ ///
+ /// Returns reference to the object in collection based on it's name.
+ ///
+ public ColumnHeader this[string name]
+ {
+ get
+ {
+ int index = IndexOf(name);
+ if (index == -1) return null;
+ return this[index];
+ }
+ set { this[IndexOf(name)] = value; }
+ }
+
+ ///
+ /// Inserts new object into the collection.
+ ///
+ /// Position of the object.
+ /// Object to insert.
+ public void Insert(int index, ColumnHeader value)
+ {
+ List.Insert(index, value);
+ }
+
+ ///
+ /// Returns index of the object inside of the collection.
+ ///
+ /// Reference to the object.
+ /// Index of the object.
+ public int IndexOf(ColumnHeader value)
+ {
+ return List.IndexOf(value);
+ }
+
+ ///
+ /// Returns index of the object inside of the collection.
+ ///
+ /// Name of column to return index for.
+ /// Index of the column or -1 if column not found.
+ public int IndexOf(string name)
+ {
+ for (int i = 0; i < this.List.Count; i++)
+ {
+ if (this[i].Name == name) return i;
+ }
+ return -1;
+ }
+
+ ///
+ /// Returns index of the object inside of the collection based on column DataFieldName.
+ ///
+ /// DataFieldName of column to return index for.
+ /// Index of the column or -1 if column not found.
+ public int IndexOfDataField(string dataFieldName)
+ {
+ dataFieldName = dataFieldName.ToLower();
+ for (int i = 0; i < this.List.Count; i++)
+ {
+ if (this[i].DataFieldName.ToLower() == dataFieldName) return i;
+ }
+ return -1;
+ }
+
+ ///
+ /// Returns index of the object inside of the collection based on column DataFieldName.
+ ///
+ /// DataFieldName of column to return index for.
+ /// Index of the column or -1 if column not found.
+ internal int IndexOfField(string fieldName)
+ {
+ fieldName = fieldName.ToLower();
+ for (int i = 0; i < this.List.Count; i++)
+ {
+ ColumnHeader header = this[i];
+ if (header.Tag is BindingMemberInfo && ((BindingMemberInfo)header.Tag).BindingField.ToLower() == fieldName)
+ return i;
+ if (header.DataFieldName.ToLower() == fieldName) return i;
+ if (header.Name == fieldName) return i;
+ }
+ return -1;
+ }
+
+ ///
+ /// Returns whether collection contains specified object.
+ ///
+ /// Object to look for.
+ /// true if object is part of the collection, otherwise false.
+ public bool Contains(ColumnHeader value)
+ {
+ return List.Contains(value);
+ }
+
+ protected override void OnSet(int index, object oldValue, object newValue)
+ {
+ if (oldValue is ColumnHeader)
+ {
+ ColumnHeader header = (ColumnHeader)oldValue;
+ if (header.SortDirection != eSortDirection.None) IsSorted = false;
+ }
+ if (newValue is ColumnHeader)
+ {
+ ColumnHeader header = (ColumnHeader)newValue;
+ if (header.SortDirection != eSortDirection.None) IsSorted = true;
+ }
+ base.OnSet(index, oldValue, newValue);
+ }
+
+ ///
+ /// Removes specified object from the collection.
+ ///
+ ///
+ public void Remove(ColumnHeader value)
+ {
+ List.Remove(value);
+ }
+
+ protected override void OnRemoveComplete(int index, object value)
+ {
+ if (value is ColumnHeader)
+ {
+ ColumnHeader header = (ColumnHeader)value;
+ if (header.SortDirection != eSortDirection.None) IsSorted = false;
+ header.HeaderSizeChanged -= new EventHandler(this.HeaderSizeChanged);
+ header.SortCells -= new SortCellsEventHandler(SortCellsHandler);
+ header.MouseDown -= new System.Windows.Forms.MouseEventHandler(ColumnMouseDown);
+ header.MouseUp -= new System.Windows.Forms.MouseEventHandler(ColumnMouseUp);
+ header.Parent = null;
+ }
+ InvalidateDisplayIndexes();
+ UpdateTreeLayout();
+ base.OnRemoveComplete(index, value);
+ }
+ protected override void OnInsertComplete(int index, object value)
+ {
+ if (value is ColumnHeader)
+ {
+ ((ColumnHeader)value).HeaderSizeChanged += new EventHandler(this.HeaderSizeChanged);
+ ((ColumnHeader)value).SortCells += new SortCellsEventHandler(SortCellsHandler);
+ ((ColumnHeader)value).MouseDown += new System.Windows.Forms.MouseEventHandler(ColumnMouseDown);
+ ((ColumnHeader)value).MouseUp += new System.Windows.Forms.MouseEventHandler(ColumnMouseUp);
+ ((ColumnHeader)value).Parent = this;
+ }
+ InvalidateDisplayIndexes();
+ UpdateTreeLayout();
+ base.OnInsertComplete(index, value);
+ }
+
+ [System.Reflection.Obfuscation(Exclude = true)]
+ private void ColumnMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
+ {
+ AdvTree tree = GetTree();
+ if (tree != null)
+ tree.InvokeColumnHeaderMouseUp(sender, e);
+ }
+ [System.Reflection.Obfuscation(Exclude = true)]
+ private void ColumnMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
+ {
+ AdvTree tree = GetTree();
+ if (tree != null)
+ tree.InvokeColumnHeaderMouseDown(sender, e);
+ }
+
+ private AdvTree GetTree()
+ {
+ AdvTree tree = _Parent;
+ if (tree == null && _ParentNode != null)
+ tree = _ParentNode.TreeControl;
+ return tree;
+ }
+
+ ///
+ /// Occurs before the cells are sorted.
+ ///
+ [Description("Occurs before the cells are sorted.")]
+ public event SortCellsEventHandler SortCells;
+ protected virtual void OnSortCells(SortEventArgs e)
+ {
+ if (SortCells != null)
+ SortCells(this, e);
+ }
+
+ private void SortCellsHandler(object sender, SortEventArgs e)
+ {
+ ColumnHeader ch = (ColumnHeader)sender;
+ int i = this.IndexOf(ch);
+
+ IComparer comparer = null;
+ if (e.ReverseSort)
+ {
+ if (ch.SortComparerReverse != null)
+ comparer = ch.SortComparerReverse;
+ else
+ comparer = new NodeComparerReverse(i);
+ }
+ else
+ {
+ if (ch.SortComparer != null)
+ comparer = ch.SortComparer;
+ else
+ comparer = new NodeComparer(i);
+ }
+
+ if (e.Comparer == null)
+ e.Comparer = comparer;
+ else
+ comparer = e.Comparer;
+ OnSortCells(e);
+ if (e.Cancel)
+ return;
+
+ if (_Parent != null)
+ {
+ _Parent.Nodes.Sort(comparer);
+ }
+ else if (_ParentNode != null)
+ _ParentNode.Nodes.Sort(comparer);
+ }
+ private bool _UpdatingSortDirection = false;
+ ///
+ /// Called when SortDirection property on column header is set to value other than None.
+ ///
+ /// Ref to column header
+ internal void SortDirectionUpdated(ColumnHeader header)
+ {
+ if (_UpdatingSortDirection) return;
+
+ _UpdatingSortDirection = true;
+ try
+ {
+ if (header.SortDirection == eSortDirection.None)
+ {
+ IsSorted = false;
+ return;
+ }
+
+ IsSorted = true;
+
+ foreach (ColumnHeader col in this.List)
+ {
+ if (col != header && col.SortDirection != eSortDirection.None)
+ col.SortDirection = eSortDirection.None;
+ }
+ }
+ finally
+ {
+ _UpdatingSortDirection = false;
+ }
+ }
+
+ private bool _IsSorted;
+ ///
+ /// Gets whether a column that is part of this collection has SortDirection set.
+ ///
+ public bool IsSorted
+ {
+ get { return _IsSorted; }
+ internal set { _IsSorted = value; }
+ }
+
+ internal void UpdateSort()
+ {
+ if (!_IsSorted) return;
+ foreach (ColumnHeader header in this.List)
+ {
+ if (header.SortDirection != eSortDirection.None)
+ {
+ header.Sort(header.SortDirection == eSortDirection.Descending);
+ break;
+ }
+ }
+ }
+
+ private void UpdateTreeLayout()
+ {
+ if (_Parent != null)
+ {
+ _Parent.InvalidateNodesSize();
+ _Parent.Invalidate();
+ if (_Parent.Nodes.Count == 0)
+ _Parent.RecalcLayout();
+ else
+ _Parent.SetPendingLayout();
+ }
+ else if (_ParentNode != null)
+ {
+ AdvTree tree = _ParentNode.TreeControl;
+ if (tree != null)
+ {
+ tree.InvalidateNodeSize(_ParentNode);
+ tree.Invalidate();
+ }
+ }
+ }
+
+ private void HeaderSizeChanged(object sender, EventArgs e)
+ {
+ UpdateTreeLayout();
+ }
+
+ ///
+ /// Copies collection into the specified array.
+ ///
+ /// Array to copy collection to.
+ /// Starting index.
+ public void CopyTo(ColumnHeader[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ ///
+ /// Copies contained items to the ColumnHeader array.
+ ///
+ /// Array to copy to.
+ internal void CopyTo(ColumnHeader[] array)
+ {
+ List.CopyTo(array, 0);
+ }
+
+ protected override void OnClear()
+ {
+ foreach (ColumnHeader item in this)
+ {
+ item.HeaderSizeChanged -= new EventHandler(this.HeaderSizeChanged);
+ item.SortCells -= new SortCellsEventHandler(SortCellsHandler);
+ item.MouseDown -= new System.Windows.Forms.MouseEventHandler(ColumnMouseDown);
+ item.MouseUp -= new System.Windows.Forms.MouseEventHandler(ColumnMouseUp);
+ item.Parent = null;
+ }
+ IsSorted = false;
+ base.OnClear();
+ }
+
+ ///
+ /// A map of display index (key) to index in the column collection (value). Used to quickly find a column from its display index.
+ ///
+ internal List DisplayIndexMap
+ {
+ get
+ {
+ if (!_IsDisplayIndexValid)
+ {
+ UpdateDisplayIndexMap();
+ }
+
+
+ return _DisplayIndexMap;
+ }
+ }
+
+ ///
+ /// Gets the display index for specified column.
+ ///
+ /// Column that is part f ColumnHeaderCollection
+ /// Display index or -1 column is not part of this collection.
+ public int GetDisplayIndex(ColumnHeader column)
+ {
+ int index = this.IndexOf(column);
+ UpdateDisplayIndexMap();
+ for (int i = 0; i < _DisplayIndexMap.Count; i++)
+ {
+ if (_DisplayIndexMap[i] == index) return i;
+ }
+ return -1;
+ }
+
+ ///
+ /// Returns the column that is displayed at specified display index..
+ ///
+ /// 0 based display index.
+ /// ColumnHeader
+ public ColumnHeader ColumnAtDisplayIndex(int displayIndex)
+ {
+ UpdateDisplayIndexMap();
+ return this[_DisplayIndexMap[displayIndex]];
+ }
+
+ private List _DisplayIndexMap = new List();
+ private bool _IsDisplayIndexValid = false;
+ private void UpdateDisplayIndexMap()
+ {
+ if (_IsDisplayIndexValid) return;
+
+ _IsDisplayIndexValid = true;
+ _DisplayIndexMap.Clear();
+ List workingMap = new List();
+ bool isAllDefault = true;
+ for (int i = 0; i < Count; i++)
+ {
+ int displayIndex = this[i].DisplayIndex;
+ if (displayIndex != -1) isAllDefault = false;
+ workingMap.Add(new IndexToDisplayIndex(i, displayIndex));
+ }
+ if (!isAllDefault)
+ workingMap.Sort(new DisplayIndexComparer());
+ foreach (IndexToDisplayIndex item in workingMap)
+ {
+ _DisplayIndexMap.Add(item.Index);
+ }
+ }
+ ///
+ /// Gets reference to last visible column or null if there is no last visible column.
+ ///
+ public DevComponents.AdvTree.ColumnHeader LastVisibleColumn
+ {
+ get
+ {
+ List displayMap = DisplayIndexMap;
+ for (int i = displayMap.Count - 1; i >=0; i--)
+ {
+ if (this[displayMap[i]].Visible) return this[displayMap[i]];
+ }
+ return null;
+ }
+ }
+
+ ///
+ /// Gets reference to first visible column or null if there is no first visible column.
+ ///
+ public DevComponents.AdvTree.ColumnHeader FirstVisibleColumn
+ {
+ get
+ {
+ List displayMap = DisplayIndexMap;
+ for (int i = 0; i < displayMap.Count; i++)
+ {
+ if (this[displayMap[i]].Visible) return this[displayMap[i]];
+ }
+ return null;
+ }
+ }
+
+ #region IndexToDisplayIndex Class
+ private class IndexToDisplayIndex
+ {
+ public int Index = -1;
+ public int DisplayIndex = -1;
+ ///
+ /// Initializes a new instance of the IndexToDisplayIndex class.
+ ///
+ ///
+ ///
+ public IndexToDisplayIndex(int index, int displayIndex)
+ {
+ Index = index;
+ DisplayIndex = displayIndex;
+ }
+ }
+ #endregion
+
+ #region DisplayIndexComparer
+
+ private class DisplayIndexComparer : IComparer
+ {
+ #region IComparer Members
+
+ public int Compare(IndexToDisplayIndex x, IndexToDisplayIndex y)
+ {
+ if (x.DisplayIndex == y.DisplayIndex)
+ {
+ return x.Index - y.Index;
+ }
+ else
+ {
+ return x.DisplayIndex - y.DisplayIndex;
+ }
+ }
+ #endregion
+ }
+
+ #endregion
+
+ internal void DisplayIndexChanged(ColumnHeader column, int newDisplayIndex, int oldDisplayIndex)
+ {
+ InvalidateDisplayIndexes();
+
+ if (_UpdatingDisplayIndexes) return;
+
+ if (_Parent != null && !_Parent.IsUpdateSuspended)
+ UpdateTreeLayout();
+ else if (_ParentNode != null && _ParentNode.TreeControl != null && !_ParentNode.TreeControl.IsUpdateSuspended)
+ UpdateTreeLayout();
+ }
+ ///
+ /// Invalidates the display indexes and causes them to be re-evaluated on next layout.
+ ///
+ public void InvalidateDisplayIndexes()
+ {
+ _IsDisplayIndexValid = false;
+ }
+ #endregion
+
+ private Rectangle _Bounds = Rectangle.Empty;
+ internal void SetBounds(System.Drawing.Rectangle totalBounds)
+ {
+ _Bounds = totalBounds;
+ }
+
+ ///
+ /// Gets the column header rendering bounds.
+ ///
+ [Browsable(false)]
+ public Rectangle Bounds
+ {
+ get { return _Bounds; }
+ }
+
+ internal bool UsesRelativeSize = false;
+
+ private bool _UpdatingDisplayIndexes = false;
+ internal bool UpdatingDisplayIndexes
+ {
+ get { return _UpdatingDisplayIndexes; }
+ set { _UpdatingDisplayIndexes = value; }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/ColumnHeaderControl.cs b/PROMS/DotNetBar Source Code/AdvTree/ColumnHeaderControl.cs
new file mode 100644
index 00000000..179854a9
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/ColumnHeaderControl.cs
@@ -0,0 +1,324 @@
+using System;
+using System.Text;
+using System.Windows.Forms;
+using System.Drawing;
+using DevComponents.DotNetBar;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+
+namespace DevComponents.AdvTree
+{
+ internal class ColumnHeaderControl : Control
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the ColumnHeaderControl class.
+ ///
+ public ColumnHeaderControl()
+ {
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(ControlStyles.DoubleBuffer, true);
+ this.SetStyle(ControlStyles.Selectable, false);
+ this.SetStyle(ControlStyles.StandardDoubleClick | ControlStyles.StandardClick, true);
+ }
+ #endregion
+
+ #region Internal Implementation
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+
+ DisplayHelp.FillRectangle(g, this.ClientRectangle, this.BackColor);
+
+ if (_Columns == null)
+ {
+ return;
+ }
+
+ AdvTree tree = GetTree();
+ if (tree != null)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ TextRenderingHint th = g.TextRenderingHint;
+ if (tree.AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+ //Creates the drawing matrix with the right zoom;
+ if (tree.Zoom != 1)
+ {
+ System.Drawing.Drawing2D.Matrix mx = GetTranslationMatrix(tree.Zoom);
+ //use it for drawing
+ g.Transform = mx;
+ }
+
+ tree.NodeDisplay.PaintColumnHeaders(_Columns, g, true);
+
+ int columnMoveMarkerIndex = _ColumnMoveMarkerIndex;
+ if (columnMoveMarkerIndex >= 0)
+ DevComponents.AdvTree.Display.ColumnHeaderDisplay.PaintColumnMoveMarker(g, tree, columnMoveMarkerIndex, _Columns);
+
+ if (tree.AntiAlias)
+ {
+ g.SmoothingMode = sm;
+ g.TextRenderingHint = th;
+ }
+ }
+
+
+ base.OnPaint(e);
+ }
+
+ private int _ColumnMoveMarkerIndex = -1;
+ ///
+ /// Gets or sets the column move marker that marks insertion point for column that is dragged. Marker is drawn before the column specified by this index.
+ ///
+ internal int ColumnMoveMarkerIndex
+ {
+ get { return _ColumnMoveMarkerIndex; }
+ set
+ {
+ _ColumnMoveMarkerIndex = value;
+ this.Invalidate();
+ }
+ }
+
+
+ ///
+ /// Returns mouse position which is translated if control Zoom is not equal 1
+ ///
+ /// X coordinate
+ /// Y coordinate
+ ///
+ private Point GetLayoutPosition(float zoom, int x, int y)
+ {
+ if (zoom == 1)
+ return new Point(x, y);
+ Point[] p = new Point[] { new Point(x, y) };
+ using (System.Drawing.Drawing2D.Matrix mx = GetTranslationMatrix(zoom))
+ {
+ mx.Invert();
+ mx.TransformPoints(p);
+ }
+ return p[0];
+ }
+
+ private System.Drawing.Drawing2D.Matrix GetTranslationMatrix(float zoom)
+ {
+ System.Drawing.Drawing2D.Matrix mx = new System.Drawing.Drawing2D.Matrix(zoom, 0, 0, zoom, 0, 0);
+ return mx;
+ }
+
+ private AdvTree GetTree()
+ {
+ return this.Parent as AdvTree;
+ }
+
+ private ColumnHeaderCollection _Columns = null;
+ ///
+ /// Gets or sets the column header collection to be rendered.
+ ///
+ public ColumnHeaderCollection Columns
+ {
+ get { return _Columns; }
+ set { _Columns = value; }
+ }
+
+ private Cursor _OldCursor = null;
+ private ColumnHeader _MouseOverColumnHeader = null;
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ AdvTree tree = GetTree();
+
+ Point p = GetLayoutPosition(tree.Zoom, e.X, e.Y);
+ ColumnHeader ch = tree.GetColumnAt(p.X, p.Y, _Columns);
+ if (_MouseOverColumnHeader != ch)
+ {
+ if (_MouseOverColumnHeader != null)
+ _MouseOverColumnHeader.InternalMouseLeave(e);
+ _MouseOverColumnHeader = ch;
+ if (_MouseOverColumnHeader != null)
+ {
+ _MouseOverColumnHeader.InternalMouseEnter(e);
+ Interop.WinApi.ResetHover(this);
+ }
+ }
+
+ if (ch != null)
+ {
+ ch.InternalMouseMove(e);
+ }
+
+ if (e.Button == MouseButtons.Left && _MouseDownHeader != null && tree.AllowUserToReorderColumns && (Math.Abs(_MouseDownPoint.X-e.X)>1))
+ {
+ tree.StartColumnReorder(p.X, p.Y);
+ return;
+ }
+
+ if (tree == null || e.Button != MouseButtons.None || !tree.AllowUserToResizeColumns) return;
+
+
+ if (tree.CanResizeColumnAt(p.X, p.Y))
+ {
+ if (_OldCursor == null)
+ {
+ _OldCursor = this.Cursor;
+ this.Cursor = Cursors.VSplit;
+ }
+ }
+ else
+ {
+ ReleaseCursor();
+ }
+
+ base.OnMouseMove(e);
+ }
+
+ ColumnHeader _MouseDownHeader = null;
+ private Point _MouseDownPoint = Point.Empty;
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ AdvTree tree = GetTree();
+ Point p = Point.Empty;
+
+ bool canResize = false;
+ _MouseDownPoint = e.Location;
+
+ if (tree != null)
+ {
+ p = GetLayoutPosition(tree.Zoom, e.X, e.Y);
+ }
+
+ if (tree != null && tree.AllowUserToResizeColumns && e.Button == MouseButtons.Left)
+ canResize = tree.CanResizeColumnAt(p.X, p.Y);
+
+ if (tree != null)
+ {
+ p = GetLayoutPosition(tree.Zoom, e.X, e.Y);
+ ColumnHeader ch = tree.GetColumnAt(p.X, p.Y, _Columns);
+ if (ch != null)
+ {
+ _MouseDownHeader = ch;
+ if (!canResize)
+ ch.OnMouseDown(e);
+ }
+ }
+
+ if (tree == null || e.Button != MouseButtons.Left || !tree.AllowUserToResizeColumns) return;
+
+ if (canResize)
+ {
+ tree.StartColumnResize(p.X, p.Y);
+ }
+
+ this.Invalidate();
+ base.OnMouseDown(e);
+ }
+
+ protected override void OnMouseHover(EventArgs e)
+ {
+ if (Control.MouseButtons == MouseButtons.None)
+ {
+ AdvTree tree = GetTree();
+ Point p = this.PointToClient(Control.MousePosition);
+ p = GetLayoutPosition(tree.Zoom, p.X, p.Y);
+ ColumnHeader ch = tree.GetColumnAt(p.X, p.Y, _Columns);
+ if (ch != null)
+ {
+ ch.InternalMouseHover(e);
+ }
+ }
+ base.OnMouseHover(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ ReleaseCursor();
+ _MouseDownPoint = Point.Empty;
+
+ if (_MouseDownHeader!=null)
+ {
+ _MouseDownHeader.OnMouseUp(e);
+ _MouseDownHeader = null;
+ }
+ this.Invalidate();
+
+ base.OnMouseUp(e);
+ }
+
+ protected override void OnClick(EventArgs e)
+ {
+ AdvTree tree = GetTree();
+ Point p = Point.Empty;
+
+ if (tree != null)
+ {
+ Point tp = tree.PointToClient(Control.MousePosition);
+ p = GetLayoutPosition(tree.Zoom, tp.X, tp.Y);
+ ColumnHeader ch = tree.GetColumnAt(p.X, p.Y, _Columns);
+ if (ch != null)
+ {
+ ch.OnClick(e);
+ }
+ }
+ this.Invalidate();
+ base.OnClick(e);
+ }
+
+ internal DateTime IgnoreDoubleClickTime = DateTime.MinValue;
+
+ protected override void OnDoubleClick(EventArgs e)
+ {
+ AdvTree tree = GetTree();
+ Point p = Point.Empty;
+
+ if (tree != null)
+ {
+ Point tp = tree.PointToClient(Control.MousePosition);
+ p = GetLayoutPosition(tree.Zoom, tp.X, tp.Y);
+ ColumnHeader ch = tree.GetColumnAt(p.X, p.Y, _Columns);
+ if (ch != null)
+ {
+ DateTime now = DateTime.Now;
+ if (IgnoreDoubleClickTime != DateTime.MinValue && now.Subtract(IgnoreDoubleClickTime).TotalMilliseconds <= SystemInformation.DoubleClickTime)
+ {
+ IgnoreDoubleClickTime = DateTime.MinValue;
+ return;
+ }
+ IgnoreDoubleClickTime = DateTime.MinValue;
+
+ ch.OnDoubleClick(e);
+ }
+ }
+ this.Invalidate();
+
+ base.OnDoubleClick(e);
+ }
+
+ private void ReleaseCursor()
+ {
+ if (_OldCursor != null)
+ {
+ this.Cursor = _OldCursor;
+ _OldCursor = null;
+ }
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ if (_MouseOverColumnHeader != null)
+ {
+ _MouseOverColumnHeader.InternalMouseLeave(e);
+ _MouseOverColumnHeader = null;
+ }
+ if (Control.MouseButtons != MouseButtons.Left)
+ ReleaseCursor();
+ base.OnMouseLeave(e);
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/ColumnWidth.cs b/PROMS/DotNetBar Source Code/AdvTree/ColumnWidth.cs
new file mode 100644
index 00000000..21a42f7d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/ColumnWidth.cs
@@ -0,0 +1,151 @@
+using System;
+using System.ComponentModel;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents the width of the Column. Supports absolute width in Pixels and
+ /// relative width as percentage of the width of parent control.
+ ///
+ [ToolboxItem(false) ,System.ComponentModel.DesignTimeVisible(false),TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+ public class ColumnWidth
+ {
+ private int m_Relative=0;
+ private int m_Absolute=0;
+ internal event EventHandler WidthChanged;
+
+ ///
+ /// Creates new instance of the object.
+ ///
+ public ColumnWidth()
+ {
+ }
+
+ ///
+ /// Gets or sets relative width expressed as percentage between 1-100. 0 indicates that
+ /// absolute width will be used.
+ ///
+ ///
+ /// Relative width is expressed as percentage between 1-100 of the parent controls
+ /// width. 0 indicates that absolute width will be used. Absolute width always takes
+ /// priority over relative width. For example value of 30 assigned to this property
+ /// indicates that width of the column will be 30% of the total client width of the
+ /// control.
+ ///
+ [DefaultValue(0),Browsable(true),Description("Gets or sets relative width in percent. Valid values are between 1-100 with 0 indicating that absolute width will be used.")]
+ public int Relative
+ {
+ get {return m_Relative;}
+ set
+ {
+ if(m_Relative!=value)
+ {
+ m_Relative=value;
+ OnSizeChanged();
+ }
+ }
+ }
+
+ /// Gets or sets the absolute width of the column in pixels.
+ ///
+ /// Absolute width always takes precedence over the relative width of the
+ /// column.
+ ///
+ [DefaultValue(0),Browsable(true),Description("Gets or sets the absolute width of the column in pixels.")]
+ public int Absolute
+ {
+ get {return m_Absolute;}
+ set
+ {
+ if(m_Absolute<0)
+ return;
+ if(m_Absolute!=value)
+ {
+ m_Absolute=value;
+ if(m_Absolute!=0)
+ m_Relative=0;
+ OnSizeChanged();
+ }
+ }
+ }
+
+ internal void SetAbsolute(int value)
+ {
+ m_Absolute = value;
+ }
+
+ internal int GetWidth(int containerWidth)
+ {
+ if (m_Absolute > 0)
+ return m_Absolute;
+ if(m_Relative>0)
+ return (100 / m_Relative) * containerWidth;
+ return 0;
+ }
+
+ private void OnSizeChanged()
+ {
+ if(WidthChanged!=null)
+ WidthChanged(this,new EventArgs());
+ }
+
+ private bool _AutoSize = false;
+ ///
+ /// Gets or sets whether column width is automatically set based on the column's content. Default value is false.
+ /// When set absolute and relative size values are ignored.
+ ///
+ [DefaultValue(false), Description("Indicates whether column is sized based on the content.")]
+ public bool AutoSize
+ {
+ get { return _AutoSize; }
+ set
+ {
+ if (_AutoSize != value)
+ {
+ _AutoSize = value;
+ OnSizeChanged();
+ }
+ }
+ }
+
+ internal void SetAutoSize(bool autoSize)
+ {
+ _AutoSize = autoSize;
+ }
+
+ private bool _AutoSizeMinHeader = false;
+ ///
+ /// Gets or sets whether column auto-width is set to minimum of the column header text width. Applies to AutoSize=true only.
+ ///
+ [DefaultValue(false), Description("Indicates whether column auto-width is set to minimum of the column header text width. Applies to AutoSize=true only.")]
+ public bool AutoSizeMinHeader
+ {
+ get { return _AutoSizeMinHeader; }
+ set
+ {
+ _AutoSizeMinHeader = value;
+ OnSizeChanged();
+ }
+ }
+
+
+ private int _AutoSizeWidth = 0;
+ ///
+ /// Gets the auto-size calculated width of the column after tree layout is performed and column has AutoSize=true.
+ ///
+ [Browsable(false)]
+ public int AutoSizeWidth
+ {
+ get { return _AutoSizeWidth; }
+// internal set
+// {
+// _AutoSizeWidth = value;
+// }
+ }
+ internal void SetAutoSizeWidth(int value)
+ {
+ _AutoSizeWidth = value;
+ }
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/CommandButtonEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/CommandButtonEventArgs.cs
new file mode 100644
index 00000000..37324a7c
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/CommandButtonEventArgs.cs
@@ -0,0 +1,30 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Provides event arguments for command button events.
+ ///
+ public class CommandButtonEventArgs:EventArgs
+ {
+ ///
+ /// Default constructor.
+ ///
+ /// Action type.
+ /// Context node.
+ public CommandButtonEventArgs(eTreeAction action, Node node)
+ {
+ this.Action=action;
+ this.Node=node;
+ }
+
+ ///
+ /// Indicates the action type that caused the event.
+ ///
+ public eTreeAction Action=eTreeAction.Code;
+ ///
+ /// Indicates the node action is peformed on.
+ ///
+ public DevComponents.AdvTree.Node Node=null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/ConnectorPointsCollection.cs b/PROMS/DotNetBar Source Code/AdvTree/ConnectorPointsCollection.cs
new file mode 100644
index 00000000..126f003b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/ConnectorPointsCollection.cs
@@ -0,0 +1,154 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents collection of connector points for a node.
+ ///
+ public class ConnectorPointsCollection:CollectionBase
+ {
+ #region Private Variables
+ private Node m_ParentNode=null;
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Default constructor.
+ ///
+ public ConnectorPointsCollection()
+ {
+ }
+ ///
+ /// Gets or sets the node this collection is associated with.
+ ///
+ [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Node ParentNode
+ {
+ get {return m_ParentNode;}
+ }
+ ///
+ /// Sets the node collection belongs to.
+ ///
+ /// Node that is parent of this collection.
+ internal void SetParentNode(Node parent)
+ {
+ m_ParentNode=parent;
+ }
+
+ ///
+ /// Adds new object to the collection.
+ ///
+ /// Object to add.
+ /// Index of newly added object.
+ public int Add(Point p)
+ {
+ return List.Add(p);
+ }
+
+ ///
+ /// Adds range of objects to the array.
+ ///
+ /// Array to add.
+ public void AddRange(Point[] ap)
+ {
+ foreach(Point p in ap)
+ this.Add(p);
+ }
+
+ ///
+ /// Copies objects of the collection to the array.
+ ///
+ ///
+ public Point[] ToArray()
+ {
+ Point[] ap=new Point[this.Count];
+ this.CopyTo(ap);
+ return ap;
+ }
+
+ ///
+ /// Returns reference to the object in collection based on it's index.
+ ///
+ public Point this[int index]
+ {
+ get {return (Point)(List[index]);}
+ set {List[index] = value;}
+ }
+
+ ///
+ /// Inserts new object into the collection.
+ ///
+ /// Position of the object.
+ /// Object to insert.
+ public void Insert(int index, Point value)
+ {
+ List.Insert(index, value);
+ }
+
+ ///
+ /// Returns index of the object inside of the collection.
+ ///
+ /// Reference to the object.
+ /// Index of the object.
+ public int IndexOf(Point value)
+ {
+ return List.IndexOf(value);
+ }
+
+ ///
+ /// Returns whether collection contains specified object.
+ ///
+ /// Object to look for.
+ /// true if object is part of the collection, otherwise false.
+ public bool Contains(Point value)
+ {
+ return List.Contains(value);
+ }
+
+ ///
+ /// Removes specified object from the collection.
+ ///
+ ///
+ public void Remove(Point value)
+ {
+ List.Remove(value);
+ }
+
+ protected override void OnRemoveComplete(int index,object value)
+ {
+ base.OnRemoveComplete(index,value);
+ }
+ protected override void OnInsertComplete(int index,object value)
+ {
+ base.OnInsertComplete(index,value);
+ }
+
+ ///
+ /// Copies collection into the specified array.
+ ///
+ /// Array to copy collection to.
+ /// Starting index.
+ public void CopyTo(Point[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ ///
+ /// Copies contained items to the ColumnHeader array.
+ ///
+ /// Array to copy to.
+ internal void CopyTo(Point[] array)
+ {
+ List.CopyTo(array,0);
+ }
+
+ protected override void OnClear()
+ {
+ base.OnClear();
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/CustomEditors.cs b/PROMS/DotNetBar Source Code/AdvTree/CustomEditors.cs
new file mode 100644
index 00000000..017e914c
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/CustomEditors.cs
@@ -0,0 +1,243 @@
+using System;
+using System.Text;
+using DevComponents.Editors;
+using System.Windows.Forms;
+using DevComponents.Editors.DateTimeAdv;
+
+namespace DevComponents.AdvTree
+{
+#if FRAMEWORK20
+ #region Integer Custom Editor
+ internal class IntegerCellEditor : IntegerInput, ICellEditControl
+ {
+ #region ICellEditControl Members
+
+ public void BeginEdit()
+ {
+#if (FRAMEWORK20)
+ this.MinimumSize = new System.Drawing.Size(32, 10);
+#endif
+ }
+
+ public void EndEdit()
+ {
+ this.Dispose();
+ }
+
+ public object CurrentValue
+ {
+ get
+ {
+ if (this.FreeTextEntryMode && this.IsKeyboardFocusWithin)
+ this.ApplyFreeTextValue();
+ return this.Text;
+ }
+ set
+ {
+ if (value is int)
+ this.Value = (int)value;
+ else if (value == null)
+ this.ValueObject = null;
+ else
+ {
+ string s = Utilities.StripNonNumeric(value.ToString());
+ int i = 0;
+#if FRAMEWORK20
+ int.TryParse(s, out i);
+#else
+ try
+ {
+ i = int.Parse(s);
+ }
+ catch { }
+#endif
+ this.Value = i;
+ }
+ }
+ }
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+ {
+ if (keyData == Keys.Enter || keyData == Keys.Tab)
+ {
+ if (EditComplete != null)
+ EditComplete(this, new EventArgs());
+ return true;
+ }
+ else if (keyData == Keys.Escape)
+ {
+ if (CancelEdit != null)
+ CancelEdit(this, new EventArgs());
+ return true;
+ }
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+
+ public event EventHandler EditComplete;
+
+ public event EventHandler CancelEdit;
+
+ public bool EditWordWrap
+ {
+ get { return false; }
+ set { }
+ }
+
+ #endregion
+ }
+ #endregion
+
+ #region Double Custom Editor
+ internal class DoubleCellEditor : DoubleInput, ICellEditControl
+ {
+ #region ICellEditControl Members
+
+ public void BeginEdit()
+ {
+#if (FRAMEWORK20)
+ this.MinimumSize = new System.Drawing.Size(32, 10);
+#endif
+ }
+
+ public void EndEdit()
+ {
+ this.Dispose();
+ }
+
+ public object CurrentValue
+ {
+ get
+ {
+ if (this.FreeTextEntryMode && this.IsKeyboardFocusWithin)
+ this.ApplyFreeTextValue();
+ return this.Text;
+ }
+ set
+ {
+ if (value is int)
+ this.Value = (int)value;
+ else if (value == null)
+ this.ValueObject = null;
+ else
+ {
+ string s = Utilities.StripNonNumeric(value.ToString());
+ double i = 0;
+#if FRAMEWORK20
+ double.TryParse(s, out i);
+#else
+ try
+ {
+ i = double.Parse(s);
+ }
+ catch { }
+#endif
+ this.Value = i;
+ }
+ }
+ }
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+ {
+ if (keyData == Keys.Enter || keyData == Keys.Tab)
+ {
+ if (EditComplete != null)
+ EditComplete(this, new EventArgs());
+ return true;
+ }
+ else if (keyData == Keys.Escape)
+ {
+ if (CancelEdit != null)
+ CancelEdit(this, new EventArgs());
+ return true;
+ }
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+
+ public event EventHandler EditComplete;
+
+ public event EventHandler CancelEdit;
+
+ public bool EditWordWrap
+ {
+ get { return false; }
+ set { }
+ }
+
+ #endregion
+ }
+ #endregion
+
+ #region Date-Time Custom Editor
+ internal class DateTimeCellEditor : DateTimeInput, ICellEditControl
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the DateTimeCellEditor class.
+ ///
+ public DateTimeCellEditor()
+ {
+ this.BackgroundStyle.BorderColor = System.Drawing.Color.Transparent;
+ }
+ #endregion
+
+ #region ICellEditControl Members
+ public void BeginEdit()
+ {
+ this.MinimumSize = new System.Drawing.Size(70, 10);
+ }
+
+ public void EndEdit()
+ {
+ this.Dispose();
+ }
+
+ public object CurrentValue
+ {
+ get
+ {
+ return this.Text;
+ }
+ set
+ {
+ if (value is DateTime)
+ this.Value = (DateTime)value;
+ else if (value == null)
+ this.ValueObject = null;
+ else if(value is string)
+ {
+ DateTime date = DateTime.MinValue;
+ if (DateTime.TryParse((string)value, out date))
+ this.Value = date;
+ }
+ }
+ }
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+ {
+ if (keyData == Keys.Enter || keyData == Keys.Tab)
+ {
+ if (EditComplete != null)
+ EditComplete(this, new EventArgs());
+ return true;
+ }
+ else if (keyData == Keys.Escape)
+ {
+ if (CancelEdit != null)
+ CancelEdit(this, new EventArgs());
+ return true;
+ }
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+
+ public event EventHandler EditComplete;
+
+ public event EventHandler CancelEdit;
+
+ public bool EditWordWrap
+ {
+ get { return false; }
+ set { }
+ }
+
+ #endregion
+ }
+ #endregion
+#endif
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/CellDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/CellDisplay.cs
new file mode 100644
index 00000000..869fbe03
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/CellDisplay.cs
@@ -0,0 +1,328 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using DevComponents.DotNetBar;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Represents cell display class.
+ ///
+ internal class CellDisplay
+ {
+ public CellDisplay()
+ {
+ }
+
+ private static Office2007CheckBoxItemPainter _CheckBoxPainter;
+ public static Office2007CheckBoxItemPainter CheckBoxPainter
+ {
+ get { return _CheckBoxPainter; }
+ set { _CheckBoxPainter = value; }
+ }
+
+ public static Office2007CheckBoxColorTable ColorTable = null;
+
+ public static void PaintCell(NodeCellRendererEventArgs ci)
+ {
+ if(ci.Cell.CheckBoxVisible)
+ CellDisplay.PaintCellCheckBox(ci);
+ if(!ci.Cell.Images.LargestImageSize.IsEmpty)
+ CellDisplay.PaintCellImage(ci);
+ CellDisplay.PaintText(ci);
+ }
+
+ public static void PaintCellCheckBox(NodeCellRendererEventArgs ci)
+ {
+ if(!ci.Cell.CheckBoxVisible)
+ return;
+ Cell cell = ci.Cell;
+ Rectangle r = cell.CheckBoxBoundsRelative;
+ r.Offset(ci.CellOffset);
+
+ if (ci.CheckBoxImageChecked != null)
+ {
+ Image img = ci.CheckBoxImageChecked;
+ if (cell.CheckState == System.Windows.Forms.CheckState.Unchecked)
+ img = ci.CheckBoxImageUnChecked;
+ else if (cell.CheckState == System.Windows.Forms.CheckState.Indeterminate)
+ img = ci.CheckBoxImageIndeterminate;
+ if (img != null)
+ ci.Graphics.DrawImage(img, r);
+ }
+ else if (_CheckBoxPainter != null)
+ {
+ Office2007CheckBoxStateColorTable ct = GetCheckBoxStateColorTable(ci);
+ if (cell.CheckBoxStyle == eCheckBoxStyle.CheckBox)
+ {
+ _CheckBoxPainter.PaintCheckBox(ci.Graphics, r, ct, cell.CheckState);
+ }
+ else
+ {
+ _CheckBoxPainter.PaintRadioButton(ci.Graphics, r, ct, cell.Checked);
+ }
+ }
+ else
+ {
+ System.Windows.Forms.ButtonState state = System.Windows.Forms.ButtonState.Normal;
+ if (ci.Cell.Checked)
+ state = System.Windows.Forms.ButtonState.Checked;
+ System.Windows.Forms.ControlPaint.DrawCheckBox(ci.Graphics, r, state);
+ }
+ }
+
+ private static Office2007CheckBoxStateColorTable GetCheckBoxStateColorTable(NodeCellRendererEventArgs e)
+ {
+ Cell cell = e.Cell;
+
+ if (ColorTable != null && BarFunctions.IsOffice2007Style(e.ColorScheme.Style))
+ {
+ Office2007CheckBoxColorTable ct = ColorTable;
+ if (!cell.GetEnabled())
+ return ct.Disabled;
+ //else if (cell.IsMouseDown)
+ // return ct.Pressed;
+ //else if (cell.IsMouseOver)
+ // return ct.MouseOver;
+ return ct.Default;
+ }
+ else
+ {
+ ColorScheme cs = e.ColorScheme;
+ // Create color table based on the ColorScheme object...
+ Office2007CheckBoxStateColorTable ct = new Office2007CheckBoxStateColorTable();
+ if (!cell.GetEnabled())
+ {
+ ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ ct.CheckBorder = cs.ItemDisabledText;
+ ct.CheckInnerBorder = cs.ItemDisabledText;
+ ct.CheckInnerBackground = new LinearGradientColorTable();
+ ct.CheckSign = new LinearGradientColorTable(cs.ItemDisabledText, Color.Empty);
+ ct.Text = cs.ItemDisabledText;
+ }
+ //else if (cell.IsMouseDown)
+ //{
+ // ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ // ct.CheckBorder = cs.ItemPressedBorder;
+ // ct.CheckInnerBorder = cs.ItemPressedBorder;
+ // ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemPressedBackground, cs.ItemPressedBackground2);
+ // ct.CheckSign = new LinearGradientColorTable(cs.ItemPressedText, Color.Empty);
+ // ct.Text = cs.ItemPressedText;
+ //}
+ //else if (cell.IsMouseOver)
+ //{
+ // ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ // ct.CheckBorder = cs.ItemHotBorder;
+ // ct.CheckInnerBorder = cs.ItemHotBorder;
+ // ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemHotBackground, cs.ItemHotBackground2);
+ // ct.CheckSign = new LinearGradientColorTable(cs.ItemHotText, Color.Empty);
+ // ct.Text = cs.ItemHotText;
+ //}
+ else
+ {
+ ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ ct.CheckBorder = cs.PanelBorder;
+ ct.CheckInnerBorder = ColorBlendFactory.SoftLight(cs.PanelBorder, Color.White);
+ ct.CheckInnerBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ ct.CheckSign = new LinearGradientColorTable(cs.ItemText, Color.Empty);
+ ct.Text = cs.ItemText;
+ }
+ return ct;
+ }
+ }
+
+ public static void PaintCellImage(NodeCellRendererEventArgs ci)
+ {
+ if(ci.Cell.Images.LargestImageSize.IsEmpty)
+ return;
+ Rectangle r=ci.Cell.ImageBoundsRelative;
+ r.Offset(ci.CellOffset);
+
+ Image image = CellDisplay.GetCellImage(ci.Cell);
+
+ if(image!=null)
+ {
+ Size imageSize = Dpi.ImageSize(image.Size);
+ ci.Graphics.DrawImage(image, r.X + (r.Width - imageSize.Width) / 2,
+ r.Y + (r.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ }
+ }
+
+ public static void PaintText(NodeCellRendererEventArgs ci)
+ {
+ Cell cell = ci.Cell;
+ if (cell.HostedControl == null && cell.HostedItem == null && (cell.DisplayText == "" || ci.Style.TextColor.IsEmpty) || cell.TextContentBounds.IsEmpty)
+ return;
+
+ Rectangle bounds = ci.Cell.TextContentBounds;
+ bounds.Offset(ci.CellOffset);
+
+ Graphics g = ci.Graphics;
+ if (cell.HostedControl != null)
+ {
+ if (!cell.HostedControl.Visible)
+ cell.HostedControl.Visible = true;
+ return;
+ }
+ else if (cell.HostedItem != null)
+ {
+ BaseItem item = cell.HostedItem;
+ if (item.ItemAlignment == eItemAlignment.Near)
+ item.LeftInternal = bounds.X;
+ else if (item.ItemAlignment == eItemAlignment.Far)
+ item.LeftInternal = bounds.X + (bounds.Width - item.WidthInternal);
+ else if (item.ItemAlignment == eItemAlignment.Center)
+ item.LeftInternal = bounds.X + (bounds.Width - item.WidthInternal) / 2;
+ if (item.DisplayRectangle.Height < bounds.Height)
+ item.TopInternal = bounds.Y + (bounds.Height - item.DisplayRectangle.Height) / 2;
+ else
+ item.TopInternal = bounds.Y;
+ item.Displayed = true;
+ Region oldClip = g.Clip;
+ Rectangle cb = bounds;
+ cb.Inflate(2, 1);
+ g.SetClip(cb, CombineMode.Intersect);
+ item.Paint(ci.ItemPaintArgs);
+ if (oldClip != null)
+ {
+ g.Clip = oldClip;
+ oldClip.Dispose();
+ }
+ return;
+ }
+
+ Font font = ci.Style.Font;
+ if (bounds.Width > 1 && bounds.Height > 1)
+ {
+ //eTextFormat textFormat = ci.Style.TextFormat;
+ //textFormat = textFormat & ~(textFormat & eTextFormat.HidePrefix);
+ //textFormat |= eTextFormat.NoPrefix;
+ if (cell.TextMarkupBody == null)
+ {
+ TextDrawing.DrawString(g, cell.DisplayText, font, ci.Style.TextColor, bounds, ci.Style.TextFormat);
+ }
+ else
+ {
+ DevComponents.DotNetBar.TextMarkup.MarkupDrawContext d = new DevComponents.DotNetBar.TextMarkup.MarkupDrawContext(g, font, ci.Style.TextColor, false);
+ d.HotKeyPrefixVisible = !((ci.Style.TextFormat & eTextFormat.HidePrefix) == eTextFormat.HidePrefix);
+ Rectangle mr = Rectangle.Empty;
+ eStyleTextAlignment lineAlignment = ci.Style.TextLineAlignment;
+ if (lineAlignment == eStyleTextAlignment.Center)
+ {
+ mr = new Rectangle(bounds.X, bounds.Y + (bounds.Height - cell.TextMarkupBody.Bounds.Height) / 2, cell.TextMarkupBody.Bounds.Width, cell.TextMarkupBody.Bounds.Height);
+ }
+ else if (lineAlignment == eStyleTextAlignment.Near)
+ {
+ mr = new Rectangle(bounds.X, bounds.Y, cell.TextMarkupBody.Bounds.Width, cell.TextMarkupBody.Bounds.Height);
+ }
+ else // Far
+ {
+ mr = new Rectangle(bounds.X, bounds.Y + (bounds.Height - cell.TextMarkupBody.Bounds.Height), cell.TextMarkupBody.Bounds.Width, cell.TextMarkupBody.Bounds.Height);
+ }
+
+ cell.TextMarkupBody.Bounds = mr;
+ cell.TextMarkupBody.Render(d);
+ }
+ }
+ }
+
+ private static Image GetCellImage(Cell cell)
+ {
+ Image img=cell.Images.Image;
+
+ bool enabled = cell.GetEnabled();
+
+ if (!enabled && (cell.Images.ImageDisabled != null || cell.Images.ImageDisabledIndex >= 0 || cell.Images.DisabledImageGenerated != null))
+ {
+ if (cell.Images.DisabledImageGenerated != null) return cell.Images.DisabledImageGenerated;
+ if (cell.Images.ImageDisabled != null) return cell.Images.ImageDisabled;
+ if (cell.Images.ImageDisabledIndex >= 0) return cell.Images.GetImageByIndex(cell.Images.ImageDisabledIndex);
+ }
+
+ if(img == null && !string.IsNullOrEmpty(cell.Images.ImageKey))
+ img = cell.Images.GetImageByKey(cell.Images.ImageKey);
+ if (img == null && cell.Images.ImageIndex >= 0)
+ img = cell.Images.GetImageByIndex(cell.Images.ImageIndex);
+
+ if (!enabled && img is Bitmap)
+ {
+ cell.Images.DisposeGeneratedDisabledImage();
+ cell.Images.DisabledImageGenerated = ImageHelper.CreateGrayScaleImage(img as Bitmap);
+ if (cell.Images.DisabledImageGenerated != null) return cell.Images.DisabledImageGenerated;
+ return img;
+ }
+
+ if(cell.IsMouseOver && (cell.Images.ImageMouseOver!=null || cell.Images.ImageMouseOverIndex>= 0 || !string.IsNullOrEmpty(cell.Images.ImageMouseOverKey)))
+ {
+ if (cell.Images.ImageMouseOver != null)
+ img = cell.Images.ImageMouseOver;
+ else if (cell.Images.ImageMouseOverIndex >= 0)
+ img = cell.Images.GetImageByIndex(cell.Images.ImageMouseOverIndex);
+ else
+ img = cell.Images.GetImageByKey(cell.Images.ImageMouseOverKey);
+ }
+ else if(cell.Parent.Expanded && (cell.Images.ImageExpanded!=null || cell.Images.ImageExpandedIndex>= 0 || !string.IsNullOrEmpty(cell.Images.ImageExpandedKey)))
+ {
+ if (cell.Images.ImageExpanded != null)
+ img = cell.Images.ImageExpanded;
+ else if (cell.Images.ImageExpandedIndex >= 0)
+ img = cell.Images.GetImageByIndex(cell.Images.ImageExpandedIndex);
+ else
+ img = cell.Images.GetImageByKey(cell.Images.ImageExpandedKey);
+ }
+ return img;
+ }
+
+ public static Font GetCellFont(AdvTree tree, Cell cell)
+ {
+ Font font=tree.Font;
+ ElementStyle style=null;
+
+ if(cell.StyleNormal!=null)
+ {
+ style=cell.StyleNormal;
+ }
+ else
+ {
+ if(tree.NodeStyle!=null)
+ style=tree.NodeStyle;
+ else
+ style=new ElementStyle();
+
+ if(tree.CellStyleDefault!=null)
+ style=tree.CellStyleDefault;
+ else
+ style=ElementStyle.GetDefaultCellStyle(style);
+ }
+
+ if(style!=null && style.Font!=null)
+ font=style.Font;
+
+ return font;
+ }
+ }
+
+ ///
+ /// Represents information necessary to paint the cell on canvas.
+ ///
+ internal class CellDisplayInfo
+ {
+ public ElementStyle Style=null;
+ public System.Drawing.Graphics Graphics=null;
+ public Cell ContextCell=null;
+ public Point CellOffset=Point.Empty;
+
+ public CellDisplayInfo()
+ {
+ }
+
+ public CellDisplayInfo(ElementStyle style, System.Drawing.Graphics g, Cell cell, Point cellOffset)
+ {
+ this.Style=style;
+ this.Graphics=g;
+ this.ContextCell=cell;
+ this.CellOffset=cellOffset;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/ColorTableInitializer.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/ColorTableInitializer.cs
new file mode 100644
index 00000000..1dbeda02
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/ColorTableInitializer.cs
@@ -0,0 +1,384 @@
+using System;
+using System.Text;
+using DevComponents.WinForms.Drawing;
+using System.Drawing;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Initializes the tree color tables.
+ ///
+ internal class ColorTableInitializer
+ {
+ #region Office 2007 Blue
+ public static void InitOffice2007Blue(TreeColorTable ct, ColorFactory factory)
+ {
+ #region Tree Selection
+ TreeSelectionColors treeSelection = new TreeSelectionColors();
+ ct.Selection = treeSelection;
+ // Highlight full row
+ SelectionColorTable selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(0xA7CDF0));
+ treeSelection.FullRowSelect = selColorTable;
+ // Highlight full row Inactive
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(0xE5E5E5));
+ treeSelection.FullRowSelectInactive = selColorTable;
+
+ // Node Marker
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(64, 0x316AC5));
+ selColorTable.Border = new SolidBorder(factory.GetColor(96, 0x316AC5), 1);
+ treeSelection.NodeMarker = selColorTable;
+ // Node marker inactibe
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(64, 0xE5E5E5));
+ selColorTable.Border = new SolidBorder(factory.GetColor(96, 0x000000), 1);
+ treeSelection.NodeMarkerInactive = selColorTable;
+
+ // Cell selection
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(new ColorStop[] {
+ new ColorStop(factory.GetColor(0xFFFCD9), 0f),
+ new ColorStop(factory.GetColor(0xFFE78D), .4f),
+ new ColorStop(factory.GetColor(0xFFD748), .4f),
+ new ColorStop(factory.GetColor(0xFFE793), 1f)
+ });
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xDDCF9B), 1);
+ selColorTable.BorderCornerRadius = 2;
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(192, 0xFFF2BE), 1);
+ //selColorTable = new SelectionColorTable();
+ //selColorTable.Fill = new GradientFill(factory.GetColor(0xF6FBFD), factory.GetColor(0xD5EFFC), 90);
+ //selColorTable.Border = new SolidBorder(factory.GetColor(0x99DEFD), 1);
+ //selColorTable.InnerBorder = new SolidBorder(factory.GetColor(192, 0xFFFFFF), 1);
+ treeSelection.HighlightCells = selColorTable;
+ // Cell selection inactive
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(factory.GetColor(0xFAFAFB), factory.GetColor(0xE5E5E5), 90);
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xD9D9D9), 1);
+ selColorTable.BorderCornerRadius = 2;
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(228, 0xFFFFFF), 1);
+ treeSelection.HighlightCellsInactive = selColorTable;
+
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(factory.GetColor(0xFAFAFB), factory.GetColor(0xE5E5E5), 90);
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xD9D9D9), 1);
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(228, 0xFFFFFF), 1);
+ treeSelection.NodeHotTracking = selColorTable;
+ #endregion
+
+ #region Expand Buttons
+ TreeExpandColorTable expand = new TreeExpandColorTable();
+ expand.CollapseBorder = new SolidBorder(factory.GetColor(0x000000), 1);
+ expand.CollapseFill = new SolidFill(factory.GetColor(0x595959));
+ expand.CollapseMouseOverBorder = new SolidBorder(factory.GetColor(0x1CC4F7), 1);
+ expand.CollapseMouseOverFill = new SolidFill(factory.GetColor(0x82DFFB));
+ expand.ExpandBorder = new SolidBorder(factory.GetColor(0x848484), 1);
+ expand.ExpandFill = new SolidFill(factory.GetColor(0xFFFFFF));
+ expand.ExpandMouseOverBorder = new SolidBorder(factory.GetColor(0x1CC4F7), 1);
+ expand.ExpandMouseOverFill = new SolidFill(factory.GetColor(0xCCEDFA));
+ ct.ExpandTriangle = expand;
+ // Rectangle
+ expand = new TreeExpandColorTable();
+ expand.CollapseForeground = new SolidFill(factory.GetColor(0x000000));
+ expand.CollapseBorder = new SolidBorder(factory.GetColor(0x969696), 1);
+ expand.CollapseFill = new GradientFill(new ColorStop[]{
+ new ColorStop(factory.GetColor(0xFFFFFF), 0f), new ColorStop(factory.GetColor(0xFFFFFF), .40f), new ColorStop(factory.GetColor(0xB6B6B6), 1f)}, 45);
+ expand.CollapseMouseOverForeground = expand.CollapseForeground;
+ expand.CollapseMouseOverBorder = expand.CollapseBorder;
+ expand.CollapseMouseOverFill = expand.CollapseFill;
+ expand.ExpandForeground = expand.CollapseForeground;
+ expand.ExpandBorder = expand.CollapseBorder;
+ expand.ExpandFill = expand.CollapseFill;
+ expand.ExpandMouseOverForeground = expand.CollapseForeground;
+ expand.ExpandMouseOverBorder = expand.CollapseBorder;
+ expand.ExpandMouseOverFill = expand.CollapseFill;
+ ct.ExpandRectangle = expand;
+ ct.ExpandEllipse = expand;
+ #endregion
+
+ #region Misc Tree Color
+ ct.GridLines = factory.GetColor(0xE1E1E1);
+ #endregion
+ }
+ #endregion
+
+ #region Office 2007 Silver
+ public static void InitOffice2007Silver(TreeColorTable ct, ColorFactory factory)
+ {
+ #region Tree Selection
+ TreeSelectionColors treeSelection = new TreeSelectionColors();
+ ct.Selection = treeSelection;
+ // Highlight full row
+ SelectionColorTable selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(0xA7CDF0));
+ treeSelection.FullRowSelect = selColorTable;
+ // Highlight full row Inactive
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(0xE5E5E5));
+ treeSelection.FullRowSelectInactive = selColorTable;
+
+ // Node Marker
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(64, 0x316AC5));
+ selColorTable.Border = new SolidBorder(factory.GetColor(96, 0x316AC5), 1);
+ treeSelection.NodeMarker = selColorTable;
+ // Node marker inactibe
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(64, 0xE5E5E5));
+ selColorTable.Border = new SolidBorder(factory.GetColor(96, 0x000000), 1);
+ treeSelection.NodeMarkerInactive = selColorTable;
+
+ // Cell selection
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(new ColorStop[] {
+ new ColorStop(factory.GetColor(0xFFFCD9), 0f),
+ new ColorStop(factory.GetColor(0xFFE78D), .4f),
+ new ColorStop(factory.GetColor(0xFFD748), .4f),
+ new ColorStop(factory.GetColor(0xFFE793), 1f)
+ });
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xDDCF9B), 1);
+ selColorTable.BorderCornerRadius = 2;
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(192, 0xFFF2BE), 1);
+ //selColorTable = new SelectionColorTable();
+ //selColorTable.Fill = new GradientFill(factory.GetColor(0xF6FBFD), factory.GetColor(0xD5EFFC), 90);
+ //selColorTable.Border = new SolidBorder(factory.GetColor(0x99DEFD), 1);
+ //selColorTable.InnerBorder = new SolidBorder(factory.GetColor(192, 0xFFFFFF), 1);
+ treeSelection.HighlightCells = selColorTable;
+ // Cell selection inactive
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(factory.GetColor(0xFAFAFB), factory.GetColor(0xE5E5E5), 90);
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xD9D9D9), 1);
+ selColorTable.BorderCornerRadius = 2;
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(228, 0xFFFFFF), 1);
+ treeSelection.HighlightCellsInactive = selColorTable;
+
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(factory.GetColor(0xFAFAFB), factory.GetColor(0xE5E5E5), 90);
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xD9D9D9), 1);
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(228, 0xFFFFFF), 1);
+ treeSelection.NodeHotTracking = selColorTable;
+ #endregion
+
+ #region Expand Buttons
+ TreeExpandColorTable expand = new TreeExpandColorTable();
+ expand.CollapseBorder = new SolidBorder(factory.GetColor(0x000000), 1);
+ expand.CollapseFill = new SolidFill(factory.GetColor(0x595959));
+ expand.CollapseMouseOverBorder = new SolidBorder(factory.GetColor(0x1CC4F7), 1);
+ expand.CollapseMouseOverFill = new SolidFill(factory.GetColor(0x82DFFB));
+ expand.ExpandBorder = new SolidBorder(factory.GetColor(0x848484), 1);
+ expand.ExpandFill = new SolidFill(factory.GetColor(0xFFFFFF));
+ expand.ExpandMouseOverBorder = new SolidBorder(factory.GetColor(0x1CC4F7), 1);
+ expand.ExpandMouseOverFill = new SolidFill(factory.GetColor(0xCCEDFA));
+ ct.ExpandTriangle = expand;
+ // Rectangle
+ expand = new TreeExpandColorTable();
+ expand.CollapseForeground = new SolidFill(factory.GetColor(0x000000));
+ expand.CollapseBorder = new SolidBorder(factory.GetColor(0x969696), 1);
+ expand.CollapseFill = new GradientFill(new ColorStop[]{
+ new ColorStop(factory.GetColor(0xFFFFFF), 0f), new ColorStop(factory.GetColor(0xFFFFFF), .40f), new ColorStop(factory.GetColor(0xB6B6B6), 1f)}, 45);
+ expand.CollapseMouseOverForeground = expand.CollapseForeground;
+ expand.CollapseMouseOverBorder = expand.CollapseBorder;
+ expand.CollapseMouseOverFill = expand.CollapseFill;
+ expand.ExpandForeground = expand.CollapseForeground;
+ expand.ExpandBorder = expand.CollapseBorder;
+ expand.ExpandFill = expand.CollapseFill;
+ expand.ExpandMouseOverForeground = expand.CollapseForeground;
+ expand.ExpandMouseOverBorder = expand.CollapseBorder;
+ expand.ExpandMouseOverFill = expand.CollapseFill;
+ ct.ExpandRectangle = expand;
+ ct.ExpandEllipse = expand;
+ #endregion
+
+ #region Misc Tree Color
+ ct.GridLines = factory.GetColor(0xE1E1E1);
+ #endregion
+ }
+ #endregion
+
+ #region Office 2007 Black
+ public static void InitOffice2007Black(TreeColorTable ct, ColorFactory factory)
+ {
+ #region Tree Selection
+ TreeSelectionColors treeSelection = new TreeSelectionColors();
+ ct.Selection = treeSelection;
+ // Highlight full row
+ SelectionColorTable selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(0xA7CDF0));
+ treeSelection.FullRowSelect = selColorTable;
+ // Highlight full row Inactive
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(0xE5E5E5));
+ treeSelection.FullRowSelectInactive = selColorTable;
+
+ // Node Marker
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(64, 0x316AC5));
+ selColorTable.Border = new SolidBorder(factory.GetColor(96, 0x316AC5), 1);
+ treeSelection.NodeMarker = selColorTable;
+ // Node marker inactibe
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(64, 0xE5E5E5));
+ selColorTable.Border = new SolidBorder(factory.GetColor(96, 0x000000), 1);
+ treeSelection.NodeMarkerInactive = selColorTable;
+
+ // Cell selection
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(new ColorStop[] {
+ new ColorStop(factory.GetColor(0xFFFCD9), 0f),
+ new ColorStop(factory.GetColor(0xFFE78D), .4f),
+ new ColorStop(factory.GetColor(0xFFD748), .4f),
+ new ColorStop(factory.GetColor(0xFFE793), 1f)
+ });
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xDDCF9B), 1);
+ selColorTable.BorderCornerRadius = 2;
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(192, 0xFFF2BE), 1);
+ //selColorTable = new SelectionColorTable();
+ //selColorTable.Fill = new GradientFill(factory.GetColor(0xF6FBFD), factory.GetColor(0xD5EFFC), 90);
+ //selColorTable.Border = new SolidBorder(factory.GetColor(0x99DEFD), 1);
+ //selColorTable.InnerBorder = new SolidBorder(factory.GetColor(192, 0xFFFFFF), 1);
+ treeSelection.HighlightCells = selColorTable;
+ // Cell selection inactive
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(factory.GetColor(0xFAFAFB), factory.GetColor(0xE5E5E5), 90);
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xD9D9D9), 1);
+ selColorTable.BorderCornerRadius = 2;
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(228, 0xFFFFFF), 1);
+ treeSelection.HighlightCellsInactive = selColorTable;
+
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(factory.GetColor(0xFAFAFB), factory.GetColor(0xE5E5E5), 90);
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xD9D9D9), 1);
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(228, 0xFFFFFF), 1);
+ treeSelection.NodeHotTracking = selColorTable;
+ #endregion
+
+ #region Expand Buttons
+ TreeExpandColorTable expand = new TreeExpandColorTable();
+ expand.CollapseBorder = new SolidBorder(factory.GetColor(0x000000), 1);
+ expand.CollapseFill = new SolidFill(factory.GetColor(0x595959));
+ expand.CollapseMouseOverBorder = new SolidBorder(factory.GetColor(0x1CC4F7), 1);
+ expand.CollapseMouseOverFill = new SolidFill(factory.GetColor(0x82DFFB));
+ expand.ExpandBorder = new SolidBorder(factory.GetColor(0x848484), 1);
+ expand.ExpandFill = new SolidFill(factory.GetColor(0xFFFFFF));
+ expand.ExpandMouseOverBorder = new SolidBorder(factory.GetColor(0x1CC4F7), 1);
+ expand.ExpandMouseOverFill = new SolidFill(factory.GetColor(0xCCEDFA));
+ ct.ExpandTriangle = expand;
+ // Rectangle
+ expand = new TreeExpandColorTable();
+ expand.CollapseForeground = new SolidFill(factory.GetColor(0x000000));
+ expand.CollapseBorder = new SolidBorder(factory.GetColor(0x969696), 1);
+ expand.CollapseFill = new GradientFill(new ColorStop[]{
+ new ColorStop(factory.GetColor(0xFFFFFF), 0f), new ColorStop(factory.GetColor(0xFFFFFF), .40f), new ColorStop(factory.GetColor(0xB6B6B6), 1f)}, 45);
+ expand.CollapseMouseOverForeground = expand.CollapseForeground;
+ expand.CollapseMouseOverBorder = expand.CollapseBorder;
+ expand.CollapseMouseOverFill = expand.CollapseFill;
+ expand.ExpandForeground = expand.CollapseForeground;
+ expand.ExpandBorder = expand.CollapseBorder;
+ expand.ExpandFill = expand.CollapseFill;
+ expand.ExpandMouseOverForeground = expand.CollapseForeground;
+ expand.ExpandMouseOverBorder = expand.CollapseBorder;
+ expand.ExpandMouseOverFill = expand.CollapseFill;
+ ct.ExpandRectangle = expand;
+ ct.ExpandEllipse = expand;
+ #endregion
+
+ #region Misc Tree Color
+ ct.GridLines = factory.GetColor(0xE1E1E1);
+ #endregion
+ }
+ #endregion
+
+ #region Office 2007 Vista Glass
+ public static void InitOffice2007VistaGlass(TreeColorTable ct, ColorFactory factory)
+ {
+ #region Tree Selection
+ TreeSelectionColors treeSelection = new TreeSelectionColors();
+ ct.Selection = treeSelection;
+ // Highlight full row
+ SelectionColorTable selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(0xC4E8FA));
+ treeSelection.FullRowSelect = selColorTable;
+ // Highlight full row Inactive
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(0xE5E5E5));
+ treeSelection.FullRowSelectInactive = selColorTable;
+
+ // Node Marker
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(64, 0x316AC5));
+ selColorTable.Border = new SolidBorder(factory.GetColor(96, 0x316AC5), 1);
+ treeSelection.NodeMarker = selColorTable;
+ // Node marker inactive
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new SolidFill(factory.GetColor(64, 0xE5E5E5));
+ selColorTable.Border = new SolidBorder(factory.GetColor(96, 0x000000), 1);
+ treeSelection.NodeMarkerInactive = selColorTable;
+
+ // Cell selection
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(new ColorStop[] {
+ new ColorStop(factory.GetColor(0xF1F8FD), 0f),
+ new ColorStop(factory.GetColor(0xD5EFFC), 1f)
+ });
+ selColorTable.Border = new SolidBorder(factory.GetColor(0x99DEFD), 1);
+ selColorTable.BorderCornerRadius = 2;
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(192, 0xF6FBFD), 1);
+ //selColorTable = new SelectionColorTable();
+ //selColorTable.Fill = new GradientFill(factory.GetColor(0xF6FBFD), factory.GetColor(0xD5EFFC), 90);
+ //selColorTable.Border = new SolidBorder(factory.GetColor(0x99DEFD), 1);
+ //selColorTable.InnerBorder = new SolidBorder(factory.GetColor(192, 0xFFFFFF), 1);
+ treeSelection.HighlightCells = selColorTable;
+ // Cell selection inactive
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(factory.GetColor(0xF8F8F8), factory.GetColor(0xE5E5E5), 90);
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xD9D9D9), 1);
+ selColorTable.BorderCornerRadius = 2;
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(228, 0xFAFAFB), 1);
+ treeSelection.HighlightCellsInactive = selColorTable;
+
+ selColorTable = new SelectionColorTable();
+ selColorTable.Fill = new GradientFill(factory.GetColor(0xF5FAFD), factory.GetColor(0xE8F5FD), 90);
+ selColorTable.Border = new SolidBorder(factory.GetColor(0xD8F0FA), 1);
+ selColorTable.InnerBorder = new SolidBorder(factory.GetColor(228, 0xF8FCFE), 1);
+ treeSelection.NodeHotTracking = selColorTable;
+ #endregion
+
+ #region Expand Buttons
+ TreeExpandColorTable expand = new TreeExpandColorTable();
+ expand.CollapseBorder = new SolidBorder(factory.GetColor(0x000000), 1);
+ expand.CollapseFill = new SolidFill(factory.GetColor(0x595959));
+ expand.CollapseMouseOverBorder = new SolidBorder(factory.GetColor(0x1CC4F7), 1);
+ expand.CollapseMouseOverFill = new SolidFill(factory.GetColor(0x82DFFB));
+ expand.ExpandBorder = new SolidBorder(factory.GetColor(0x848484), 1);
+ expand.ExpandFill = new SolidFill(factory.GetColor(0xFFFFFF));
+ expand.ExpandMouseOverBorder = new SolidBorder(factory.GetColor(0x1CC4F7), 1);
+ expand.ExpandMouseOverFill = new SolidFill(factory.GetColor(0xCCEDFA));
+ ct.ExpandTriangle = expand;
+ // Rectangle
+ expand = new TreeExpandColorTable();
+ expand.CollapseForeground = new SolidFill(factory.GetColor(0x000000));
+ expand.CollapseBorder = new SolidBorder(factory.GetColor(0x969696), 1);
+ expand.CollapseFill = new GradientFill(new ColorStop[]{
+ new ColorStop(factory.GetColor(0xFFFFFF), 0f), new ColorStop(factory.GetColor(0xFFFFFF), .40f), new ColorStop(factory.GetColor(0xB6B6B6), 1f)}, 45);
+ expand.CollapseMouseOverForeground = expand.CollapseForeground;
+ expand.CollapseMouseOverBorder = expand.CollapseBorder;
+ expand.CollapseMouseOverFill = expand.CollapseFill;
+ expand.ExpandForeground = expand.CollapseForeground;
+ expand.ExpandBorder = expand.CollapseBorder;
+ expand.ExpandFill = expand.CollapseFill;
+ expand.ExpandMouseOverForeground = expand.CollapseForeground;
+ expand.ExpandMouseOverBorder = expand.CollapseBorder;
+ expand.ExpandMouseOverFill = expand.CollapseFill;
+ ct.ExpandRectangle = expand;
+ ct.ExpandEllipse = expand;
+ #endregion
+
+ #region Misc Tree Color
+ ct.GridLines = factory.GetColor(0xEDEDED);
+ #endregion
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/ColumnHeaderDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/ColumnHeaderDisplay.cs
new file mode 100644
index 00000000..13dc9d8c
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/ColumnHeaderDisplay.cs
@@ -0,0 +1,119 @@
+using System;
+using System.Text;
+using DevComponents.DotNetBar;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.AdvTree.Display
+{
+ internal class ColumnHeaderDisplay
+ {
+ internal void DrawColumnHeader(ColumnHeaderRendererEventArgs e, ElementStyleDisplayInfo di)
+ {
+ // Adjust the header bounds so the header is filled completely
+ if (e.Tree != null && e.Tree.CellHorizontalSpacing > 0 && !e.ColumnHeader.IsFirstVisible) {
+ Rectangle ob = di.Bounds;
+ di.Bounds = new Rectangle(ob.X - e.Tree.CellHorizontalSpacing, ob.Y, ob.Width + e.Tree.CellHorizontalSpacing, ob.Height);
+ ElementStyleDisplay.Paint(di);
+ di.Bounds = ob;
+ }
+ else
+ ElementStyleDisplay.Paint(di);
+ di.Bounds.Inflate(-1, -1);
+ if (di.Bounds.Width > 1 && di.Bounds.Height > 1)
+ {
+ if (e.ColumnHeader.IsFirstVisible)
+ {
+ Rectangle r = di.Bounds;
+ r.Width -= 3;
+ r.X += 3;
+ di.Bounds = r;
+ }
+
+ if (e.ColumnHeader.SortDirection != eSortDirection.None && !e.SortIndicatorColor.IsEmpty)
+ {
+ using (GraphicsPath sortShapePath = UIGraphics.GetTrianglePath(
+ new Point(di.Bounds.Right - 11, di.Bounds.Y + (di.Bounds.Height - 5) / 2), 9,
+ (e.ColumnHeader.SortDirection == eSortDirection.Ascending ? eTriangleDirection.Top : eTriangleDirection.Bottom)))
+ {
+ SmoothingMode sm = e.Graphics.SmoothingMode;
+ e.Graphics.SmoothingMode = SmoothingMode.Default;
+ using (SolidBrush brush = new SolidBrush(e.SortIndicatorColor))
+ e.Graphics.FillPath(brush, sortShapePath);
+ e.Graphics.SmoothingMode = sm;
+ }
+ di.Bounds.Width -= 12;
+ }
+
+ if (e.ColumnHeader.Image != null)
+ {
+ Image image = e.ColumnHeader.Image;
+ Rectangle r = di.Bounds;
+ if (e.ColumnHeader.ImageAlignment == eColumnImageAlignment.Left)
+ {
+ e.Graphics.DrawImage(image, r.X,
+ r.Y + (r.Height - image.Height) / 2, image.Width, image.Height);
+ r.X += image.Width + 2;
+ r.Width -= image.Width + 2;
+
+ }
+ else if (e.ColumnHeader.ImageAlignment == eColumnImageAlignment.Right)
+ {
+ e.Graphics.DrawImage(image, r.Right - image.Width,
+ r.Y + (r.Height - image.Height) / 2, image.Width, image.Height);
+ r.Width -= image.Width + 2;
+ }
+ di.Bounds = r;
+ }
+
+ ElementStyleDisplay.PaintText(di, e.ColumnHeader.Text, e.Tree.Font);
+ }
+ }
+
+ internal static void PaintColumnMoveMarker(Graphics g, AdvTree tree, int columnMoveMarkerIndex, ColumnHeaderCollection columns)
+ {
+ if (columnMoveMarkerIndex == -1) throw new ArgumentException("columnMoveMarkerIndex must be grater or equal than 0");
+ if (columns == null) throw new ArgumentNullException("columns");
+
+ Color lineColor = ColorScheme.GetColor("834DD5");
+ Color fillColor = ColorScheme.GetColor("CCCFF8");
+ Size markerSize = new Size(10, 14);
+
+ ColumnHeader header = null;
+
+ if (columnMoveMarkerIndex == columns.Count)
+ header = columns.LastVisibleColumn;
+ else
+ header = columns[columnMoveMarkerIndex];
+ Rectangle markerBounds = Rectangle.Empty;
+ if (columnMoveMarkerIndex == columns.Count)
+ markerBounds = new Rectangle(header.Bounds.Right - markerSize.Width, header.Bounds.Bottom - markerSize.Height, markerSize.Width, markerSize.Height);
+ else if (columns[columnMoveMarkerIndex] == columns.FirstVisibleColumn)
+ markerBounds = new Rectangle(header.Bounds.X, header.Bounds.Bottom - markerSize.Height, markerSize.Width, markerSize.Height);
+ else
+ markerBounds = new Rectangle(header.Bounds.X - markerSize.Width / 2 - tree.NodeLayout.GetCellLayout().LayoutSettings.CellHorizontalSpacing, header.Bounds.Bottom - markerSize.Height, markerSize.Width, markerSize.Height);
+ if (tree.AutoScrollPosition.X != 0)
+ markerBounds.Offset(tree.AutoScrollPosition.X, 0);
+ using (GraphicsPath path = CreateMarker(markerBounds))
+ {
+ using (SolidBrush brush = new SolidBrush(fillColor))
+ g.FillPath(brush, path);
+ using (Pen pen = new Pen(lineColor, 1))
+ g.DrawPath(pen, path);
+ }
+ }
+ private static GraphicsPath CreateMarker(Rectangle markerBounds)
+ {
+ markerBounds.Height--;
+ GraphicsPath path = new GraphicsPath();
+ path.AddLine(markerBounds.X + markerBounds.Width / 2, markerBounds.Bottom, markerBounds.X, markerBounds.Bottom - markerBounds.Width / 2);
+ path.AddLine(markerBounds.X, markerBounds.Bottom - markerBounds.Width / 2, markerBounds.X + markerBounds.Width / 3, markerBounds.Bottom - markerBounds.Width / 2);
+ path.AddLine(markerBounds.X + markerBounds.Width / 3, markerBounds.Bottom - markerBounds.Width / 2, markerBounds.X + markerBounds.Width / 3, markerBounds.Y);
+ path.AddLine(markerBounds.X + markerBounds.Width / 3, markerBounds.Y, markerBounds.Right - markerBounds.Width / 3, markerBounds.Y);
+ path.AddLine(markerBounds.Right - markerBounds.Width / 3, markerBounds.Y, markerBounds.Right - markerBounds.Width / 3, markerBounds.Bottom - markerBounds.Width / 2);
+ path.AddLine(markerBounds.Right - markerBounds.Width / 3, markerBounds.Bottom - markerBounds.Width / 2, markerBounds.Right, markerBounds.Bottom - markerBounds.Width / 2);
+ path.CloseAllFigures();
+ return path;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/ColumnHeaderRendererEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/ColumnHeaderRendererEventArgs.cs
new file mode 100644
index 00000000..06765d91
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/ColumnHeaderRendererEventArgs.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Text;
+using System.Drawing;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Provides data for RenderColumnHeader event.
+ ///
+ public class ColumnHeaderRendererEventArgs : EventArgs
+ {
+ ///
+ /// Gets the column header that is rendered.
+ ///
+ public ColumnHeader ColumnHeader = null;
+ ///
+ /// Target Graphics canvas.
+ ///
+ public Graphics Graphics;
+ ///
+ /// Gets the bounds of the column header.
+ ///
+ public Rectangle Bounds;
+ ///
+ /// Gets the effective style for the column.
+ ///
+ public ElementStyle Style = null;
+ ///
+ /// Gets the AdvTree control header is rendered for.
+ ///
+ public AdvTree Tree = null;
+ ///
+ /// Gets or sets the color of the column sort indicator.
+ ///
+ public Color SortIndicatorColor = Color.Empty;
+
+ ///
+ /// Initializes a new instance of the ColumnHeaderRendererEventArgs class.
+ ///
+ public ColumnHeaderRendererEventArgs()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the ColumnHeaderRendererEventArgs class.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public ColumnHeaderRendererEventArgs(AdvTree tree, ColumnHeader columnHeader, Graphics graphics, Rectangle bounds, ElementStyle style)
+ {
+ Tree = tree;
+ ColumnHeader = columnHeader;
+ Graphics = graphics;
+ Bounds = bounds;
+ Style = style;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/ConnectorRendererEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/ConnectorRendererEventArgs.cs
new file mode 100644
index 00000000..599bad6d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/ConnectorRendererEventArgs.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Drawing;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Represents helper class for node connector display.
+ ///
+ public class ConnectorRendererEventArgs:EventArgs
+ {
+ ///
+ /// From node reference.
+ ///
+ public Node FromNode=null;
+ ///
+ /// From node style reference.
+ ///
+ public ElementStyle StyleFromNode=null;
+ ///
+ /// To node reference.
+ ///
+ public Node ToNode=null;
+ ///
+ /// To node style reference.
+ ///
+ public ElementStyle StyleToNode=null;
+ ///
+ /// Graphics object used for drawing.
+ ///
+ public System.Drawing.Graphics Graphics=null;
+ ///
+ /// Node offset since some node coordinates are relative.
+ ///
+ public Point Offset=Point.Empty;
+ ///
+ /// Indicates whether from node is a root node.
+ ///
+ public bool IsRootNode=false;
+ ///
+ /// Reference to node connector object that describes connector type.
+ ///
+ public NodeConnector NodeConnector=null;
+ ///
+ /// Gets or sets whether connector is link connector.
+ ///
+ public bool LinkConnector=false;
+ ///
+ /// Reference to the collection of the connector path points. Default value is null indicating there are no path points.
+ ///
+ public ConnectorPointsCollection ConnectorPoints=null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/DragDropMarkerDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/DragDropMarkerDisplay.cs
new file mode 100644
index 00000000..c4dca5a4
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/DragDropMarkerDisplay.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.AdvTree.Display
+{
+ internal class DragDropMarkerDisplay
+ {
+ public void DrawMarker(DragDropMarkerRendererEventArgs e)
+ {
+ Graphics g = e.Graphics;
+ Rectangle bounds = e.Bounds;
+ if (bounds.IsEmpty || _MarkerColor.IsEmpty) return;
+
+ if (bounds.Width == AdvTree.DragInsertMarkSize) // Vertical insert mark
+ {
+ using (SolidBrush brush = new SolidBrush(_MarkerColor))
+ {
+ using (Pen pen = new Pen(brush, 1))
+ {
+ Point p = new Point(bounds.X + 4, bounds.Y);
+ g.DrawLine(pen, p.X, p.Y, p.X, bounds.Bottom - 1);
+ }
+
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddLine(bounds.X, bounds.Y, bounds.X + 8, bounds.Y );
+ path.AddLine(bounds.X + 8, bounds.Y, bounds.X + 4, bounds.Y + 4);
+ path.CloseAllFigures();
+ g.FillPath(brush, path);
+ }
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddLine(bounds.X, bounds.Bottom, bounds.X + 8, bounds.Bottom);
+ path.AddLine(bounds.X + 8, bounds.Bottom, bounds.X + 4, bounds.Bottom - 4);
+ path.CloseAllFigures();
+ g.FillPath(brush, path);
+ }
+ }
+ }
+ else
+ {
+ // Horizontal insert mark
+ using (SolidBrush brush = new SolidBrush(_MarkerColor))
+ {
+ using (Pen pen = new Pen(brush, 1))
+ {
+ Point p = new Point(bounds.X, bounds.Y + 4);
+ g.DrawLine(pen, p.X, p.Y, bounds.Right - 1, p.Y);
+ }
+
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddLine(bounds.X, bounds.Y, bounds.X, bounds.Y + 8);
+ path.AddLine(bounds.X, bounds.Y + 8, bounds.X + 4, bounds.Y + 4);
+ path.CloseAllFigures();
+ g.FillPath(brush, path);
+ }
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddLine(bounds.Right, bounds.Y, bounds.Right, bounds.Y + 8);
+ path.AddLine(bounds.Right, bounds.Y + 8, bounds.Right - 4, bounds.Y + 4);
+ path.CloseAllFigures();
+ g.FillPath(brush, path);
+ }
+ }
+ }
+ }
+
+ private Color _MarkerColor;
+ public Color MarkerColor
+ {
+ get { return _MarkerColor; }
+ set { _MarkerColor = value; }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/DragDropMarkerRendererEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/DragDropMarkerRendererEventArgs.cs
new file mode 100644
index 00000000..a2cfecb5
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/DragDropMarkerRendererEventArgs.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Text;
+using System.Drawing;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Provides data for the NodeRenderer.RenderDragDropMarker event.
+ ///
+ public class DragDropMarkerRendererEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets reference to Graphics object, canvas node is rendered on.
+ ///
+ public System.Drawing.Graphics Graphics = null;
+ ///
+ /// Gets or sets the selection bounds.
+ ///
+ public Rectangle Bounds = Rectangle.Empty;
+
+ ///
+ /// Initializes a new instance of the DragDropMarkerRendererEventArgs class.
+ ///
+ public DragDropMarkerRendererEventArgs()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the DragDropMarkerRendererEventArgs class.
+ ///
+ ///
+ ///
+ public DragDropMarkerRendererEventArgs(System.Drawing.Graphics graphics, Rectangle bounds)
+ {
+ Graphics = graphics;
+ Bounds = bounds;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/LineConnectorDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/LineConnectorDisplay.cs
new file mode 100644
index 00000000..45651c23
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/LineConnectorDisplay.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using DevComponents.AdvTree.Display;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Represents the line connector display class.
+ ///
+ public class LineConnectorDisplay:NodeConnectorDisplay
+ {
+ ///
+ /// Draws connector line between two nodes.
+ ///
+ /// Connector context information.
+ public override void DrawConnector(ConnectorRendererEventArgs info)
+ {
+ if(info.NodeConnector.LineColor.IsEmpty || info.NodeConnector.LineWidth<=0)
+ return;
+
+ Point pStart, pEnd;
+
+ // FromNode is null when connector is rendered for the child node
+ if (info.FromNode == null)
+ {
+ Rectangle cellBounds = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, info.ToNode, info.Offset);
+ Rectangle expandBounds = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandBounds, info.ToNode, info.Offset);
+ pStart = new Point(cellBounds.X - 4, cellBounds.Y + cellBounds.Height / 2);
+ pEnd = new Point(expandBounds.X + expandBounds.Width / 2, pStart.Y);
+ }
+ else
+ {
+ // FromNode is parent node, ToNode is last visible child node. Connector is vertical line from parent to last visible child
+ Rectangle cellBounds = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, info.FromNode, info.Offset);
+ Rectangle expandBounds = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandBounds, info.ToNode, info.Offset);
+ pStart = new Point(expandBounds.X + expandBounds.Width / 2, cellBounds.Bottom);
+ pEnd = new Point(pStart.X, expandBounds.Y + expandBounds.Height / 2);
+ }
+
+ Graphics g = info.Graphics;
+ using (Pen pen = GetLinePen(info))
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ if (pen.DashStyle != DashStyle.Solid)
+ g.SmoothingMode = SmoothingMode.Default;
+ g.DrawLine(pen, pStart, pEnd);
+ g.SmoothingMode = sm;
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeCellRendererEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeCellRendererEventArgs.cs
new file mode 100644
index 00000000..62ca06b0
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeCellRendererEventArgs.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Drawing;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Provides information for cell rendering methods and events.
+ ///
+ public class NodeCellRendererEventArgs:NodeRendererEventArgs
+ {
+ ///
+ /// Gets or sets the cell being rendered.
+ ///
+ public Cell Cell=null;
+
+ ///
+ /// Gets or sets absolute cell bounds.
+ ///
+ public Rectangle CellBounds=Rectangle.Empty;
+
+ ///
+ /// Gets or sets the internal cell offset.
+ ///
+ internal Point CellOffset=Point.Empty;
+
+ ///
+ /// Gets or sets the color scheme.
+ ///
+ internal ColorScheme ColorScheme = null;
+
+ internal Image CheckBoxImageChecked = null;
+ internal Image CheckBoxImageUnChecked = null;
+ internal Image CheckBoxImageIndeterminate = null;
+ internal ItemPaintArgs ItemPaintArgs = null;
+
+ ///
+ /// Creates new instance of the class.
+ ///
+ public NodeCellRendererEventArgs():base(null,null,Rectangle.Empty,null)
+ {
+ }
+
+ ///
+ /// Creates new instance of the class and initializes it with default values.
+ ///
+ /// Reference to graphics object.
+ /// Reference to context node.
+ /// Reference to node bounds
+ /// Reference to cell style
+ /// Reference to cell
+ /// Reference to cell bounds
+ public NodeCellRendererEventArgs(Graphics g, Node node, Rectangle bounds, ElementStyle style, Cell cell, Rectangle cellBounds):base(g,node,bounds,style)
+ {
+ this.Cell = cell;
+ this.CellBounds = cellBounds;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeConnectorDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeConnectorDisplay.cs
new file mode 100644
index 00000000..63231b26
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeConnectorDisplay.cs
@@ -0,0 +1,511 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.AdvTree
+{
+ namespace Display
+ {
+ ///
+ /// Base class for drawing node connectors.
+ ///
+ public abstract class NodeConnectorDisplay
+ {
+ //private bool m_RootNode=false;
+ //private bool m_DrawRootAllLevels=false;
+ //private bool m_EndCap=true;
+ //private bool m_DrawConnectorUnderNodes=true;
+
+ ///
+ /// Creates new instance of the object.
+ ///
+ public NodeConnectorDisplay()
+ {
+ }
+
+ ///
+ /// Draws connector line between two nodes.
+ ///
+ /// Connector context information.
+ public virtual void DrawConnector(ConnectorRendererEventArgs info){}
+
+ /////
+ ///// Returns the connector starting coordinates.
+ /////
+ ///// Connector display information.
+ ///// Point object.
+ //protected virtual Point GetStartPoint(ConnectorRendererEventArgs info)
+ //{
+ // Point p=Point.Empty;
+
+ // if(info.IsRootNode)
+ // {
+ // //int toMidPoint=info.ToNode.Bounds.Top+info.ToNode.Bounds.Height/2;
+ // //if(info.FromNode.Bounds.Top>toMidPoint)
+ // if(IsAbove(info.FromNode,info.ToNode))
+ // p=new Point(info.FromNode.BoundsRelative.Left+info.FromNode.BoundsRelative.Width/2,info.FromNode.BoundsRelative.Top);
+ // //else if(info.FromNode.Bounds.Bottom
+ ///// Returns true if fromNode is above the toNode.
+ /////
+ ///// From Node object.
+ ///// To Node object
+ ///// True if fromNode is above toNode.
+ //protected bool IsAbove(Node fromNode, Node toNode)
+ //{
+ // //int toMidPoint=toNode.Bounds.Top+toNode.Bounds.Height/2;
+ // //if(fromNode.Bounds.Top>toMidPoint)
+ // if(fromNode.BoundsRelative.Top>toNode.BoundsRelative.Bottom)
+ // return true;
+ // return false;
+ //}
+
+ /////
+ ///// Returns true if fromNode is below toNode.
+ /////
+ ///// From Node object.
+ ///// To Node object.
+ ///// True if fromNode is below toNode.
+ //protected bool IsBelow(Node fromNode, Node toNode)
+ //{
+ // int toMidPoint=toNode.BoundsRelative.Top+toNode.BoundsRelative.Height/2;
+ // if(fromNode.BoundsRelative.Bottom
+ ///// Returns whether connector is extended to underline the node.
+ /////
+ ///// Refernce to Node style.
+ ///// True if node should be underlined by connector.
+ //protected bool UnderlineNode(ElementStyle nodeStyle)
+ //{
+ // if(!nodeStyle.PaintBottomBorder && !nodeStyle.PaintTopBorder &&
+ // !nodeStyle.PaintLeftBorder && !nodeStyle.PaintRightBorder)
+ // return true;
+ // return false;
+ //}
+
+ /////
+ ///// Returns the connector end point. The array of end points. Two valid points will be returned if node needs to be underlined by connector.
+ /////
+ ///// Connector display info.
+ ///// Array of point objects.
+ //protected Point[] GetEndPoint(ConnectorRendererEventArgs info)
+ //{
+ // // If to element is to the right of the from node and has left border end point is the vertical mid-point
+ // // If to element is to the left of the from node and has right border end point is the vertical mid-point
+ // // If there is no border end point is text bottom
+ // // If this is link connector the end point is the middle bottom or top point of the node
+
+ // Point p=Point.Empty;
+ // Point pLineEnd=Point.Empty;
+ // int capWidthOffset = 0; // GetCapWidthOffset(info.NodeConnector.EndCap, info.NodeConnector.EndCapSize);
+ // bool leftSide=this.IsOnLeftSide(info.FromNode,info.ToNode);
+
+ // if(info.LinkConnector && info.FromNode.BoundsRelative.Top>info.ToNode.BoundsRelative.Bottom)
+ // p=new Point(info.ToNode.BoundsRelative.X+info.ToNode.BoundsRelative.Width/2+(leftSide?capWidthOffset:-capWidthOffset),info.ToNode.BoundsRelative.Bottom+1);
+ // else if(info.LinkConnector && info.FromNode.BoundsRelative.Bottom
+ ///// Returns the offest for the node connector cap.
+ /////
+ ///// Cap type.
+ ///// Cap size.
+ /////
+ //protected int GetCapWidthOffset(eConnectorCap cap,Size size)
+ //{
+ // int capWidthOffset=0;
+ // switch(cap)
+ // {
+ // case eConnectorCap.Arrow:
+ // capWidthOffset=size.Width+1;
+ // break;
+ // case eConnectorCap.Ellipse:
+ // capWidthOffset=size.Width;
+ // break;
+ // }
+ // return capWidthOffset;
+ //}
+
+ /////
+ ///// Returns true if source node is on the left side of the target node.
+ /////
+ ///// Reference to source node.
+ ///// Reference to target node.
+ ///// True if source is on the left side of target.
+ //protected bool IsOnLeftSide(Node source, Node target)
+ //{
+ // if((source.BoundsRelative.Left+source.BoundsRelative.Width/2)>target.BoundsRelative.Left)
+ // return true;
+ // return false;
+ //}
+
+ ///
+ /// Returns new instance of pen object for node connector line. Caller is responsible for
+ /// disposing of this object.
+ ///
+ /// Node connector display info.
+ /// New instance of Pen object.
+ protected Pen GetLinePen(ConnectorRendererEventArgs info)
+ {
+ Pen pen = new Pen(info.NodeConnector.LineColor, info.NodeConnector.LineWidth);
+ pen.DashStyle = info.NodeConnector.DashStyle;
+ return pen;
+ }
+
+ /////
+ ///// Returns new instance of pen object for the end node connector line. Caller is responsible for
+ ///// disposing of this object.
+ /////
+ ///// Node connector display info.
+ ///// New instance of Pen object.
+ //protected Pen GetEndLinePen(ConnectorRendererEventArgs info)
+ //{
+ // return new Pen(info.NodeConnector.LineColor,EndLineWidth);
+ //}
+
+ /////
+ ///// Returns new instance of pen object for the node underline line. Caller is responsible for
+ ///// disposing of this object.
+ /////
+ ///// Node connector display info.
+ ///// New instance of Pen object.
+ //protected Pen GetEndUnderlinePen(ConnectorRendererEventArgs info)
+ //{
+ // return new Pen(info.NodeConnector.LineColor,EndLineWidth);
+ //}
+
+ //private int EndLineWidth
+ //{
+ // get {return 1;}
+ //}
+
+// ///
+// /// Draws straight line connector between start and end point.
+// ///
+// /// Node connector display info.
+// /// Start point.
+// /// End point.
+// /// Underline end point if any.
+// protected void DrawStraightLineConnector(ConnectorRendererEventArgs info, Point pStart, Point pEnd)
+// {
+// using (Pen pen = this.GetLinePen(info))
+// {
+// if (pen.DashStyle != DashStyle.Solid)
+// {
+// SmoothingMode sm = info.Graphics.SmoothingMode;
+// info.Graphics.SmoothingMode = SmoothingMode.Default;
+// info.Graphics.DrawLine(pen, pStart, pEnd);
+// info.Graphics.SmoothingMode = sm;
+// }
+// else
+// info.Graphics.DrawLine(pen, pStart, pEnd);
+// }
+// }
+
+// ///
+// /// Draws straight line connector between start and end point.
+// ///
+// /// Node connector display info.
+// /// Start point.
+// /// End point.
+// /// Underline end point if any.
+// protected void DrawLineConnector(ConnectorRendererEventArgs info,Point pStart,Point pEnd, Point pEndUnderLine)
+// {
+// if(info.NodeConnector.LineWidth>1)
+// {
+// // Merge lines nicely by filling and creating path...
+// int rootLineWidth=this.EndLineWidth;
+// int lineWidth=info.NodeConnector.LineWidth;
+
+// using(Brush brush=GetLineBrush(info))
+// {
+// GraphicsPath path=GetConnectingPath(pStart,pEnd,lineWidth,rootLineWidth,info.IsRootNode,!(IsAbove(info.FromNode,info.ToNode) || IsBelow(info.FromNode,info.ToNode)));
+// info.Graphics.FillPath(brush,path);
+// }
+// }
+// else
+// {
+// using(Pen pen=this.GetLinePen(info))
+// {
+// info.Graphics.DrawLine(pen,pStart,pEnd);
+// }
+// }
+
+// if(!pEndUnderLine.IsEmpty)
+// {
+// using(Pen pen=this.GetEndUnderlinePen(info))
+// {
+// info.Graphics.DrawLine(pen,pEnd,pEndUnderLine);
+// }
+// }
+// }
+
+// private GraphicsPath GetConnectingPath(Point pStart, Point pEnd, int lineStartWidth, int lineEndWidth, bool bRoot, bool bRootSide)
+// {
+// int direction=1;
+// if(pStart.X>pEnd.X)
+// direction=-1;
+// lineStartWidth++;
+// lineEndWidth++;
+// GraphicsPath path=new GraphicsPath();
+// if(bRoot && !bRootSide)
+// {
+// path.AddLine(pStart.X,pStart.Y,pStart.X+lineStartWidth*direction,pStart.Y);
+//// if(direction>0)
+//// path.AddLine(pEnd.X+lineEndWidth*direction,pEnd.Y,pEnd.X,pEnd.Y);
+//// else
+//// path.AddLine(pEnd.X,pEnd.Y,pEnd.X+lineEndWidth*direction,pEnd.Y);
+// if(direction>0)
+// {
+// path.AddLine(pStart.X+lineStartWidth*direction,pStart.Y, pEnd.X, pEnd.Y);
+// path.AddLine(pEnd.X, pEnd.Y, pEnd.X, pEnd.Y + lineEndWidth*direction);
+// path.AddLine(pEnd.X, pEnd.Y + lineEndWidth*direction, pStart.X, pStart.Y);
+// }
+// else
+// path.AddLine(pEnd.X, pEnd.Y, pEnd.X, pEnd.Y + lineEndWidth*direction);
+
+// path.CloseAllFigures();
+//// if(Math.Abs(pEnd.Y-pStart.Y)<=8)
+//// path.Widen(SystemPens.Highlight);
+// }
+// else
+// {
+// int offsetStart=lineStartWidth/2;
+// int offsetEnd=lineEndWidth/2;
+// path.AddLine(pStart.X,pStart.Y-offsetStart,pStart.X,pStart.Y+offsetStart);
+// path.AddLine(pEnd.X,pEnd.Y+offsetEnd,pEnd.X,pEnd.Y-offsetEnd);
+// path.AddLine(pEnd.X,pEnd.Y-offsetEnd,pStart.X,pStart.Y-offsetStart);
+// path.CloseAllFigures();
+// }
+
+// return path;
+// }
+
+// protected Brush GetLineBrush(ConnectorRendererEventArgs info)
+// {
+// return new SolidBrush(info.NodeConnector.LineColor);
+// }
+
+// protected void DrawEndLine(ConnectorRendererEventArgs info,Point pStart,Point pEnd,Point pEndUnderLine)
+// {
+// if(pEndUnderLine.IsEmpty)
+// {
+// switch(info.NodeConnector.EndCap)
+// {
+// case eConnectorCap.Ellipse:
+// {
+// using(Pen pen=this.GetEndLinePen(info))
+// {
+// Size endCapSize=info.NodeConnector.EndCapSize;
+// if(pStart.XpEnd.X)
+// direction=-1;
+// info.Graphics.DrawLine(pen,pEnd,new Point(pEnd.X+info.NodeConnector.EndCapSize.Width/3*direction,pEnd.Y));
+
+// Size endCapSize=info.NodeConnector.EndCapSize;
+// GraphicsPath arrow=GetArrowPath(endCapSize,pStart,pEnd);
+// info.Graphics.DrawPath(pen,arrow);
+// }
+// break;
+// }
+// }
+// }
+// else
+// {
+// using(Pen pen=this.GetEndUnderlinePen(info))
+// {
+// info.Graphics.DrawLine(pen,pEnd,pEndUnderLine);
+
+// // Connect underline to expand part
+// if(NodeDisplay.DrawExpandPart(info.ToNode))
+// {
+// Rectangle re=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandBounds,info.ToNode,info.Offset);
+// Point p2=new Point((re.X>pEndUnderLine.X?re.X:re.Right)+(re.Width/2*(re.X>pEndUnderLine.X?1:-1)),re.Bottom);
+// Point p1=new Point(p2.X,pEndUnderLine.Y+(pEndUnderLine.Y>p2.Y?(p2.Y-pEndUnderLine.Y)/2:-(p2.Y-pEndUnderLine.Y)/2));
+// info.Graphics.DrawCurve(pen,new Point[]{pEndUnderLine,p1,p2},.5f);
+// }
+// }
+// }
+// }
+
+// private GraphicsPath GetArrowPath(Size capSize,Point pStart,Point pEnd)
+// {
+// GraphicsPath path=new GraphicsPath();
+// int direction=1;
+// if(pStart.X>pEnd.X)
+// direction=-1;
+
+// pEnd.X+=(GetCapWidthOffset(eConnectorCap.Arrow,capSize)*direction);
+// path.AddLine(pEnd.X,pEnd.Y,pEnd.X-capSize.Width*direction,pEnd.Y-capSize.Height/2);
+// path.AddLine(pEnd.X-(2*capSize.Width/3*direction),pEnd.Y,pEnd.X-capSize.Width*direction,pEnd.Y+capSize.Height/2);
+
+// path.CloseAllFigures();
+// return path;
+// }
+
+ //internal virtual ConnectorPointInfo GetConnectorPointInfo(ConnectorRendererEventArgs info, Point pStart, Point pEnd)
+ //{
+ // ConnectorPointInfo pointInfo=new ConnectorPointInfo();
+
+ // int xMulti=1/*, yMulti=1*/;
+ // int lineWidth=info.NodeConnector.LineWidth;
+
+ // // used for direction control
+ // if(pStart.X>pEnd.X)
+ // xMulti=-1;
+ // //if(pStart.Y>pEnd.Y)
+ // // yMulti=-1;
+
+ // if(info.ConnectorPoints!=null)
+ // {
+ // Point connPointsOffset=info.ToNode.BoundsRelative.Location;
+ // connPointsOffset.Offset(info.Offset.X,info.Offset.Y);
+ // GraphicsPath path=new GraphicsPath();
+
+ // pointInfo.Points1=new Point[info.ConnectorPoints.Count+2];
+ // pointInfo.Points1[0]=pStart;
+ // pointInfo.Points1[pointInfo.Points1.Length-1]=pEnd;
+
+ // if(lineWidth>1)
+ // {
+ // pointInfo.Points2=new Point[info.ConnectorPoints.Count+2];
+ // pointInfo.Points2[pointInfo.Points2.Length-1]=pStart;
+ // pointInfo.Points2[0]=pEnd;
+
+ // int i=pointInfo.Points1.Length-2;
+ // int k=1;
+
+ // foreach(Point pcp in info.ConnectorPoints)
+ // {
+ // pointInfo.Points1[i]=pcp;
+ // pointInfo.Points1[i].Offset(connPointsOffset.X,connPointsOffset.Y);
+ // pointInfo.Points2[k]=new Point(pcp.X+lineWidth*xMulti,pcp.Y);
+ // pointInfo.Points2[k].Offset(connPointsOffset.X,connPointsOffset.Y);
+ // k++;
+ // i--;
+ // }
+ // }
+ // else
+ // {
+ // int i=pointInfo.Points1.Length-2;
+ // foreach(Point pcp in info.ConnectorPoints)
+ // {
+ // pointInfo.Points1[i]=pcp;
+ // pointInfo.Points1[i].Offset(connPointsOffset.X,connPointsOffset.Y);
+ // i--;
+ // }
+ // }
+ // }
+ // return pointInfo;
+ //}
+ }
+ }
+
+ ///
+ /// Represents custom connector path info.
+ ///
+ internal class ConnectorPointInfo
+ {
+ public Point[] Points1=null;
+ public Point[] Points2=null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeDisplay.cs
new file mode 100644
index 00000000..59e30afb
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeDisplay.cs
@@ -0,0 +1,351 @@
+using System;
+using System.Drawing;
+using DevComponents.AdvTree.Layout;
+using System.Collections;
+using DevComponents.DotNetBar;
+using System.ComponentModel;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Summary description for NodeDisplay.
+ ///
+ public class NodeDisplay
+ {
+ #region Private Variables
+ private Point m_Offset=Point.Empty;
+ private Point m_LockedOffset=Point.Empty;
+ private AdvTree m_Tree=null;
+ internal ArrayList _PaintedNodes = new ArrayList(100);
+#if !TRIAL
+ internal static bool keyInvalid=false;
+#endif
+ #endregion
+ /// Creates new instance of the class
+ /// Object to initialize class with.
+ public NodeDisplay(AdvTree tree)
+ {
+ m_Tree=tree;
+ }
+
+ ///
+ /// Paints the layout on canvas.
+ ///
+ public virtual void Paint(Graphics g, Rectangle clipRectangle)
+ {
+ }
+
+ ///
+ /// Gets or sets the offset of the tree content relative to the size of the container control.
+ ///
+ public virtual Point Offset
+ {
+ get
+ {
+ if(!m_LockedOffset.IsEmpty)
+ return m_LockedOffset;
+
+ Node displayNode=m_Tree.GetDisplayRootNode();
+ if(displayNode==null)
+ return Point.Empty;;
+
+ Size nodesSize = m_Tree.GetScreenSize(new Size(m_Tree.NodeLayout.Width, m_Tree.NodeLayout.Height));
+ return m_Tree.GetLayoutPosition(m_Offset);
+ }
+ set {m_Offset=value;}
+ }
+
+ /// Gets or sets whether offset is locked, i.e. cannot be changed.
+ public bool LockOffset
+ {
+ get {return (!m_LockedOffset.IsEmpty);}
+ set
+ {
+ if(value)
+ m_LockedOffset=this.Offset;
+ else
+ m_LockedOffset=Point.Empty;
+ }
+ }
+
+ ///
+ /// Sets locked offset to specific value. Point.Empty means there is no locked offset set.
+ ///
+ /// New locked offset.
+ public void SetLockedOffset(Point p)
+ {
+ m_LockedOffset=p;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public Point GetLockedOffset()
+ {
+ return m_LockedOffset;
+ }
+
+ ///
+ /// Returns the default offset for the tree content relative to the size of the container.
+ ///
+ public virtual Point DefaultOffset
+ {
+ get
+ {
+ Node displayNode=m_Tree.GetDisplayRootNode();
+ if(displayNode==null)
+ return Point.Empty;;
+
+ //if(m_Tree.NodeLayout is NodeMapLayout && m_Tree.Nodes.Count>0)
+ //{
+ // if(!m_Tree.CenterContent)
+ // return new Point(Math.Abs(displayNode.ChildNodesBounds.Left),Math.Abs(displayNode.ChildNodesBounds.Top));
+ // else
+ // return new Point(m_Tree.SelectionBoxSize+(m_Tree.Width - m_Tree.SelectionBoxSize * 2 - m_Tree.NodeLayout.Width) / 2 + Math.Abs(displayNode.ChildNodesBounds.Left),
+ // m_Tree.SelectionBoxSize + (m_Tree.Height - m_Tree.SelectionBoxSize * 2 - m_Tree.NodeLayout.Height) / 2 + Math.Abs(displayNode.ChildNodesBounds.Top));
+ //}
+ //if(m_Tree.NodeLayout is Layout.NodeDiagramLayout)
+ //{
+ // if(!m_Tree.CenterContent)
+ // return m_Tree.ClientRectangle.Location;
+ // else
+ // return new Point((m_Tree.Width-m_Tree.NodeLayout.Width)/2,(m_Tree.Height-m_Tree.NodeLayout.Height)/2);
+ //}
+ //else
+ return m_Tree.ClientRectangle.Location;
+ }
+ }
+
+ ///
+ /// Gets or sets the reference to the tree control managed by display class.
+ ///
+ protected virtual AdvTree Tree
+ {
+ get {return m_Tree;}
+ set {m_Tree=value;}
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Rectangle GetNodeRectangle(eNodeRectanglePart part, Node node, Point offset)
+ {
+ Rectangle r=Rectangle.Empty;
+ if(part==eNodeRectanglePart.CellsBounds)
+ {
+ r=node.CellsBoundsRelative;
+ if(!r.IsEmpty)
+ {
+ r.Offset(offset);
+ r.Offset(node.BoundsRelative.Location);
+ }
+ }
+ else if (part == eNodeRectanglePart.ExpandHitTestBounds)
+ {
+ Rectangle nodeBounds = GetNodeRectangle(eNodeRectanglePart.NodeBounds, node, offset);
+
+ r = node.ExpandPartRectangleRelative;
+ if (!r.IsEmpty)
+ {
+ r.Offset(offset);
+ r.Offset(node.BoundsRelative.Location);
+ }
+ r.Y = nodeBounds.Y;
+ r.Height = nodeBounds.Height;
+ r.Inflate(1, 0);
+ }
+ else if(part==eNodeRectanglePart.ExpandBounds)
+ {
+ r=node.ExpandPartRectangleRelative;
+ if(!r.IsEmpty)
+ {
+ r.Offset(offset);
+ r.Offset(node.BoundsRelative.Location);
+ }
+ }
+ else if(part==eNodeRectanglePart.CommandBounds)
+ {
+ r=node.CommandBoundsRelative;
+ if(!r.IsEmpty)
+ {
+ r.Offset(offset);
+ r.Offset(node.BoundsRelative.Location);
+ }
+ }
+ else if(part==eNodeRectanglePart.NodeContentBounds)
+ {
+ r=node.ContentBounds;
+ if(!r.IsEmpty)
+ {
+ r.Offset(offset);
+ r.Offset(node.BoundsRelative.Location);
+ }
+ }
+ else if(part==eNodeRectanglePart.NodeBounds)
+ {
+ r=node.BoundsRelative;
+ if(!r.IsEmpty)
+ r.Offset(offset);
+ }
+ else if (part == eNodeRectanglePart.ChildNodeBounds)
+ {
+ r = node.ChildNodesBounds;
+ if (!r.IsEmpty)
+ {
+ //r.Offset(node.Bounds.Location);
+ r.Offset(offset);
+ }
+ }
+ else if (part == eNodeRectanglePart.ColumnsBounds && HasColumnsVisible(node))
+ {
+ r = node.NodesColumns.Bounds;
+ if(!r.IsEmpty)
+ r.Offset(offset);
+ }
+ return r;
+ }
+
+ internal static bool HasColumnsVisible(Node node)
+ {
+ return node.Expanded && node.HasColumns && node.NodesColumnsHeaderVisible;
+ }
+
+ internal static Rectangle GetCellRectangle(eCellRectanglePart part, Cell cell, Point offset)
+ {
+ Rectangle r=Rectangle.Empty;
+
+ // If cell parent is not assigned rectangle cannot be returned.
+ if(cell.Parent==null)
+ return r;
+
+ if(part==eCellRectanglePart.CheckBoxBounds)
+ {
+ r=cell.CheckBoxBoundsRelative;
+ if(!r.IsEmpty)
+ {
+ r.Offset(offset);
+ r.Offset(cell.Parent.BoundsRelative.Location);
+ }
+ }
+ else if(part==eCellRectanglePart.ImageBounds)
+ {
+ r=cell.ImageBoundsRelative;
+ if(!r.IsEmpty)
+ {
+ r.Offset(offset);
+ r.Offset(cell.Parent.BoundsRelative.Location);
+ }
+ }
+ else if(part==eCellRectanglePart.TextBounds)
+ {
+ r=cell.TextContentBounds;
+ if(!r.IsEmpty)
+ {
+ r.Offset(offset);
+ r.Offset(cell.Parent.BoundsRelative.Location);
+ }
+ }
+ else if(part==eCellRectanglePart.CellBounds)
+ {
+ r=cell.BoundsRelative;
+ if(!r.IsEmpty)
+ {
+ r.Offset(offset);
+ r.Offset(cell.Parent.BoundsRelative.Location);
+ }
+ }
+ return r;
+ }
+
+ internal static bool DrawExpandPart(Node node)
+ {
+ if(node.Nodes.Count>0 && node.ExpandVisibility!=eNodeExpandVisibility.Hidden || node.ExpandVisibility==eNodeExpandVisibility.Visible)
+ return true;
+ return false;
+ }
+
+ protected NodeExpandDisplay GetExpandDisplay(eExpandButtonType e)
+ {
+ NodeExpandDisplay d=null;
+ switch(e)
+ {
+ case eExpandButtonType.Rectangle:
+ d = new NodeExpandRectDisplay();
+ break;
+ case eExpandButtonType.Triangle:
+ d = new NodeExpandTriangleDisplay();
+ break;
+ case eExpandButtonType.Ellipse:
+ d=new NodeExpandEllipseDisplay();
+ break;
+ case eExpandButtonType.Image:
+ d=new NodeExpandImageDisplay();
+ break;
+ }
+ return d;
+ }
+
+ protected bool IsRootNode(Node node)
+ {
+ return NodeOperations.IsRootNode(m_Tree,node);
+ }
+
+ protected ElementStyle GetDefaultNodeStyle()
+ {
+ ElementStyle style=new ElementStyle();
+ style.TextColorSchemePart=eColorSchemePart.ItemText;
+
+ return style;
+ }
+
+ public void MoveHostedControls()
+ {
+ Point offset = this.Offset;
+ float zoom = this.Tree.Zoom;
+ foreach (Cell cell in this.Tree.HostedControlCells)
+ {
+ System.Windows.Forms.Control cellHostedControl = cell.HostedControl;
+ if (cellHostedControl == null) continue;
+ Rectangle bounds = NodeDisplay.GetCellRectangle(eCellRectanglePart.TextBounds, cell, offset);
+ Rectangle screenBounds = this.Tree.GetScreenRectangle(bounds);
+ if (!bounds.IsEmpty && cellHostedControl.Bounds != screenBounds)
+ {
+ if (zoom != 1)
+ {
+ cell.HostedControlSize = bounds.Size;
+ cell.IgnoreHostedControlSizeChange = true;
+ }
+ else
+ {
+ cell.HostedControlSize = Size.Empty;
+ if (screenBounds.Height > cellHostedControl.Height && cellHostedControl.Height > 0)
+ {
+ screenBounds.Y += (screenBounds.Height - cellHostedControl.Height) / 2;
+ screenBounds.Height = cellHostedControl.Height;
+ }
+ }
+ cellHostedControl.Bounds = screenBounds;
+ if (zoom != 1)
+ cell.IgnoreHostedControlSizeChange = false;
+ if (cell.Parent != null)
+ {
+ bool visible = NodeOperations.GetIsNodeVisible(cell.Parent) && cell.IsVisible;
+ if (visible != cellHostedControl.Visible)
+ cellHostedControl.Visible = visible;
+ }
+ }
+ }
+ }
+
+ public ArrayList PaintedNodes
+ {
+ get
+ {
+ return _PaintedNodes;
+ }
+ }
+
+ internal virtual void PaintColumnHeaders(ColumnHeaderCollection columns, Graphics g, bool treeControlHeader)
+ {
+
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandDisplay.cs
new file mode 100644
index 00000000..f340c175
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandDisplay.cs
@@ -0,0 +1,139 @@
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree
+{
+ namespace Display
+ {
+ ///
+ /// Base class for node expand button display.
+ ///
+ public abstract class NodeExpandDisplay
+ {
+ /// Creates new instance of the class
+ public NodeExpandDisplay()
+ {
+ }
+
+ /// Draws expand button.
+ /// Context parameters for drawing expand button.
+ public abstract void DrawExpandButton(NodeExpandPartRendererEventArgs e);
+
+ protected Pen GetBorderPen(NodeExpandPartRendererEventArgs e)
+ {
+ if(!e.BorderColor.IsEmpty)
+ return new Pen(e.BorderColor,1);
+ if (_ColorTable != null)
+ {
+ bool expanded = e.Node.Expanded;
+ TreeExpandColorTable ct = GetExpandColorTable(e);
+ if (ct == null) return null;
+ if (expanded)
+ {
+ // Collapse node colors
+ if (!e.IsMouseOver && ct.CollapseBorder != null)
+ return ct.CollapseBorder.CreatePen();
+ else if (e.IsMouseOver && ct.CollapseMouseOverBorder != null)
+ return ct.CollapseMouseOverBorder.CreatePen();
+ }
+ else
+ {
+ // Expand node colors
+ if (!e.IsMouseOver && ct.ExpandBorder != null)
+ return ct.ExpandBorder.CreatePen();
+ else if (e.IsMouseOver && ct.ExpandMouseOverBorder != null)
+ return ct.ExpandMouseOverBorder.CreatePen();
+ }
+ }
+ return null;
+ }
+
+ private TreeExpandColorTable GetExpandColorTable(NodeExpandPartRendererEventArgs e)
+ {
+ TreeExpandColorTable ct = null;
+ if (e.ExpandButtonType == eExpandButtonType.Rectangle)
+ ct = _ColorTable.ExpandRectangle;
+ else if (e.ExpandButtonType == eExpandButtonType.Triangle)
+ ct = _ColorTable.ExpandTriangle;
+ else if (e.ExpandButtonType == eExpandButtonType.Ellipse)
+ ct = _ColorTable.ExpandEllipse;
+ return ct;
+ }
+
+ protected Pen GetExpandPen(NodeExpandPartRendererEventArgs e)
+ {
+ if (e.ExpandLineColor.IsEmpty)
+ {
+ TreeExpandColorTable ct = GetExpandColorTable(e);
+ if (ct != null)
+ {
+ bool expanded = e.Node.Expanded;
+ if (expanded)
+ {
+ // Collapse node colors
+ if (!e.IsMouseOver && ct.CollapseForeground != null)
+ return ct.CollapseForeground.CreatePen(Dpi.Width1);
+ else if (e.IsMouseOver && ct.CollapseMouseOverForeground != null)
+ return ct.CollapseMouseOverForeground.CreatePen(Dpi.Width1);
+ }
+ else
+ {
+ // Collapse node colors
+ if (!e.IsMouseOver && ct.ExpandForeground != null)
+ return ct.ExpandForeground.CreatePen(Dpi.Width1);
+ else if (e.IsMouseOver && ct.ExpandMouseOverForeground != null)
+ return ct.ExpandMouseOverForeground.CreatePen(Dpi.Width1);
+ }
+ }
+
+ return GetBorderPen(e);
+ }
+
+ return new Pen(e.ExpandLineColor,1);
+ }
+
+ protected Brush GetBackgroundBrush(NodeExpandPartRendererEventArgs e)
+ {
+ if (e.BackColor.IsEmpty && e.BackColor2.IsEmpty)
+ {
+ bool expanded = e.Node.Expanded;
+ TreeExpandColorTable ct = GetExpandColorTable(e);
+ if (ct == null) return null;
+ if (expanded)
+ {
+ // Collapse node colors
+ if (!e.IsMouseOver && ct.CollapseFill != null)
+ return ct.CollapseFill.CreateBrush(e.ExpandPartBounds);
+ else if (e.IsMouseOver && ct.CollapseMouseOverFill != null)
+ return ct.CollapseMouseOverFill.CreateBrush(e.ExpandPartBounds);
+ }
+ else
+ {
+ // Expand node colors
+ if (!e.IsMouseOver && ct.ExpandFill != null)
+ return ct.ExpandFill.CreateBrush(e.ExpandPartBounds);
+ else if (e.IsMouseOver && ct.ExpandMouseOverFill != null)
+ return ct.ExpandMouseOverFill.CreateBrush(e.ExpandPartBounds);
+ }
+
+ return null;
+ }
+
+ if(e.BackColor2.IsEmpty)
+ return new SolidBrush(e.BackColor);
+
+ System.Drawing.Drawing2D.LinearGradientBrush brush=DisplayHelp.CreateLinearGradientBrush(e.ExpandPartBounds,e.BackColor,e.BackColor2,e.BackColorGradientAngle);
+ //brush.SetSigmaBellShape(0.8f);
+ return brush;
+ }
+
+ private TreeColorTable _ColorTable;
+ public TreeColorTable ColorTable
+ {
+ get { return _ColorTable; }
+ set { _ColorTable = value; }
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandEllipseDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandEllipseDisplay.cs
new file mode 100644
index 00000000..88ec8330
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandEllipseDisplay.cs
@@ -0,0 +1,57 @@
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Represents class that paints elliptical expand button.
+ ///
+ public class NodeExpandEllipseDisplay:NodeExpandDisplay
+ {
+ /// Draws ellipse type expand button.
+ /// Expand context drawing information.
+ public override void DrawExpandButton(NodeExpandPartRendererEventArgs e)
+ {
+ if(e.ExpandPartBounds.IsEmpty)
+ return;
+
+ Brush brush=GetBackgroundBrush(e);
+ if(brush!=null)
+ {
+ e.Graphics.FillEllipse(brush,e.ExpandPartBounds);
+ brush.Dispose();
+ }
+
+ Pen pen=GetBorderPen(e);
+ if (pen != null)
+ {
+ SmoothingMode sm = e.Graphics.SmoothingMode;
+ e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
+ e.Graphics.DrawEllipse(pen, e.ExpandPartBounds);
+ e.Graphics.SmoothingMode = sm;
+ pen.Dispose();
+ pen = null;
+ }
+
+ if(e.Node.Expanded)
+ {
+ pen = GetExpandPen(e);
+ if (pen != null)
+ {
+ e.Graphics.DrawLine(pen, e.ExpandPartBounds.X + 2, e.ExpandPartBounds.Y + e.ExpandPartBounds.Height / 2, e.ExpandPartBounds.Right - 2, e.ExpandPartBounds.Y + e.ExpandPartBounds.Height / 2);
+ pen.Dispose();
+ }
+ }
+ else
+ {
+ pen = GetExpandPen(e);
+ if (pen != null)
+ {
+ e.Graphics.DrawLine(pen,e.ExpandPartBounds.X+2,e.ExpandPartBounds.Y+e.ExpandPartBounds.Height/2,e.ExpandPartBounds.Right-2,e.ExpandPartBounds.Y+e.ExpandPartBounds.Height/2);
+ e.Graphics.DrawLine(pen,e.ExpandPartBounds.X+e.ExpandPartBounds.Width/2,e.ExpandPartBounds.Y+2,e.ExpandPartBounds.X+e.ExpandPartBounds.Width/2,e.ExpandPartBounds.Bottom-2);
+ pen.Dispose();
+ }
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandImageDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandImageDisplay.cs
new file mode 100644
index 00000000..f581b073
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandImageDisplay.cs
@@ -0,0 +1,25 @@
+
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Represents expand button display using predefined images.
+ ///
+ public class NodeExpandImageDisplay:NodeExpandDisplay
+ {
+ ///
+ /// Draws image type expand button.
+ ///
+ /// Expand context information
+ public override void DrawExpandButton(NodeExpandPartRendererEventArgs e)
+ {
+ if(e.Node.Expanded)
+ {
+ if(e.ExpandImageCollapse!=null)
+ e.Graphics.DrawImage(e.ExpandImageCollapse,e.ExpandPartBounds);
+ }
+ else if(e.ExpandImage!=null)
+ e.Graphics.DrawImage(e.ExpandImage,e.ExpandPartBounds);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandPartRendererEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandPartRendererEventArgs.cs
new file mode 100644
index 00000000..c3ef9ec9
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandPartRendererEventArgs.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Drawing;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents event arguments for RenderExpandPart event.
+ ///
+ public class NodeExpandPartRendererEventArgs:EventArgs
+ {
+ ///
+ /// Gets or sets reference to Graphics object, canvas node is rendered on.
+ ///
+ public System.Drawing.Graphics Graphics=null;
+ ///
+ /// Gets or sets the reference to Node object being rendered.
+ ///
+ public DevComponents.AdvTree.Node Node=null;
+ /// Expand part bounds
+ public Rectangle ExpandPartBounds=Rectangle.Empty;
+ /// Expand part border color
+ public Color BorderColor=Color.Empty;
+ /// Expand part line color
+ public Color ExpandLineColor=Color.Empty;
+ /// Expand part background color
+ public Color BackColor=Color.Empty;
+ /// Expand part target gradient background color
+ public Color BackColor2=Color.Empty;
+ /// Gradient angle
+ public int BackColorGradientAngle=90;
+ /// Expand part image when node is expanded
+ public Image ExpandImage=null;
+ /// Expand part image when node is collapsed
+ public Image ExpandImageCollapse=null;
+ /// Internal support for expand button types
+ internal eExpandButtonType ExpandButtonType=eExpandButtonType.Ellipse;
+ /// Gets whether mouse is over expand part
+ public bool IsMouseOver = false;
+
+ ///
+ /// Creates new instance of the class and initializes it with default values.
+ ///
+ /// Reference to graphics object.
+ public NodeExpandPartRendererEventArgs(Graphics g)
+ {
+ this.Graphics = g;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandRectDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandRectDisplay.cs
new file mode 100644
index 00000000..65ba6b8b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandRectDisplay.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Drawing;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Represents class that paints rectangular expand button.
+ ///
+ public class NodeExpandRectDisplay:NodeExpandDisplay
+ {
+ ///
+ /// Draw rectangular type expand button.
+ ///
+ /// Expand button context information.
+ public override void DrawExpandButton(NodeExpandPartRendererEventArgs e)
+ {
+ if(e.ExpandPartBounds.IsEmpty)
+ return;
+
+ Brush brush=GetBackgroundBrush(e);
+ if(brush!=null)
+ {
+ e.Graphics.FillRectangle(brush,e.ExpandPartBounds);
+ brush.Dispose();
+ }
+
+ Pen pen = GetBorderPen(e);
+ if (pen != null)
+ {
+ e.Graphics.DrawRectangle(pen, e.ExpandPartBounds);
+ pen.Dispose();
+ pen = null;
+ }
+
+ if(e.Node.Expanded)
+ {
+ pen = GetExpandPen(e);
+ if (pen != null)
+ {
+ e.Graphics.DrawLine(pen, e.ExpandPartBounds.X + 2, e.ExpandPartBounds.Y + e.ExpandPartBounds.Height / 2, e.ExpandPartBounds.Right - 2, e.ExpandPartBounds.Y + e.ExpandPartBounds.Height / 2);
+ pen.Dispose();
+ }
+ }
+ else
+ {
+ pen = GetExpandPen(e);
+ if (pen != null)
+ {
+ e.Graphics.DrawLine(pen,e.ExpandPartBounds.X+2,e.ExpandPartBounds.Y+e.ExpandPartBounds.Height/2,e.ExpandPartBounds.Right-2,e.ExpandPartBounds.Y+e.ExpandPartBounds.Height/2);
+ e.Graphics.DrawLine(pen,e.ExpandPartBounds.X+e.ExpandPartBounds.Width/2,e.ExpandPartBounds.Y+2,e.ExpandPartBounds.X+e.ExpandPartBounds.Width/2,e.ExpandPartBounds.Bottom-2);
+ pen.Dispose();
+ }
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandTriangleDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandTriangleDisplay.cs
new file mode 100644
index 00000000..6df26b02
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeExpandTriangleDisplay.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Display
+{
+ internal class NodeExpandTriangleDisplay : NodeExpandDisplay
+ {
+ ///
+ /// Draw triangular type expand button.
+ ///
+ /// Expand button context information.
+ public override void DrawExpandButton(NodeExpandPartRendererEventArgs e)
+ {
+ if (e.ExpandPartBounds.IsEmpty)
+ return;
+
+ SmoothingMode sm = e.Graphics.SmoothingMode;
+ e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
+ int pw = Dpi.Width5;
+ Rectangle r = new Rectangle(e.ExpandPartBounds.X , e.ExpandPartBounds.Y + (e.ExpandPartBounds.Height - 8) / 2, pw, Dpi.Height8);
+
+ GraphicsPath path = null;
+ if (e.Node.Expanded)
+ {
+ path = new GraphicsPath();
+ path.AddLine(r.X, r.Y + pw, r.X + pw, r.Y);
+ path.AddLine(r.X + pw, r.Y, r.X + pw, r.Y + pw);
+ path.CloseAllFigures();
+ }
+ else
+ {
+ path = new GraphicsPath();
+ path.AddLine(r.X, r.Y, r.X, r.Bottom);
+ path.AddLine(r.X, r.Bottom, r.X + Dpi.Width4, r.Y + r.Height / 2);
+ path.CloseAllFigures();
+ }
+
+ Brush brush = GetBackgroundBrush(e);
+ if (brush != null)
+ {
+ e.Graphics.FillPath(brush, path);
+ brush.Dispose();
+ }
+
+ Pen pen = GetBorderPen(e);
+ if(pen!=null)
+ {
+ e.Graphics.DrawPath(pen, path);
+ pen.Dispose();
+ }
+ e.Graphics.SmoothingMode = sm;
+ if(path!=null) path.Dispose();
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeGroupLineDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeGroupLineDisplay.cs
new file mode 100644
index 00000000..58198541
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeGroupLineDisplay.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using DevComponents.AdvTree.Layout;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Display
+{
+ internal class NodeGroupLineDisplay
+ {
+ private static readonly int LineMargin = 4;
+ public void DrawGroupLine(NodeRendererEventArgs e)
+ {
+ Color lineColor = e.Color;
+ Node node = e.Node;
+
+ if (lineColor.IsEmpty || lineColor.A == 0 || node.Cells.Count == 0) return;
+ Graphics g = e.Graphics;
+
+ Rectangle r = node.Bounds;
+
+ Cell lastCell = node.Cells[node.Cells.Count - 1];
+ if (lastCell.CheckBoxVisible && CellLayout.GetCheckBoxHorizontalAlign(lastCell.CheckBoxAlignment, true, eView.Tile) == eHorizontalAlign.Right)
+ {
+ r.Width -= (lastCell.CheckBoxBounds.Right - r.X) + LineMargin;
+ r.X = lastCell.CheckBoxBounds.Right + LineMargin;
+ }
+ else if (!lastCell.ImageBoundsRelative.IsEmpty && CellLayout.GetHorizontalAlign(lastCell.ImageAlignment, true, eView.Tile) == eHorizontalAlign.Right)
+ {
+ r.Width -= (lastCell.ImageBounds.Right - r.X) + LineMargin;
+ r.X = lastCell.ImageBounds.Right + LineMargin;
+ }
+ else if (e.Style.TextAlignment == eStyleTextAlignment.Near)
+ {
+ Rectangle textBounds = lastCell.TextBounds;
+ if (lastCell.TextMarkupBody == null)
+ textBounds.Width = TextDrawing.MeasureString(g, lastCell.Text, e.Style.Font).Width;
+ r.Width -= (textBounds.Right - r.X) + LineMargin;
+ r.X = textBounds.Right + LineMargin;
+ }
+ else
+ return;
+
+ using (Pen pen = new Pen(lineColor, 1))
+ {
+ g.DrawLine(pen, r.X, r.Y + r.Height / 2, r.Right, r.Y + r.Height / 2);
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeRendererEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeRendererEventArgs.cs
new file mode 100644
index 00000000..1c9ad961
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeRendererEventArgs.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Drawing;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Summary description for NodeRendererEventArgs.
+ ///
+ public class NodeRendererEventArgs:EventArgs
+ {
+ ///
+ /// Gets or sets reference to Graphics object, canvas node is rendered on.
+ ///
+ public System.Drawing.Graphics Graphics=null;
+ ///
+ /// Gets or sets the reference to Node object being rendered.
+ ///
+ public DevComponents.AdvTree.Node Node=null;
+ ///
+ /// Gets or sets the absolute node bounds.
+ ///
+ public Rectangle NodeBounds=Rectangle.Empty;
+ ///
+ /// Gets or sets the reference to element style for rendered node or cell. Style provided here is the style
+ /// for current node or cell state.
+ ///
+ public ElementStyle Style=null;
+ ///
+ /// Gets or sets color that is passed to renderer. May be Color.Empty.
+ ///
+ public Color Color = Color.Empty;
+
+ ///
+ /// Creates new instance of the class.
+ ///
+ public NodeRendererEventArgs()
+ {
+ }
+
+ public NodeRendererEventArgs(Graphics g, Node node, Rectangle bounds, ElementStyle style)
+ : this(g, node, bounds, style, Color.Empty)
+ {
+ }
+
+ public NodeRendererEventArgs(Graphics g, Node node, Rectangle bounds, ElementStyle style, Color color)
+ {
+ this.Graphics = g;
+ this.Node = node;
+ this.NodeBounds = bounds;
+ this.Style = style;
+ this.Color = color;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeSelectionDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeSelectionDisplay.cs
new file mode 100644
index 00000000..5a41d02b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeSelectionDisplay.cs
@@ -0,0 +1,190 @@
+using System.Drawing;
+using DevComponents.WinForms.Drawing;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Represent class that paints selection around node.
+ ///
+ internal class NodeSelectionDisplay
+ {
+ public void PaintSelection(SelectionRendererEventArgs info)
+ {
+ if (info.SelectionBoxStyle == eSelectionStyle.HighlightCells)
+ PaintHighlightCellsSelectionStyle(info);
+ else if (info.SelectionBoxStyle == eSelectionStyle.FullRowSelect)
+ PaintFullRowSelectSelectionStyle(info);
+ else if (info.SelectionBoxStyle == eSelectionStyle.NodeMarker)
+ PaintNodeMarkerSelectionStyle(info);
+
+ }
+
+ public void PaintHotTracking(SelectionRendererEventArgs info)
+ {
+ // Full row is just a rectangle with the background...
+ Shape[] fullRowShapes = GetHotTrackingShapes();
+ Graphics g = info.Graphics;
+ Rectangle bounds = info.Bounds;
+ bounds.Width--;
+ bounds.Height--;
+ foreach (Shape shape in fullRowShapes)
+ {
+ shape.Paint(g, bounds);
+ }
+ }
+
+ private void PaintFullRowSelectSelectionStyle(SelectionRendererEventArgs info)
+ {
+ // Full row is just a rectangle with the background...
+ Shape[] fullRowShapes = GetFullRowShapes(info.TreeActive);
+ Graphics g = info.Graphics;
+ Rectangle bounds = info.Bounds;
+ //bounds.Width--;
+ //bounds.Height--;
+
+ foreach (Shape shape in fullRowShapes)
+ {
+ shape.Paint(g, bounds);
+ }
+ }
+
+ Shape[] _FullRowShapes = null;
+ private Shape[] GetFullRowShapes(bool treeActive)
+ {
+ if (_FullRowShapes == null)
+ {
+ _FullRowShapes = new Shape[1];
+ _FullRowShapes[0] = new RectangleShape();
+ }
+ RectangleShape shape = (RectangleShape)_FullRowShapes[0];
+ SelectionColorTable colors = treeActive ? _SelectionColors.FullRowSelect : _SelectionColors.FullRowSelectInactive;
+ shape.Fill = colors.Fill;
+ shape.Border = colors.Border;
+
+ return _FullRowShapes;
+ }
+
+ private void PaintHighlightCellsSelectionStyle(SelectionRendererEventArgs info)
+ {
+ // Full row is just a rectangle with the background...
+ Shape[] fullRowShapes = GetHighlightCellsShapes(info.TreeActive);
+ Graphics g = info.Graphics;
+ Rectangle bounds = info.Bounds;
+ bounds.Width--;
+ bounds.Height--;
+ foreach (Shape shape in fullRowShapes)
+ {
+ shape.Paint(g, bounds);
+ }
+ }
+
+ Shape[] _HighlightCellsShapes = null;
+ private Shape[] GetHighlightCellsShapes(bool treeActive)
+ {
+ SelectionColorTable colorTable = treeActive ? _SelectionColors.HighlightCells : _SelectionColors.HighlightCellsInactive;
+
+ if (_HighlightCellsShapes == null || ((RectangleShape)_HighlightCellsShapes[0]).CornerRadius != null && ((RectangleShape)_HighlightCellsShapes[0]).CornerRadius.TopLeft != colorTable.BorderCornerRadius)
+ {
+ _HighlightCellsShapes = new Shape[1];
+ RectangleShape rectShape = new RectangleShape();
+ if (colorTable.BorderCornerRadius > 0)
+ {
+ rectShape.CornerRadius = new CornerRadius(colorTable.BorderCornerRadius);
+ RectangleShape inner = new RectangleShape();
+ rectShape.Content = inner;
+ }
+ _HighlightCellsShapes[0] = rectShape;
+ }
+
+ RectangleShape shape = (RectangleShape)_HighlightCellsShapes[0];
+ shape.Fill = colorTable.Fill;
+ shape.Border = colorTable.Border;
+ if (shape.Content != null)
+ {
+ shape = (RectangleShape)shape.Content;
+ shape.Border = colorTable.InnerBorder;
+ }
+
+ return _HighlightCellsShapes;
+ }
+
+ Shape[] _HotTrackingShapes = null;
+ private Shape[] GetHotTrackingShapes()
+ {
+ if (_HotTrackingShapes == null)
+ {
+ _HotTrackingShapes = new Shape[1];
+ RectangleShape rectShape = new RectangleShape();
+ rectShape.CornerRadius = new CornerRadius(2);
+ RectangleShape inner = new RectangleShape();
+ //inner.CornerRadius = new CornerRadius(2);
+ rectShape.Content = inner;
+ _HotTrackingShapes[0] = rectShape;
+ }
+
+ SelectionColorTable colorTable = _SelectionColors.NodeHotTracking;
+ RectangleShape shape = (RectangleShape)_HotTrackingShapes[0];
+ shape.Fill = colorTable.Fill;
+ shape.Border = colorTable.Border;
+ shape = (RectangleShape)shape.Content;
+ shape.Border = colorTable.InnerBorder;
+
+ return _HotTrackingShapes;
+ }
+
+ private void PaintNodeMarkerSelectionStyle(SelectionRendererEventArgs info)
+ {
+ Rectangle inside = info.Bounds;
+ int borderWidth = 4;
+ inside.Inflate(1, 1);
+ inside.Width--;
+ inside.Height--;
+ Rectangle outside = info.Bounds;
+ outside.Inflate(borderWidth, borderWidth);
+ outside.Width--;
+ outside.Height--;
+
+ SelectionColorTable colorTable = info.TreeActive ? _SelectionColors.NodeMarker : _SelectionColors.NodeMarkerInactive;
+
+ if (colorTable.Border != null)
+ {
+ Pen pen = colorTable.Border.CreatePen();
+ if (pen != null)
+ {
+ info.Graphics.DrawRectangle(pen, inside);
+ info.Graphics.DrawRectangle(pen, outside);
+ pen.Dispose();
+ }
+ }
+
+ if (colorTable.Fill != null)
+ {
+ Brush brush = colorTable.Fill.CreateBrush(outside);
+ if (brush != null)
+ {
+ Region region = new Region(outside);
+ region.Exclude(inside);
+ info.Graphics.FillRegion(brush, region);
+ brush.Dispose();
+ }
+ }
+ }
+
+ private TreeSelectionColors _SelectionColors = null;
+ public TreeSelectionColors SelectionColors
+ {
+ get { return _SelectionColors; }
+ set { _SelectionColors = value; }
+ }
+ }
+
+ internal class NodeSelectionDisplayInfo
+ {
+ public Node Node=null;
+ public Graphics Graphics=null;
+ public Rectangle Bounds=Rectangle.Empty;
+ public Color BorderColor=Color.Empty;
+ public Color FillColor=Color.Empty;
+ public int Width=4;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeSystemRenderer.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeSystemRenderer.cs
new file mode 100644
index 00000000..49f17339
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeSystemRenderer.cs
@@ -0,0 +1,270 @@
+using System;
+using System.Drawing;
+using DevComponents.DotNetBar;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Represents default system node and cell renderer.
+ ///
+ public class NodeSystemRenderer:TreeRenderer
+ {
+ #region Private Variables
+ private NodeExpandEllipseDisplay m_NodeExpandEllipseDisplay=new NodeExpandEllipseDisplay();
+ private NodeExpandRectDisplay m_NodeExpandRectDisplay=new NodeExpandRectDisplay();
+ private NodeExpandTriangleDisplay m_NodeExpandTriangleDisplay = new NodeExpandTriangleDisplay();
+ private NodeExpandImageDisplay m_NodeExpandImageDisplay=new NodeExpandImageDisplay();
+ private ElementStyleDisplayInfo m_ElementStyleDisplayInfo=new ElementStyleDisplayInfo();
+ private NodeSelectionDisplay m_SelectionDisplay=new NodeSelectionDisplay();
+ private LineConnectorDisplay m_LineConnectorDisplay=null;
+ private DragDropMarkerDisplay m_DragDropMarkerDisplay = new DragDropMarkerDisplay();
+ private ColumnHeaderDisplay m_ColumnHeaderDisplay = new ColumnHeaderDisplay();
+ private Office2007CheckBoxItemPainter m_CheckBoxPainter = new Office2007CheckBoxItemPainter();
+ private NodeGroupLineDisplay _GroupLineDisplay = new NodeGroupLineDisplay();
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Returns ElementStyleDisplayInfo class that provides information for ElementStyle rendering.
+ ///
+ /// Reference to style.
+ /// Reference to graphics object.
+ /// Style bounds
+ /// New instance of ElementStyleDisplayInfo
+ protected ElementStyleDisplayInfo GetElementStyleDisplayInfo(ElementStyle style, Graphics g, Rectangle bounds)
+ {
+ m_ElementStyleDisplayInfo.Style=style;
+ m_ElementStyleDisplayInfo.Graphics=g;
+ m_ElementStyleDisplayInfo.Bounds=bounds;
+ return m_ElementStyleDisplayInfo;
+ }
+
+ private NodeConnectorDisplay GetConnectorDisplay(NodeConnector c)
+ {
+ NodeConnectorDisplay d=null;
+ if(c==null)
+ return null;
+
+ switch(c.ConnectorType)
+ {
+ case eNodeConnectorType.Line:
+ {
+ if(m_LineConnectorDisplay==null)
+ m_LineConnectorDisplay=new LineConnectorDisplay();
+ d=m_LineConnectorDisplay;
+ break;
+ }
+ }
+ return d;
+ }
+
+ ///
+ /// Draws node background. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderNodeBackground method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawNodeBackground(NodeRendererEventArgs e)
+ {
+ ElementStyleDisplayInfo di = GetElementStyleDisplayInfo(e.Style, e.Graphics, e.NodeBounds);
+ ElementStyleDisplay.Paint(di);
+
+ base.DrawNodeBackground(e);
+ }
+
+ ///
+ /// Draws node expand part. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderNodeExpandPart method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawNodeExpandPart(NodeExpandPartRendererEventArgs e)
+ {
+ NodeExpandDisplay expandDisplay = GetExpandDisplay(e.ExpandButtonType);
+ expandDisplay.ColorTable = this.ColorTable;
+ expandDisplay.DrawExpandButton(e);
+ expandDisplay.ColorTable = null;
+ base.DrawNodeExpandPart(e);
+ }
+
+ private NodeExpandDisplay GetExpandDisplay(eExpandButtonType e)
+ {
+ NodeExpandDisplay d=null;
+ switch(e)
+ {
+ case eExpandButtonType.Rectangle:
+ d=m_NodeExpandRectDisplay;
+ break;
+ case eExpandButtonType.Triangle:
+ d = m_NodeExpandTriangleDisplay;
+ break;
+ case eExpandButtonType.Ellipse:
+ d = m_NodeExpandEllipseDisplay;
+ break;
+ case eExpandButtonType.Image:
+ d= m_NodeExpandImageDisplay;
+ break;
+ }
+ return d;
+ }
+
+ /////
+ ///// Draws node command part. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ ///// do not want default rendering to occur do not call the base implementation. You can call OnRenderNodeCommandPart method so events can occur.
+ /////
+ ///// Information provided for rendering.
+ //public override void DrawNodeCommandPart(NodeCommandPartRendererEventArgs e)
+ //{
+ // m_NodeCommandDisplay.DrawCommandButton(e);
+ // base.DrawNodeCommandPart(e);
+ //}
+
+ ///
+ /// Draws cell background. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderCellBackground method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawCellBackground(NodeCellRendererEventArgs e)
+ {
+ ElementStyleDisplayInfo di=GetElementStyleDisplayInfo(e.Style,e.Graphics,DisplayHelp.GetDrawRectangle(e.CellBounds));
+ ElementStyleDisplay.Paint(di);
+
+ base.DrawCellBackground(e);
+ }
+
+ ///
+ /// Draws cell check box. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderCellCheckBox method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawCellCheckBox(NodeCellRendererEventArgs e)
+ {
+ CellDisplay.CheckBoxPainter = m_CheckBoxPainter;
+ if (Office2007ColorTable != null)
+ CellDisplay.ColorTable = Office2007ColorTable.CheckBoxItem;
+ CellDisplay.PaintCellCheckBox(e);
+ base.DrawCellCheckBox(e);
+ CellDisplay.CheckBoxPainter = null;
+ }
+
+ ///
+ /// Draws cell image. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderCellImage method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawCellImage(NodeCellRendererEventArgs e)
+ {
+ CellDisplay.PaintCellImage(e);
+ base.DrawCellImage(e);
+ }
+
+ ///
+ /// Draws cell text. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderCellText method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawCellText(NodeCellRendererEventArgs e)
+ {
+ CellDisplay.PaintText(e);
+ base.DrawCellText(e);
+ }
+
+ ///
+ /// Draws selection for SelectedNode. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderSelection method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawSelection(SelectionRendererEventArgs e)
+ {
+ m_SelectionDisplay.SelectionColors = ColorTable.Selection;
+ m_SelectionDisplay.PaintSelection(e);
+ base.DrawSelection(e);
+ }
+
+ ///
+ /// Draws hot-tracking marker for mouse over node. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderHotTracking method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawHotTracking(SelectionRendererEventArgs e)
+ {
+ m_SelectionDisplay.SelectionColors = ColorTable.Selection;
+ m_SelectionDisplay.PaintHotTracking(e);
+ base.DrawHotTracking(e);
+ }
+
+ ///
+ /// Draws connector between nodes. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderConnector method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawConnector(ConnectorRendererEventArgs e)
+ {
+ NodeConnectorDisplay display = GetConnectorDisplay(e.NodeConnector);
+ if(display!=null)
+ display.DrawConnector(e);
+
+ base.DrawConnector(e);
+ }
+
+ ///
+ /// Draws the tree background. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderTreeBackground method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawTreeBackground(TreeBackgroundRendererEventArgs e)
+ {
+ AdvTree tree = e.AdvTree;
+ Graphics g = e.Graphics;
+
+ if(!tree.BackColor.IsEmpty)
+ {
+ using(SolidBrush brush=new SolidBrush(tree.BackColor))
+ g.FillRectangle(brush,tree.DisplayRectangle);
+ }
+
+ ElementStyleDisplayInfo info=new ElementStyleDisplayInfo();
+ info.Bounds=tree.DisplayRectangle;
+ info.Graphics=g;
+ info.Style=tree.BackgroundStyle;
+ ElementStyleDisplay.Paint(info);
+
+ base.DrawTreeBackground (e);
+ }
+
+ ///
+ /// Draws the drag & drop marker that indicates the insertion point for the node. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderDragDropMarker method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawDragDropMarker(DragDropMarkerRendererEventArgs e)
+ {
+ m_DragDropMarkerDisplay.MarkerColor = this.ColorTable.DragDropMarker;
+ m_DragDropMarkerDisplay.DrawMarker(e);
+ base.DrawDragDropMarker(e);
+ }
+
+ ///
+ /// Draws the column header. If you need to provide custom rendering this is the method that you should override in your custom renderer. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderColumnHeader method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawColumnHeader(ColumnHeaderRendererEventArgs e)
+ {
+ ElementStyleDisplayInfo di = GetElementStyleDisplayInfo(e.Style, e.Graphics, e.Bounds);
+ m_ColumnHeaderDisplay.DrawColumnHeader(e, di);
+ base.DrawColumnHeader(e);
+ }
+
+ ///
+ /// Draws node group line when in tile view. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderTileGroupLine method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public override void DrawTileGroupLine(NodeRendererEventArgs e)
+ {
+ _GroupLineDisplay.DrawGroupLine(e);
+ OnRenderTileGroupLine(e);
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/NodeTreeDisplay.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeTreeDisplay.cs
new file mode 100644
index 00000000..8653e3a3
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/NodeTreeDisplay.cs
@@ -0,0 +1,1139 @@
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System;
+using System.Collections;
+using DevComponents.DotNetBar;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Summary description for NodeTreeDisplay.
+ ///
+ public class NodeTreeDisplay:NodeDisplay
+ {
+ #region Private Variables
+ // Cashed objects
+ ElementStyleDisplayInfo m_ElementStyleDisplayInfo=new ElementStyleDisplayInfo();
+ NodeCellRendererEventArgs m_CellDisplayInfo=new NodeCellRendererEventArgs();
+// CurveConnectorDisplay m_CurveConnectorDisplay=null;
+// LineConnectorDisplay m_LineConnectorDisplay=null;
+ private NodeSystemRenderer m_SystemRenderer=new NodeSystemRenderer();
+ //private NodeProfessionalRenderer m_ProfRenderer=new NodeProfessionalRenderer();
+ #endregion
+ /// Creates new instance of the class
+ /// Object to initialize class with.
+ public NodeTreeDisplay(AdvTree tree):base(tree)
+ {
+ m_SystemRenderer.ColorTable = new TreeColorTable();
+ ColorTableInitializer.InitOffice2007Blue(m_SystemRenderer.ColorTable, new ColorFactory());
+ }
+
+ public NodeSystemRenderer SystemRenderer
+ {
+ get { return m_SystemRenderer; }
+ set { m_SystemRenderer = value; }
+ }
+
+ public TreeRenderer GetTreeRenderer()
+ {
+ TreeRenderer renderer = m_SystemRenderer;
+ if (this.Tree.NodeRenderer != null && this.Tree.RenderMode == eNodeRenderMode.Custom)
+ renderer = this.Tree.NodeRenderer;
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ renderer.Office2007ColorTable = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
+ renderer.ColorTable = renderer.Office2007ColorTable.AdvTree;
+ }
+
+ return renderer;
+ }
+
+ private NodeDisplayContext CreateDisplayContext(Graphics g, Rectangle clipRectangle)
+ {
+ NodeDisplayContext context = new NodeDisplayContext();
+ context.Graphics = g;
+ context.DefaultFont = this.Tree.Font;
+ context.ClipRectangle = clipRectangle;
+ context.Offset = this.Offset;
+ context.Styles = this.Tree.Styles;
+ context.IsBackgroundSelection = IsBackgroundSelection;
+ context.ClientRectangle = ElementStyleLayout.GetInnerRect(Tree.BackgroundStyle, Tree.ClientRectangle);
+ context.ColorScheme = Tree.ColorScheme;
+ context.GridRowLines = Tree.GridRowLines;
+ context.GridRowLineColor = Tree.GridLinesColor;
+ context.CellSelection = Tree.SelectionPerCell;
+ context.AlternateRowBrush = CreateBrush(Tree.AlternateRowColor);
+ context.DrawAlternateRowBackground = !Tree.AlternateRowColor.IsEmpty;
+ context.View = this.Tree.View;
+ context.TileGroupLineColor = this.Tree.TileGroupLineColor;
+ // Setup rendering
+ context.NodeRenderer = m_SystemRenderer;
+ if (this.Tree.NodeRenderer != null && this.Tree.RenderMode == eNodeRenderMode.Custom)
+ context.NodeRenderer = this.Tree.NodeRenderer;
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ context.NodeRenderer.Office2007ColorTable = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
+ context.NodeRenderer.ColorTable = context.NodeRenderer.Office2007ColorTable.AdvTree;
+ }
+
+ context.NodeRendererEventArgs = new NodeRendererEventArgs();
+
+ if (this.Tree.NodeStyle != null)
+ context.DefaultNodeStyle = this.Tree.NodeStyle;
+ else
+ context.DefaultNodeStyle = GetDefaultNodeStyle();
+
+ if (this.Tree.NodeStyleExpanded != null)
+ context.ExpandedNodeStyle = this.Tree.NodeStyleExpanded;
+ if (this.Tree.NodeStyleSelected != null)
+ context.SelectedNodeStyle = this.Tree.NodeStyleSelected;
+ if (this.Tree.NodeStyleMouseOver != null)
+ context.MouseOverNodeStyle = this.Tree.NodeStyleMouseOver;
+
+ if (this.Tree.CellStyleDefault != null)
+ context.CellStyleDefault = this.Tree.CellStyleDefault;
+ if (this.Tree.CellStyleDisabled != null)
+ context.CellStyleDisabled = this.Tree.CellStyleDisabled;
+ else
+ context.CellStyleDisabled = ElementStyle.GetDefaultDisabledCellStyle();
+ if (this.Tree.CellStyleMouseDown != null)
+ context.CellStyleMouseDown = this.Tree.CellStyleMouseDown;
+ if (this.Tree.CellStyleMouseOver != null)
+ context.CellStyleMouseOver = this.Tree.CellStyleMouseOver;
+ if (this.Tree.CellStyleSelected != null)
+ context.CellStyleSelected = this.Tree.CellStyleSelected;
+ else
+ context.CellStyleSelected = ElementStyle.GetDefaultSelectedCellStyle();
+
+ // Setup connector
+ context.ConnectorDisplayInfo = new ConnectorRendererEventArgs();
+ context.ConnectorDisplayInfo.Graphics = context.Graphics;
+
+ // Setup Node Expander Painter
+ context.ExpandDisplayInfo = new NodeExpandPartRendererEventArgs(context.Graphics);
+ context.ExpandDisplayInfo.BackColor = this.Tree.GetColor(this.Tree.ExpandBackColor, this.Tree.ExpandBackColorSchemePart);
+ context.ExpandDisplayInfo.BackColor2 = this.Tree.GetColor(this.Tree.ExpandBackColor2, this.Tree.ExpandBackColor2SchemePart);
+
+ context.ExpandDisplayInfo.BackColorGradientAngle = this.Tree.ExpandBackColorGradientAngle;
+ context.ExpandDisplayInfo.BorderColor = this.Tree.GetColor(this.Tree.ExpandBorderColor, this.Tree.ExpandBorderColorSchemePart);
+ context.ExpandDisplayInfo.ExpandLineColor = this.Tree.GetColor(this.Tree.ExpandLineColor, this.Tree.ExpandLineColorSchemePart);
+ context.ExpandDisplayInfo.Graphics = context.Graphics;
+ context.ExpandDisplayInfo.ExpandButtonType = this.Tree.ExpandButtonType;
+ context.ExpandDisplayInfo.ExpandImage = this.Tree.ExpandImage;
+ context.ExpandDisplayInfo.ExpandImageCollapse = this.Tree.ExpandImageCollapse;
+
+ // Setup Selection Display
+ context.SelectionDisplayInfo = new SelectionRendererEventArgs();
+ context.SelectionDisplayInfo.Graphics = context.Graphics;
+ context.SelectionDisplayInfo.SelectionBoxStyle = this.Tree.SelectionBoxStyle;
+ context.SelectionDisplayInfo.TreeActive = this.Tree.IsKeyboardFocusWithin || !this.Tree.SelectionFocusAware;
+
+ return context;
+ }
+
+ private Brush CreateBrush(Color color)
+ {
+ if (color.IsEmpty) return null;
+ return new SolidBrush(color);
+ }
+
+ ///
+ /// Paints the tree on canvas.
+ ///
+ public override void Paint(Graphics g, Rectangle clipRectangle)
+ {
+ base.Paint(g,clipRectangle);
+
+ // Setup custom check box images if any
+ m_CellDisplayInfo.CheckBoxImageChecked = this.Tree.CheckBoxImageChecked;
+ m_CellDisplayInfo.CheckBoxImageUnChecked = this.Tree.CheckBoxImageUnChecked;
+ m_CellDisplayInfo.CheckBoxImageIndeterminate = this.Tree.CheckBoxImageIndeterminate;
+ m_CellDisplayInfo.ItemPaintArgs = new ItemPaintArgs(null, Tree, g, new ColorScheme());
+
+ // Paint header
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ m_SystemRenderer.Office2007ColorTable = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
+ m_CellDisplayInfo.ItemPaintArgs.Colors = m_SystemRenderer.Office2007ColorTable.LegacyColors;
+ m_CellDisplayInfo.ItemPaintArgs.Renderer = GlobalManager.Renderer;
+ }
+ // Paint Nodes...
+ NodeDisplayContext context = CreateDisplayContext(g, clipRectangle);
+
+ if(this.Tree.SelectedPathConnector!=null)
+ {
+ // Prepare nodes for path display. Downstream nodes are easily recognized when
+ // path upstream nodes need special treatment to improve performance
+ if(this.Tree.SelectedNode!=null)
+ {
+ Node n=this.Tree.SelectedNode;
+ while(n!=null)
+ {
+ // This marker will be reset once node is painted...
+ n.SelectedConnectorMarker = true;
+ n=n.Parent;
+ }
+ }
+ //context.SelectedPathConnectorDisplay=GetConnectorDisplay(this.Tree.SelectedPathConnector);
+ }
+
+ if (context.DrawAlternateRowBackground)
+ {
+ PaintAlternateRowBackground(context);
+ }
+
+ // Paint Grid Lines
+ if (this.Tree.GridColumnLines && this.Tree.Columns.Count > 0)
+ {
+ PaintGridLines(context);
+ }
+
+ // Paint background for nodes with full row background
+ if (this.Tree.FullRowBackgroundNodes != null && this.Tree.FullRowBackgroundNodes.Count > 0)
+ PaintFullRowBackgroundForNodes(context, this.Tree.FullRowBackgroundNodes);
+
+ // Paint selection
+ if (context.IsBackgroundSelection)
+ {
+ PaintSelection(context);
+ }
+ if (Tree.HotTracking)
+ PaintHotTracking(context);
+ Rectangle innerRect = Tree.GetPaintRectangle();
+ Rectangle clientRect = Tree.ClientRectangle;
+
+ if(innerRect == clipRectangle || clientRect == clipRectangle || clipRectangle.IsEmpty)
+ _PaintedNodes.Clear();
+
+ if(this.Tree.DisplayRootNode!=null)
+ this.PaintNode(this.Tree.DisplayRootNode, context);
+ else
+ this.PaintNodes(this.Tree.Nodes, context);
+
+ Node dragNode=this.Tree.GetDragNode();
+ if(dragNode!=null && dragNode.Parent==null)
+ {
+ Point p=context.Offset;
+ context.Offset=Point.Empty;
+ PaintNode(dragNode,context);
+ context.Offset=p;
+ }
+ if (this.Tree.IsDragDropInProgress && this.Tree.PaintDragDropInsertMarker)
+ {
+ PaintDragInsertMarker(context, this.Tree.GetDragInsertionBounds(this.Tree.GetNodeDragInfo()));
+ }
+
+ if(!context.IsBackgroundSelection)
+ PaintSelection(context);
+
+ if (context.AlternateRowBrush != null)
+ {
+ context.AlternateRowBrush.Dispose();
+ context.AlternateRowBrush = null;
+ }
+ }
+
+ private void PaintAlternateRowBackground(NodeDisplayContext context)
+ {
+ if (this.Tree.DisplayRootNode != null)
+ {
+ context.AlternateRowFlag = true;
+ PaintAlternateRowBackground(context, this.Tree.DisplayRootNode.Nodes);
+ }
+ else
+ {
+ PaintAlternateRowBackground(context, this.Tree.Nodes);
+ }
+ }
+
+ private void PaintAlternateRowBackground(NodeDisplayContext context, NodeCollection nodeCollection)
+ {
+ foreach (Node node in nodeCollection)
+ {
+ if (!node.Visible) continue;
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset);
+ if (r.Y > context.ClientRectangle.Bottom) break;
+
+ if (r.Y >= context.ClientRectangle.Y)
+ {
+ if (context.AlternateRowFlag)
+ {
+ Rectangle backRect = new Rectangle(context.ClientRectangle.X, r.Y - 1, context.ClientRectangle.Width, r.Height + 1);
+ context.Graphics.FillRectangle(context.AlternateRowBrush, backRect);
+ }
+ }
+ context.AlternateRowFlag = !context.AlternateRowFlag;
+
+ if (node.Expanded && node.HasChildNodes) PaintAlternateRowBackground(context, node.Nodes);
+ }
+ }
+
+ public void ExternalPaintNode(Node node, Graphics g, Rectangle bounds)
+ {
+ // Setup custom check box images if any
+ m_CellDisplayInfo.CheckBoxImageChecked = this.Tree.CheckBoxImageChecked;
+ m_CellDisplayInfo.CheckBoxImageUnChecked = this.Tree.CheckBoxImageUnChecked;
+ m_CellDisplayInfo.CheckBoxImageIndeterminate = this.Tree.CheckBoxImageIndeterminate;
+
+ // Paint header
+ if (GlobalManager.Renderer is Office2007Renderer)
+ m_SystemRenderer.Office2007ColorTable = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
+ // Paint Nodes...
+ NodeDisplayContext context = CreateDisplayContext(g, bounds);
+ context.ExpandDisplayInfo = null;
+ context.ConnectorDisplayInfo = null;
+
+ // Update offset
+ context.Offset = new Point(bounds.X - node.BoundsRelative.X, bounds.Y - node.BoundsRelative.Y);
+
+ PaintSingleNode(node, context);
+ }
+
+ private void PaintGridLines(NodeDisplayContext context)
+ {
+ PaintGridLines(context, Tree.Columns, context.ClientRectangle);
+ }
+
+ private void PaintGridLines(NodeDisplayContext context, ColumnHeaderCollection columnHeaderCollection, Rectangle bounds)
+ {
+ Color color = this.Tree.GridLinesColor.IsEmpty ? context.NodeRenderer.ColorTable.GridLines : this.Tree.GridLinesColor;
+ Graphics g = context.Graphics;
+ for (int i = 0; i < columnHeaderCollection.Count; i++)
+ {
+ ColumnHeader columnHeader = columnHeaderCollection.ColumnAtDisplayIndex(i);
+ if (!columnHeader.Visible || columnHeader.Bounds.Width <= 0) continue;
+ Rectangle r = columnHeader.Bounds;
+ r.Offset(context.Offset);
+ if (columnHeaderCollection.ParentNode == null)
+ {
+ r.Offset(bounds.Location);
+ if (!columnHeader.CellsBackColor.IsEmpty)
+ {
+ SmoothingMode oldSmoothing = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.None;
+ Rectangle rBack = new Rectangle(r.X - 5, context.ClientRectangle.Y, r.Width + 4, context.ClientRectangle.Height);
+ using (SolidBrush brush = new SolidBrush(columnHeader.CellsBackColor))
+ g.FillRectangle(brush, rBack);
+ g.SmoothingMode = oldSmoothing;
+ }
+ }
+ DisplayHelp.DrawLine(g, r.Right - (columnHeader.IsLastVisible ? 0 : 1), bounds.Y, r.Right - (columnHeader.IsLastVisible ? 0 : 1), bounds.Bottom, color, 1);
+ }
+ }
+
+ private void PaintFullRowBackgroundForNodes(NodeDisplayContext context, ArrayList nodesCollection)
+ {
+ Rectangle clientRectangle = context.ClientRectangle;
+ if (this.Tree.VScrollBar != null) clientRectangle.Width -= this.Tree.VScrollBar.Width;
+
+ foreach (Node node in nodesCollection)
+ {
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset);
+
+ if (!r.IsEmpty)
+ {
+ r.X = clientRectangle.X;
+ r.Width = clientRectangle.Width;
+ r.Inflate(0, 1);
+ }
+
+ if (r.IsEmpty || !r.IntersectsWith(context.ClipRectangle) && !context.ClipRectangle.IsEmpty)
+ continue;
+ ElementStyle style = GetEffectiveNodeBackgroundStyle(node, context);
+ if (style == null)
+ continue;
+ TreeRenderer renderer = context.NodeRenderer;
+ if (node.NodeRenderer != null && node.RenderMode == eNodeRenderMode.Custom)
+ renderer = node.NodeRenderer;
+ if (style != null)
+ {
+ context.NodeRendererEventArgs.Graphics = context.Graphics;
+ context.NodeRendererEventArgs.Node = node;
+ context.NodeRendererEventArgs.NodeBounds = r;
+ context.NodeRendererEventArgs.Style = style;
+ renderer.DrawNodeBackground(context.NodeRendererEventArgs);
+ }
+ }
+ }
+
+ private void PaintDragInsertMarker(NodeDisplayContext context, Rectangle dragInsertionBounds)
+ {
+ if (dragInsertionBounds.IsEmpty) return;
+ context.NodeRenderer.DrawDragDropMarker(new DragDropMarkerRendererEventArgs(context.Graphics, dragInsertionBounds));
+ }
+
+ public bool IsBackgroundSelection
+ {
+ get { return this.Tree.SelectionBoxStyle != eSelectionStyle.NodeMarker; }
+ }
+
+ private void PaintSelection(NodeDisplayContext context)
+ {
+ if (!this.Tree.MultiSelect && this.Tree.SelectedNode != null && this.Tree.SelectedNode.Visible && this.Tree.SelectionBox && !(this.Tree.HideSelection && !this.Tree.Focused))
+ {
+ PaintNodeSelection(this.Tree.SelectedNode, context);
+ }
+ else if (this.Tree.MultiSelect && this.Tree.SelectedNodes.Count>0 && this.Tree.SelectionBox && !(this.Tree.HideSelection && !this.Tree.Focused))
+ {
+ foreach (Node node in Tree.SelectedNodes)
+ {
+ if(node.IsVisible)
+ PaintNodeSelection(node, context);
+ }
+ }
+ }
+
+ private void PaintNodeSelection(Node node, NodeDisplayContext context)
+ {
+ if (!node.IsSelectionVisible) return;
+
+ context.SelectionDisplayInfo.Node = node;
+ Rectangle r;
+ if (this.Tree.SelectionBoxStyle == eSelectionStyle.FullRowSelect)
+ {
+ if (context.CellSelection)
+ {
+ Cell cell = context.SelectionDisplayInfo.Node.SelectedCell != null ? context.SelectionDisplayInfo.Node.SelectedCell : context.SelectionDisplayInfo.Node.Cells[0];
+ r = NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds,
+ cell, context.Offset);
+ }
+ else
+ {
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, context.SelectionDisplayInfo.Node, context.Offset);
+ r.X = context.ClientRectangle.X;
+ r.Width = context.ClientRectangle.Width;
+ }
+ if(context.GridRowLines)
+ r.Inflate(0, (int)Math.Floor((float)Tree.NodeSpacing / 2));
+ else
+ r.Inflate(0, (int)Math.Ceiling((float)Tree.NodeSpacing / 2));
+ }
+ else if (this.Tree.SelectionBoxStyle == eSelectionStyle.HighlightCells)
+ {
+ if (context.CellSelection)
+ {
+ Cell cell = context.SelectionDisplayInfo.Node.SelectedCell != null ? context.SelectionDisplayInfo.Node.SelectedCell : context.SelectionDisplayInfo.Node.Cells[0];
+ r = NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds,
+ cell, context.Offset);
+ }
+ else
+ {
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.CellsBounds, context.SelectionDisplayInfo.Node, context.Offset);
+ }
+ r.Inflate(2, 2);
+ if (r.Right > context.ClientRectangle.Right)
+ r.Width -= (r.Right - context.ClientRectangle.Right);
+
+ }
+ else
+ {
+ if (context.CellSelection)
+ {
+ Cell cell = context.SelectionDisplayInfo.Node.SelectedCell != null ? context.SelectionDisplayInfo.Node.SelectedCell : context.SelectionDisplayInfo.Node.Cells[0];
+ r = NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds,
+ cell, context.Offset);
+ }
+ else
+ {
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, context.SelectionDisplayInfo.Node, context.Offset);
+ }
+ }
+
+ context.SelectionDisplayInfo.Bounds = r;
+ context.NodeRenderer.DrawSelection(context.SelectionDisplayInfo);
+ }
+
+ private void PaintHotTracking(NodeDisplayContext context)
+ {
+ Node node = this.Tree.MouseOverNode;
+ if (node != null && !node.IsSelected && node.Selectable)
+ {
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.CellsBounds, node, context.Offset);
+ r.Inflate(2, 2);
+ context.SelectionDisplayInfo.Node = node;
+ context.SelectionDisplayInfo.Bounds = r;
+ context.NodeRenderer.DrawHotTracking(context.SelectionDisplayInfo);
+ }
+ }
+
+ private Node PaintNodes(NodeCollection nodes, NodeDisplayContext context)
+ {
+ Node lastPainted = null;
+ int count = nodes.Count;
+ int start = 0;
+
+ // Find first node to render in case there are lot of them
+ if (context.View == eView.Tree && count > 99 && /*this.Tree.NodesConnector == null &&*/ context.Offset.Y != 0)
+ {
+ int testIndex = count / 2;
+ int chunk = testIndex;
+ while (testIndex > 0 && testIndex < count)
+ {
+ chunk = chunk / 2;
+ Node node = nodes[testIndex];
+ if (!node.Visible)
+ {
+ int ti = testIndex + 1;
+ while (ti < count)
+ {
+ node = nodes[ti];
+ ti++;
+ if (node.Visible) break;
+ }
+ if (!node.Visible)
+ {
+ ti = testIndex - 1;
+ while (ti >= 0)
+ {
+ node = nodes[ti];
+ ti--;
+ if (node.Visible) break;
+ }
+ }
+ }
+ if (!node.Visible)
+ {
+ start = 0;
+ break;
+ }
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset);
+ if (chunk > 0 && r.Y > context.ClipRectangle.Bottom) // go back
+ testIndex -= chunk;
+ else if (chunk > 0 && r.Y < context.ClipRectangle.Y) // go forward
+ testIndex += chunk;
+ else
+ {
+ if (testIndex == 0) break;
+ testIndex--;
+ for (int i = testIndex; i >= 0; i--)
+ {
+ node = nodes[i];
+ if (!node.Visible) continue;
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset);
+ if (r.Y < context.ClipRectangle.Y)
+ {
+ start = i;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ bool clipEmpty = context.ClipRectangle.IsEmpty;
+ for (int i = start; i < count; i++)
+ {
+ Node node = nodes[i];
+ if (PaintNode(node, context))
+ {
+ lastPainted = node;
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset);
+ if (!clipEmpty && r.Y > context.ClipRectangle.Bottom && !context.ClientRectangle.IsEmpty)
+ break;
+ }
+ }
+ return lastPainted;
+ }
+
+ private bool PaintNode(Node node, NodeDisplayContext context)
+ {
+ if(!node.Visible)
+ {
+ node.SelectedConnectorMarker = false;
+ return false;
+ }
+
+ Rectangle r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds,node,context.Offset);
+ if(r.IsEmpty)
+ {
+ node.SelectedConnectorMarker = false;
+ return false;
+ }
+
+ if (context.GridRowLines && !node.IsDragNode)
+ {
+ DisplayHelp.DrawLine(context.Graphics, context.ClientRectangle.X, r.Bottom+1, context.ClientRectangle.Right, r.Bottom+1, context.GridRowLineColor, 1);
+ }
+
+ bool paintChildNodes = (node.Expanded && node.Nodes.Count > 0);
+
+ if (!node.IsDragNode && (node.Parent != null || node.ExpandVisibility != eNodeExpandVisibility.Hidden))
+ this.PaintConnector(null, node, context, false);
+
+ if (paintChildNodes)
+ {
+ Node lastChildNode = NodeOperations.GetLastVisibleChildNode(node);
+ if (lastChildNode != null)
+ this.PaintConnector(node, lastChildNode, context, false);
+ }
+
+ node.SelectedConnectorMarker = false;
+
+ if (NodeDisplay.HasColumnsVisible(node))
+ {
+ r.Height += node.ColumnHeaderHeight;
+ r.Width = Math.Max(r.Width, node.NodesColumns.Bounds.Width);
+ }
+ if (r.Y >= context.ClipRectangle.Y && r.Y <= context.ClipRectangle.Bottom ||
+ r.Bottom >= context.ClipRectangle.Y && r.Bottom <= context.ClipRectangle.Bottom ||
+ r.Y <= context.ClipRectangle.Y && r.Bottom > context.ClipRectangle.Y ||
+ context.ClipRectangle.IsEmpty)
+ PaintSingleNode(node, context);
+
+ if (paintChildNodes)
+ {
+ PaintNodes(node.Nodes, context);
+ }
+
+ return true;
+ }
+
+ private ElementStyle GetEffectiveNodeBackgroundStyle(Node node, NodeDisplayContext context)
+ {
+ ElementStyle style = context.DefaultNodeStyle.Copy();
+
+ bool bApplyStyles = true;
+ bool isSelected = (node.IsSelected && node.IsSelectionVisible);
+
+ if (isSelected && context.SelectedNodeStyle == null && node.StyleSelected == null && !node.FullRowBackground) bApplyStyles = false;
+
+ if (isSelected && (context.SelectedNodeStyle == null || context.SelectedNodeStyle.TextColor.IsEmpty) &&
+ (node.StyleSelected == null || node.StyleSelected.TextColor.IsEmpty))
+ {
+ eSelectionStyle ss = Tree.SelectionBoxStyle;
+ TreeSelectionColors table = context.NodeRenderer.ColorTable.Selection;
+ if (context.SelectionDisplayInfo.TreeActive)
+ {
+ if (ss == eSelectionStyle.FullRowSelect && !table.FullRowSelect.TextColor.IsEmpty)
+ style.TextColor = table.FullRowSelect.TextColor;
+ else if (ss == eSelectionStyle.HighlightCells && !table.HighlightCells.TextColor.IsEmpty)
+ style.TextColor = table.HighlightCells.TextColor;
+ else if (ss == eSelectionStyle.NodeMarker && !table.NodeMarker.TextColor.IsEmpty)
+ style.TextColor = table.NodeMarker.TextColor;
+ }
+ else
+ {
+ if (ss == eSelectionStyle.FullRowSelect && !table.FullRowSelectInactive.TextColor.IsEmpty)
+ style.TextColor = table.FullRowSelectInactive.TextColor;
+ else if (ss == eSelectionStyle.HighlightCells && !table.HighlightCellsInactive.TextColor.IsEmpty)
+ style.TextColor = table.HighlightCellsInactive.TextColor;
+ else if (ss == eSelectionStyle.NodeMarker && !table.NodeMarkerInactive.TextColor.IsEmpty)
+ style.TextColor = table.NodeMarkerInactive.TextColor;
+ }
+
+ }
+ else if (this.Tree.HotTracking && !node.IsSelected && node.Selectable && this.Tree.MouseOverNode == node)
+ {
+ SelectionColorTable table = context.NodeRenderer.ColorTable.Selection.NodeHotTracking;
+ if (!table.TextColor.IsEmpty)
+ style.TextColor = table.TextColor;
+ }
+
+ if (node.Style != null)
+ {
+ if (bApplyStyles)
+ style.ApplyStyle(node.Style); //=node.Style.Copy();
+ else
+ style.ApplyFontStyle(node.Style);
+ }
+
+ if (bApplyStyles && node.MouseOverNodePart == eMouseOverNodePart.Node && style != null)
+ {
+ ElementStyle mouseOverStyle = context.MouseOverNodeStyle;
+ if (node.StyleMouseOver != null)
+ {
+ mouseOverStyle = node.StyleMouseOver;
+ bApplyStyles = false;
+ }
+ if (mouseOverStyle != null)
+ {
+ style.ApplyStyle(mouseOverStyle);
+ bApplyStyles = false;
+ }
+ }
+
+ // On default style apply expanded style
+ if (bApplyStyles && node.Expanded && style != null)
+ {
+ ElementStyle expandedStyle = context.ExpandedNodeStyle;
+ if (node.StyleExpanded != null)
+ expandedStyle = node.StyleExpanded;
+ if (expandedStyle != null)
+ style.ApplyStyle(expandedStyle);
+ }
+
+ // Apply selected style if needed too
+ if (bApplyStyles && node.IsSelected && style != null)
+ {
+ ElementStyle selectedStyle = context.SelectedNodeStyle;
+ if (node.StyleSelected != null)
+ selectedStyle = node.StyleSelected;
+ if (selectedStyle != null)
+ style.ApplyStyle(selectedStyle);
+ }
+
+ if (style != null)
+ {
+ if (style.Font == null)
+ style.Font = context.DefaultFont;
+ }
+
+ return style;
+ }
+
+ private void PaintSingleNode(Node node, NodeDisplayContext context)
+ {
+ _PaintedNodes.Add(node);
+ Rectangle r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds,node,context.Offset);
+ TreeRenderer renderer=context.NodeRenderer;
+ if(node.NodeRenderer!=null && node.RenderMode==eNodeRenderMode.Custom)
+ renderer = node.NodeRenderer;
+ bool isSelected = node.IsSelectionVisible && node.IsSelected;
+
+ // Paint node background
+ ElementStyle style = GetEffectiveNodeBackgroundStyle(node, context);
+
+ Region backRegion=null;
+ if(style!=null)
+ {
+ context.NodeRendererEventArgs.Graphics=context.Graphics;
+ context.NodeRendererEventArgs.Node = node;
+ context.NodeRendererEventArgs.NodeBounds = r;
+ context.NodeRendererEventArgs.Style = style;
+ if (!node.FullRowBackground) // Node full row backgrounds are drawn first...
+ renderer.DrawNodeBackground(context.NodeRendererEventArgs);
+ ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(style, context.Graphics, context.NodeRendererEventArgs.NodeBounds);
+ di.Bounds.Inflate(1, 1);
+ backRegion=ElementStyleDisplay.GetStyleRegion(di);
+ di.Bounds = r;
+ }
+
+ if (NodeDisplay.DrawExpandPart(node) && context.ExpandDisplayInfo != null)
+ {
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandBounds, node, context.Offset);
+ context.ExpandDisplayInfo.Node = node;
+ context.ExpandDisplayInfo.ExpandPartBounds = r;
+ context.ExpandDisplayInfo.IsMouseOver = node.MouseOverNodePart == eMouseOverNodePart.Expand;
+ renderer.DrawNodeExpandPart(context.ExpandDisplayInfo);
+ }
+
+ if (NodeDisplay.HasColumnsVisible(node))
+ {
+ PaintColumnHeaders(node.NodesColumns, context.Graphics, false);
+ }
+
+ Region oldRegion=null;
+ if(backRegion!=null)
+ {
+ oldRegion=context.Graphics.Clip;
+ context.Graphics.SetClip(backRegion,CombineMode.Intersect);
+ }
+
+ ElementStyle cellStyle = null;
+ if (context.CellStyleDefault == null)
+ {
+ cellStyle = new ElementStyle();
+ cellStyle.TextColor = style.TextColor;
+ cellStyle.TextShadowColor = style.TextShadowColor;
+ cellStyle.TextShadowOffset = style.TextShadowOffset;
+ cellStyle.TextAlignment = style.TextAlignment;
+ cellStyle.TextLineAlignment = style.TextLineAlignment;
+ cellStyle.TextTrimming = style.TextTrimming;
+ cellStyle.WordWrap = style.WordWrap;
+ cellStyle.Font = style.Font;
+ cellStyle.UseMnemonic = style.UseMnemonic;
+ }
+
+ foreach(Cell cell in node.Cells)
+ {
+ if (!cell.IsVisible) continue;
+ if (cell.StyleNormal != null)
+ {
+ if (context.CellStyleDefault != null)
+ style = context.CellStyleDefault.Copy();
+ else
+ style = cellStyle.Copy();
+ style.ApplyStyle(cell.StyleNormal);
+ }
+ else if (context.CellStyleDefault != null)
+ style = context.CellStyleDefault.Copy();
+ else
+ {
+ if (!cell.Enabled || cell.IsMouseDown && (cell.StyleMouseDown != null || context.CellStyleMouseDown != null) ||
+ cell.IsSelected && (cell.StyleSelected != null || context.CellStyleSelected != null) ||
+ cell.IsMouseOver && (cell.StyleMouseOver != null || context.CellStyleMouseOver != null))
+ style = cellStyle.Copy();
+ else
+ style = cellStyle;
+ }
+
+ if(!cell.Enabled && cell.StyleDisabled!=null)
+ style.ApplyStyle(cell.StyleDisabled);
+ else if(!cell.Enabled && context.CellStyleDisabled!=null)
+ style.ApplyStyle(context.CellStyleDisabled);
+ else if(cell.IsMouseDown && cell.StyleMouseDown!=null)
+ style.ApplyStyle(cell.StyleMouseDown);
+ else if(cell.IsMouseDown && context.CellStyleMouseDown!=null)
+ style.ApplyStyle(context.CellStyleMouseDown);
+ else
+ {
+ if (cell.IsSelected && cell.StyleSelected != null)
+ style.ApplyStyle(cell.StyleSelected);
+ else if (cell.IsSelected && context.CellStyleSelected != null && context.CellStyleSelected.Custom)
+ style.ApplyStyle(context.CellStyleSelected);
+ else if (isSelected && !cell.IsSelected && this.Tree.SelectionPerCell)
+ style.TextColor = context.DefaultNodeStyle.TextColor;
+
+ if(cell.IsMouseOver && cell.StyleMouseOver!=null)
+ style.ApplyStyle(cell.StyleMouseOver);
+ else if(cell.IsMouseOver && context.CellStyleMouseOver!=null)
+ style.ApplyStyle(context.CellStyleMouseOver);
+ }
+
+ r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds,node,context.Offset);
+
+ if(style!=null)
+ {
+ if(style.Font==null)
+ style.Font=context.DefaultFont;
+ if (isSelected)
+ {
+ style.BackColor = Color.Empty;
+ style.BackColorSchemePart = eColorSchemePart.None;
+ style.BackColor2 = Color.Empty;
+ style.BackColor2SchemePart = eColorSchemePart.None;
+ }
+
+ Rectangle rCell=cell.BoundsRelative;
+ Rectangle rText=cell.TextContentBounds;
+ rCell.Offset(r.Location);
+ rText.Offset(r.Location);
+ ElementStyleDisplayInfo di=GetElementStyleDisplayInfo(style,context.Graphics,rCell);
+ ElementStyleDisplay.Paint(di);
+ NodeCellRendererEventArgs ci=GetCellDisplayInfo(style,context.Graphics,cell,r.Location, context.ColorScheme);
+
+ if(ci.Cell.CheckBoxVisible)
+ renderer.DrawCellCheckBox(ci);
+ if(!ci.Cell.Images.LargestImageSize.IsEmpty)
+ renderer.DrawCellImage(ci);
+ renderer.DrawCellText(ci);
+ if (context.View == eView.Tile && node.HasChildNodes && !context.TileGroupLineColor.IsEmpty)
+ renderer.DrawTileGroupLine(new NodeRendererEventArgs(context.Graphics, node, r, style, context.TileGroupLineColor));
+ }
+ }
+
+ if (backRegion != null)
+ {
+ context.Graphics.SetClip(oldRegion, CombineMode.Replace);
+ backRegion.Dispose();
+ }
+ if(oldRegion!=null) oldRegion.Dispose();
+ }
+
+ private void PaintConnector(Node fromNode, Node toNode, NodeDisplayContext context,bool linkConnector)
+ {
+ PaintConnector(fromNode, toNode, context, linkConnector, null);
+ }
+
+ private void PaintConnector(Node fromNode, Node toNode, NodeDisplayContext context,bool linkConnector, ConnectorPointsCollection connectorPoints)
+ {
+ bool isRootNode = fromNode != null ? IsRootNode(fromNode) : IsRootNode(toNode);
+
+ if (context.View == eView.Tile || isRootNode && fromNode == null && toNode.Nodes.Count == 0 && toNode.ExpandVisibility != eNodeExpandVisibility.Visible || context.ConnectorDisplayInfo == null)
+ return;
+
+ context.ConnectorDisplayInfo.FromNode=fromNode;
+ context.ConnectorDisplayInfo.ToNode=toNode;
+ context.ConnectorDisplayInfo.IsRootNode=isRootNode;
+ context.ConnectorDisplayInfo.LinkConnector=linkConnector;
+ if (fromNode != null && fromNode.Style != null)
+ context.ConnectorDisplayInfo.StyleFromNode = fromNode.Style;
+ else
+ context.ConnectorDisplayInfo.StyleFromNode = context.DefaultNodeStyle;
+ if(toNode.Style!=null)
+ context.ConnectorDisplayInfo.StyleToNode=toNode.Style;
+ else
+ context.ConnectorDisplayInfo.StyleToNode=context.DefaultNodeStyle;
+ context.ConnectorDisplayInfo.Offset=context.Offset;
+
+ /*if(linkConnector)
+ {
+ context.ConnectorDisplayInfo.NodeConnector=this.Tree.LinkConnector;
+ }
+ else*/ if(toNode.SelectedConnectorMarker)
+ {
+ context.ConnectorDisplayInfo.NodeConnector=this.Tree.SelectedPathConnector;
+ }
+ else if(toNode.ParentConnector!=null)
+ {
+ context.ConnectorDisplayInfo.NodeConnector=toNode.ParentConnector;
+ }
+ //else if(isRootNode)
+ //{
+ // context.ConnectorDisplayInfo.NodeConnector=this.Tree.RootConnector;
+ //}
+ else
+ {
+ context.ConnectorDisplayInfo.NodeConnector=this.Tree.NodesConnector;
+ }
+
+ if(linkConnector)
+ {
+ context.ConnectorDisplayInfo.ConnectorPoints=connectorPoints;
+ }
+ else
+ {
+ if(connectorPoints!=null)
+ context.ConnectorDisplayInfo.ConnectorPoints=connectorPoints;
+ else
+ context.ConnectorDisplayInfo.ConnectorPoints=null;
+ }
+
+ context.NodeRenderer.DrawConnector(context.ConnectorDisplayInfo);
+ }
+
+ private void PaintConnector(Node toNode, NodeDisplayContext context)
+ {
+ PaintConnector(toNode.Parent, toNode, context,false);
+ }
+
+// private void MoveHostedControls(Node node, NodeDisplayContext context)
+// {
+// foreach(Cell cell in node.Cells)
+// {
+// if(cell.HostedControl!=null && cell.HostedControl.Visible)
+// {
+// Rectangle bounds = NodeDisplay.GetCellRectangle(eCellRectanglePart.TextBounds, cell, context.Offset);
+// if(cell.HostedControl.Bounds!=bounds)
+// cell.HostedControl.Bounds=bounds;
+// return;
+// }
+// }
+// }
+
+ private ElementStyleDisplayInfo GetElementStyleDisplayInfo(ElementStyle style, Graphics g, Rectangle bounds)
+ {
+ m_ElementStyleDisplayInfo.Style=style;
+ m_ElementStyleDisplayInfo.Graphics=g;
+ m_ElementStyleDisplayInfo.Bounds=bounds;
+ return m_ElementStyleDisplayInfo;
+ }
+
+ private NodeCellRendererEventArgs GetCellDisplayInfo(ElementStyle style, Graphics g, Cell cell, Point cellOffset, ColorScheme cs)
+ {
+ m_CellDisplayInfo.Cell=cell;
+ m_CellDisplayInfo.Graphics=g;
+ m_CellDisplayInfo.Style=style;
+ m_CellDisplayInfo.CellOffset=cellOffset;
+ m_CellDisplayInfo.ColorScheme = cs;
+ return m_CellDisplayInfo;
+ }
+ internal override void PaintColumnHeaders(ColumnHeaderCollection columns, Graphics g, bool treeControlHeader)
+ {
+ // Setup rendering
+ TreeRenderer renderer = m_SystemRenderer;
+ if (this.Tree.NodeRenderer != null && this.Tree.RenderMode == eNodeRenderMode.Custom)
+ renderer = this.Tree.NodeRenderer;
+ //else if (this.Tree.RenderMode == eNodeRenderMode.Professional)
+ // renderer = m_ProfRenderer;
+ PaintColumnHeaders(renderer, columns, g, treeControlHeader);
+ }
+
+ internal void PaintColumnHeaders(TreeRenderer renderer, ColumnHeaderCollection columns, Graphics g, bool treeControlHeader)
+ {
+ ColumnHeaderRendererEventArgs ce = new ColumnHeaderRendererEventArgs();
+ ce.Graphics = g;
+ ce.Tree = this.Tree;
+ ce.SortIndicatorColor = renderer.ColorTable.ColumnSortIndicatorColor;
+
+ ElementStyle defaultNormalStyle = GetDefaultColumnStyleNormal(renderer);
+ ElementStyle headerStyle = null;
+ if(treeControlHeader)
+ headerStyle = this.Tree.ColumnsBackgroundStyle == null ? GetDefaultHeaderStyle(renderer) : this.Tree.ColumnsBackgroundStyle;
+ else
+ headerStyle = this.Tree.NodesColumnsBackgroundStyle == null ? GetDefaultNodesHeaderStyle(renderer) : this.Tree.NodesColumnsBackgroundStyle;
+
+ if (Tree.ColumnStyleNormal != null && Tree.ColumnStyleNormal.Custom)
+ defaultNormalStyle = Tree.ColumnStyleNormal;
+
+ Point offset = Point.Empty;
+ if (this.Tree.AutoScroll)
+ {
+ offset = this.Tree.GetAutoScrollPositionOffset();
+ if (treeControlHeader)
+ offset.Y = 0;
+ }
+
+ Rectangle columnsBounds = columns.Bounds;
+ if (!treeControlHeader) columnsBounds.Offset(offset);
+ ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(headerStyle, g, columnsBounds);
+ ElementStyleDisplay.Paint(di);
+ Color columnSeparator = (headerStyle != null && !headerStyle.BorderColor.IsEmpty) ? headerStyle.BorderColor : Color.Empty;
+ for (int i = 0; i < columns.Count; i++)
+ {
+ ColumnHeader column = columns.ColumnAtDisplayIndex(i);
+ if (!column.Visible) continue;
+ ElementStyle style = null;
+ if (column.StyleNormal != "")
+ style = Tree.Styles[column.StyleNormal].Copy();
+ else
+ style = defaultNormalStyle.Copy();
+
+ if (column.IsMouseDown)
+ {
+ if (column.StyleMouseDown != "")
+ style.ApplyStyle(Tree.Styles[column.StyleMouseDown]);
+ else if (Tree.ColumnStyleMouseDown != null)
+ style.ApplyStyle(Tree.ColumnStyleMouseDown);
+ }
+ else if (column.IsMouseOver)
+ {
+ if (column.StyleMouseOver != "")
+ style.ApplyStyle(Tree.Styles[column.StyleMouseOver]);
+ else if (Tree.ColumnStyleMouseOver != null)
+ style.ApplyStyle(Tree.ColumnStyleMouseOver);
+ }
+
+ ce.ColumnHeader = column;
+ Rectangle columnBounds = column.Bounds;
+ columnBounds.Offset(offset);
+ ce.Bounds = columnBounds;
+ ce.Style = style;
+ renderer.DrawColumnHeader(ce);
+ if (!columnSeparator.IsEmpty)
+ DisplayHelp.DrawLine(g, columnBounds.Right - (column.IsLastVisible ? 0 : 1), columnBounds.Y, columnBounds.Right - (column.IsLastVisible ? 0 : 1), columnBounds.Bottom - 1, columnSeparator, 1);
+ }
+ }
+
+ private ElementStyle GetDefaultHeaderStyle(TreeRenderer renderer)
+ {
+ if (renderer != null && renderer.Office2007ColorTable != null)
+ {
+ return renderer.Office2007ColorTable.StyleClasses[ElementStyleClassKeys.TreeColumnsHeaderKey] as ElementStyle;
+ }
+ else
+ {
+ ElementStyle style = new ElementStyle();
+ style.BackColor = ColorScheme.GetColor(0xF9FCFD);
+ style.BackColor2 = ColorScheme.GetColor(0xD3DBE9);
+ style.BackColorGradientAngle = 90;
+ style.TextColor = ColorScheme.GetColor(0x000000);
+ style.BorderColor = ColorScheme.GetColor(0x9EB6CE);
+ style.BorderBottom = eStyleBorderType.Solid;
+ style.BorderBottomWidth = 1;
+ return style;
+ }
+ }
+
+ private ElementStyle GetDefaultNodesHeaderStyle(TreeRenderer renderer)
+ {
+ if (renderer != null && renderer.Office2007ColorTable != null)
+ {
+ return renderer.Office2007ColorTable.StyleClasses[ElementStyleClassKeys.TreeNodesColumnsHeaderKey] as ElementStyle;
+ }
+ else
+ {
+ ElementStyle style = new ElementStyle();
+ style.BackColor = ColorScheme.GetColor(0xF9FCFD);
+ style.BackColor2 = ColorScheme.GetColor(0xD3DBE9);
+ style.BackColorGradientAngle = 90;
+ style.TextColor = ColorScheme.GetColor(0x000000);
+ style.BorderColor = ColorScheme.GetColor(0x9EB6CE);
+ style.BorderBottom = eStyleBorderType.Solid;
+ style.BorderBottomWidth = 1;
+ style.BorderLeft = eStyleBorderType.Solid;
+ style.BorderLeftWidth = 1;
+ style.BorderTop = eStyleBorderType.Solid;
+ style.BorderTopWidth = 1;
+ return style;
+ }
+ }
+
+ private ElementStyle GetDefaultColumnStyleNormal(TreeRenderer renderer)
+ {
+ if (renderer != null && renderer.Office2007ColorTable != null)
+ {
+ return renderer.Office2007ColorTable.StyleClasses[ElementStyleClassKeys.TreeColumnKey] as ElementStyle;
+ }
+ else
+ {
+ ElementStyle style = new ElementStyle();
+ style.TextColor = ColorScheme.GetColor(0x000000);
+ return style;
+ }
+ }
+
+// private NodeConnectorDisplay GetConnectorDisplay(NodeConnector c)
+// {
+// NodeConnectorDisplay d=null;
+// if(c==null)
+// return null;
+//
+// switch(c.ConnectorType)
+// {
+// case eNodeConnectorType.Curve:
+// {
+// if(m_CurveConnectorDisplay==null)
+// m_CurveConnectorDisplay=new CurveConnectorDisplay();
+// d=m_CurveConnectorDisplay;
+// break;
+// }
+// case eNodeConnectorType.Line:
+// {
+// if(m_LineConnectorDisplay==null)
+// m_LineConnectorDisplay=new LineConnectorDisplay();
+// d=m_LineConnectorDisplay;
+// break;
+// }
+// }
+// return d;
+// }
+
+ private class NodeDisplayContext
+ {
+ public Graphics Graphics=null;
+ public Font DefaultFont=null;
+ public Rectangle ClipRectangle=Rectangle.Empty;
+ public Point Offset=Point.Empty;
+ public ElementStyle DefaultNodeStyle=null;
+ public ElementStyle ExpandedNodeStyle=null;
+ public ElementStyle SelectedNodeStyle=null;
+ public ElementStyle MouseOverNodeStyle=null;
+ public ElementStyle CellStyleDefault=null;
+ public ElementStyle CellStyleMouseDown=null;
+ public ElementStyle CellStyleMouseOver=null;
+ public ElementStyle CellStyleSelected=null;
+ public ElementStyle CellStyleDisabled=null;
+ public ElementStyleCollection Styles=null;
+ //public NodeConnectorDisplay RootConnectorDisplay=null;
+ //public NodeConnectorDisplay NodesConnectorDisplay=null;
+ //public NodeConnectorDisplay LinkConnectorDisplay=null;
+ //public NodeConnectorDisplay SelectedPathConnectorDisplay=null;
+ public ConnectorRendererEventArgs ConnectorDisplayInfo=null;
+ public NodeExpandPartRendererEventArgs ExpandDisplayInfo=null;
+ //public NodeExpandDisplay ExpandDisplay=null;
+ //public NodeSelectionDisplay SelectionDisplay=null;
+ public SelectionRendererEventArgs SelectionDisplayInfo=null;
+ //public NodeCommandDisplay CommandDisplay=null;
+ //public NodeCommandPartRendererEventArgs CommandDisplayInfo=null;
+ public bool SelectedNodePath=false;
+ public TreeRenderer NodeRenderer=null;
+ public NodeRendererEventArgs NodeRendererEventArgs=null;
+ public bool IsBackgroundSelection = false;
+ public Rectangle ClientRectangle = Rectangle.Empty;
+ public ColorScheme ColorScheme = null;
+ public bool GridRowLines = false;
+ public Color GridRowLineColor = Color.Empty;
+ public bool CellSelection = false;
+ public Brush AlternateRowBrush = null;
+ public bool DrawAlternateRowBackground = false;
+ public bool AlternateRowFlag = false;
+ public eView View = eView.Tree;
+ public Color TileGroupLineColor = Color.Empty;
+ }
+
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/SelectionColorTable.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/SelectionColorTable.cs
new file mode 100644
index 00000000..411e30aa
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/SelectionColorTable.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Text;
+using DevComponents.WinForms.Drawing;
+using System.Drawing;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Defines the color table for tree selection.
+ ///
+ public class SelectionColorTable
+ {
+ ///
+ /// Gets or sets the outer border for the selection.
+ ///
+ public Border Border = null;
+ ///
+ /// Gets or sets the outer border corner radius.
+ ///
+ public int BorderCornerRadius = 0;
+ ///
+ /// Gets or sets the inner border for the selection.
+ ///
+ public Border InnerBorder = null;
+ ///
+ /// Gets or sets the selection fill.
+ ///
+ public Fill Fill = null;
+ ///
+ /// Gets or sets the selection text color.
+ ///
+ public Color TextColor = Color.Empty;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/SelectionRendererEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/SelectionRendererEventArgs.cs
new file mode 100644
index 00000000..e0475495
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/SelectionRendererEventArgs.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Drawing;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Data form RenderSelection event.
+ ///
+ public class SelectionRendererEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets reference to Graphics object, canvas node is rendered on.
+ ///
+ public System.Drawing.Graphics Graphics=null;
+ ///
+ /// Gets or sets the reference to selected Node object.
+ ///
+ public DevComponents.AdvTree.Node Node=null;
+ ///
+ /// Gets or sets the selection bounds.
+ ///
+ public Rectangle Bounds=Rectangle.Empty;
+ ///
+ /// Gets or sets the node selection box style.
+ ///
+ public eSelectionStyle SelectionBoxStyle = eSelectionStyle.HighlightCells;
+ ///
+ /// Gets or sets whether tree control is active, focused.
+ ///
+ public bool TreeActive = false;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/TreeBackgroundRendererEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeBackgroundRendererEventArgs.cs
new file mode 100644
index 00000000..79f82314
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeBackgroundRendererEventArgs.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Drawing;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Provides data for tree background rendering events.
+ ///
+ public class TreeBackgroundRendererEventArgs
+ {
+ ///
+ /// Gets or sets reference to Graphics object, canvas tree background is rendered on.
+ ///
+ public System.Drawing.Graphics Graphics=null;
+
+ ///
+ /// Gets or sets the reference to AdvTree control.
+ ///
+ public AdvTree AdvTree = null;
+
+ ///
+ /// Creates new instance of the class and initializes it with default values.
+ ///
+ /// Reference to graphics object.
+ public TreeBackgroundRendererEventArgs(Graphics g, AdvTree tree)
+ {
+ this.Graphics = g;
+ this.AdvTree = tree;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/TreeColorTable.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeColorTable.cs
new file mode 100644
index 00000000..fdcd7717
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeColorTable.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Defines the Tree color table.
+ ///
+ [ToolboxItem(false)]
+ public class TreeColorTable : Component
+ {
+ #region Internal Implementation
+ ///
+ /// Gets or sets the color table used for the node selection display.
+ ///
+ public TreeSelectionColors Selection = new TreeSelectionColors();
+ ///
+ /// Gets or sets the color for node drag & drop marker.
+ ///
+ public Color DragDropMarker = Color.Black;
+ ///
+ /// Gets or sets the color of tree expand button type of rectangle.
+ ///
+ public TreeExpandColorTable ExpandRectangle = new TreeExpandColorTable();
+ ///
+ /// Gets or sets the color of tree expand button type of Ellipse.
+ ///
+ public TreeExpandColorTable ExpandEllipse = new TreeExpandColorTable();
+ ///
+ /// Gets or sets the color of tree expand button type of Triangle.
+ ///
+ public TreeExpandColorTable ExpandTriangle = new TreeExpandColorTable();
+ ///
+ /// Gets or sets the color for tree grid lines.
+ ///
+ public Color GridLines = Color.Empty;
+ ///
+ /// Gets or sets the color of the column sort indicator which is rendered on columns when sorted.
+ ///
+ public Color ColumnSortIndicatorColor = Color.Gray;
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/TreeExpandColorTable.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeExpandColorTable.cs
new file mode 100644
index 00000000..a079d19a
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeExpandColorTable.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Text;
+using DevComponents.WinForms.Drawing;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Defines the color table for node expand button.
+ ///
+ public class TreeExpandColorTable
+ {
+ ///
+ /// Gets or sets the border for the expand button which expands the node.
+ ///
+ public Border ExpandBorder = null;
+ ///
+ /// Gets or sets the expand button fill for button that expands the node.
+ ///
+ public Fill ExpandFill = null;
+ ///
+ /// Gets or sets the expand button foreground for button that expands the node.
+ ///
+ public Fill ExpandForeground = null;
+ ///
+ /// Gets or sets the border for the expand button which expands the node.
+ ///
+ public Border ExpandMouseOverBorder = null;
+ ///
+ /// Gets or sets the expand button fill for button that expands the node.
+ ///
+ public Fill ExpandMouseOverFill = null;
+ ///
+ /// Gets or sets the expand button foreground for button that expands the node.
+ ///
+ public Fill ExpandMouseOverForeground = null;
+ ///
+ /// Gets or sets the border for the expand button which collapses the node.
+ ///
+ public Border CollapseBorder = null;
+ ///
+ /// Gets or sets the expand button fill for button that collapses the node.
+ ///
+ public Fill CollapseFill = null;
+ ///
+ /// Gets or sets the expand button foreground for button that expands the node.
+ ///
+ public Fill CollapseForeground = null;
+ ///
+ /// Gets or sets the border for the expand button which collapses the node.
+ ///
+ public Border CollapseMouseOverBorder = null;
+ ///
+ /// Gets or sets the expand button fill for button that collapses the node.
+ ///
+ public Fill CollapseMouseOverFill = null;
+ ///
+ /// Gets or sets the expand button foreground for button that expands the node.
+ ///
+ public Fill CollapseMouseOverForeground = null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/TreeRenderer.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeRenderer.cs
new file mode 100644
index 00000000..62fcbebb
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeRenderer.cs
@@ -0,0 +1,386 @@
+using System;
+using System.Drawing;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Represents abstract renderer class for node objects.
+ ///
+ public abstract class TreeRenderer
+ {
+ #region Events
+ ///
+ /// Occurs when node background is being drawn.
+ ///
+ public event NodeRendererEventHandler RenderNodeBackground;
+ ///
+ /// Occurs when node expand part is being drawn.
+ ///
+ public event NodeExpandPartRendererEventHandler RenderNodeExpandPart;
+ /////
+ ///// Occurs when node command part is being drawn.
+ /////
+ //public event NodeCommandPartRendererEventHandler RenderNodeCommandPart;
+ ///
+ /// Occurs when cell background is being drawn.
+ ///
+ public event NodeCellRendererEventHandler RenderCellBackground;
+ ///
+ /// Occurs when cell check-box is being drawn.
+ ///
+ public event NodeCellRendererEventHandler RenderCellCheckBox;
+ ///
+ /// Occurs when cell image is being drawn.
+ ///
+ public event NodeCellRendererEventHandler RenderCellImage;
+ ///
+ /// Occurs when cell text is being drawn.
+ ///
+ public event NodeCellRendererEventHandler RenderCellText;
+ ///
+ /// Occurs when node selection marker is rendered.
+ ///
+ public event SelectionRendererEventHandler RenderSelection;
+ ///
+ /// Occurs when node hot-tracking marker is rendered.
+ ///
+ public event SelectionRendererEventHandler RenderHotTracking;
+ ///
+ /// Occurs when node connector is being drawn.
+ ///
+ public event ConnectorRendererEventHandler RenderConnector;
+
+ ///
+ /// Occurs when tree background is rendered.
+ ///
+ public event TreeBackgroundRendererEventHandler RenderTreeBackground;
+
+ ///
+ /// Occurs when drag & drop marker is rendered.
+ ///
+ public event DragDropMarkerRendererEventHandler RenderDragDropMarker;
+ ///
+ /// Renders the Column Header.
+ ///
+ public event ColumnHeaderRendererEventHandler RenderColumnHeader;
+ ///
+ /// Occurs when node group line is being rendered while control is in tile view.
+ ///
+ public event NodeRendererEventHandler RenderTileGroupLine;
+ #endregion
+
+ #region Private Variables
+ #endregion
+
+ #region Constructor
+ public TreeRenderer()
+ {
+ }
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Draws node background. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderNodeBackground method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawNodeBackground(NodeRendererEventArgs e)
+ {
+ OnRenderNodeBackground(e);
+ }
+
+ ///
+ /// Raises RenderNodeBackground event.
+ ///
+ /// Event arguments.
+ protected virtual void OnRenderNodeBackground(NodeRendererEventArgs e)
+ {
+ if(RenderNodeBackground!=null)
+ RenderNodeBackground(this,e);
+ }
+
+ ///
+ /// Draws node expand part. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderNodeExpandPart method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawNodeExpandPart(NodeExpandPartRendererEventArgs e)
+ {
+ OnRenderNodeExpandPart(e);
+ }
+
+ ///
+ /// Raises RenderNodeExpandPart event.
+ ///
+ ///
+ protected virtual void OnRenderNodeExpandPart(NodeExpandPartRendererEventArgs e)
+ {
+ if(RenderNodeExpandPart!=null)
+ RenderNodeExpandPart(this,e);
+ }
+
+ /////
+ ///// Draws node command part. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ ///// do not want default rendering to occur do not call the base implementation. You can call OnRenderNodeCommandPart method so events can occur.
+ /////
+ ///// Information provided for rendering.
+ //public virtual void DrawNodeCommandPart(NodeCommandPartRendererEventArgs e)
+ //{
+ // OnRenderNodeCommandPart(e);
+ //}
+
+ /////
+ ///// Raises RenderNodeCommandPart event.
+ /////
+ ///// Event arguments.
+ //protected virtual void OnRenderNodeCommandPart(NodeCommandPartRendererEventArgs e)
+ //{
+ // if(RenderNodeCommandPart!=null)
+ // RenderNodeCommandPart(this,e);
+ //}
+
+ ///
+ /// Draws cell background. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderCellBackground method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawCellBackground(NodeCellRendererEventArgs e)
+ {
+ OnRenderCellBackground(e);
+ }
+
+ ///
+ /// Raises RenderCellBackground event.
+ ///
+ /// Event arguments
+ protected virtual void OnRenderCellBackground(NodeCellRendererEventArgs e)
+ {
+ if(RenderCellBackground!=null)
+ RenderCellBackground(this, e);
+ }
+
+ ///
+ /// Draws cell check box. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderCellCheckBox method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawCellCheckBox(NodeCellRendererEventArgs e)
+ {
+ OnRenderCellCheckBox(e);
+ }
+
+ ///
+ /// Raises RenderCellCheckBox event.
+ ///
+ /// Event arguments
+ protected virtual void OnRenderCellCheckBox(NodeCellRendererEventArgs e)
+ {
+ if(RenderCellCheckBox!=null)
+ RenderCellCheckBox(this, e);
+ }
+
+ ///
+ /// Draws cell image. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderCellImage method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawCellImage(NodeCellRendererEventArgs e)
+ {
+ OnRenderCellImage(e);
+ }
+
+ ///
+ /// Raises RenderCellImage event.
+ ///
+ /// Event arguments
+ protected virtual void OnRenderCellImage(NodeCellRendererEventArgs e)
+ {
+ if(RenderCellImage!=null)
+ RenderCellImage(this, e);
+ }
+
+ ///
+ /// Draws cell text. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderCellText method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawCellText(NodeCellRendererEventArgs e)
+ {
+ OnRenderCellText(e);
+ }
+
+ ///
+ /// Raises RenderCellImage event.
+ ///
+ /// Event arguments
+ protected virtual void OnRenderCellText(NodeCellRendererEventArgs e)
+ {
+ if(RenderCellText!=null)
+ RenderCellText(this, e);
+ }
+
+ ///
+ /// Draws selection for SelectedNode. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderSelection method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawSelection(SelectionRendererEventArgs e)
+ {
+ OnRenderSelection(e);
+ }
+
+ ///
+ /// Raises RenderSelection event.
+ ///
+ /// Event data.
+ protected virtual void OnRenderSelection(SelectionRendererEventArgs e)
+ {
+ if(RenderSelection!=null)
+ RenderSelection(this, e);
+ }
+
+ ///
+ /// Draws hot-tracking marker for mouse over node. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderHotTracking method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawHotTracking(SelectionRendererEventArgs e)
+ {
+ OnRenderHotTracking(e);
+ }
+
+ ///
+ /// Raises RenderHotTracking event.
+ ///
+ /// Event data.
+ protected virtual void OnRenderHotTracking(SelectionRendererEventArgs e)
+ {
+ if (RenderHotTracking != null)
+ RenderHotTracking(this, e);
+ }
+
+ ///
+ /// Draws connector between nodes. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderConnector method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawConnector(ConnectorRendererEventArgs e)
+ {
+ OnRenderConnector(e);
+ }
+
+ ///
+ /// Raises RenderConnector event.
+ ///
+ /// Event data.
+ protected virtual void OnRenderConnector(ConnectorRendererEventArgs e)
+ {
+ if(RenderConnector!=null)
+ RenderConnector(this, e);
+ }
+
+ ///
+ /// Draws the tree background. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderTreeBackground method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawTreeBackground(TreeBackgroundRendererEventArgs e)
+ {
+ OnRenderTreeBackground(e);
+ }
+
+ ///
+ /// Raises RenderTreeBackground event.
+ ///
+ /// Event data.
+ protected virtual void OnRenderTreeBackground(TreeBackgroundRendererEventArgs e)
+ {
+ if(RenderTreeBackground!=null)
+ RenderTreeBackground(this, e);
+ }
+
+ ///
+ /// Draws the drag & drop marker that indicates the insertion point for the node. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderDragDropMarker method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawDragDropMarker(DragDropMarkerRendererEventArgs e)
+ {
+ OnRenderDragDropMarker(e);
+ }
+
+ ///
+ /// Raises RenderDragDropMarker event.
+ ///
+ /// Event data.
+ protected virtual void OnRenderDragDropMarker(DragDropMarkerRendererEventArgs e)
+ {
+ if (RenderDragDropMarker != null)
+ RenderDragDropMarker(this, e);
+ }
+
+ ///
+ /// Draws the column header. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderColumnHeader method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawColumnHeader(ColumnHeaderRendererEventArgs e)
+ {
+ OnRenderColumnHeader(e);
+ }
+
+ ///
+ /// Raises RenderDragDropMarker event.
+ ///
+ /// Event data.
+ protected virtual void OnRenderColumnHeader(ColumnHeaderRendererEventArgs e)
+ {
+ if (RenderColumnHeader != null)
+ RenderColumnHeader(this, e);
+ }
+
+ private TreeColorTable _ColorTable = null;
+ ///
+ /// Gets or sets the color table used by the renderer.
+ ///
+ public TreeColorTable ColorTable
+ {
+ get { return _ColorTable; }
+ set { _ColorTable = value; }
+ }
+
+ private Office2007ColorTable _Office2007ColorTable = null;
+ ///
+ /// Gets or sets the color table used by the renderer.
+ ///
+ internal Office2007ColorTable Office2007ColorTable
+ {
+ get { return _Office2007ColorTable; }
+ set { _Office2007ColorTable = value; }
+ }
+
+ ///
+ /// Draws node group line when in tile view. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
+ /// do not want default rendering to occur do not call the base implementation. You can call OnRenderTileGroupLine method so events can occur.
+ ///
+ /// Information provided for rendering.
+ public virtual void DrawTileGroupLine(NodeRendererEventArgs e)
+ {
+ OnRenderTileGroupLine(e);
+ }
+
+ ///
+ /// Raises RenderNodeBackground event.
+ ///
+ /// Event arguments.
+ protected virtual void OnRenderTileGroupLine(NodeRendererEventArgs e)
+ {
+ if (RenderTileGroupLine != null)
+ RenderTileGroupLine(this, e);
+ }
+
+ #endregion
+ }
+
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Display/TreeSelectionColors.cs b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeSelectionColors.cs
new file mode 100644
index 00000000..4909d030
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Display/TreeSelectionColors.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Text;
+
+namespace DevComponents.AdvTree.Display
+{
+ ///
+ /// Defines the color table for tree selection.
+ ///
+ public class TreeSelectionColors
+ {
+ ///
+ /// Gets or sets the color table for FullRowSelect selection type.
+ ///
+ public SelectionColorTable FullRowSelect = null;
+ ///
+ /// Gets or sets the color table for FullRowSelect selection type when tree control is inactive.
+ ///
+ public SelectionColorTable FullRowSelectInactive = null;
+ ///
+ /// Gets or sets the color table for HighlightCells selection type.
+ ///
+ public SelectionColorTable HighlightCells = null;
+ ///
+ /// Gets or sets the color table for HighlightCells selection type when tree control is inactive.
+ ///
+ public SelectionColorTable HighlightCellsInactive = null;
+ ///
+ /// Gets or sets the color table for NodeMarker selection type.
+ ///
+ public SelectionColorTable NodeMarker = null;
+ ///
+ /// Gets or sets the color table for NodeMarker selection type when tree control is inactive.
+ ///
+ public SelectionColorTable NodeMarkerInactive = null;
+ ///
+ /// Gets or sets the color table used for node hot-tracking.
+ ///
+ public SelectionColorTable NodeHotTracking = null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/Border.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/Border.cs
new file mode 100644
index 00000000..250c4817
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/Border.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace DevComponents.WinForms.Drawing
+{
+ [ToolboxItem(false)]
+ public abstract class Border : Component
+ {
+ #region Internal Implementation
+ ///
+ /// Creates the pen for the border.
+ ///
+ /// Returns pen or null if pen cannot be created.
+ public abstract Pen CreatePen();
+
+ internal int _Width = 0;
+ ///
+ /// Gets or sets the border width. Default value is 0.
+ ///
+ [DefaultValue(0), Description("Indicates border width.")]
+ public int Width
+ {
+ get { return _Width; }
+ set
+ {
+ _Width = value;
+ }
+ }
+
+ internal static Rectangle Deflate(Rectangle bounds, Border border)
+ {
+ if (border == null) return bounds;
+ bounds.Inflate(-border.Width, -border.Width);
+ return bounds;
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorBlendCollection.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorBlendCollection.cs
new file mode 100644
index 00000000..a0e0de54
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorBlendCollection.cs
@@ -0,0 +1,234 @@
+using System;
+using System.Collections;
+using System.Text;
+using System.Drawing.Drawing2D;
+using System.Drawing;
+
+namespace DevComponents.WinForms.Drawing
+{
+ ///
+ /// Represents Collection for the ColorStop objects.
+ ///
+ public class ColorBlendCollection : CollectionBase
+ {
+ #region Private Variables
+
+ #endregion
+
+ #region Internal Implementation
+ /// Creates new instance of the class.
+ public ColorBlendCollection() { }
+
+ ///
+ /// Adds new object to the collection.
+ ///
+ /// Object to add.
+ /// Index of newly added object.
+ public int Add(ColorStop item)
+ {
+ return List.Add(item);
+ }
+
+ ///
+ /// Adds array of new objects to the collection.
+ ///
+ /// Array of object to add.
+ public void AddRange(ColorStop[] items)
+ {
+ foreach (ColorStop item in items)
+ this.Add(item);
+ }
+
+ ///
+ /// Returns reference to the object in collection based on it's index.
+ ///
+ public ColorStop this[int index]
+ {
+ get { return (ColorStop)(List[index]); }
+ set { List[index] = value; }
+ }
+
+ ///
+ /// Inserts new object into the collection.
+ ///
+ /// Position of the object.
+ /// Object to insert.
+ public void Insert(int index, ColorStop value)
+ {
+ List.Insert(index, value);
+ }
+
+ ///
+ /// Returns index of the object inside of the collection.
+ ///
+ /// Reference to the object.
+ /// Index of the object.
+ public int IndexOf(ColorStop value)
+ {
+ return List.IndexOf(value);
+ }
+
+ ///
+ /// Returns whether collection contains specified object.
+ ///
+ /// Object to look for.
+ /// true if object is part of the collection, otherwise false.
+ public bool Contains(ColorStop value)
+ {
+ return List.Contains(value);
+ }
+
+ ///
+ /// Removes specified object from the collection.
+ ///
+ ///
+ public void Remove(ColorStop value)
+ {
+ List.Remove(value);
+ }
+
+ //protected override void OnRemoveComplete(int index,object value)
+ //{
+ // base.OnRemoveComplete(index,value);
+ // ColorStop me=value as ColorStop;
+ //}
+ //protected override void OnInsertComplete(int index,object value)
+ //{
+ // base.OnInsertComplete(index,value);
+ // ColorStop me=value as ColorStop;
+ //}
+
+ ///
+ /// Copies collection into the specified array.
+ ///
+ /// Array to copy collection to.
+ /// Starting index.
+ public void CopyTo(ColorStop[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ ///
+ /// Copies contained items to the ColorStop array.
+ ///
+ /// Array to copy to.
+ internal void CopyTo(ColorStop[] array)
+ {
+ List.CopyTo(array, 0);
+ }
+
+ ///
+ /// Creates ColorBlend object based on the members of the collection. ColorBlend object will be valid only if all members of the collection
+ /// represents relative/percentage based color blends.
+ ///
+ ///
+ public ColorBlend GetColorBlend()
+ {
+ ColorBlend blend = new ColorBlend();
+ Color[] colors = new Color[this.Count];
+ float[] positions = new float[this.Count];
+
+ for (int i = 0; i < this.Count; i++)
+ {
+ ColorStop b = this[i];
+ colors[i] = b.Color;
+ positions[i] = b.Position;
+ }
+
+ blend.Colors = colors;
+ blend.Positions = positions;
+
+ return blend;
+ }
+
+ ///
+ /// Adds the ColorStop objects from the collection.
+ ///
+ /// Collection to copy objects from
+ public void CopyFrom(ColorBlendCollection col)
+ {
+ foreach (ColorStop b in col)
+ this.Add(b);
+ }
+
+ internal eColorStopType GetBlendType()
+ {
+ ColorBlendCollection c = this;
+ if (c.Count <= 1)
+ return eColorStopType.Invalid;
+
+ eColorStopType t = eColorStopType.Invalid;
+
+ foreach (ColorStop b in c)
+ {
+ if (b.Position == 0 || b.Position == 1f)
+ continue;
+ if (b.Position <= 1f)
+ {
+ if (t == eColorStopType.Invalid)
+ t = eColorStopType.Relative;
+ else if (t == eColorStopType.Absolute)
+ {
+ t = eColorStopType.Invalid;
+ break;
+ }
+ }
+ else
+ {
+ if (t == eColorStopType.Invalid)
+ t = eColorStopType.Absolute;
+ else if (t == eColorStopType.Relative)
+ {
+ t = eColorStopType.Invalid;
+ break;
+ }
+ }
+ }
+
+ if (c.Count == 2 && c[0].Position == 0f && c[1].Position == 1f)
+ return eColorStopType.Relative;
+
+ if (t == eColorStopType.Invalid)
+ return t;
+
+ if (t == eColorStopType.Relative && c[0].Position != 0f && c[c.Count - 1].Position != 1f)
+ return eColorStopType.Invalid;
+ else if (t == eColorStopType.Absolute && ((c.Count / 2) * 2 != c.Count))
+ return eColorStopType.Invalid;
+
+ return t;
+ }
+
+ /////
+ ///// Initializes the collection with the two color blend.
+ /////
+ ///// Collection to initialize.
+ ///// Start color.
+ ///// End color.
+ //public static void InitializeCollection(ColorBlendCollection collection, int backColor1, int backColor2)
+ //{
+ // InitializeCollection(collection, ColorScheme.GetColor(backColor1), ColorScheme.GetColor(backColor2));
+ //}
+
+ ///
+ /// Initializes the collection with the two color blend.
+ ///
+ /// Collection to initialize.
+ /// Start color.
+ /// End color.
+ public static void InitializeCollection(ColorBlendCollection collection, Color backColor1, Color backColor2)
+ {
+ collection.Clear();
+ collection.Add(new ColorStop(backColor1, 0f));
+ collection.Add(new ColorStop(backColor2, 1f));
+ }
+ #endregion
+ }
+
+ internal enum eColorStopType
+ {
+ Invalid,
+ Relative,
+ Absolute
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorStop.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorStop.cs
new file mode 100644
index 00000000..b17a4a50
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorStop.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace DevComponents.WinForms.Drawing
+{
+ ///
+ /// Defines single color blend point for the multicolor gradient fills.
+ ///
+ [ToolboxItem(false), DesignTimeVisible(false), TypeConverter(typeof(ColorStopConverter))]
+ public class ColorStop
+ {
+ #region Private Variables
+ private Color _Color = Color.Empty;
+ private float _Position = 0;
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Creates new instance of the class. When defining multicolor gradient blends and using the percentage positions the positions created
+ /// must start with 0f and end with 1f.
+ ///
+ public ColorStop() { }
+
+ ///
+ /// Creates new instance of the class and initialize it with default values.
+ ///
+ public ColorStop(Color color, float position)
+ {
+ _Color = color;
+ _Position = position;
+ }
+
+ /////
+ ///// Creates new instance of the class and initialize it with default values.
+ /////
+ //public ColorStop(int color, float position)
+ //{
+ // _Color = ColorScheme.GetColor(color);
+ // _Position = position;
+ //}
+
+ ///
+ /// Gets or sets Color to use in multicolor gradient blend at specified position.
+ ///
+ [Browsable(true), Description("Indicates the Color to use in multicolor gradient blend at specified position.")]
+ public Color Color
+ {
+ get { return _Color; }
+ set
+ {
+ _Color = value;
+ OnColorBlendChanged();
+ }
+ }
+ private bool ShouldSerializeColor()
+ {
+ return !_Color.IsEmpty;
+ }
+
+ ///
+ /// Gets or sets the color position in multicolor gradient blend. Values less or equal to 1 are used as percentage specifing percentages of distance along the gradient line.
+ /// Values greater than 1 are used as absolute pixel values of distance along the gradient line.
+ ///
+ [Browsable(true), DefaultValue(0f), Description("")]
+ public float Position
+ {
+ get { return _Position; }
+ set
+ {
+ _Position = value;
+ OnColorBlendChanged();
+ }
+ }
+
+ private void OnColorBlendChanged()
+ {
+ }
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorStopConverter.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorStopConverter.cs
new file mode 100644
index 00000000..17656735
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorStopConverter.cs
@@ -0,0 +1,49 @@
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+using System.Reflection;
+using System.Drawing;
+
+namespace DevComponents.WinForms.Drawing
+{
+ ///
+ /// Represents BackgroundColorBlend object converter.
+ ///
+ public class ColorStopConverter : TypeConverter
+ {
+ public ColorStopConverter() { }
+
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
+ {
+ if (destinationType == typeof(InstanceDescriptor))
+ return true;
+ return base.CanConvertTo(context, destinationType);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if ((destinationType == typeof(InstanceDescriptor)) && (value is ColorStop))
+ {
+ ColorStop doc = (ColorStop)value;
+ Type[] constructorParams = null;
+ MemberInfo constructorMemberInfo = null;
+ object[] constructorValues = null;
+
+ constructorParams = new Type[2] { typeof(Color), typeof(float) };
+ constructorMemberInfo = typeof(ColorStop).GetConstructor(constructorParams);
+ constructorValues = new object[2] { doc.Color, doc.Position };
+
+ if (constructorMemberInfo != null)
+ {
+ return new InstanceDescriptor(constructorMemberInfo, constructorValues);
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/CornerRadius.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/CornerRadius.cs
new file mode 100644
index 00000000..85b1b91f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/CornerRadius.cs
@@ -0,0 +1,258 @@
+using System;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+using System.Globalization;
+using System.ComponentModel.Design.Serialization;
+
+namespace DevComponents.WinForms.Drawing
+{
+ [StructLayout(LayoutKind.Sequential), TypeConverter(typeof(CornerRadiusConverter))]
+ public struct CornerRadius
+#if FRAMEWORK20
+ : IEquatable
+#endif
+ {
+ #region Private Variables
+ private int _TopLeft;
+ private int _topRight;
+ private int _bottomLeft;
+ private int _bottomRight;
+ #endregion
+
+ #region Constructor
+ public CornerRadius(int uniformRadius)
+ {
+ this._TopLeft = this._topRight = this._bottomLeft = this._bottomRight = uniformRadius;
+ }
+
+ public CornerRadius(int topLeft, int topRight, int bottomRight, int bottomLeft)
+ {
+ this._TopLeft = topLeft;
+ this._topRight = topRight;
+ this._bottomRight = bottomRight;
+ this._bottomLeft = bottomLeft;
+ }
+ #endregion
+
+ #region Internal Implementation
+ public override bool Equals(object obj)
+ {
+ if (obj is CornerRadius)
+ {
+ CornerRadius radius = (CornerRadius)obj;
+ return (this == radius);
+ }
+ return false;
+ }
+
+ public bool Equals(CornerRadius cornerRadius)
+ {
+ return (this == cornerRadius);
+ }
+
+ public override int GetHashCode()
+ {
+ return (((this._TopLeft.GetHashCode() ^ this._topRight.GetHashCode()) ^ this._bottomLeft.GetHashCode()) ^ this._bottomRight.GetHashCode());
+ }
+
+ public override string ToString()
+ {
+ return CornerRadiusConverter.ToString(this, CultureInfo.InvariantCulture);
+ }
+
+ public static bool operator ==(CornerRadius cr1, CornerRadius cr2)
+ {
+ return ((cr1._TopLeft == cr2._TopLeft) && (cr1._topRight == cr2._topRight) && (cr1._bottomRight == cr2._bottomRight) && (cr1._bottomLeft == cr2._bottomLeft));
+ }
+
+ public static bool operator !=(CornerRadius cr1, CornerRadius cr2)
+ {
+ return !(cr1 == cr2);
+ }
+
+ public int TopLeft
+ {
+ get
+ {
+ return this._TopLeft;
+ }
+ set
+ {
+ this._TopLeft = value;
+ }
+ }
+ public int TopRight
+ {
+ get
+ {
+ return this._topRight;
+ }
+ set
+ {
+ this._topRight = value;
+ }
+ }
+ public int BottomRight
+ {
+ get
+ {
+ return this._bottomRight;
+ }
+ set
+ {
+ this._bottomRight = value;
+ }
+ }
+ public int BottomLeft
+ {
+ get
+ {
+ return this._bottomLeft;
+ }
+ set
+ {
+ this._bottomLeft = value;
+ }
+ }
+
+ internal bool IsValid(bool allowNegative)
+ {
+ if (!allowNegative && (((this._TopLeft < 0.0) || (this._topRight < 0.0)) || ((this._bottomLeft < 0.0) || (this._bottomRight < 0.0))))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ internal bool IsZero
+ {
+ get
+ {
+ return (_TopLeft == 0 && _topRight == 0 && _bottomRight == 0 && _bottomLeft == 0);
+ }
+ }
+ #endregion
+ }
+
+ #region CornerRadiusConverter
+ public class CornerRadiusConverter : TypeConverter
+ {
+ // Methods
+ public override bool CanConvertFrom(ITypeDescriptorContext typeDescriptorContext, Type sourceType)
+ {
+ switch (Type.GetTypeCode(sourceType))
+ {
+ case TypeCode.Int16:
+ case TypeCode.UInt16:
+ case TypeCode.Int32:
+ case TypeCode.UInt32:
+ case TypeCode.Int64:
+ case TypeCode.UInt64:
+ case TypeCode.Single:
+ case TypeCode.Double:
+ case TypeCode.Decimal:
+ case TypeCode.String:
+ return true;
+ }
+ return false;
+ }
+
+ public override bool CanConvertTo(ITypeDescriptorContext typeDescriptorContext, Type destinationType)
+ {
+ if ((destinationType != typeof(InstanceDescriptor)) && (destinationType != typeof(string)))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object source)
+ {
+ if (source == null)
+ {
+ throw base.GetConvertFromException(source);
+ }
+ if (source is string)
+ {
+ return FromString((string)source, cultureInfo);
+ }
+ return new CornerRadius(Convert.ToInt32(source, cultureInfo));
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType)
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException("value");
+ }
+ if (destinationType == null)
+ {
+ throw new ArgumentNullException("destinationType");
+ }
+ if (!(value is CornerRadius))
+ {
+ throw new ArgumentException("Unexpected parameter type", "value");
+ }
+ CornerRadius cr = (CornerRadius)value;
+ if (destinationType == typeof(string))
+ {
+ return ToString(cr, cultureInfo);
+ }
+ if (destinationType != typeof(InstanceDescriptor))
+ {
+ throw new ArgumentException("Cannot convert to type " + destinationType.FullName);
+ }
+ return new InstanceDescriptor(typeof(CornerRadius).GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) }), new object[] { cr.TopLeft, cr.TopRight, cr.BottomRight, cr.BottomLeft });
+ }
+
+ internal static CornerRadius FromString(string s, CultureInfo cultureInfo)
+ {
+ string[] parsed = s.Split(GetNumericListSeparator(cultureInfo));
+ int[] numArray = new int[4];
+ for (int i = 0; i < parsed.Length; i++)
+ {
+ numArray[i] = int.Parse(parsed[i], cultureInfo);
+ }
+
+ int index = Math.Min(5, parsed.Length);
+
+ switch (index)
+ {
+ case 1:
+ return new CornerRadius(numArray[0]);
+
+ case 4:
+ return new CornerRadius(numArray[0], numArray[1], numArray[2], numArray[3]);
+ }
+ throw new FormatException("Invalid string corner radius");
+ }
+
+ internal static string ToString(CornerRadius cr, CultureInfo cultureInfo)
+ {
+ char numericListSeparator = GetNumericListSeparator(cultureInfo);
+ StringBuilder builder = new StringBuilder(0x40);
+ builder.Append(cr.TopLeft.ToString(cultureInfo));
+ builder.Append(numericListSeparator);
+ builder.Append(cr.TopRight.ToString(cultureInfo));
+ builder.Append(numericListSeparator);
+ builder.Append(cr.BottomRight.ToString(cultureInfo));
+ builder.Append(numericListSeparator);
+ builder.Append(cr.BottomLeft.ToString(cultureInfo));
+ return builder.ToString();
+ }
+
+ internal static char GetNumericListSeparator(IFormatProvider provider)
+ {
+ char ch = ',';
+ NumberFormatInfo instance = NumberFormatInfo.GetInstance(provider);
+ if ((instance.NumberDecimalSeparator.Length > 0) && (ch == instance.NumberDecimalSeparator[0]))
+ {
+ ch = ';';
+ }
+ return ch;
+ }
+ }
+ #endregion
+
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/Fill.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/Fill.cs
new file mode 100644
index 00000000..9757f71a
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/Fill.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace DevComponents.WinForms.Drawing
+{
+ [ToolboxItem(false)]
+ public abstract class Fill : Component
+ {
+ #region Internal Implementation
+ ///
+ /// Creates the brush for fill.
+ ///
+ /// Bounds for the brush
+ /// Returns brush or null if brush cannot be created for given bounds or colors are not set. It is responsibility of caller to Dispose the brush.
+ public abstract Brush CreateBrush(Rectangle bounds);
+
+ ///
+ /// Creates a pen based on fill parameters.
+ ///
+ /// Width of the pen to create
+ /// new instance of pen or null if pen cannot be created.
+ public abstract Pen CreatePen(int width);
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/GradientFill.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/GradientFill.cs
new file mode 100644
index 00000000..8072a5b3
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/GradientFill.cs
@@ -0,0 +1,179 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.WinForms.Drawing
+{
+ public class GradientFill : Fill
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the GradientFill class.
+ ///
+ public GradientFill()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the GradientFill class.
+ ///
+ ///
+ ///
+ public GradientFill(Color color1, Color color2)
+ {
+ _Color1 = color1;
+ _Color2 = color2;
+ }
+
+ ///
+ /// Initializes a new instance of the GradientFill class.
+ ///
+ ///
+ ///
+ ///
+ public GradientFill(Color color1, Color color2, float angle)
+ {
+ _Color1 = color1;
+ _Color2 = color2;
+ _Angle = angle;
+ }
+
+ ///
+ /// Initializes a new instance of the GradientFill class.
+ ///
+ ///
+ public GradientFill(ColorStop[] interpolationColors)
+ {
+ _InterpolationColors.AddRange(interpolationColors);
+ }
+
+ ///
+ /// Initializes a new instance of the GradientFill class.
+ ///
+ ///
+ public GradientFill(ColorStop[] interpolationColors, int angle)
+ {
+ _InterpolationColors.AddRange(interpolationColors);
+ _Angle = angle;
+ }
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Creates the brush for fill.
+ ///
+ /// Bounds for the brush
+ /// Returns brush or null if brush cannot be created for given bounds or colors are not set. It is responsibility of caller to Dispose the brush.
+ public override Brush CreateBrush(Rectangle bounds)
+ {
+ if (_Color1.IsEmpty && _Color2.IsEmpty && _InterpolationColors.Count == 0 || bounds.Width < 1 || bounds.Height < 1) return null;
+
+ LinearGradientBrush brush=new LinearGradientBrush(bounds, _Color1, _Color2, _Angle);
+ if (_InterpolationColors.Count == 0)
+ return brush;
+ brush.InterpolationColors = _InterpolationColors.GetColorBlend();
+
+ return brush;
+ }
+
+ private Color _Color1 = Color.Empty;
+ ///
+ /// Gets or sets the starting gradient fill color.
+ ///
+ [Description("Indicates the fill color.")]
+ public Color Color1
+ {
+ get { return _Color1; }
+ set { _Color1 = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ /// true if property should be serialized
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeColor1()
+ {
+ return !_Color1.IsEmpty;
+ }
+ ///
+ /// Sets the property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetColor1()
+ {
+ Color1 = Color.Empty;
+ }
+
+ private Color _Color2 = Color.Empty;
+ ///
+ /// Gets or sets the end gradient fill color.
+ ///
+ [Description("Indicates the fill color.")]
+ public Color Color2
+ {
+ get { return _Color2; }
+ set { _Color2 = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ /// true if property should be serialized
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeColor2()
+ {
+ return !_Color2.IsEmpty;
+ }
+ ///
+ /// Sets the property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetColor2()
+ {
+ Color2 = Color.Empty;
+ }
+
+ private ColorBlendCollection _InterpolationColors = new ColorBlendCollection();
+ ///
+ /// Gets the collection that defines the multicolor gradient background.
+ ///
+ ///
+ /// Setting this property creates a multicolor gradient with one color at each position along the gradient line. Setting this property nullifies all previous color, position, and falloff settings for this gradient fill.
+ ///
+ [Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Description("Collection that defines the multicolor gradient background.")]
+ public ColorBlendCollection InterpolationColors
+ {
+ get { return _InterpolationColors; }
+ }
+
+ private float _Angle = 90;
+ ///
+ /// Gets or sets the gradient fill angle. Default value is 90.
+ ///
+ [DefaultValue(90), Description("Indicates gradient fill angle.")]
+ public float Angle
+ {
+ get { return _Angle; }
+ set
+ {
+ _Angle = value;
+ }
+ }
+ ///
+ /// Creates a pen based on fill parameters.
+ ///
+ /// Width of the pen to create
+ /// new instance of pen or null if pen cannot be created.
+ public override Pen CreatePen(int width)
+ {
+ if (!_Color1.IsEmpty)
+ return new Pen(_Color1, width);
+ if (!_Color2.IsEmpty)
+ return new Pen(_Color2, width);
+ return null;
+ }
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/RectangleShape.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/RectangleShape.cs
new file mode 100644
index 00000000..5cb76178
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/RectangleShape.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+using DevComponents.AdvTree;
+using System.Drawing.Drawing2D;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.WinForms.Drawing
+{
+ internal class RectangleShape : Shape
+ {
+ #region Internal Implementation
+ ///
+ /// Renders rectangle on canvas.
+ ///
+ /// Target graphics to render shape on.
+ /// Shape bounds.
+ public override void Paint(Graphics g, Rectangle bounds)
+ {
+ if (bounds.Width < 2 || bounds.Height < 2 || g == null || _Fill == null && _Border == null) return;
+
+ GraphicsPath path = null;
+
+ if (!_CornerRadius.IsZero)
+ {
+ path = DisplayHelp.GetRoundedRectanglePath(bounds, _CornerRadius.TopLeft, _CornerRadius.TopRight,
+ _CornerRadius.BottomRight, _CornerRadius.BottomLeft);
+ }
+
+ if (_Fill != null)
+ {
+ Brush brush = _Fill.CreateBrush(bounds);
+ if (brush != null)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ if (brush is SolidBrush && path==null)
+ g.SmoothingMode = SmoothingMode.None;
+ if (path == null)
+ g.FillRectangle(brush, bounds);
+ else
+ g.FillPath(brush, path);
+ g.SmoothingMode = sm;
+ brush.Dispose();
+ }
+ }
+
+ if (_Border != null)
+ {
+ Pen pen = _Border.CreatePen();
+ if (pen != null)
+ {
+ if (path == null)
+ g.DrawRectangle(pen, bounds);
+ else
+ g.DrawPath(pen, path);
+
+ pen.Dispose();
+ }
+ }
+
+ Shape content = this.Content;
+ if (content != null)
+ {
+ Rectangle contentBounds = Border.Deflate(bounds, _Border);
+ Region oldClip = null;
+ if (path != null && ClipToBounds)
+ {
+ oldClip = g.Clip;
+ g.SetClip(path, CombineMode.Intersect);
+ }
+ content.Paint(g, contentBounds);
+ if (oldClip != null) g.Clip = oldClip;
+ }
+
+ if (path != null) path.Dispose();
+ }
+
+ private Border _Border;
+ ///
+ /// Gets or sets shape border.
+ ///
+ [DefaultValue(null), Description("Indicates shape border.")]
+ public Border Border
+ {
+ get { return _Border; }
+ set { _Border = value; }
+ }
+
+ private Fill _Fill = null;
+ ///
+ /// Gets or sets the shape fill.
+ ///
+ [DefaultValue(null), Description("Indicates shape fill")]
+ public Fill Fill
+ {
+ get { return _Fill; }
+ set { _Fill = value; }
+ }
+
+ private CornerRadius _CornerRadius;
+ ///
+ /// Gets or sets the CornerRadius.
+ ///
+ public CornerRadius CornerRadius
+ {
+ get { return _CornerRadius; }
+ set { _CornerRadius = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeCornerRadius()
+ {
+ return !_CornerRadius.IsZero;
+ }
+ ///
+ /// Resets the property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetCornerRadius()
+ {
+ CornerRadius = new CornerRadius();
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/Shape.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/Shape.cs
new file mode 100644
index 00000000..78600219
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/Shape.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace DevComponents.WinForms.Drawing
+{
+ ///
+ /// Defines a visual shape.
+ ///
+ internal abstract class Shape
+ {
+ #region Internal Implementation
+ ///
+ /// Renders shape on canvas.
+ ///
+ /// Target graphics to render shape on.
+ /// Shape bounds.
+ public abstract void Paint(Graphics g, Rectangle bounds);
+
+ private Shape _Content = null;
+ ///
+ /// Gets or sets the single piece of content inside of the shape.
+ ///
+ [DefaultValue(null)]
+ public Shape Content
+ {
+ get { return _Content; }
+ set { _Content = value; }
+ }
+
+ private bool _ClipToBounds = false;
+ ///
+ /// Gets or sets whether to clip the Content of this shape. Default value is false.
+ ///
+ [DefaultValue(false)]
+ public bool ClipToBounds
+ {
+ get { return _ClipToBounds; }
+ set
+ {
+ _ClipToBounds = value;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidBorder.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidBorder.cs
new file mode 100644
index 00000000..7609a497
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidBorder.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace DevComponents.WinForms.Drawing
+{
+ public class SolidBorder : Border
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the SolidBorder class.
+ ///
+ ///
+ ///
+ public SolidBorder(Color color, int width)
+ {
+ _Color = color;
+ _Width = width;
+ }
+
+ ///
+ /// Initializes a new instance of the SolidBorder class.
+ ///
+ ///
+ public SolidBorder(Color color)
+ {
+ _Color = color;
+ }
+
+ ///
+ /// Initializes a new instance of the SolidBorder class.
+ ///
+ public SolidBorder()
+ {
+ }
+ #endregion
+ #region Internal Implementation
+ ///
+ /// Creates the pen for the border.
+ ///
+ /// Returns pen or null if pen cannot be created.
+ public override Pen CreatePen()
+ {
+ if (!CanCreatePen()) return null;
+
+ return new Pen(_Color, _Width);
+ }
+
+ private bool CanCreatePen()
+ {
+ return !_Color.IsEmpty && _Width > 0;
+ }
+
+ private Color _Color = Color.Empty;
+ ///
+ /// Gets or sets the fill color.
+ ///
+ [Description("Indicates the fill color.")]
+ public Color Color
+ {
+ get { return _Color; }
+ set { _Color = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ /// true if property should be serialized
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeColor()
+ {
+ return !_Color.IsEmpty;
+ }
+ ///
+ /// Sets the property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetColor()
+ {
+ Color = Color.Empty;
+ }
+
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidFill.cs b/PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidFill.cs
new file mode 100644
index 00000000..ae63361b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidFill.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace DevComponents.WinForms.Drawing
+{
+ public class SolidFill : Fill
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the SolidFill class.
+ ///
+ ///
+ public SolidFill(Color color)
+ {
+ _Color = color;
+ }
+
+ ///
+ /// Initializes a new instance of the SolidFill class.
+ ///
+ public SolidFill()
+ {
+ }
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Creates the brush for fill.
+ ///
+ /// Bounds for the brush
+ /// Returns brush or null if brush cannot be created for given bounds or colors are not set. It is responsibility of caller to Dispose the brush.
+ public override Brush CreateBrush(Rectangle bounds)
+ {
+ if (_Color.IsEmpty) return null;
+ return new SolidBrush(_Color);
+ }
+
+ private Color _Color = Color.Empty;
+ ///
+ /// Gets or sets the fill color.
+ ///
+ [Description("Indicates the fill color.")]
+ public Color Color
+ {
+ get { return _Color; }
+ set { _Color = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ /// true if property should be serialized
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeColor()
+ {
+ return !_Color.IsEmpty;
+ }
+ ///
+ /// Sets the property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetColor()
+ {
+ Color = Color.Empty;
+ }
+
+ public override Pen CreatePen(int width)
+ {
+ if (!_Color.IsEmpty)
+ return new Pen(_Color, width);
+ return null;
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/ElementStyleCollection.cs b/PROMS/DotNetBar Source Code/AdvTree/ElementStyleCollection.cs
new file mode 100644
index 00000000..ff62e6d1
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/ElementStyleCollection.cs
@@ -0,0 +1,143 @@
+using System;
+using System.Collections;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents collection for Node objects.
+ ///
+ public class ElementStyleCollection:CollectionBase
+ {
+ #region Private Variables
+ private AdvTree m_TreeControl=null;
+ //private Hashtable m_InnerHashtable=new Hashtable();
+ #endregion
+
+ #region Internal Implementation
+ /// Creates new instance of the object.
+ public ElementStyleCollection()
+ {
+ }
+ internal AdvTree TreeControl
+ {
+ get {return m_TreeControl;}
+ set {m_TreeControl=value;}
+ }
+
+ ///
+ /// Adds new object to the collection.
+ ///
+ /// Object to add.
+ /// Index of newly added object.
+ public int Add(ElementStyle style)
+ {
+ return List.Add(style);
+ }
+ ///
+ /// Returns reference to the object in collection based on it's index.
+ ///
+ public ElementStyle this[int index]
+ {
+ get {return (ElementStyle)(List[index]);}
+ set {List[index] = value;}
+ }
+
+ ///
+ /// Returns reference to the object in collection based on it's name.
+ ///
+ public ElementStyle this[string name]
+ {
+ get
+ {
+ foreach(ElementStyle style in this.List)
+ {
+ if(style.Name==name)
+ return style;
+ }
+ return null;
+ }
+ }
+
+ ///
+ /// Inserts new object into the collection.
+ ///
+ /// Position of the object.
+ /// Object to insert.
+ public void Insert(int index, ElementStyle value)
+ {
+ List.Insert(index, value);
+ }
+
+ ///
+ /// Returns index of the object inside of the collection.
+ ///
+ /// Reference to the object.
+ /// Index of the object.
+ public int IndexOf(ElementStyle value)
+ {
+ return List.IndexOf(value);
+ }
+
+ ///
+ /// Returns whether collection contains specified object.
+ ///
+ /// Object to look for.
+ /// true if object is part of the collection, otherwise false.
+ public bool Contains(ElementStyle value)
+ {
+ return List.Contains(value);
+ }
+
+ ///
+ /// Removes specified object from the collection.
+ ///
+ ///
+ public void Remove(ElementStyle value)
+ {
+ List.Remove(value);
+ }
+
+ protected override void OnRemoveComplete(int index,object value)
+ {
+ base.OnRemoveComplete(index,value);
+ ElementStyle style=value as ElementStyle;
+ style.Parent=null;
+ //m_InnerHashtable.Remove(style.Name);
+ }
+ protected override void OnInsertComplete(int index,object value)
+ {
+ base.OnInsertComplete(index,value);
+ ElementStyle style=value as ElementStyle;
+ if(style.Parent!=null && style.Parent!=this)
+ style.Parent.Remove(style);
+ style.Parent=this;
+ //m_InnerHashtable.Add(style.Name,style);
+ }
+
+ ///
+ /// Copies collection into the specified array.
+ ///
+ /// Array to copy collection to.
+ /// Starting index.
+ public void CopyTo(ElementStyle[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ ///
+ /// Copies contained items to the Node array.
+ ///
+ /// Array to copy to.
+ internal void CopyTo(ElementStyle[] array)
+ {
+ List.CopyTo(array,0);
+ }
+
+ protected override void OnClear()
+ {
+ base.OnClear();
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Enums.cs b/PROMS/DotNetBar Source Code/AdvTree/Enums.cs
new file mode 100644
index 00000000..55fece33
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Enums.cs
@@ -0,0 +1,766 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Specifies layout of the items in AdvTree control.
+ ///
+ public enum eView
+ {
+ ///
+ /// Standard TreeView layout.
+ ///
+ Tree,
+ ///
+ /// ListView style tile layout.
+ ///
+ Tile
+ }
+
+ /// Specifies the way background image is displayed on background.
+ public enum eStyleBackgroundImage:int
+ {
+ /// Image is stretched to fill the background
+ Stretch=0,
+ /// Image is centered inside the background
+ Center=1,
+ /// Image is tiled inside the background
+ Tile=2,
+ ///
+ /// Image is drawn in top left corner of container space.
+ ///
+ TopLeft=3,
+ ///
+ /// Image is drawn in top right corner of container space.
+ ///
+ TopRight=4,
+ ///
+ /// Image is drawn in bottom left corner of container space.
+ ///
+ BottomLeft=5,
+ ///
+ /// Image is drawn in bottom right corner of container space.
+ ///
+ BottomRight=6
+ }
+
+ /// Indicates alignment of a part of the cell like image or check box in relation to the text.
+ public enum eCellPartAlignment:int
+ {
+ ///
+ /// Part is aligned to the left center of the text assuming left-to-right
+ /// orientation.
+ ///
+ NearCenter=0,
+ ///
+ /// Part is aligned to the right center of the text assuming left-to-right
+ /// orientation.
+ ///
+ FarCenter=1,
+ ///
+ /// Part is aligned to the top left of the text assuming left-to-right
+ /// orientation.
+ ///
+ NearTop=2,
+ /// Part is aligned above the text and centered.
+ CenterTop=3,
+ ///
+ /// Part is aligned to the top right of the text assuming left-to-right
+ /// orientation.
+ ///
+ FarTop=4,
+ ///
+ /// Part is aligned to the bottom left of the text assuming left-to-right
+ /// orientation.
+ ///
+ NearBottom=5,
+ /// Part is aligned below the text and centered.
+ CenterBottom=6,
+ ///
+ /// Part is aligned to the bottom right of the text assuming left-to-right
+ /// orientation.
+ ///
+ FarBottom=7,
+ ///
+ /// Part has default alignment that depends on the parent control view.
+ ///
+ Default = 8
+ }
+
+ ///
+ /// Specifies how to trim characters from a text that does not completely fit into a element's shape.
+ ///
+ public enum eStyleTextTrimming
+ {
+ ///
+ /// Specifies that the text is trimmed to the nearest character.
+ ///
+ Character=System.Drawing.StringTrimming.Character,
+ ///
+ /// Specifies that the text is trimmed to the nearest character, and an ellipsis is inserted at the end of a trimmed line.
+ ///
+ EllipsisCharacter=System.Drawing.StringTrimming.EllipsisCharacter,
+ ///
+ /// The center is removed from trimmed lines and replaced by an ellipsis. The algorithm keeps as much of the last slash-delimited segment of the line as possible.
+ ///
+ EllipsisPath=System.Drawing.StringTrimming.EllipsisPath,
+ ///
+ /// Specifies that text is trimmed to the nearest word, and an ellipsis is inserted at the end of a trimmed line.
+ ///
+ EllipsisWord=System.Drawing.StringTrimming.EllipsisWord,
+ ///
+ /// Specifies no trimming.
+ ///
+ None=System.Drawing.StringTrimming.None,
+ ///
+ /// Specifies that text is trimmed to the nearest word.
+ ///
+ Word=System.Drawing.StringTrimming.Word
+ }
+
+ /////
+ ///// Specifies the border type for style element.
+ /////
+ //public enum eStyleBorderType:int
+ //{
+ // /// Indicates no border
+ // None,
+ // /// Border is a solid line
+ // Solid,
+ // /// Border is a solid dash line
+ // Dash,
+ // /// Border is solid dash-dot line
+ // DashDot,
+ // /// Border is solid dash-dot-dot line
+ // DashDotDot,
+ // /// Border consists of dots
+ // Dot,
+ // /// Etched Border
+ // Etched,
+ // /// Double Border
+ // Double
+ //}
+
+ ///
+ /// Indicates absolute vertical alignment of the content.
+ ///
+ public enum eVerticalAlign
+ {
+ ///
+ /// Content is aligned to the top
+ ///
+ Top,
+ ///
+ /// Content is aligned in the middle
+ ///
+ Middle,
+ ///
+ /// Content is aligned at the bottom
+ ///
+ Bottom
+ }
+
+ ///
+ /// Indicates absolute horizontal alignment
+ ///
+ public enum eHorizontalAlign
+ {
+ ///
+ /// Content is left aligned
+ ///
+ Left,
+ ///
+ /// Content is centered
+ ///
+ Center,
+ ///
+ /// Content is right aligned
+ ///
+ Right
+ }
+
+ ///
+ /// Indicates prefered node layout position on Map tree layout when node is the child node of the top-level root node.
+ ///
+ public enum eMapPosition
+ {
+ ///
+ /// Node is positioned based on default algorithm.
+ ///
+ Default,
+ ///
+ /// Sub-root node and all nodes after it are positioned to the left of the root.
+ ///
+ Near,
+ ///
+ /// Sub-root node and all nodes before it are positioned to the right of the root.
+ ///
+ Far
+ }
+
+ /////
+ ///// Indicates corner type for the border around visual element.
+ /////
+ //public enum eCornerType
+ //{
+ // ///
+ // /// Specifies that corner type is inherited from parent setting.
+ // ///
+ // Inherit,
+ // ///
+ // /// Specifies square corner.
+ // ///
+ // Square,
+ // ///
+ // /// Specifies rounded corner.
+ // ///
+ // Rounded,
+ // ///
+ // /// Specifies diagonal corner.
+ // ///
+ // Diagonal
+ //}
+
+ ///
+ /// Specifies the column header visibility for the node.
+ ///
+ public enum eNodeHeaderVisibility
+ {
+ ///
+ /// Column header is automatically shown/hidden based on the node's position in the tree. When
+ /// Node is first child node i.e. with index=0 the header will be shown, otherwise header will
+ /// be hidden.
+ ///
+ Automatic,
+ ///
+ /// Column header is always displayed regardless of node's position.
+ ///
+ AlwaysShow,
+ ///
+ /// Column header is always hidden regardless of node's position.
+ ///
+ AlwaysHide
+ }
+
+ ///
+ /// Indicates the part of the node.
+ ///
+ public enum eNodeRectanglePart
+ {
+ ///
+ /// Bounds of complete node content except expand button. This also includes the child node bounds if node is expanded.
+ ///
+ NodeContentBounds,
+ ///
+ /// Bounds of the expand button which collapses/expands the node.
+ ///
+ ExpandBounds,
+ ///
+ /// Hit test bounds of the expand button which collapses/expands the node used by mouse routines to trigger node expansion/collapse.
+ ///
+ ExpandHitTestBounds,
+ ///
+ /// Bounds of all child nodes of give node.
+ ///
+ ChildNodeBounds,
+ ///
+ /// Bounds for cells inside a node.
+ ///
+ CellsBounds,
+ ///
+ /// Complete node bounds including expand button.
+ ///
+ NodeBounds,
+ ///
+ /// Bounds of the command button.
+ ///
+ CommandBounds,
+ ///
+ /// Bounds of child node columns if node has columns defined.
+ ///
+ ColumnsBounds
+ }
+
+ ///
+ /// Indicates the part of the cell.
+ ///
+ internal enum eCellRectanglePart
+ {
+ ///
+ /// Bounds of check box or Rectangle.Empty if there is no check-box.
+ ///
+ CheckBoxBounds,
+ ///
+ /// Bounds of image inside the cell or Rectangle.Empty if there is no image.
+ ///
+ ImageBounds,
+ ///
+ /// Text bounds inside of cell.
+ ///
+ TextBounds,
+ ///
+ /// Cell bounds
+ ///
+ CellBounds
+ }
+
+ ///
+ /// Indicates part of the node mouse is placed over.
+ ///
+ internal enum eMouseOverNodePart
+ {
+ ///
+ /// Mouse is not over any node part.
+ ///
+ None,
+ ///
+ /// Mouse is placed over the node.
+ ///
+ Node,
+ ///
+ /// Mouse is placed over node expand button.
+ ///
+ Expand,
+ ///
+ /// Mouse is placed over the cell.
+ ///
+ Cell,
+ ///
+ /// Mouse is placed over the command button.
+ ///
+ Command
+ }
+
+ /////
+ ///// Indicates white-space part of the style.
+ /////
+ //[Flags()]
+ //public enum eSpacePart
+ //{
+ // ///
+ // /// Represents style padding.
+ // ///
+ // Padding=1,
+ // ///
+ // /// Represents style border.
+ // ///
+ // Border=2,
+ // ///
+ // /// Represents style margin.
+ // ///
+ // Margin=4
+ //}
+
+ /////
+ ///// Indicates the style side.
+ /////
+ //public enum eStyleSide
+ //{
+ // ///
+ // /// Specifies left side of the style.
+ // ///
+ // Left,
+ // ///
+ // /// Specifies right side of the style.
+ // ///
+ // Right,
+ // ///
+ // /// Specifies top side of the style.
+ // ///
+ // Top,
+ // ///
+ // /// Specifies bottom side of the style.
+ // ///
+ // Bottom
+ //}
+
+ ///
+ /// Indicates the visibility of node expand part which allows user to expand/collaps node.
+ ///
+ public enum eNodeExpandVisibility
+ {
+ ///
+ /// Default setting which indicates that when node has child nodes expand part is visible otherwise it is hidden.
+ ///
+ Auto,
+ ///
+ /// Expand part is always visible regardless of whether child nodes are present or not.
+ ///
+ Visible,
+ ///
+ /// Expand part is always hidden regardless of whether child nodes are present or not.
+ ///
+ Hidden
+ }
+
+ ///
+ /// Specifies the action that raised a AdvTreeEventArgs event
+ ///
+ public enum eTreeAction
+ {
+ ///
+ /// The event was caused by a keystroke.
+ ///
+ Keyboard,
+ ///
+ /// The event was caused by a mouse operation.
+ ///
+ Mouse,
+ ///
+ /// The event was caused by the Node collapsing.
+ ///
+ Collapse,
+ ///
+ /// The event was caused by the Node expanding.
+ ///
+ Expand,
+ ///
+ /// The event is caused programmatically from user code.
+ ///
+ Code
+ }
+
+ ///
+ /// Specifies node connector type. Node connector is the type of the line/connection that is drawn to connect child node to it's parent node.
+ ///
+ public enum eNodeConnectorType
+ {
+ /////
+ ///// Curved line connector type.
+ /////
+ //Curve,
+ ///
+ /// Straight line connector type.
+ ///
+ Line
+ }
+
+ /////
+ ///// Specifies the cap style with which the connector line will start or end.
+ /////
+ //public enum eConnectorCap
+ //{
+ // ///
+ // /// Specifies no cap.
+ // ///
+ // None,
+ // ///
+ // /// Round cap type.
+ // ///
+ // Ellipse,
+ // ///
+ // /// Arrow cap type.
+ // ///
+ // Arrow
+ //}
+
+ ///
+ /// Specifies the layout type used to position the cells within the nodes.
+ ///
+ public enum eCellLayout
+ {
+ ///
+ /// Specifies that default setting is to be used for cell layout. Default is Horizontal. When set to default on the Node, setting from Tree control is used.
+ ///
+ Default,
+ /// Horizontal layout positions the cells horizontally next to each other.
+ Horizontal,
+ ///
+ /// Vertical layout positions cell vertically on top of each other.
+ ///
+ Vertical
+ }
+
+ ///
+ /// Specifies the layout type used to position the parts of the cell like image, checkbox and text.
+ ///
+ public enum eCellPartLayout
+ {
+ ///
+ /// Specifies that default setting is to be used for cell parts layout. Default is Horizontal. When set to default on the Cell, setting from Tree control is used.
+ ///
+ Default,
+ /// Horizontal layout positions the parts of the cell horizontally next to each other.
+ Horizontal,
+ ///
+ /// Vertical layout positions parts of the cell vertically on top of each other.
+ ///
+ Vertical
+ }
+
+ ///
+ /// Specifies the color scheme loaded by ColorScheme object.
+ ///
+ public enum eColorSchemeStyle
+ {
+ ///
+ /// Indicates Office 2003 like color scheme.
+ ///
+ Office2003,
+ ///
+ /// Indicates VS.NET 2005 like color scheme.
+ ///
+ VS2005,
+ ///
+ /// Indicates Office 2007 like color scheme.
+ ///
+ Office2007
+ }
+
+ ///
+ /// Specifies the currently selected system color scheme if running on Windows XP.
+ ///
+ internal enum eWinXPColorScheme
+ {
+ ///
+ /// Color scheme cannot be determined.
+ ///
+ Undetermined,
+ ///
+ /// Blue color scheme.
+ ///
+ Blue,
+ ///
+ /// Olive green color scheme.
+ ///
+ OliveGreen,
+ ///
+ /// Silver color scheme.
+ ///
+ Silver
+ }
+
+ ///
+ /// Specifies the flow of diagram layout related to the root node.
+ ///
+ public enum eDiagramFlow
+ {
+ ///
+ /// Nodes are positioned from left to right with root node being the left-most node.
+ ///
+ LeftToRight,
+ ///
+ /// Nodes are positioned from right to left with root node being the right-most
+ /// node.
+ ///
+ RightToLeft,
+ ///
+ /// Nodes are positioned from top to bottom with root node being the top node.
+ ///
+ TopToBottom,
+ ///
+ /// Nodes are positioned from bottom to top with root node being bottom node.
+ ///
+ BottomToTop
+ }
+
+ ///
+ /// Specifies the flow of the map layout.
+ ///
+ public enum eMapFlow
+ {
+ ///
+ /// Nodes are arranged around the root node.
+ ///
+ Spread,
+ ///
+ /// Nodes are arranged from below the root node.
+ ///
+ TopToBottom,
+ ///
+ /// Nodes are arranged above the root node.
+ ///
+ BottomToTop,
+ ///
+ /// Nodes are arranged to the right of the root node.
+ ///
+ LeftToRight,
+ ///
+ /// Nodes are arranged to the left of the root node.
+ ///
+ RightToLeft
+ }
+
+ ///
+ /// Specifies the type of the expand button.
+ ///
+ public enum eExpandButtonType
+ {
+ ///
+ /// Indicates elliptical expand button.
+ ///
+ Ellipse,
+ ///
+ /// Indicates rectangular expand button.
+ ///
+ Rectangle,
+ ///
+ /// Indicates that images are used for expand button.
+ ///
+ Image,
+ ///
+ /// Indicates the Windows Vista style expand button.
+ ///
+ Triangle
+ }
+
+ ///
+ /// Specifies the visual style for the tree control.
+ ///
+ public enum eVisualStyle
+ {
+ ///
+ /// Indicates default visual style.
+ ///
+ Default
+ }
+
+ ///
+ /// Specifies the layout type for the nodes.
+ ///
+ public enum eNodeLayout
+ {
+ ///
+ /// Nodes are arranged around root node in map format.
+ ///
+ Map,
+ ///
+ /// Nodes are arranged from left-to-right in diagram format.
+ ///
+ Diagram
+ }
+
+ ///
+ /// Specifies renderer type used to render nodes.
+ ///
+ public enum eNodeRenderMode
+ {
+
+ ///
+ /// Specifies default renderer which allows most customization through AdvTree
+ /// properties. Default renderer integrates with the Style architecture to provide
+ /// customization on renderer behavior.
+ ///
+ Default,
+ /////
+ ///// Specifies professional renderer. Professional renderer is custom renderer
+ ///// which does not rely on Style architecture for customization of renderer appearance
+ ///// since it provides much richer appearance than Default renderer.
+ ///// Professional renderer colors can be controls through
+ ///// NodeProfessionalColorTable object which is exposed by
+ ///// NodeProfessionalRenderer.ColorTable property.
+ /////
+ //Professional,
+ ///
+ /// Specifies that custom renderer is used. When set you must also set NodeRenderer
+ /// to renderer you want to use.
+ ///
+ Custom
+ }
+
+ ///
+ /// Specifies the node selection style.
+ ///
+ public enum eSelectionStyle
+ {
+ ///
+ /// Node selector highlights the complete node row when node is selected.
+ ///
+ FullRowSelect,
+ ///
+ /// Node selector draws the rectangle that highlights the node content. Appearance similar to system tree view in Windows Vista.
+ ///
+ HighlightCells,
+ ///
+ /// Node selector draws hollow selection rectangle around the node.
+ ///
+ NodeMarker,
+ }
+
+ ///
+ /// Specifies the rule for multi-node selection.
+ ///
+ public enum eMultiSelectRule
+ {
+ ///
+ /// Allows multiple selection of nodes with same parent node only.
+ ///
+ SameParent,
+ ///
+ /// Allows multiple selection of any node.
+ ///
+ AnyNode
+ }
+
+ ///
+ /// Gets or sets the image alignment inside of column header.
+ ///
+ public enum eColumnImageAlignment
+ {
+ ///
+ /// Image is left aligned.
+ ///
+ Left,
+ ///
+ /// Image is right aligned.
+ ///
+ Right
+ }
+
+ ///
+ /// Specifies the editor type used when cell is edited.
+ ///
+ public enum eCellEditorType
+ {
+ ///
+ /// Indicates default, text based editor.
+ ///
+ Default,
+ ///
+ /// Indicates that Integer numeric editor will be used for editing the value of the cell or column.
+ ///
+ NumericInteger,
+ ///
+ /// Indicates that Double numeric editor will be used for editing the value of the cell or column.
+ ///
+ NumericDouble,
+ ///
+ /// Indicates that Currency numeric editor will be used for editing the value of the cell or column.
+ ///
+ NumericCurrency,
+ ///
+ /// Indicates that date editor will be used for editing the value of the cell or column.
+ ///
+ Date,
+ ///
+ /// Indicates that time editor will be used for editing the value of the cell or column.
+ ///
+ Time,
+ ///
+ /// Indicates that date and time editor will be used for editing the value of the cell or column.
+ ///
+ DateTime,
+ ///
+ /// Indicates that cell will use custom editor that you provide by handling AdvTree.ProvideCustomCellEditor event.
+ ///
+ Custom
+ }
+ ///
+ /// Specifies the sort direction for the column header.
+ ///
+ public enum eSortDirection
+ {
+ ///
+ /// No sort is specified.
+ ///
+ None,
+ ///
+ /// Ascending sorting is in effect, i.e. A-Z
+ ///
+ Ascending,
+ ///
+ /// Descending sorting is in effect, i.e. Z-A
+ ///
+ Descending
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/EventDelegates.cs b/PROMS/DotNetBar Source Code/AdvTree/EventDelegates.cs
new file mode 100644
index 00000000..6da07b7e
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/EventDelegates.cs
@@ -0,0 +1,98 @@
+using System;
+using DevComponents.AdvTree.Display;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Defines the delegate for AdvTree cell based action events.
+ ///
+ public delegate void AdvTreeCellEventHandler(object sender, AdvTreeCellEventArgs e);
+
+ ///
+ /// Defines the delegate for AdvTree cell based action events.
+ ///
+ public delegate void AdvTreeCellCancelEventHandler(object sender, TreeCellCancelEventArgs e);
+
+ ///
+ /// Defines the delegate for AdvTree node based action events that can be cancelled.
+ ///
+ public delegate void AdvTreeNodeCancelEventHandler(object sender, AdvTreeNodeCancelEventArgs e);
+
+ ///
+ /// Defines the delegate for AdvTree node based action events.
+ ///
+ public delegate void AdvTreeNodeEventHandler(object sender, AdvTreeNodeEventArgs e);
+
+ ///
+ /// Defines delegate for Command button events.
+ ///
+ public delegate void CommandButtonEventHandler(object sender, CommandButtonEventArgs e);
+
+ ///
+ /// Defines delegate for label editing events.
+ ///
+ public delegate void CellEditEventHandler(object sender, CellEditEventArgs e);
+
+ ///
+ /// Defines the delegate for AdvTree node based action events.
+ ///
+ public delegate void TreeNodeCollectionEventHandler(object sender, TreeNodeCollectionEventArgs e);
+
+ ///
+ /// Defines the delegate for BeforeNodeDrop and AfterNodeDrop events
+ ///
+ public delegate void TreeDragDropEventHandler(object sender, TreeDragDropEventArgs e);
+
+ ///
+ /// Defines the delegate for NodeDragFeedback event.
+ ///
+ public delegate void TreeDragFeedbackEventHander(object sender, TreeDragFeedbackEventArgs e);
+
+ ///
+ /// Defines the delegate for mouse based node events
+ ///
+ public delegate void TreeNodeMouseEventHandler(object sender, TreeNodeMouseEventArgs e);
+
+ ///
+ /// Defines delegate for node rendering events.
+ ///
+ public delegate void NodeRendererEventHandler(object sender, NodeRendererEventArgs e);
+
+ ///
+ /// Defines delegate for cell rendering events.
+ ///
+ public delegate void NodeCellRendererEventHandler(object sender, NodeCellRendererEventArgs e);
+
+ ///
+ /// Defines delegate for RenderExpandPart event.
+ ///
+ public delegate void NodeExpandPartRendererEventHandler(object sender, NodeExpandPartRendererEventArgs e);
+
+ /////
+ ///// Defines delegate for RenderExpandPart event.
+ /////
+ //public delegate void NodeCommandPartRendererEventHandler(object sender, NodeCommandPartRendererEventArgs e);
+
+ ///
+ /// Defines delegate for RenderExpandPart event.
+ ///
+ public delegate void SelectionRendererEventHandler(object sender, SelectionRendererEventArgs e);
+ ///
+ /// Defines delegate for RenderConnector event.
+ ///
+ public delegate void ConnectorRendererEventHandler(object sender, ConnectorRendererEventArgs e);
+ ///
+ /// Defines delegate for TreeBackgroundRenderer events.
+ ///
+ public delegate void TreeBackgroundRendererEventHandler(object sender, TreeBackgroundRendererEventArgs e);
+ ///
+ /// Defines delegate for RenderDragDropMarker event.
+ ///
+ public delegate void DragDropMarkerRendererEventHandler(object sender, DragDropMarkerRendererEventArgs e);
+ ///
+ /// Defines delegate for RenderColumnHeader event.
+ ///
+ public delegate void ColumnHeaderRendererEventHandler(object sender, ColumnHeaderRendererEventArgs e);
+
+ public delegate void AdvTreeCellBeforeCheckEventHandler(object sender, AdvTreeCellBeforeCheckEventArgs e);
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Events/CustomCellEditorEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Events/CustomCellEditorEventArgs.cs
new file mode 100644
index 00000000..e24d95f6
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Events/CustomCellEditorEventArgs.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Text;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Provides data for the ProvideCustomCellEditor event.
+ ///
+ public class CustomCellEditorEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets the cell editor. You must set this property in your event handler to the custom
+ /// editor to be used for cell editing.
+ ///
+ public ICellEditControl EditControl = null;
+ ///
+ /// Gets the cell editor will be used for.
+ ///
+ public readonly Cell Cell;
+
+ ///
+ /// Initializes a new instance of the CustomCellEditorEventArgs class.
+ ///
+ ///
+ public CustomCellEditorEventArgs(Cell cell)
+ {
+ Cell = cell;
+ }
+ }
+ ///
+ /// Defines delegate for ProvideCustomCellEditor event.
+ ///
+ public delegate void CustomCellEditorEventHandler(object sender, CustomCellEditorEventArgs e);
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Events/MarkupLinkClickEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Events/MarkupLinkClickEventArgs.cs
new file mode 100644
index 00000000..0cfecee9
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Events/MarkupLinkClickEventArgs.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Provides more information about MarkupLinkClick event.
+ ///
+ public class MarkupLinkClickEventArgs : EventArgs
+ {
+ ///
+ /// Gets the value of href attribute from the markup link that was clicked.
+ ///
+ public readonly string HRef = "";
+
+ ///
+ /// Gets the value of name attribute from the markup link that was clicked.
+ ///
+ public readonly string Name = "";
+
+ ///
+ /// Creates new instance of the object.
+ ///
+ /// Value of name attribute.
+ /// Value of href attribute.
+ public MarkupLinkClickEventArgs(string name, string href)
+ {
+ this.HRef = href;
+ this.Name = name;
+ }
+ }
+
+ ///
+ /// Defines delegate for MarkupLinkClick event.
+ ///
+ public delegate void MarkupLinkClickEventHandler(object sender, MarkupLinkClickEventArgs e);
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Events/SerializeNodeEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/Events/SerializeNodeEventArgs.cs
new file mode 100644
index 00000000..6424cf0f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Events/SerializeNodeEventArgs.cs
@@ -0,0 +1,38 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents arguments for SerializeNode event which allows you to add custom serialization data to definitions saved by control.
+ ///
+ public class SerializeNodeEventArgs : EventArgs
+ {
+ ///
+ /// Gets reference to the node being serialized or de-serialized.
+ ///
+ public Node Node = null;
+
+ ///
+ /// Gets reference to instance of XmlElement that item is serialized to or is being de-serialized from. You should not change any data directly on this element.
+ ///
+ public System.Xml.XmlElement ItemXmlElement = null;
+
+ ///
+ /// Gets the reference to XmlElement that you can serialize to or de-serialize any custom data from. You can add child elements or set the attributes on
+ /// this XmlElement when handling SerializeItem event. When handling DeserializeItem event you can load your data from this element.
+ ///
+ public System.Xml.XmlElement CustomXmlElement = null;
+
+ public SerializeNodeEventArgs(Node node, System.Xml.XmlElement itemXmlElement, System.Xml.XmlElement customXmlElement)
+ {
+ this.Node = node;
+ this.ItemXmlElement = itemXmlElement;
+ this.CustomXmlElement = customXmlElement;
+ }
+ }
+
+ ///
+ /// Defines delegate for SerializeItem event.
+ ///
+ public delegate void SerializeNodeEventHandler(object sender, SerializeNodeEventArgs e);
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/HeaderDefinition.cs b/PROMS/DotNetBar Source Code/AdvTree/HeaderDefinition.cs
new file mode 100644
index 00000000..35a7a948
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/HeaderDefinition.cs
@@ -0,0 +1,40 @@
+using System;
+using System.ComponentModel;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents the table header.
+ ///
+ public class HeaderDefinition
+ {
+ private string m_Name="";
+ private ColumnHeaderCollection m_Columns=new ColumnHeaderCollection();
+
+ ///
+ /// Default constructor.
+ ///
+ public HeaderDefinition()
+ {
+ }
+
+ ///
+ /// Gets the reference to the collection that contains the columns associated with header.
+ ///
+ [Browsable(true),Category("Columns"),Description("Gets the reference to the collection that contains the columns associated with header."),DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ColumnHeaderCollection Columns
+ {
+ get {return m_Columns;}
+ }
+
+ ///
+ /// Gets or sets the name associated with this header definition.
+ ///
+ [Browsable(true),Category("Design"),Description("Indicates name associated with this header definition."),DefaultValue("")]
+ public string Name
+ {
+ get {return m_Name;}
+ set {m_Name=value;}
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/HeadersCollection.cs b/PROMS/DotNetBar Source Code/AdvTree/HeadersCollection.cs
new file mode 100644
index 00000000..1ba13231
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/HeadersCollection.cs
@@ -0,0 +1,135 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents collection for HeaderDefinition objects.
+ ///
+ public class HeadersCollection:CollectionBase
+ {
+ #region Private Variables
+ private AdvTree m_Parent=null;
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Gets or sets the node this collection is associated with.
+ ///
+ [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public AdvTree Parent
+ {
+ get {return m_Parent;}
+ }
+ ///
+ /// Sets the node collection belongs to.
+ ///
+ /// HeaderDefinition that is parent of this collection.
+ internal void SetParent(AdvTree parent)
+ {
+ m_Parent=parent;
+ }
+
+ ///
+ /// Adds new object to the collection.
+ ///
+ /// Object to add.
+ /// Index of newly added object.
+ public int Add(HeaderDefinition ch)
+ {
+ return List.Add(ch);
+ }
+ ///
+ /// Returns reference to the object in collection based on it's index.
+ ///
+ public HeaderDefinition this[int index]
+ {
+ get {return (HeaderDefinition)(List[index]);}
+ set {List[index] = value;}
+ }
+
+ ///
+ /// Inserts new object into the collection.
+ ///
+ /// Position of the object.
+ /// Object to insert.
+ public void Insert(int index, HeaderDefinition value)
+ {
+ List.Insert(index, value);
+ }
+
+ ///
+ /// Returns index of the object inside of the collection.
+ ///
+ /// Reference to the object.
+ /// Index of the object.
+ public int IndexOf(HeaderDefinition value)
+ {
+ return List.IndexOf(value);
+ }
+
+ ///
+ /// Returns whether collection contains specified object.
+ ///
+ /// Object to look for.
+ /// true if object is part of the collection, otherwise false.
+ public bool Contains(HeaderDefinition value)
+ {
+ return List.Contains(value);
+ }
+
+ ///
+ /// Removes specified object from the collection.
+ ///
+ ///
+ public void Remove(HeaderDefinition value)
+ {
+ List.Remove(value);
+ }
+
+ protected override void OnRemoveComplete(int index,object value)
+ {
+ base.OnRemoveComplete(index,value);
+ }
+ protected override void OnInsertComplete(int index,object value)
+ {
+ base.OnInsertComplete(index,value);
+ }
+
+ ///
+ /// Copies collection into the specified array.
+ ///
+ /// Array to copy collection to.
+ /// Starting index.
+ public void CopyTo(HeaderDefinition[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ ///
+ /// Copies contained items to the HeaderDefinition array.
+ ///
+ /// Array to copy to.
+ internal void CopyTo(HeaderDefinition[] array)
+ {
+ List.CopyTo(array,0);
+ }
+
+ protected override void OnClear()
+ {
+ base.OnClear();
+ }
+
+ public HeaderDefinition GetByName(string name)
+ {
+ foreach(HeaderDefinition d in this.List)
+ {
+ if(d.Name==name)
+ return d;
+ }
+ return null;
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/INodeNotify.cs b/PROMS/DotNetBar Source Code/AdvTree/INodeNotify.cs
new file mode 100644
index 00000000..040d7ccf
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/INodeNotify.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Specifies the notification interface that node uses to communicate status changes to it's parent tree.
+ ///
+ public interface INodeNotify
+ {
+ /// Called when Node.Expanded property has changed.
+ /// Node which Expanded property has changed.
+ void ExpandedChanged(Node node);
+ /// Called before node is collapsed
+ /// Context information.
+ void OnBeforeCollapse(AdvTreeNodeCancelEventArgs e);
+ /// Called before node is expanded
+ /// Context information.
+ void OnBeforeExpand(AdvTreeNodeCancelEventArgs e);
+ /// Called after node is collapsed.
+ /// Context information.
+ void OnAfterCollapse(AdvTreeNodeEventArgs e);
+ /// Called after node is expanded
+ /// Context information
+ void OnAfterExpand(AdvTreeNodeEventArgs e);
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Interop/WinApi.cs b/PROMS/DotNetBar Source Code/AdvTree/Interop/WinApi.cs
new file mode 100644
index 00000000..489a6eeb
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Interop/WinApi.cs
@@ -0,0 +1,58 @@
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+using System;
+
+namespace DevComponents.AdvTree.Interop
+{
+ ///
+ /// Provides WinApi functions to rest of the application.
+ ///
+ internal class WinApi
+ {
+
+ #region API Calls Declaration
+
+ [DllImport("user32")]
+ private static extern bool TrackMouseEvent(ref TRACKMOUSEEVENT tme);
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct TRACKMOUSEEVENT
+ {
+ public int cbSize;
+ public uint dwFlags;
+ public int dwHoverTime;
+ public IntPtr hwndTrack;
+ }
+
+ // Track Mouse Event Flags
+ private const uint
+ TME_HOVER=0x00000001,
+ TME_LEAVE=0x00000002,
+ TME_NONCLIENT=0x00000010,
+ TME_QUERY=0x40000000,
+ TME_CANCEL=0x80000000,
+ HOVER_DEFAULT=0xFFFFFFFF;
+
+ #endregion
+
+ #region Functions
+ ///
+ /// Resets Hoover timer for specified control.
+ ///
+ public static void ResetHover(System.Windows.Forms.Control c)
+ {
+ if (c==null || !c.IsHandleCreated)
+ return;
+
+ // We need to reset hover thing since it is fired only first time mouse hovers inside the window and we need it for each of our items
+ TRACKMOUSEEVENT tme = new TRACKMOUSEEVENT();
+ tme.dwFlags = TME_QUERY;
+ tme.hwndTrack = c.Handle;
+ tme.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(tme);
+ TrackMouseEvent(ref tme);
+ tme.dwFlags = tme.dwFlags | TME_HOVER;
+ TrackMouseEvent(ref tme);
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/KeyNavigation.cs b/PROMS/DotNetBar Source Code/AdvTree/KeyNavigation.cs
new file mode 100644
index 00000000..853e9fe5
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/KeyNavigation.cs
@@ -0,0 +1,370 @@
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Provides AdvTree Keyboard handling.
+ ///
+ internal class KeyNavigation
+ {
+ public static void KeyDown(AdvTree tree, KeyEventArgs e)
+ {
+ Node node = tree.SelectedNode;
+ if (node != null)
+ {
+ node.InternalKeyDown(e);
+ if (e.Handled) return;
+ }
+
+ switch(e.KeyCode)
+ {
+ case Keys.Space:
+ {
+ SpaceKeyDown(tree, e);
+ e.Handled = true;
+ break;
+ }
+ case Keys.Add:
+ {
+ e.Handled = PlusKeyDown(tree, e);
+ break;
+ }
+ case Keys.Subtract:
+ {
+ e.Handled = MinusKeyDown(tree, e);
+ break;
+ }
+ case Keys.F2:
+ {
+ F2KeyDown(tree, e);
+ break;
+ }
+ default:
+ {
+ if (e.Control && e.KeyCode == Keys.C)
+ CopyKeyDown(tree, e);
+ else if (e.Control && e.KeyCode == Keys.V)
+ PasteKeyDown(tree, e);
+ break;
+ }
+ }
+ }
+
+ private static bool MinusKeyDown(AdvTree tree, KeyEventArgs e)
+ {
+ Node node = tree.SelectedNode;
+ if (node != null && tree.SelectedNodes.Count == 1 && node.Expanded)
+ {
+ node.Collapse();
+ return true;
+ }
+ return false;
+ }
+ private static bool PlusKeyDown(AdvTree tree, KeyEventArgs e)
+ {
+ Node node = tree.SelectedNode;
+ if (node != null && tree.SelectedNodes.Count == 1 && !node.Expanded)
+ {
+ node.Expand();
+ return true;
+ }
+ return false;
+ }
+
+ private static void PasteKeyDown(AdvTree tree, KeyEventArgs args)
+ {
+ if (tree.SelectedNode != null)
+ tree.SelectedNode.InvokeKeyboardPaste(args);
+ }
+
+ private static void CopyKeyDown(AdvTree tree, KeyEventArgs args)
+ {
+ if (tree.SelectedNode != null)
+ tree.SelectedNode.InvokeKeyboardCopy(args);
+ }
+
+ private static void F2KeyDown(AdvTree tree, KeyEventArgs e)
+ {
+ if (tree.EditSelectedCell(eTreeAction.Keyboard))
+ e.Handled = true;
+ }
+
+ public static void SpaceKeyDown(AdvTree tree, KeyEventArgs e)
+ {
+ Node node = tree.SelectedNode;
+ if (node != null && node.CheckBoxVisible && node.Enabled)
+ {
+ if (node.CheckBoxThreeState)
+ {
+ if (node.CheckState == CheckState.Checked)
+ node.SetChecked(CheckState.Indeterminate, eTreeAction.Keyboard);
+ else if (node.CheckState == CheckState.Unchecked)
+ node.SetChecked(CheckState.Checked, eTreeAction.Keyboard);
+ else if (node.CheckState == CheckState.Indeterminate)
+ node.SetChecked(CheckState.Unchecked, eTreeAction.Keyboard);
+ }
+ else
+ node.SetChecked(!node.Checked, eTreeAction.Keyboard);
+ e.Handled = true;
+ }
+ }
+
+ public static void EnterKeyDown(AdvTree tree, KeyEventArgs e)
+ {
+ if (tree.SelectedNode != null && tree.SelectedNode.Nodes.Count > 0)
+ {
+ tree.SelectedNode.Toggle(eTreeAction.Keyboard);
+ }
+ }
+
+ public static bool NavigateKeyDown(AdvTree tree, KeyEventArgs e)
+ {
+ if(tree.SelectedNode==null)
+ {
+ if(tree.DisplayRootNode!=null)
+ tree.SelectNode(tree.DisplayRootNode, eTreeAction.Keyboard);
+ else if (tree.Nodes.Count > 0)
+ {
+ Node firstSelectable = NodeOperations.GetFirstVisibleNode(tree);
+ if (firstSelectable != null)
+ {
+ while (firstSelectable!=null && !firstSelectable.Selectable)
+ firstSelectable = NodeOperations.GetNextVisibleNode(firstSelectable);
+ if (firstSelectable != null)
+ tree.SelectNode(firstSelectable, eTreeAction.Keyboard);
+ }
+ }
+ return true;
+ }
+
+ Node node = tree.SelectedNode;
+ if (node != null && !node.IsKeyboardNavigationEnabled(e))
+ {
+ return false;
+ }
+
+ if(e.KeyCode == Keys.Right)
+ {
+ if (node != null && node.Cells.Count > 1 && tree.SelectionPerCell && node.CellNavigationEnabled)
+ {
+ if (node.SelectedCell == null)
+ node.SetSelectedCell(NodeOperations.GetNextVisibleCell(node, -1), eTreeAction.Keyboard);
+ else
+ node.SetSelectedCell(NodeOperations.GetNextVisibleCell(node, node.Cells.IndexOf(node.SelectedCell)), eTreeAction.Keyboard);
+ return true;
+ }
+
+ if (tree.View == eView.Tile)
+ {
+ Node nextNode = NodeOperations.GetNextVisibleNode(node);
+ if (nextNode != null)
+ {
+ if (node.Expanded || !node.HasChildNodes)
+ tree.SelectNode(nextNode, eTreeAction.Keyboard);
+ else
+ node.Expand(eTreeAction.Keyboard);
+ }
+ else if (node != null && node.ExpandVisibility == eNodeExpandVisibility.Visible && !node.Expanded)
+ node.Expand(eTreeAction.Keyboard);
+ }
+ else
+ {
+ Node childNode = NodeOperations.GetFirstVisibleChildNode(node);
+ if (childNode != null)
+ {
+ if (node.Expanded)
+ tree.SelectNode(childNode, eTreeAction.Keyboard);
+ else
+ node.Expand(eTreeAction.Keyboard);
+ }
+ else if (node != null && node.ExpandVisibility == eNodeExpandVisibility.Visible && !node.Expanded)
+ node.Expand(eTreeAction.Keyboard);
+ }
+ }
+ else if(e.KeyCode == Keys.Left)
+ {
+ if (node != null && node.Cells.Count > 1 && tree.SelectionPerCell && node.CellNavigationEnabled)
+ {
+ if (node.SelectedCell == null)
+ node.SetSelectedCell(NodeOperations.GetPreviousVisibleCell(node, node.Cells.Count - 1), eTreeAction.Keyboard);
+ else
+ node.SetSelectedCell(NodeOperations.GetPreviousVisibleCell(node, node.Cells.IndexOf(node.SelectedCell)), eTreeAction.Keyboard);
+ return true;
+ }
+
+ if (tree.View == eView.Tile)
+ {
+ Node previousNode = NodeOperations.GetPreviousVisibleNode(node);
+ if (previousNode != null)
+ tree.SelectNode(previousNode, eTreeAction.Keyboard);
+ }
+ else
+ {
+ if (node.Expanded && node.IsSelected && NodeOperations.GetFirstVisibleChildNode(node) != null)
+ node.Collapse(eTreeAction.Keyboard);
+ else if (node.Parent != null)
+ tree.SelectNode(node.Parent, eTreeAction.Keyboard);
+ }
+ }
+ else if (e.KeyCode == Keys.End)
+ {
+ Node last = NodeOperations.GetLastVisibleNode(tree);
+ if (last != null)
+ {
+ if (!last.Selectable)
+ {
+ while (last != null)
+ {
+ last = NodeOperations.GetPreviousVisibleNode(last);
+ if (last!=null && last.Selectable) break;
+ }
+ }
+ if (last != null)
+ tree.SelectNode(last, eTreeAction.Keyboard);
+ }
+ }
+ else if (e.KeyCode == Keys.Home || e.KeyCode == Keys.PageDown && node == null)
+ {
+ Node first = NodeOperations.GetFirstVisibleNode(tree);
+ if (first != null)
+ {
+ if (!first.Selectable)
+ {
+ while (first != null)
+ {
+ first = NodeOperations.GetNextVisibleNode(first);
+ if (first != null && first.Selectable) break;
+ }
+ }
+ if (first != null)
+ tree.SelectNode(first, eTreeAction.Keyboard);
+ }
+ }
+ else if (e.KeyCode == Keys.PageDown)
+ {
+ // Find last fully rendered node
+ Node lastNode = NodeOperations.GetLastDisplayedNode(tree);
+ if (lastNode != null)
+ {
+ if (tree.SelectedNode == lastNode)
+ {
+ if (tree.VScrollBar != null && tree.AutoScroll)
+ {
+ tree.AutoScrollPosition = new Point(tree.AutoScrollPosition.X, Math.Max(tree.AutoScrollPosition.Y - tree.VScrollBar.LargeChange, -(tree.VScrollBar.Maximum - tree.VScrollBar.LargeChange)));
+ lastNode = NodeOperations.GetLastDisplayedNode(tree);
+ }
+ }
+ }
+ if (lastNode != null)
+ tree.SelectNode(lastNode, eTreeAction.Keyboard);
+ }
+ else if (e.KeyCode == Keys.PageUp)
+ {
+ // Find last fully rendered node
+ Node firstNode = NodeOperations.GetFirstDisplayedNode(tree);
+ if (firstNode != null)
+ {
+ if (tree.SelectedNode == firstNode)
+ {
+ if (tree.VScrollBar != null && tree.AutoScroll && tree.AutoScrollPosition.Y < 0)
+ {
+ tree.AutoScrollPosition = new Point(tree.AutoScrollPosition.X, Math.Min(0, tree.AutoScrollPosition.Y + tree.VScrollBar.LargeChange));
+ firstNode = NodeOperations.GetFirstDisplayedNode(tree);
+ }
+ }
+ }
+ if (firstNode != null)
+ tree.SelectNode(firstNode, eTreeAction.Keyboard);
+ }
+ else if ((e.KeyCode & Keys.Down) == Keys.Down)
+ {
+ int currentCell = 0;
+
+ if (node != null && node.SelectedCell != null) currentCell = node.Cells.IndexOf(node.SelectedCell);
+
+ Node nextNode = NodeOperations.GetNextVisibleNode(node);
+
+ // Adjust nextNode so the multi-selection is proper
+ if ((e.KeyData & Keys.Shift) == Keys.Shift && tree.MultiSelect && tree.SelectedNodes.Count > 1)
+ {
+ if (tree.SelectedNodes[0].Bounds.Y > tree.SelectedNodes[tree.SelectedNodes.Count - 1].Bounds.Y)
+ nextNode = tree.SelectedNodes[tree.SelectedNodes.Count - 1];
+ }
+
+ if (nextNode != null)
+ {
+ if (!nextNode.CanSelect)
+ {
+ int counter = 0;
+ while (nextNode != null && counter < 100)
+ {
+ nextNode = NodeOperations.GetNextVisibleNode(nextNode);
+ if (nextNode != null && nextNode.CanSelect) break;
+ }
+ }
+ if (nextNode != null)
+ {
+ if ((e.KeyData & Keys.Shift) == Keys.Shift && tree.MultiSelect && tree.SelectedNodes.Count > 0)
+ {
+ if (tree.MultiSelectRule == eMultiSelectRule.SameParent && tree.SelectedNodes[0].Parent != nextNode.Parent) return true;
+
+ if (nextNode.IsSelected)
+ tree.SelectedNodes.Remove(nextNode, eTreeAction.Keyboard);
+ else
+ tree.SelectedNodes.Add(nextNode, eTreeAction.Keyboard);
+ nextNode.EnsureVisible();
+ }
+ else
+ {
+ tree.SelectNode(nextNode, eTreeAction.Keyboard);
+ if (tree.SelectionPerCell && currentCell < nextNode.Cells.Count && currentCell > 0)
+ nextNode.SetSelectedCell(nextNode.Cells[currentCell], eTreeAction.Keyboard);
+ }
+ }
+ }
+ }
+ else if ((e.KeyCode & Keys.Up) == Keys.Up)
+ {
+ int currentCell = 0;
+ if (node != null && node.SelectedCell != null) currentCell = node.Cells.IndexOf(node.SelectedCell);
+
+ Node prevNode = NodeOperations.GetPreviousVisibleNode(node);
+ if (prevNode != null)
+ {
+ if (!prevNode.CanSelect)
+ {
+ int counter = 0;
+ while (prevNode != null && counter < 100)
+ {
+ prevNode = NodeOperations.GetPreviousVisibleNode(prevNode);
+ if (prevNode != null && prevNode.CanSelect) break;
+ }
+ }
+ if (prevNode != null)
+ {
+ if ((e.KeyData & Keys.Shift) == Keys.Shift && tree.MultiSelect && tree.SelectedNodes.Count > 0)
+ {
+ if (tree.MultiSelectRule == eMultiSelectRule.SameParent && tree.SelectedNodes[0].Parent != prevNode.Parent) return true;
+ if (prevNode.IsSelected)
+ {
+ tree.SelectedNodes.Remove(tree.SelectedNodes[tree.SelectedNodes.Count - 1], eTreeAction.Keyboard);
+ }
+ else
+ tree.SelectedNodes.Add(prevNode, eTreeAction.Keyboard);
+ prevNode.EnsureVisible();
+ }
+ else if (prevNode != null)
+ {
+ tree.SelectNode(prevNode, eTreeAction.Keyboard);
+ if (tree.SelectionPerCell && currentCell < prevNode.Cells.Count && currentCell > 0)
+ prevNode.SetSelectedCell(prevNode.Cells[currentCell], eTreeAction.Keyboard);
+ }
+ }
+ }
+ }
+ return true;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Layout/CellTileLayout.cs b/PROMS/DotNetBar Source Code/AdvTree/Layout/CellTileLayout.cs
new file mode 100644
index 00000000..70a01e08
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Layout/CellTileLayout.cs
@@ -0,0 +1,393 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Layout
+{
+ internal class CellTileLayout : CellLayout
+ {
+ ///
+ /// Initializes a new instance of the CellTileLayout class.
+ ///
+ public CellTileLayout(LayoutSettings layoutSettings) : base(layoutSettings)
+ {
+
+ }
+ public override Size LayoutCells(NodeLayoutContextInfo layoutInfo, int x, int y)
+ {
+ eCellLayout layout = layoutInfo.CellLayout;
+ if (layoutInfo.ContextNode.CellLayout != layoutInfo.CellLayout && layoutInfo.ContextNode.CellLayout != eCellLayout.Default)
+ layout = layoutInfo.ContextNode.CellLayout;
+ if (layout == eCellLayout.Default && !(layoutInfo.ContextNode.HasChildNodes && layoutInfo.IsViewGroupping) && layoutInfo.ContextNode.ImageAlignment == eCellPartAlignment.Default)
+ {
+ return TileLayout(layoutInfo, x, y);
+ }
+ else
+ return base.LayoutCells(layoutInfo, x, y);
+
+ }
+ private Size TileLayout(NodeLayoutContextInfo layoutInfo, int x, int y)
+ {
+ Node node = layoutInfo.ContextNode;
+ int height = 0, width = 0, realHeight = 0;
+ //eHorizontalAlign align = eHorizontalAlign.Left;
+ Size tileSize = layoutInfo.TileSize;
+ int iVisibleCells = 0;
+ int cellCount = node.Cells.Count;
+ bool isVerticalOverflow = false;
+ for (int i = 0; i < cellCount; i++)
+ {
+ Cell cell = node.Cells[i];
+
+ bool bCellVisible = isVerticalOverflow ? false : true;
+
+ // Setup cell layout helper class
+ LayoutCellInfo cellLayout = this.GetLayoutCellInfo();
+ cellLayout.Top = y;
+ cellLayout.Left = x;
+ cellLayout.CellWidth = tileSize.Width;
+ cellLayout.ContextCell = cell;
+ cellLayout.Graphics = layoutInfo.Graphics;
+ cellLayout.LeftToRight = layoutInfo.LeftToRight;
+ cellLayout.Font = layoutInfo.DefaultFont;
+ cellLayout.View = layoutInfo.View;
+ cellLayout.CellIndex = i;
+ if (cell.Layout != eCellPartLayout.Default)
+ cellLayout.VerticalPartAlignment = (cell.Layout == eCellPartLayout.Vertical);
+ else if (layoutInfo.CellPartLayout != eCellPartLayout.Default)
+ cellLayout.VerticalPartAlignment = (layoutInfo.CellPartLayout == eCellPartLayout.Vertical);
+
+ // Prepare union style
+ if (cell.StyleNormal != null)
+ cellLayout.LayoutStyle = cell.StyleNormal;
+ else
+ cellLayout.LayoutStyle = layoutInfo.DefaultCellStyle;
+
+ this.LayoutSingleTileCell(cellLayout);
+ if (bCellVisible && y + cell.BoundsRelative.Height > tileSize.Height && i > 0)
+ {
+ isVerticalOverflow = true;
+ bCellVisible = false;
+ }
+ cell.SetVisible(bCellVisible);
+
+ if (bCellVisible)
+ {
+ iVisibleCells++;
+ y += cell.BoundsRelative.Height;
+ height += cell.BoundsRelative.Height;
+ if (cell.BoundsRelative.Height > 0)
+ {
+ y += this.CellVerticalSpacing;
+ height += this.CellVerticalSpacing;
+ }
+ if (cell.BoundsRelative.Width > width)
+ width = cell.BoundsRelative.Width;
+ if (i == 0)
+ {
+ realHeight += cell.BoundsRelative.Height;
+ if (cell.BoundsRelative.Height > 0)
+ realHeight += this.CellVerticalSpacing;
+ }
+ else
+ realHeight = Math.Max(realHeight, height);
+
+ // Align other cells under the text of the first cell and to the right of the image, if any
+ if (i == 0 && !cell.Images.LargestImageSize.IsEmpty && cellCount > 1)
+ {
+ Size largestImageSize = Dpi.ImageSize(cell.Images.LargestImageSize);
+ if (cell.TextContentBounds.IsEmpty)
+ x += largestImageSize.Width + this.ImageTextSpacing;
+ else
+ x += (cell.TextContentBounds.X - x);
+ tileSize.Width = cell.TextContentBounds.Width;
+ height -= cell.BoundsRelative.Height;
+ height += cell.TextContentBounds.Height;
+ y -= cell.BoundsRelative.Height;
+ y += cell.TextContentBounds.Height;
+ }
+ }
+ }
+
+ // Take last added spacing off
+ y -= this.CellVerticalSpacing;
+ height -= this.CellVerticalSpacing;
+ realHeight -= this.CellVerticalSpacing;
+
+ if (node.Cells[0].BoundsRelative.Height > height && !node.Cells[0].Images.LargestImageSize.IsEmpty)
+ {
+ int textOffset = ((realHeight - height) / iVisibleCells) / 2;
+ if (textOffset > 0)
+ {
+ foreach (Cell cell in node.Cells)
+ {
+ if (!cell.IsVisible) continue;
+ cell.TextContentBounds = new Rectangle(cell.TextContentBounds.X, cell.TextContentBounds.Y + textOffset, cell.TextContentBounds.Width, cell.TextContentBounds.Height);
+ }
+ }
+ }
+ else if(iVisibleCells == 1)
+ {
+ Rectangle rtc = node.Cells[0].TextContentBounds;
+ node.Cells[0].TextContentBounds = new Rectangle(rtc.X, rtc.Y, rtc.Width, node.Cells[0].BoundsRelative.Height);
+ }
+
+ // Additional pass needed if horizontal alignment is other than left and there is more than one cell visible
+ //if (align != eHorizontalAlign.Left && iVisibleCells > 1)
+ //{
+ // foreach (Cell cell in node.Cells)
+ // {
+ // if (!cell.IsVisible)
+ // continue;
+ // if (align == eHorizontalAlign.Center)
+ // this.Offset(cell, (width - cell.BoundsRelative.Width) / 2, 0);
+ // else // Right aligned cells
+ // this.Offset(cell, width - cell.BoundsRelative.Width, 0);
+ // }
+ //}
+ if (width < layoutInfo.TileSize.Width)
+ width = layoutInfo.TileSize.Width;
+ if (realHeight < layoutInfo.TileSize.Height)
+ realHeight = layoutInfo.TileSize.Height;
+ return new Size(width, realHeight);
+ }
+
+ protected virtual void LayoutSingleTileCell(LayoutCellInfo info)
+ {
+ Size textSize = Size.Empty;
+ Font font = info.Font;
+ int fontHeight = info.FontHeight;
+ int height = 0;
+ if (info.LayoutStyle.Font != null)
+ {
+ font = info.LayoutStyle.Font;
+ fontHeight = font.Height;
+ }
+
+ info.ContextCell.OnLayoutCell();
+
+ Size largestImageSize = info.ContextCell.Images.LargestImageSize;
+ if (largestImageSize.IsEmpty && HasImage(info.ContextCell))
+ info.ContextCell.Images.RefreshLargestImageSize();
+ largestImageSize = Dpi.ImageSize(info.ContextCell.Images.LargestImageSize);
+
+ if (info.ContextCell.HostedControl != null)
+ {
+ Size controlSize = info.ContextCell.HostedControl.Size;
+ if (!info.ContextCell.HostedControlSize.IsEmpty)
+ controlSize = info.ContextCell.HostedControlSize;
+ if (info.CellWidth == 0)
+ textSize = new Size(controlSize.Width, controlSize.Height);
+ else
+ {
+ int availTextWidth = info.CellWidth -
+ ElementStyleLayout.HorizontalStyleWhiteSpace(info.LayoutStyle);
+ textSize = new Size(availTextWidth, controlSize.Height);
+ }
+ }
+ else if (info.ContextCell.HostedItem != null)
+ {
+ if (info.CellWidth != 0) info.ContextCell.HostedItem.WidthInternal = info.CellWidth;
+ info.ContextCell.HostedItem.RecalcSize();
+
+ Size controlSize = info.ContextCell.HostedItem.Size;
+ if (info.CellWidth == 0)
+ textSize = new Size(controlSize.Width, controlSize.Height);
+ else
+ {
+ int availTextWidth = info.CellWidth -
+ ElementStyleLayout.HorizontalStyleWhiteSpace(info.LayoutStyle);
+ textSize = new Size(availTextWidth, controlSize.Height);
+ info.ContextCell.HostedItem.WidthInternal = availTextWidth;
+ }
+ }
+ else
+ {
+ // Calculate Text Width and Height
+ if (info.CellWidth == 0)
+ {
+ if (info.ContextCell.TextMarkupBody == null)
+ {
+ string text = info.ContextCell.DisplayText;
+ if (text != "")
+ {
+ if (info.LayoutStyle.WordWrap && info.LayoutStyle.MaximumWidth > 0)
+ textSize = TextDrawing.MeasureString(info.Graphics, text, font, info.LayoutStyle.MaximumWidth);
+ else if (info.ContextCell.Parent != null && info.ContextCell.Parent.Style != null && info.ContextCell.Parent.Style.WordWrap && info.ContextCell.Parent.Style.MaximumWidth > 0)
+ textSize = TextDrawing.MeasureString(info.Graphics, text, font, info.ContextCell.Parent.Style.MaximumWidth);
+ else
+ textSize = TextDrawing.MeasureString(info.Graphics, text, font, 0, eTextFormat.Left | eTextFormat.LeftAndRightPadding | eTextFormat.GlyphOverhangPadding | eTextFormat.NoPrefix);
+#if (FRAMEWORK20)
+ if (!BarFunctions.IsVista && BarUtilities.UseTextRenderer) textSize.Width += 4;
+#endif
+ }
+ else if (largestImageSize.IsEmpty && !info.ContextCell.CheckBoxVisible)
+ {
+ textSize = new Size(5, fontHeight);
+ }
+ }
+ else
+ {
+ Size availSize = new Size(1600, 1);
+ if (info.LayoutStyle.WordWrap && info.LayoutStyle.MaximumWidth > 0)
+ availSize.Width = info.LayoutStyle.MaximumWidth;
+ else if (info.ContextCell.Parent != null && info.ContextCell.Parent.Style != null && info.ContextCell.Parent.Style.WordWrap && info.ContextCell.Parent.Style.MaximumWidth > 0)
+ availSize.Width = info.ContextCell.Parent.Style.MaximumWidth;
+
+ DevComponents.DotNetBar.TextMarkup.MarkupDrawContext d = new DevComponents.DotNetBar.TextMarkup.MarkupDrawContext(info.Graphics, font, Color.Empty, false);
+ info.ContextCell.TextMarkupBody.Measure(availSize, d);
+ availSize = info.ContextCell.TextMarkupBody.Bounds.Size;
+ d.RightToLeft = !info.LeftToRight;
+ info.ContextCell.TextMarkupBody.Arrange(new Rectangle(0, 0, availSize.Width, availSize.Height), d);
+
+ textSize = info.ContextCell.TextMarkupBody.Bounds.Size;
+ }
+ }
+ else
+ {
+ int availTextWidth = info.CellWidth -
+ ElementStyleLayout.HorizontalStyleWhiteSpace(info.LayoutStyle);
+
+ availTextWidth -= largestImageSize.Width +
+ (largestImageSize.Width > 0 ? ImageTextSpacing * 2 : 0);
+
+ if (info.ContextCell.CheckBoxVisible)
+ availTextWidth -= CheckBoxSize.Width + ImageTextSpacing * 2;
+
+ int cellHeight = fontHeight;
+
+ if (info.LayoutStyle.WordWrap || info.ContextCell.TextMarkupBody != null)
+ {
+ cellHeight = info.LayoutStyle.MaximumHeight - info.LayoutStyle.MarginTop -
+ info.LayoutStyle.MarginBottom - info.LayoutStyle.PaddingTop - info.LayoutStyle.PaddingBottom;
+
+ if (info.ContextCell.TextMarkupBody == null)
+ {
+ if (availTextWidth > 0)
+ {
+ if (cellHeight > 0)
+ textSize = TextDrawing.MeasureString(info.Graphics, info.ContextCell.DisplayText, font, new Size(availTextWidth, cellHeight), info.LayoutStyle.TextFormat);
+ else
+ textSize = TextDrawing.MeasureString(info.Graphics, info.ContextCell.DisplayText, font, availTextWidth, info.LayoutStyle.TextFormat);
+ }
+ }
+ else
+ {
+ Size availSize = new Size(availTextWidth, 1);
+ DevComponents.DotNetBar.TextMarkup.MarkupDrawContext d = new DevComponents.DotNetBar.TextMarkup.MarkupDrawContext(info.Graphics, font, Color.Empty, false);
+ info.ContextCell.TextMarkupBody.Measure(availSize, d);
+ availSize = info.ContextCell.TextMarkupBody.Bounds.Size;
+ availSize.Width = availTextWidth;
+ d.RightToLeft = !info.LeftToRight;
+ info.ContextCell.TextMarkupBody.Arrange(new Rectangle(0, 0, availSize.Width, availSize.Height), d);
+
+ textSize = info.ContextCell.TextMarkupBody.Bounds.Size;
+ }
+ }
+ else
+ textSize = new Size(availTextWidth, cellHeight);
+ }
+ }
+
+ if (info.LayoutStyle.WordWrap)
+ info.ContextCell.WordWrap = true;
+ else
+ info.ContextCell.WordWrap = false;
+
+ height = (int)Math.Max(height, Math.Ceiling((double)textSize.Height));
+ if (info.VerticalPartAlignment)
+ {
+ if (largestImageSize.Height > 0)
+ height += largestImageSize.Height + this.ImageTextSpacing;
+ if (info.ContextCell.CheckBoxVisible)
+ height += CheckBoxSize.Height + this.ImageCheckBoxSpacing;
+ }
+ else
+ {
+ if (largestImageSize.Height > height)
+ height = largestImageSize.Height;
+ if (info.ContextCell.CheckBoxVisible && CheckBoxSize.Height > height)
+ height = CheckBoxSize.Height;
+ }
+
+ Rectangle r = new Rectangle(info.Left + ElementStyleLayout.LeftWhiteSpace(info.LayoutStyle),
+ info.Top + ElementStyleLayout.TopWhiteSpace(info.LayoutStyle)
+ , info.CellWidth, height);
+
+ if (r.Width == 0)
+ {
+ if (info.VerticalPartAlignment)
+ {
+ r.Width = (int)Math.Ceiling((double)textSize.Width);
+ if (largestImageSize.Width > r.Width)
+ r.Width = (largestImageSize.Width + this.ImageTextSpacing);
+ if (info.ContextCell.CheckBoxVisible && CheckBoxSize.Width > r.Width)
+ r.Width += (CheckBoxSize.Width + this.ImageTextSpacing);
+ }
+ else
+ {
+ r.Width = (int)Math.Ceiling((double)textSize.Width);
+ if (largestImageSize.Width > 0)
+ r.Width += (largestImageSize.Width + this.ImageTextSpacing);
+ if (info.ContextCell.CheckBoxVisible)
+ r.Width += (CheckBoxSize.Width + this.ImageTextSpacing);
+ }
+ }
+
+ // Now that we have cell bounds store them
+ Rectangle rCellBounds = new Rectangle(info.Left, info.Top, info.CellWidth, r.Height + info.LayoutStyle.MarginTop + info.LayoutStyle.MarginBottom + info.LayoutStyle.PaddingTop + info.LayoutStyle.PaddingBottom);
+ if (rCellBounds.Width == 0)
+ rCellBounds.Width = r.Width + ElementStyleLayout.HorizontalStyleWhiteSpace(info.LayoutStyle);
+ info.ContextCell.SetBounds(rCellBounds);
+
+ // Set position of the check box
+ if (info.ContextCell.CheckBoxVisible && rCellBounds.Width >= this.CheckBoxSize.Width)
+ {
+ eVerticalAlign va = GetCheckBoxVerticalAlign(info.ContextCell.CheckBoxAlignment, info.View);
+ eHorizontalAlign ha = GetCheckBoxHorizontalAlign(info.ContextCell.CheckBoxAlignment, info.LeftToRight, info.View);
+ if (ha == eHorizontalAlign.Center && (!string.IsNullOrEmpty(info.ContextCell.Text) || !largestImageSize.IsEmpty))
+ ha = eHorizontalAlign.Left;
+
+ if (info.VerticalPartAlignment)
+ info.ContextCell.SetCheckBoxBounds(AlignContentVertical(this.CheckBoxSize, ref r, ha, va, this.ImageTextSpacing));
+ else
+ info.ContextCell.SetCheckBoxBounds(AlignContent(this.CheckBoxSize, ref r, ha, va, this.ImageTextSpacing));
+ }
+ else
+ info.ContextCell.SetCheckBoxBounds(Rectangle.Empty);
+
+ // Set Position of the image
+ if (!largestImageSize.IsEmpty && rCellBounds.Width >= largestImageSize.Width)
+ {
+ eVerticalAlign va = GetVerticalAlign(info.ContextCell.ImageAlignment, info.View);
+ eHorizontalAlign ha = GetHorizontalAlign(info.ContextCell.ImageAlignment, info.LeftToRight, info.View);
+ if (ha == eHorizontalAlign.Center && (!string.IsNullOrEmpty(info.ContextCell.Text) || info.ContextCell.CheckBoxVisible))
+ ha = eHorizontalAlign.Left;
+
+ if (info.VerticalPartAlignment)
+ info.ContextCell.SetImageBounds(AlignContentVertical(largestImageSize, ref r, ha, va, this.ImageTextSpacing));
+ else
+ info.ContextCell.SetImageBounds(AlignContent(largestImageSize, ref r, ha, va, this.ImageTextSpacing));
+ }
+ else
+ info.ContextCell.SetImageBounds(Rectangle.Empty);
+
+ // Set position of the text
+ //info.ContextCell.SetTextBounds(Rectangle.Empty);
+ if (!textSize.IsEmpty)
+ {
+ if (info.CellWidth > 0)
+ r.Width -= 2;
+ if (info.View == eView.Tile && info.CellIndex == 0)
+ info.ContextCell.TextContentBounds = new Rectangle(r.X, r.Y, textSize.Width, textSize.Height + 1);
+ else
+ info.ContextCell.TextContentBounds = r;
+ }
+ else
+ info.ContextCell.TextContentBounds = Rectangle.Empty;
+
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Layout/ColumnHeaderLayout.cs b/PROMS/DotNetBar Source Code/AdvTree/Layout/ColumnHeaderLayout.cs
new file mode 100644
index 00000000..d4052832
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Layout/ColumnHeaderLayout.cs
@@ -0,0 +1,193 @@
+using System;
+using System.Drawing;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Layout
+{
+ ///
+ /// Class that is used to layout column header.
+ ///
+ internal class ColumnHeaderLayout
+ {
+ public ColumnHeaderLayout()
+ {
+ }
+
+ // Assumes that layoutInfo is up-to-date and that Node that is connected with
+ // columns is already processed and it's size and location calculated.
+ // layoutInfo.Top member reflects the next position below the node
+ // layoutInfo.LevelOffset should reflect the X offset for the child nodes.
+ public static int LayoutColumnHeader(NodeLayoutContextInfo layoutInfo,int x, int y, int clientWidth, int cellHorizontalSpacing)
+ {
+ ColumnHeaderCollection columns = null;
+ Node node=layoutInfo.ContextNode;
+ if (node == null)
+ columns = layoutInfo.TreeColumns;
+ else
+ columns = node.NodesColumns;
+ columns.UsesRelativeSize = false;
+ int height=0;
+ bool adjustHeight = false;
+ Rectangle totalBounds = Rectangle.Empty;
+ ColumnHeader lastVisibleColumn = null;
+ ColumnHeader stretchToFillColumn = null;
+ bool allRelative = true;
+ bool firstVisible = true;
+ for (int i = 0; i < columns.Count; i++)
+ {
+ ColumnHeader col = columns.ColumnAtDisplayIndex(i);
+ col.IsLastVisible = false;
+ if(!col.Visible)
+ continue;
+ col.IsFirstVisible = firstVisible;
+ firstVisible = false;
+ //if(col.SizeChanged)
+ {
+ // Column for child nodes is always placed below the current node and
+ // is not included in the node's rectangle
+ Rectangle bounds=Rectangle.Empty;
+ bounds.X=x;
+ bounds.Y=y;
+ if (col.Width.AutoSize)
+ {
+ int autoWidth = col.Width.AutoSizeWidth;
+ if (col.Width.AutoSizeMinHeader)
+ {
+ Font headerFont = layoutInfo.DefaultFont;
+ if (!string.IsNullOrEmpty(col.StyleNormal))
+ {
+ ElementStyle style = layoutInfo.Styles[col.StyleNormal];
+ if (style != null && style.Font != null)
+ headerFont = style.Font;
+ }
+ else if (layoutInfo.ColumnStyle != null && layoutInfo.ColumnStyle.Font != null)
+ headerFont = layoutInfo.ColumnStyle.Font;
+ if (headerFont != null)
+ {
+ int columnHeaderTextWidth = (int)Math.Ceiling(layoutInfo.Graphics.MeasureString(col.Text, headerFont).Width) + 2;
+ autoWidth = Math.Max(autoWidth, columnHeaderTextWidth);
+ col.Width.SetAutoSizeWidth(autoWidth);
+ }
+ }
+ bounds.Width = autoWidth;
+ allRelative = false;
+ }
+ else if (col.Width.Absolute > 0)
+ {
+ bounds.Width = col.Width.Absolute;
+ allRelative = false;
+ }
+ else if (col.Width.Absolute == -1)
+ {
+ bounds.Width = 0;
+ allRelative = false;
+ }
+ else if (col.Width.Relative > 0)
+ {
+ if (col.IsFirstVisible)
+ {
+ clientWidth -= layoutInfo.ExpandPartWidth;
+ bounds.Width = (clientWidth * col.Width.Relative) / 100 - cellHorizontalSpacing;
+ bounds.Width += layoutInfo.ExpandPartWidth;
+ }
+ else
+ bounds.Width = (clientWidth * col.Width.Relative) / 100 - cellHorizontalSpacing;
+ columns.UsesRelativeSize = true;
+ }
+ lastVisibleColumn = col;
+
+ if (col.StretchToFill)
+ {
+ stretchToFillColumn = col;
+ columns.UsesRelativeSize = true;
+ }
+
+ if(col.StyleNormal=="" && col.StyleMouseDown=="" && col.StyleMouseOver=="")
+ {
+ bounds.Height=layoutInfo.DefaultHeaderSize.Height;
+ }
+ else
+ {
+ Size sz=Size.Empty;
+ if(col.StyleNormal!="")
+ {
+ ElementStyleLayout.CalculateStyleSize(layoutInfo.Styles[col.StyleNormal],layoutInfo.DefaultFont);
+ sz=layoutInfo.Styles[col.StyleNormal].Size;
+ }
+
+ if(sz.Height==0)
+ bounds.Height=layoutInfo.DefaultHeaderSize.Height;
+ else
+ bounds.Height=sz.Height;
+ }
+
+ if (col.Image != null && col.Image.Height+4>bounds.Height)
+ {
+ bounds.Height = col.Image.Height + 4;
+ }
+
+ col.SetBounds(bounds);
+ col.SizeChanged=false;
+
+ x += (bounds.Width + cellHorizontalSpacing);
+
+ if (bounds.Height > height)
+ {
+ if (height > 0)
+ adjustHeight = true;
+ height = bounds.Height;
+ }
+ else if (bounds.Height < height)
+ adjustHeight = true;
+ }
+
+ if (totalBounds.IsEmpty)
+ totalBounds = col.Bounds;
+ else
+ totalBounds = Rectangle.Union(totalBounds, col.Bounds);
+ }
+ if (adjustHeight)
+ {
+ foreach (ColumnHeader col in columns)
+ {
+ col.SetBounds(new Rectangle(col.Bounds.X, col.Bounds.Y, col.Bounds.Width, height));
+ }
+ }
+ if (lastVisibleColumn != null && allRelative)
+ {
+ lastVisibleColumn.SetBounds(new Rectangle(lastVisibleColumn.Bounds.X, lastVisibleColumn.Bounds.Y, lastVisibleColumn.Bounds.Width + cellHorizontalSpacing, lastVisibleColumn.Bounds.Height));
+ totalBounds = Rectangle.Union(totalBounds, lastVisibleColumn.Bounds);
+ }
+
+ if (lastVisibleColumn != null) lastVisibleColumn.IsLastVisible = true;
+
+ if (stretchToFillColumn != null && totalBounds.Width < clientWidth)
+ {
+ int stretch = clientWidth - totalBounds.Width;
+ if (stretchToFillColumn.IsFirstVisible && stretchToFillColumn.IsLastVisible) // Single column visible only case
+ stretch -= layoutInfo.Indent;
+ else if (stretchToFillColumn.Parent != null && stretchToFillColumn.Parent.ParentNode != null)
+ stretch -= layoutInfo.Indent;
+ stretchToFillColumn.SetBounds(new Rectangle(stretchToFillColumn.Bounds.X, stretchToFillColumn.Bounds.Y,
+ stretchToFillColumn.Bounds.Width + stretch, stretchToFillColumn.Bounds.Height));
+ totalBounds = Rectangle.Union(totalBounds, stretchToFillColumn.Bounds);
+ if (!stretchToFillColumn.IsLastVisible) // Offset columns to the right if this was not last visible column
+ {
+ int startIndex = columns.GetDisplayIndex(stretchToFillColumn) + 1;
+ for (int i = startIndex; i < columns.Count; i++)
+ {
+ ColumnHeader col = columns.ColumnAtDisplayIndex(i);
+ if (!col.Visible) continue;
+ col.SetBounds(new Rectangle(col.Bounds.X + stretch, col.Bounds.Y, col.Bounds.Width, col.Bounds.Height));
+ totalBounds = Rectangle.Union(totalBounds, col.Bounds);
+ }
+ }
+ }
+
+
+ columns.SetBounds(totalBounds);
+ return height;
+ }
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Layout/LayoutSettings.cs b/PROMS/DotNetBar Source Code/AdvTree/Layout/LayoutSettings.cs
new file mode 100644
index 00000000..1a99be55
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Layout/LayoutSettings.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+
+namespace DevComponents.AdvTree.Layout
+{
+ internal class LayoutSettings
+ {
+ #region Internal Implementation
+ private int _NodeVerticalSpacing = 3;
+ ///
+ /// Gets or sets the vertical spacing between nodes in pixels.
+ ///
+ public virtual int NodeVerticalSpacing
+ {
+ get { return _NodeVerticalSpacing; }
+ set { _NodeVerticalSpacing = value; }
+ }
+
+ private int _NodeHorizontalSpacing = 4;
+ ///
+ /// Gets or sets the horizontal spacing between nodes in pixels.
+ ///
+ public virtual int NodeHorizontalSpacing
+ {
+ get { return _NodeHorizontalSpacing; }
+ set { _NodeHorizontalSpacing = value; }
+ }
+
+ private int _CellHorizontalSpacing = 5;
+ ///
+ /// Returns horizontal spacing between cells in a node
+ ///
+ public int CellHorizontalSpacing
+ {
+ get { return _CellHorizontalSpacing; }
+ set
+ {
+ _CellHorizontalSpacing = value;
+ }
+ }
+
+ private int _ExpandAreaWidth = 24;
+ ///
+ /// Returns width of the expand button area. Default is 24 pixels.
+ ///
+ public virtual int ExpandAreaWidth
+ {
+ get { return _ExpandAreaWidth; }
+ set
+ {
+ _ExpandAreaWidth = value;
+ }
+ }
+
+ protected Size _ExpandPartSize = new Size(8, 8);
+ ///
+ /// Gets or sets the size of the expand part that is expanding/collapsing the node. Default value is 8,8.
+ ///
+ public System.Drawing.Size ExpandPartSize
+ {
+ get { return _ExpandPartSize; }
+ set { _ExpandPartSize = value; }
+ }
+
+ private int _CommandAreaWidth = 10;
+ ///
+ /// Gets or sets width of command button area. Default is 8 pixels.
+ ///
+ public virtual int CommandAreaWidth
+ {
+ get { return _CommandAreaWidth; }
+ set { _CommandAreaWidth = value; }
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeCellLayout.cs b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeCellLayout.cs
new file mode 100644
index 00000000..69773d21
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeCellLayout.cs
@@ -0,0 +1,888 @@
+using System;
+using System.Drawing;
+using DevComponents.DotNetBar;
+using System.Collections;
+
+namespace DevComponents.AdvTree
+{
+ namespace Layout
+ {
+ ///
+ /// Represents class for Node's cell layout.
+ ///
+ internal class CellLayout
+ {
+ public CellLayout(LayoutSettings layoutSettings)
+ {
+ _LayoutSettings = layoutSettings;
+ }
+
+ private LayoutSettings _LayoutSettings;
+ public LayoutSettings LayoutSettings
+ {
+ get { return _LayoutSettings; }
+ set { _LayoutSettings = value; }
+ }
+ ///
+ /// Offset cell bounds, check box bounds, image bounds and text bounds by specified offset.
+ ///
+ /// Cell to offset.
+ /// Horizontal offset in pixels.
+ /// Vertical offset in pixels.
+ protected void Offset(Cell cell, int x, int y)
+ {
+ if (x == 0 && y == 0) return;
+ cell.SetBounds(new Rectangle(cell.BoundsRelative.X+x,cell.BoundsRelative.Y+y,cell.BoundsRelative.Width,cell.BoundsRelative.Height));
+ if(!cell.CheckBoxBoundsRelative.IsEmpty)
+ cell.SetCheckBoxBounds(new Rectangle(cell.CheckBoxBoundsRelative.X+x,cell.CheckBoxBoundsRelative.Y+y,cell.CheckBoxBoundsRelative.Width,cell.CheckBoxBoundsRelative.Height));
+ if(!cell.ImageBoundsRelative.IsEmpty)
+ cell.SetImageBounds(new Rectangle(cell.ImageBoundsRelative.X+x,cell.ImageBoundsRelative.Y+y,cell.ImageBoundsRelative.Width,cell.ImageBoundsRelative.Height));
+ if(!cell.TextContentBounds.IsEmpty)
+ cell.TextContentBounds=new Rectangle(cell.TextContentBounds.X+x,cell.TextContentBounds.Y+y,cell.TextContentBounds.Width,cell.TextContentBounds.Height);
+ }
+
+ protected virtual void LayoutSingleCell(LayoutCellInfo info)
+ {
+ Size textSize = Size.Empty;
+ Font font = info.Font;
+ int fontHeight = info.FontHeight; // Uses cached FontHeight reference. Huge performance savings on some fonts!!!
+ int height = 0;
+ if (info.LayoutStyle.Font != null)
+ {
+ font = info.LayoutStyle.Font;
+ fontHeight = font.Height;
+ }
+
+ info.ContextCell.OnLayoutCell();
+
+ if (info.ContextCell.Images.LargestImageSize.IsEmpty && HasImage(info.ContextCell))
+ info.ContextCell.Images.RefreshLargestImageSize();
+ Size largestImageSize = Dpi.ImageSize(info.ContextCell.Images.LargestImageSize);
+ Size checkBoxSize = Dpi.Size(CheckBoxSize);
+ if (info.ContextCell.HostedControl != null)
+ {
+ Size controlSize = info.ContextCell.HostedControl.Size;
+ if (!info.ContextCell.HostedControlSize.IsEmpty)
+ controlSize = info.ContextCell.HostedControlSize;
+ if (info.CellWidth == 0)
+ textSize = new Size(controlSize.Width, controlSize.Height);
+ else
+ {
+ int availTextWidth = info.CellWidth -
+ ElementStyleLayout.HorizontalStyleWhiteSpace(info.LayoutStyle);
+ textSize = new Size(availTextWidth, controlSize.Height);
+ }
+ }
+ else if (info.ContextCell.HostedItem != null)
+ {
+ if (info.CellWidth != 0) info.ContextCell.HostedItem.WidthInternal = info.CellWidth;
+ info.ContextCell.HostedItem.RecalcSize();
+
+ Size controlSize = info.ContextCell.HostedItem.Size;
+ if (info.CellWidth == 0)
+ textSize = new Size(controlSize.Width, controlSize.Height);
+ else
+ {
+ int availTextWidth = info.CellWidth -
+ ElementStyleLayout.HorizontalStyleWhiteSpace(info.LayoutStyle);
+ textSize = new Size(availTextWidth, controlSize.Height);
+ info.ContextCell.HostedItem.WidthInternal = availTextWidth;
+ }
+ }
+ else
+ {
+ // Calculate Text Width and Height
+ string cellDisplayText = info.ContextCell.DisplayText;
+ if (info.CellWidth == 0)
+ {
+ if (info.ContextCell.TextMarkupBody == null)
+ {
+ string text = cellDisplayText;
+ if (text != "")
+ {
+ if (info.LayoutStyle.WordWrap && info.LayoutStyle.MaximumWidth > 0)
+ textSize = TextDrawing.MeasureString(info.Graphics, text, font, info.LayoutStyle.MaximumWidth);
+ else if (info.ContextCell.Parent != null && info.ContextCell.Parent.Style != null && info.ContextCell.Parent.Style.WordWrap && info.ContextCell.Parent.Style.MaximumWidth > 0)
+ textSize = TextDrawing.MeasureString(info.Graphics, text, font, info.ContextCell.Parent.Style.MaximumWidth);
+ else
+ textSize = TextDrawing.MeasureString(info.Graphics, text, font, 0, eTextFormat.Left | eTextFormat.LeftAndRightPadding | eTextFormat.GlyphOverhangPadding | eTextFormat.NoPrefix);
+#if (FRAMEWORK20)
+ if (!BarFunctions.IsVista && BarUtilities.UseTextRenderer) textSize.Width += 4;
+#endif
+ }
+ else if (largestImageSize.IsEmpty && !info.ContextCell.CheckBoxVisible)
+ {
+ textSize = new Size(5, fontHeight);
+ }
+ }
+ else
+ {
+ Size availSize = new Size(1600, 1);
+ if (info.LayoutStyle.WordWrap && info.LayoutStyle.MaximumWidth > 0)
+ availSize.Width = info.LayoutStyle.MaximumWidth;
+ else if (info.ContextCell.Parent != null && info.ContextCell.Parent.Style != null && info.ContextCell.Parent.Style.WordWrap && info.ContextCell.Parent.Style.MaximumWidth > 0)
+ availSize.Width = info.ContextCell.Parent.Style.MaximumWidth;
+
+ DevComponents.DotNetBar.TextMarkup.MarkupDrawContext d = new DevComponents.DotNetBar.TextMarkup.MarkupDrawContext(info.Graphics, font, Color.Empty, false);
+ info.ContextCell.TextMarkupBody.Measure(availSize, d);
+ availSize = info.ContextCell.TextMarkupBody.Bounds.Size;
+ d.RightToLeft = !info.LeftToRight;
+ info.ContextCell.TextMarkupBody.Arrange(new Rectangle(0, 0, availSize.Width, availSize.Height), d);
+
+ textSize = info.ContextCell.TextMarkupBody.Bounds.Size;
+ }
+ }
+ else
+ {
+ int availTextWidth = info.CellWidth -
+ ElementStyleLayout.HorizontalStyleWhiteSpace(info.LayoutStyle);
+
+ availTextWidth -= largestImageSize.Width +
+ (largestImageSize.Width > 0 ? ImageTextSpacing * 2 : 0);
+
+ if (info.ContextCell.CheckBoxVisible)
+ availTextWidth -= checkBoxSize.Width + ImageTextSpacing * 2;
+
+ int cellHeight = fontHeight;
+
+ if (info.LayoutStyle.WordWrap || info.ContextCell.TextMarkupBody != null)
+ {
+ cellHeight = info.LayoutStyle.MaximumHeight - info.LayoutStyle.MarginTop -
+ info.LayoutStyle.MarginBottom - info.LayoutStyle.PaddingTop - info.LayoutStyle.PaddingBottom;
+
+ if (info.ContextCell.TextMarkupBody == null)
+ {
+ if (availTextWidth > 0)
+ {
+ if (cellHeight > 0)
+ {
+ textSize = TextDrawing.MeasureString(info.Graphics, cellDisplayText, font, new Size(availTextWidth, cellHeight), info.LayoutStyle.TextFormat);
+ if (textSize.Height == 0) textSize.Height = cellHeight;
+ }
+ else if (!string.IsNullOrEmpty(cellDisplayText))
+ textSize = TextDrawing.MeasureString(info.Graphics, cellDisplayText, font, availTextWidth, info.LayoutStyle.TextFormat);
+ else
+ textSize = new Size(availTextWidth, fontHeight);
+ }
+ }
+ else
+ {
+ Size availSize = new Size(availTextWidth, 1);
+ DevComponents.DotNetBar.TextMarkup.MarkupDrawContext d = new DevComponents.DotNetBar.TextMarkup.MarkupDrawContext(info.Graphics, font, Color.Empty, false);
+ info.ContextCell.TextMarkupBody.Measure(availSize, d);
+ availSize = info.ContextCell.TextMarkupBody.Bounds.Size;
+ availSize.Width = availTextWidth;
+ d.RightToLeft = !info.LeftToRight;
+ info.ContextCell.TextMarkupBody.Arrange(new Rectangle(0, 0, availSize.Width, availSize.Height), d);
+
+ textSize = info.ContextCell.TextMarkupBody.Bounds.Size;
+ }
+ }
+ else
+ textSize = new Size(availTextWidth, cellHeight);
+ }
+ }
+
+ if (info.LayoutStyle.WordWrap)
+ info.ContextCell.WordWrap = true;
+ else
+ info.ContextCell.WordWrap = false;
+
+ height = (int)Math.Max(height, Math.Ceiling((double)textSize.Height));
+ if (info.VerticalPartAlignment)
+ {
+ if (largestImageSize.Height > 0)
+ height += largestImageSize.Height + this.ImageTextSpacing;
+ if (info.ContextCell.CheckBoxVisible)
+ height += checkBoxSize.Height + this.ImageCheckBoxSpacing;
+ }
+ else
+ {
+ if (largestImageSize.Height > height)
+ height = largestImageSize.Height;
+ if (info.ContextCell.CheckBoxVisible && checkBoxSize.Height > height)
+ height = checkBoxSize.Height;
+ }
+
+ Rectangle r = new Rectangle(info.Left + ElementStyleLayout.LeftWhiteSpace(info.LayoutStyle),
+ info.Top + ElementStyleLayout.TopWhiteSpace(info.LayoutStyle)
+ , info.CellWidth, height);
+
+ if (r.Width == 0)
+ {
+ if (info.VerticalPartAlignment)
+ {
+ r.Width = (int)Math.Ceiling((double)textSize.Width);
+ if (largestImageSize.Width > r.Width)
+ r.Width = (largestImageSize.Width + this.ImageTextSpacing);
+ if (info.ContextCell.CheckBoxVisible && checkBoxSize.Width > r.Width)
+ r.Width += (checkBoxSize.Width + this.ImageTextSpacing);
+ }
+ else
+ {
+ r.Width = (int)Math.Ceiling((double)textSize.Width);
+ if (largestImageSize.Width > 0)
+ r.Width += (largestImageSize.Width + this.ImageTextSpacing);
+ if (info.ContextCell.CheckBoxVisible)
+ r.Width += (checkBoxSize.Width + this.ImageTextSpacing);
+ }
+ }
+
+ // Now that we have cell bounds store them
+ Rectangle rCellBounds = new Rectangle(info.Left, info.Top, info.CellWidth, r.Height + info.LayoutStyle.MarginTop + info.LayoutStyle.MarginBottom + info.LayoutStyle.PaddingTop + info.LayoutStyle.PaddingBottom);
+ if (rCellBounds.Width == 0)
+ rCellBounds.Width = r.Width + ElementStyleLayout.HorizontalStyleWhiteSpace(info.LayoutStyle);
+ info.ContextCell.SetBounds(rCellBounds);
+
+ // Set position of the check box
+ //Size checkBoxSize = this.CheckBoxSize;
+ if (info.ContextCell.CheckBoxVisible && rCellBounds.Width >= checkBoxSize.Width)
+ {
+ eVerticalAlign va = GetCheckBoxVerticalAlign(info.ContextCell.CheckBoxAlignment, info.View);
+ eHorizontalAlign ha = GetCheckBoxHorizontalAlign(info.ContextCell.CheckBoxAlignment, info.LeftToRight, info.View);
+ if (ha == eHorizontalAlign.Center && (!string.IsNullOrEmpty(info.ContextCell.Text) || !largestImageSize.IsEmpty))
+ ha = eHorizontalAlign.Left;
+ if (info.VerticalPartAlignment)
+ info.ContextCell.SetCheckBoxBounds(AlignContentVertical(checkBoxSize, ref r, ha, va, this.ImageTextSpacing));
+ else
+ info.ContextCell.SetCheckBoxBounds(AlignContent(checkBoxSize, ref r, ha, va, this.ImageTextSpacing));
+ }
+ else
+ info.ContextCell.SetCheckBoxBounds(Rectangle.Empty);
+
+ // Set Position of the image
+ if (!largestImageSize.IsEmpty && rCellBounds.Width >= largestImageSize.Width)
+ {
+ eVerticalAlign va = GetVerticalAlign(info.ContextCell.ImageAlignment, info.View);
+ eHorizontalAlign ha = GetHorizontalAlign(info.ContextCell.ImageAlignment, info.LeftToRight, info.View);
+ if (ha == eHorizontalAlign.Center && (!string.IsNullOrEmpty(info.ContextCell.Text) || info.ContextCell.CheckBoxVisible) && !info.VerticalPartAlignment)
+ ha = eHorizontalAlign.Left;
+ if (info.VerticalPartAlignment)
+ info.ContextCell.SetImageBounds(AlignContentVertical(largestImageSize, ref r, ha, va, this.ImageTextSpacing));
+ else
+ info.ContextCell.SetImageBounds(AlignContent(largestImageSize, ref r, ha, va, this.ImageTextSpacing));
+ }
+ else
+ info.ContextCell.SetImageBounds(Rectangle.Empty);
+
+ // Set position of the text
+ //info.ContextCell.SetTextBounds(Rectangle.Empty);
+ if (!textSize.IsEmpty)
+ {
+ if (info.CellWidth > 0)
+ {
+ r.Width -= 2 + ElementStyleLayout.HorizontalStyleWhiteSpace(info.LayoutStyle);
+ }
+ info.ContextCell.TextContentBounds = r;
+ }
+ else
+ info.ContextCell.TextContentBounds = Rectangle.Empty;
+
+ }
+
+ protected Rectangle AlignContent(System.Drawing.Size contentSize, ref Rectangle boundingRectangle, eHorizontalAlign horizAlign, eVerticalAlign vertAlign, int contentSpacing)
+ {
+ Rectangle contentRect=new Rectangle(Point.Empty,contentSize);
+ switch(horizAlign)
+ {
+ case eHorizontalAlign.Right:
+ {
+ contentRect.X=boundingRectangle.Right-contentRect.Width;
+ boundingRectangle.Width-=(contentRect.Width+contentSpacing);
+ break;
+ }
+ case eHorizontalAlign.Center:
+ {
+ contentRect.X = boundingRectangle.X + (boundingRectangle.Width - contentRect.Width) / 2;
+ break;
+ }
+ default:
+ {
+ contentRect.X=boundingRectangle.X;
+ boundingRectangle.X=contentRect.Right+contentSpacing;
+ boundingRectangle.Width-=(contentRect.Width+contentSpacing);
+ break;
+ }
+ }
+
+ switch(vertAlign)
+ {
+ case eVerticalAlign.Top:
+ {
+ contentRect.Y=boundingRectangle.Y;
+ break;
+ }
+ case eVerticalAlign.Middle:
+ {
+ contentRect.Y=boundingRectangle.Y+(boundingRectangle.Height-contentRect.Height)/2;
+ break;
+ }
+ case eVerticalAlign.Bottom:
+ {
+ contentRect.Y=boundingRectangle.Bottom-contentRect.Height;
+ break;
+ }
+ }
+
+ return contentRect;
+ }
+
+ protected Rectangle AlignContentVertical(System.Drawing.Size contentSize, ref Rectangle boundingRectangle, eHorizontalAlign horizAlign, eVerticalAlign vertAlign, int contentSpacing)
+ {
+ Rectangle contentRect=new Rectangle(Point.Empty,contentSize);
+ switch(horizAlign)
+ {
+ case eHorizontalAlign.Left:
+ {
+ contentRect.X=boundingRectangle.X;
+ break;
+ }
+ case eHorizontalAlign.Right:
+ {
+ contentRect.X=boundingRectangle.Right-contentRect.Width;
+ break;
+ }
+ case eHorizontalAlign.Center:
+ {
+ contentRect.X=boundingRectangle.X+(boundingRectangle.Width-contentRect.Width)/2;
+ break;
+ }
+ }
+
+ switch(vertAlign)
+ {
+ case eVerticalAlign.Bottom:
+ {
+ contentRect.Y=boundingRectangle.Bottom-contentRect.Height;
+ boundingRectangle.Height-=(contentRect.Height+contentSpacing);
+ break;
+ }
+ //case eVerticalAlign.Top:
+ default:
+ {
+ contentRect.Y=boundingRectangle.Y;
+ boundingRectangle.Y=contentRect.Bottom+contentSpacing;
+ boundingRectangle.Height-=(contentRect.Height+contentSpacing);
+ break;
+ }
+// case eVerticalAlign.Middle:
+// {
+// contentRect.Y=boundingRectangle.Y+(boundingRectangle.Height-contentRect.Height)/2;
+// break;
+// }
+ }
+
+ return contentRect;
+ }
+
+ public static eHorizontalAlign GetHorizontalAlign(eCellPartAlignment align, bool leftToRight, eView view)
+ {
+ if (align == eCellPartAlignment.Default)
+ {
+ if (view == eView.Tree)
+ align = eCellPartAlignment.NearCenter;
+ else if (view == eView.Tile)
+ align = eCellPartAlignment.NearCenter;
+ }
+
+ if(((align==eCellPartAlignment.NearBottom || align==eCellPartAlignment.NearCenter ||
+ align==eCellPartAlignment.NearTop) && leftToRight) ||
+ ((align==eCellPartAlignment.FarBottom || align==eCellPartAlignment.FarCenter ||
+ align==eCellPartAlignment.FarTop) && !leftToRight))
+ return eHorizontalAlign.Left;
+ else if(align==eCellPartAlignment.CenterBottom || align==eCellPartAlignment.CenterTop)
+ return eHorizontalAlign.Center;
+ return eHorizontalAlign.Right;
+ }
+
+ public static eVerticalAlign GetVerticalAlign(eCellPartAlignment align, eView view)
+ {
+ if (align == eCellPartAlignment.Default)
+ {
+ if (view == eView.Tree)
+ align = eCellPartAlignment.NearCenter;
+ else if (view == eView.Tile)
+ align = eCellPartAlignment.NearCenter;
+ }
+ eVerticalAlign va=eVerticalAlign.Middle;
+
+ switch(align)
+ {
+ case eCellPartAlignment.FarBottom:
+ case eCellPartAlignment.NearBottom:
+ case eCellPartAlignment.CenterBottom:
+ va=eVerticalAlign.Bottom;
+ break;
+ case eCellPartAlignment.FarTop:
+ case eCellPartAlignment.NearTop:
+ case eCellPartAlignment.CenterTop:
+ va=eVerticalAlign.Top;
+ break;
+ }
+
+ return va;
+ }
+
+ public static eHorizontalAlign GetCheckBoxHorizontalAlign(eCellPartAlignment align, bool leftToRight, eView view)
+ {
+ if (align == eCellPartAlignment.Default)
+ {
+ if (view == eView.Tree)
+ align = eCellPartAlignment.NearCenter;
+ else if (view == eView.Tile)
+ align = eCellPartAlignment.NearCenter;
+ }
+
+ if (((align == eCellPartAlignment.NearBottom || align == eCellPartAlignment.NearCenter ||
+ align == eCellPartAlignment.NearTop) && leftToRight) ||
+ ((align == eCellPartAlignment.FarBottom || align == eCellPartAlignment.FarCenter ||
+ align == eCellPartAlignment.FarTop) && !leftToRight))
+ return eHorizontalAlign.Left;
+ else if (align == eCellPartAlignment.CenterBottom || align == eCellPartAlignment.CenterTop)
+ return eHorizontalAlign.Center;
+ return eHorizontalAlign.Right;
+ }
+ public static eVerticalAlign GetCheckBoxVerticalAlign(eCellPartAlignment align, eView view)
+ {
+ if (align == eCellPartAlignment.Default)
+ {
+ if (view == eView.Tree)
+ align = eCellPartAlignment.NearCenter;
+ else if (view == eView.Tile)
+ align = eCellPartAlignment.NearCenter;
+ }
+ eVerticalAlign va = eVerticalAlign.Middle;
+
+ switch (align)
+ {
+ case eCellPartAlignment.FarBottom:
+ case eCellPartAlignment.NearBottom:
+ case eCellPartAlignment.CenterBottom:
+ va = eVerticalAlign.Bottom;
+ break;
+ case eCellPartAlignment.FarTop:
+ case eCellPartAlignment.NearTop:
+ case eCellPartAlignment.CenterTop:
+ va = eVerticalAlign.Top;
+ break;
+ }
+
+ return va;
+ }
+
+ private Size _CheckBoxSize = new Size(12, 12);
+ internal System.Drawing.Size CheckBoxSize
+ {
+ get
+ {
+ return _CheckBoxSize;
+ }
+ set
+ {
+ _CheckBoxSize = value;
+ }
+ }
+ internal void ResetCheckBoxSize()
+ {
+ _CheckBoxSize = new Size(12, 12);
+ }
+
+ ///
+ /// Returns spacing between check box and image if both are displayed
+ ///
+ protected int ImageCheckBoxSpacing
+ {
+ get {return 4;}
+ }
+
+ ///
+ /// Returns spacing between image or checkbox and text
+ ///
+ protected int ImageTextSpacing
+ {
+ get {return 4;}
+ }
+
+ //private int _CellHorizontalSpacing = 5;
+ /////
+ ///// Returns horizontal spacing between cells in a node
+ /////
+ //public int CellHorizontalSpacing
+ //{
+ // get {return _CellHorizontalSpacing;}
+ // set
+ // {
+ // _CellHorizontalSpacing = value;
+ // }
+ //}
+
+ ///
+ /// Returns vertical spacing between cells in a node
+ ///
+ public int CellVerticalSpacing
+ {
+ get {return 1;}
+ }
+
+ ///
+ /// Spacing between different parts of the cell, like image, option button, text and expand button area
+ ///
+ public int CellPartSpacing
+ {
+ get {return 1;}
+ }
+
+ public virtual Size LayoutCells(NodeLayoutContextInfo layoutInfo, int x, int y)
+ {
+ eCellLayout layout=layoutInfo.CellLayout;
+ if (layoutInfo.ContextNode.CellLayout != layoutInfo.CellLayout && layoutInfo.ContextNode.CellLayout != eCellLayout.Default)
+ layout = layoutInfo.ContextNode.CellLayout;
+
+ if (layout == eCellLayout.Horizontal || layout == eCellLayout.Default && layoutInfo.View == eView.Tree || layoutInfo.View == eView.Tile && layoutInfo.IsViewGroupping && layoutInfo.ContextNode.HasChildNodes)
+ return this.LayoutCellsHorizontal(layoutInfo, x, y);
+ else
+ return this.LayoutCellsVertical(layoutInfo, x, y);
+ }
+
+ protected virtual Size LayoutCellsHorizontal(NodeLayoutContextInfo layoutInfo, int x, int y)
+ {
+ Node node=layoutInfo.ContextNode;
+ int height=0, width=0;
+ bool adjustHeight = false;
+ int cellCount = node.Cells.Count;
+ bool firstVisible = true;
+ int runningColumnWidth = 0;
+
+ for(int i=0;i 0 || layoutInfo.ChildColumns != null && layoutInfo.ChildColumns.ColumnInfo.Count > 0) &&
+ (node.Cells.Count > 1 || node.Cells.Count == layoutInfo.DefaultColumns.ColumnInfo.Count ||
+ layoutInfo.ChildColumns != null && layoutInfo.ChildColumns.ColumnInfo.Count == node.Cells.Count))
+ {
+ bool usingTopLevelColumns = false;
+ if (layoutInfo.ChildColumns != null && layoutInfo.ChildColumns.ColumnInfo.Count > 0 && i < layoutInfo.ChildColumns.ColumnInfo.Count)
+ ci = layoutInfo.ChildColumns.ColumnInfo[i] as ColumnInfo;
+ else if (i < layoutInfo.DefaultColumns.ColumnInfo.Count)
+ {
+ ci = layoutInfo.DefaultColumns.ColumnInfo[i] as ColumnInfo;
+ usingTopLevelColumns = true;
+ }
+
+ if (ci != null)
+ {
+ bCellVisible = ci.Visible;
+ if (ci.AutoSize && cell.HostedControl == null)
+ cellLayout.CellWidth = 0;
+ else
+ {
+ cellLayout.CellWidth = ci.Width;
+ /*if (firstVisible && usingTopLevelColumns && cellLayout.CellWidth > 0)
+ {
+ cellLayout.CellWidth = Math.Max(-1, cellLayout.CellWidth - (layoutInfo.Left + x + this.LayoutSettings.CellHorizontalSpacing));
+ if (cellLayout.CellWidth == 0) cellLayout.CellWidth = -1; // this ensures that cell content is not visible since 0 indicates to take as much space as needed
+ }
+ else*/ if(usingTopLevelColumns && cellLayout.CellWidth>0 && runningColumnWidth0)
+ {
+ x += this.LayoutSettings.CellHorizontalSpacing;
+ width += this.LayoutSettings.CellHorizontalSpacing;
+ }
+ if (cell.BoundsRelative.Height > height)
+ {
+ if (height != 0) adjustHeight = true;
+ height = cell.BoundsRelative.Height;
+ }
+ else if (!firstVisible && cell.BoundsRelative.Height < height && !cell.TextContentBounds.IsEmpty)
+ adjustHeight = true;
+
+ firstVisible = false;
+ }
+ }
+
+ // Apply the uniform cell text height to all cells
+ if (adjustHeight)
+ {
+ for (int i = 0; i < node.Cells.Count; i++)
+ {
+ Cell cell = node.Cells[i];
+ if (cell.BoundsRelative.Height != height && !cell.TextContentBounds.IsEmpty)
+ {
+ cell.TextContentBounds = new Rectangle(cell.TextContentBounds.X, cell.TextContentBounds.Y,
+ cell.TextContentBounds.Width, cell.TextContentBounds.Height + (height - cell.BoundsRelative.Height));
+ int diff = height - cell.BoundsRelative.Height;
+ if (!cell.CheckBoxBoundsRelative.IsEmpty)
+ {
+ eVerticalAlign va = GetCheckBoxVerticalAlign(cell.CheckBoxAlignment, layoutInfo.View);
+ if (va == eVerticalAlign.Middle)
+ cell.SetCheckBoxBounds(new Rectangle(cell.CheckBoxBoundsRelative.X, cell.CheckBoxBoundsRelative.Y + (int)Math.Ceiling((double)diff / 2), cell.CheckBoxBoundsRelative.Width, cell.CheckBoxBoundsRelative.Height));
+ if (va == eVerticalAlign.Bottom)
+ cell.SetCheckBoxBounds(new Rectangle(cell.CheckBoxBoundsRelative.X, cell.CheckBoxBoundsRelative.Y + diff, cell.CheckBoxBoundsRelative.Width, cell.CheckBoxBoundsRelative.Height));
+ }
+ if (!cell.ImageBoundsRelative.IsEmpty)
+ {
+ eVerticalAlign va = GetVerticalAlign(cell.ImageAlignment, layoutInfo.View);
+ if(va== eVerticalAlign.Middle)
+ cell.SetImageBounds(new Rectangle(cell.ImageBoundsRelative.X, cell.ImageBoundsRelative.Y + (int)Math.Ceiling((double)diff / 2), cell.ImageBoundsRelative.Width, cell.ImageBoundsRelative.Height));
+ else if (va == eVerticalAlign.Bottom)
+ cell.SetImageBounds(new Rectangle(cell.ImageBoundsRelative.X, cell.ImageBoundsRelative.Y + diff, cell.ImageBoundsRelative.Width, cell.ImageBoundsRelative.Height));
+ }
+ cell.SetBounds(new Rectangle(cell.BoundsRelative.X, cell.BoundsRelative.Y, cell.BoundsRelative.Width, height));
+ }
+ }
+ }
+
+ // Take last added spacing off
+ x -= this.LayoutSettings.CellHorizontalSpacing;
+ width -= this.LayoutSettings.CellHorizontalSpacing;
+
+ return new Size(width,height);
+ }
+
+ protected virtual Size LayoutCellsVertical(NodeLayoutContextInfo layoutInfo, int x, int y)
+ {
+ Node node=layoutInfo.ContextNode;
+ int height=0, width=0;
+ eHorizontalAlign align = node.VerticalCellLayoutAlignment; // eHorizontalAlign.Center;
+ int iVisibleCells=0;
+ int cellCount = node.Cells.Count;
+ for(int i=0;i 0 || layoutInfo.ChildColumns != null && layoutInfo.ChildColumns.ColumnInfo.Count > 0)
+ {
+ ColumnInfo ci=null;
+ if (layoutInfo.ChildColumns != null && layoutInfo.ChildColumns.ColumnInfo.Count > 0)
+ ci=layoutInfo.ChildColumns.ColumnInfo[i] as ColumnInfo;
+ else
+ ci=layoutInfo.DefaultColumns.ColumnInfo[i] as ColumnInfo;
+
+ bCellVisible=ci.Visible;
+ cellLayout.CellWidth=ci.Width;
+ }
+ else if (layoutInfo.View == eView.Tile)
+ {
+ cellLayout.CellWidth = layoutInfo.TileSize.Width;
+ cellLayout.CellHeight = layoutInfo.TileSize.Height;
+ }
+
+ // Prepare union style
+ if(cell.StyleNormal!=null)
+ cellLayout.LayoutStyle=cell.StyleNormal;
+ else
+ cellLayout.LayoutStyle=layoutInfo.DefaultCellStyle;
+
+ this.LayoutSingleCell(cellLayout);
+
+ cell.SetVisible(bCellVisible);
+ if(bCellVisible)
+ {
+ iVisibleCells++;
+ y+=cell.BoundsRelative.Height;
+ height+=cell.BoundsRelative.Height;
+ if(cell.BoundsRelative.Height>0)
+ {
+ y+=this.CellVerticalSpacing;
+ height+=this.CellVerticalSpacing;
+ }
+ if(cell.BoundsRelative.Width>width)
+ width=cell.BoundsRelative.Width;
+ }
+ }
+
+ // Take last added spacing off
+ y-=this.CellVerticalSpacing;
+ height-=this.CellVerticalSpacing;
+
+ // Additional pass needed if horizontal alignment is other than left and there is more than one cell visible
+ if(align!=eHorizontalAlign.Left && iVisibleCells>1)
+ {
+ foreach(Cell cell in node.Cells)
+ {
+ if(!cell.IsVisible)
+ continue;
+ if(align==eHorizontalAlign.Center)
+ this.Offset(cell,(width-cell.BoundsRelative.Width)/2,0);
+ else // Right aligned cells
+ this.Offset(cell,width-cell.BoundsRelative.Width,0);
+ }
+ }
+
+ return new Size(width,height);
+ }
+
+ private LayoutCellInfo m_LayoutCellInfo=null;
+ protected virtual LayoutCellInfo GetLayoutCellInfo()
+ {
+ if(m_LayoutCellInfo==null)
+ m_LayoutCellInfo=new LayoutCellInfo();
+ return m_LayoutCellInfo;
+ }
+
+ protected virtual bool HasImage(Cell cell)
+ {
+ if (cell.Images.Image != null || cell.Images.ImageIndex >= 0 || !string.IsNullOrEmpty(cell.Images.ImageKey))
+ return true;
+ return false;
+ }
+ }
+ }
+
+ internal class LayoutCellInfo
+ {
+ public Cell ContextCell=null;
+ public int CellWidth=0;
+ public int CellHeight = 0;
+ public System.Drawing.Graphics Graphics=null;
+ public int Left=0;
+ public int Top=0;
+ public ElementStyle LayoutStyle=null;
+ public bool LeftToRight=true;
+ public bool VerticalPartAlignment=false;
+ public eView View = eView.Tree;
+ public int CellIndex = 0;
+
+ private Font _Font;
+ public Font Font
+ {
+ get { return _Font; }
+ set
+ {
+ if (_Font != value)
+ {
+ _Font = value;
+ if (_Font != null)
+ FontHeight = _Font.Height;
+ else
+ FontHeight = 0;
+ }
+ }
+ }
+ public int FontHeight = 0;
+
+ public LayoutCellInfo()
+ {
+ }
+ }
+
+ internal class ColumnInfo
+ {
+ public bool Visible;
+ public int Width;
+ public int MaxWidth = 0;
+ public ColumnHeader ColumnHeader = null;
+ public bool AutoSize = false;
+ // Specifies the absolute index for column data. AbsoluteIndex may be different from DisplayIndex of columns are re-arranged
+ public int AbsoluteIndex = -1;
+ public ColumnInfo(int width, bool visible, ColumnHeader h, int absoluteIndex)
+ {
+ this.Width=width;
+ this.Visible=visible;
+ this.ColumnHeader = h;
+ this.AutoSize = h.Width.AutoSize;
+ this.AbsoluteIndex = absoluteIndex;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeLayout.cs b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeLayout.cs
new file mode 100644
index 00000000..76425a45
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeLayout.cs
@@ -0,0 +1,702 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using DevComponents.DotNetBar;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+using System.Collections.Generic;
+
+namespace DevComponents.AdvTree.Layout
+{
+ ///
+ /// Summary description for NodeLayout.
+ ///
+ internal abstract class NodeLayout
+ {
+ #region Private Variables
+ protected int m_Height=0;
+ protected int m_Width=0;
+ protected AdvTree m_Tree=null;
+ protected Rectangle m_ClientArea;
+ //protected int m_ExpandAreaWidth=8;
+ protected Size m_ExpandPartSize=new Size(8,8);
+ private Size _CachedExpandPartSize = Size.Empty;
+ private int m_CommandAreaWidth=10;
+ private int m_TreeLayoutChildNodeIndent = 16;
+
+ private System.Windows.Forms.LeftRightAlignment m_LeftRight=System.Windows.Forms.LeftRightAlignment.Left;
+ private int m_NodeVerticalSpacing=3;
+ private int m_NodeHorizontalSpacing=0;
+ private CellLayout m_CellLayout=null;
+ private Graphics m_Graphics=null;
+ #endregion
+
+ public NodeLayout(AdvTree treeControl, Rectangle clientArea, LayoutSettings layoutSettings)
+ {
+ m_Tree=treeControl;
+ m_ClientArea=clientArea;
+ _LayoutSettings = layoutSettings;
+ }
+
+ ///
+ /// Performs layout of the nodes inside of the tree control.
+ ///
+ public virtual void PerformLayout()
+ {
+ }
+
+ public virtual void UpdateTopLevelColumnsWidth()
+ {
+ }
+
+ private LayoutSettings _LayoutSettings;
+ ///
+ /// Gets or sets layout settings.
+ ///
+ public LayoutSettings LayoutSettings
+ {
+ get { return _LayoutSettings; }
+ set { _LayoutSettings = value; }
+ }
+
+ ///
+ /// Performs layout for single unassigned node. Node does not have to be part of the tree control.
+ ///
+ /// Node to perform layout on.
+ public virtual void PerformSingleNodeLayout(Node node)
+ {
+ if(node==null)
+ return;
+
+ this.PrepareStyles();
+ // Get default Columns
+
+ System.Drawing.Graphics g=this.GetGraphics();
+
+ SmoothingMode sm = g.SmoothingMode;
+ TextRenderingHint th = g.TextRenderingHint;
+ if (m_Tree.AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ //g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ try
+ {
+ NodeLayoutContextInfo layoutInfo=this.GetDefaultNodeLayoutContextInfo(g);
+ layoutInfo.ContextNode=node;
+ if (node.IsDragNode)
+ layoutInfo.DefaultColumns = new NodeColumnInfo(new List(), false);
+ LayoutNode(layoutInfo);
+ }
+ finally
+ {
+ if (m_Tree.AntiAlias)
+ {
+ g.SmoothingMode = sm;
+ //g.TextRenderingHint = th;
+ }
+ g.Dispose();
+ }
+ }
+
+ public int Width
+ {
+ get {return m_Width;}
+ }
+
+ public int Height
+ {
+ get {return m_Height;}
+ }
+
+ public Rectangle ClientArea
+ {
+ get {return m_ClientArea;}
+ set {m_ClientArea=value;}
+ }
+
+ public Graphics Graphics
+ {
+ get { return m_Graphics;}
+ set { m_Graphics = value;}
+ }
+
+ internal bool DisposeGraphics
+ {
+ get
+ {
+ return (m_Graphics == null);
+ }
+ }
+
+ protected virtual System.Drawing.Graphics GetGraphics()
+ {
+ if(m_Graphics!=null)
+ return m_Graphics;
+
+ Graphics g=m_Tree.CreateGraphics();
+
+
+ return g;
+ }
+
+ ///
+ /// Resizes all styles and prepares them for layout.
+ ///
+ protected virtual void PrepareStyles()
+ {
+ // Resize styles if needed
+ foreach(ElementStyle es in m_Tree.Styles)
+ {
+ if(es.SizeChanged)
+ ElementStyleLayout.CalculateStyleSize(es,m_Tree.Font);
+ }
+
+ if (_LayoutSettings != null)
+ _CachedExpandPartSize = Dpi.Size(_LayoutSettings.ExpandPartSize);
+ else
+ _CachedExpandPartSize = Dpi.Size(m_ExpandPartSize);
+
+ }
+
+ ///
+ /// Returns default top-level columns for tree control.
+ ///
+ /// Returns array list of ColumnInfo objects.
+ protected virtual NodeColumnInfo GetDefaultColumnInfo()
+ {
+ List ci = new List();
+ NodeColumnInfo info = new NodeColumnInfo(ci, false);
+ ColumnHeaderCollection columns=m_Tree.Columns;
+ //int treeWidth = m_Tree.ClientRectangle.Width;
+ if(columns!=null)
+ {
+ for (int i = 0; i < columns.Count; i++)
+ {
+ int columnIndex = columns.DisplayIndexMap[i];
+ ColumnHeader h = columns[columnIndex];
+ ColumnInfo columnInfo = new ColumnInfo(h.Bounds.Width, h.Visible, h, columnIndex);
+ ci.Add(columnInfo);
+ info.HasAutoSizeColumn |= columnInfo.AutoSize;
+ }
+ }
+
+ return info;
+ }
+
+ ///
+ /// Returns column information for a given node.
+ ///
+ /// Node to return column information for
+ /// Returns array list of ColumnInfo objects or null if there are no columns defined.
+ protected virtual NodeColumnInfo GetNodeColumnInfo(Node node)
+ {
+ if (!node.HasColumns)
+ {
+ return null;
+ }
+
+ List ci = new List();
+ NodeColumnInfo info = new NodeColumnInfo(ci, false);
+ ColumnHeaderCollection columns = node.NodesColumns;
+ for (int i = 0; i < columns.Count; i++)
+ {
+ int columnIndex = columns.DisplayIndexMap[i];
+ ColumnHeader h = columns[columnIndex];
+ ColumnInfo columnInfo = new ColumnInfo(h.Bounds.Width, h.Visible, h, columnIndex);
+ ci.Add(columnInfo);
+ info.HasAutoSizeColumn |= columnInfo.AutoSize;
+ }
+
+ return info;
+ }
+
+ /////
+ ///// Gets or sets the vertical spacing between nodes in pixels.
+ /////
+ //public virtual int NodeVerticalSpacing
+ //{
+ // get {return m_NodeVerticalSpacing;}
+ // set {m_NodeVerticalSpacing=value;}
+ //}
+
+ /////
+ ///// Gets or sets the horizontal spacing between nodes in pixels.
+ /////
+ //public virtual int NodeHorizontalSpacing
+ //{
+ // get {return m_NodeHorizontalSpacing;}
+ // set {m_NodeHorizontalSpacing=value;}
+ //}
+
+ ///
+ /// Gets or sets the child node indent in pixels.
+ ///
+ public virtual int TreeLayoutChildNodeIndent
+ {
+ get {return m_TreeLayoutChildNodeIndent; }
+ set { m_TreeLayoutChildNodeIndent = value; }
+ }
+
+ ///
+ /// Returns column header collection for the given column template name.
+ ///
+ /// Name of the column template.
+ /// Column header collection or null if template name cannot be found.
+ public virtual ColumnHeaderCollection GetColumnHeader(string name)
+ {
+ if(name=="" || name==null)
+ return null;
+ return m_Tree.Headers.GetByName(name).Columns;
+ }
+
+ //private int _ExpandAreaWidth = 24;
+ /////
+ ///// Returns width of the expand button area. Default is 24 pixels.
+ /////
+ //public virtual int ExpandAreaWidth
+ //{
+ // get { return _ExpandAreaWidth; }
+ // set
+ // {
+ // _ExpandAreaWidth = value;
+ // }
+ //}
+
+ /////
+ ///// Gets or sets width of command button area. Default is 8 pixels.
+ /////
+ //public virtual int CommandAreaWidth
+ //{
+ // get {return m_CommandAreaWidth;}
+ // set {m_CommandAreaWidth=value;}
+ //}
+
+ ///
+ /// Sets the position and size of the node command button.
+ ///
+ /// Node layout context information
+ protected virtual void LayoutCommandPart(NodeLayoutContextInfo layoutInfo, ElementStyle nodeStyle)
+ {
+ // Command part is right-aligned just before the node border
+ Rectangle bounds = new Rectangle(layoutInfo.ContextNode.ContentBounds.Right - this.LayoutSettings.CommandAreaWidth -
+ ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Right),layoutInfo.ContextNode.ContentBounds.Y+
+ ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Top),
+ this.LayoutSettings.CommandAreaWidth, layoutInfo.ContextNode.ContentBounds.Height -
+ ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Top)-
+ ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Bottom));
+// Rectangle bounds=new Rectangle(layoutInfo.ContextNode.ContentBounds.Right-this.CommandAreaWidth-
+// ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Right),layoutInfo.ContextNode.ContentBounds.Y,
+// this.CommandAreaWidth, layoutInfo.ContextNode.ContentBounds.Height);
+ layoutInfo.ContextNode.CommandBoundsRelative=bounds;
+ }
+
+ ///
+ /// Determines the rectangle of the +/- part of the tree node that is used to expand node.
+ ///
+ /// Node layout context information
+ protected virtual void LayoutExpandPart(NodeLayoutContextInfo layoutInfo, bool bLeftNode, int x)
+ {
+ Node node=layoutInfo.ContextNode;
+
+ Size partSize=GetExpandPartSize();
+
+ Rectangle bounds=new Rectangle(x,0,partSize.Width,partSize.Height);
+
+ if (node.ExpandPartVerticalAlignment == eVerticalAlign.Middle)
+ bounds.Y = (node.BoundsRelative.Height - bounds.Height) / 2;
+ else if (node.ExpandPartVerticalAlignment == eVerticalAlign.Top)
+ bounds.Y = Dpi.Height3;
+ else
+ bounds.Y = node.BoundsRelative.Height - partSize.Height - Dpi.Height3;
+
+ if (bLeftNode || layoutInfo.ExpandPartAlignedLeft && layoutInfo.LeftToRight)
+ bounds.X += (layoutInfo.ExpandAreaWidth - bounds.Width) / 2;
+ else
+ bounds.X = node.BoundsRelative.Right - layoutInfo.ExpandAreaWidth + (layoutInfo.ExpandAreaWidth - partSize.Width) / 2;
+
+ node.SetExpandPartRectangle(bounds);
+ }
+
+ ///
+ /// Returns the size of the node expand part.
+ ///
+ /// Size of the expand part, default 8,8.
+ protected virtual Size GetExpandPartSize()
+ {
+ return _CachedExpandPartSize;
+ //if (_LayoutSettings != null)
+ // return _LayoutSettings.ExpandPartSize;
+ //return m_ExpandPartSize;
+ }
+
+ /////
+ ///// Gets or sets the size of the expand part that is expanding/collapsing the node. Default value is 8,8.
+ /////
+ //public System.Drawing.Size ExpandPartSize
+ //{
+ // get {return m_ExpandPartSize;}
+ // set {m_ExpandPartSize=value;}
+ //}
+
+ ///
+ /// Provides the layout for single node.
+ ///
+ /// Layout information.
+ protected virtual void LayoutNode(NodeLayoutContextInfo layoutInfo)
+ {
+ bool bHasExpandPart=this.HasExpandPart(layoutInfo);
+ bool bHasCommandPart=this.HasCommandPart(layoutInfo);
+
+ Node node=layoutInfo.ContextNode;
+
+ Rectangle nodeRect = new Rectangle(layoutInfo.Left, layoutInfo.Top, 0, 0);
+ Rectangle nodeContentRect=Rectangle.Empty; // Node content rect excludes expand rect
+
+ int height=0, width=0;
+
+ // Left node relative to the main root node...
+ bool bLeftNode = layoutInfo.LeftToRight; // (layoutInfo.MapPositionNear && layoutInfo.LeftToRight);
+ layoutInfo.LayoutNodeExpandPartWidth = 0;
+ if(bLeftNode && bHasExpandPart || this.ReserveExpandPartSpace)
+ {
+ layoutInfo.LayoutNodeExpandPartWidth = (layoutInfo.ExpandAreaWidth + this.GetCellLayout().CellPartSpacing);
+ width += (layoutInfo.ExpandAreaWidth + this.GetCellLayout().CellPartSpacing);
+ }
+
+ int x=width; // relative to 0,0 of the node
+ int y=0; // Relative to 0,0 of the node
+
+ // Apply node style
+ ElementStyle nodeStyle=null;
+ if(node.Expanded && node.StyleExpanded!=null)
+ nodeStyle=node.StyleExpanded;
+ else if(node.Style!=null)
+ nodeStyle=node.Style;
+ else
+ nodeStyle=layoutInfo.DefaultNodeStyle;
+
+ nodeContentRect.X=x;
+
+ if(nodeStyle!=null)
+ {
+ x+=ElementStyleLayout.LeftWhiteSpace(nodeStyle);
+ y+=ElementStyleLayout.TopWhiteSpace(nodeStyle);
+ nodeContentRect.X+=nodeStyle.MarginLeft;
+ nodeContentRect.Y+=nodeStyle.MarginTop;
+ }
+
+ Size size = this.GetCellLayout().LayoutCells(layoutInfo, x, y);
+
+ node.SetCellsBounds(new Rectangle(x, y, size.Width, size.Height));
+
+ height=size.Height;
+ width+=size.Width;
+
+ nodeContentRect.Width=size.Width;
+ nodeContentRect.Height=size.Height;
+
+ if(nodeStyle!=null)
+ {
+ nodeContentRect.Width+=(ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Padding | eSpacePart.Border,eStyleSide.Left)+
+ ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Padding | eSpacePart.Border,eStyleSide.Right));
+ nodeContentRect.Height+=(ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Padding | eSpacePart.Border,eStyleSide.Top)+
+ ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Padding | eSpacePart.Border,eStyleSide.Bottom));
+
+ width+=(ElementStyleLayout.HorizontalStyleWhiteSpace(nodeStyle));
+ height+=(ElementStyleLayout.VerticalStyleWhiteSpace(nodeStyle));
+ }
+
+ if (!bLeftNode && bHasExpandPart && !this.ReserveExpandPartSpace)
+ width += layoutInfo.ExpandAreaWidth;
+
+ if(bHasCommandPart)
+ {
+ width += this.LayoutSettings.CommandAreaWidth;
+ nodeContentRect.Width += this.LayoutSettings.CommandAreaWidth;
+ }
+
+ nodeRect.Height=height;
+ nodeRect.Width=width;
+ node.SetBounds(nodeRect);
+ node.SetContentBounds(nodeContentRect);
+
+ if(bHasCommandPart)
+ LayoutCommandPart(layoutInfo, nodeStyle);
+ else
+ node.CommandBoundsRelative=Rectangle.Empty;
+
+ if (bHasExpandPart || this.ReserveExpandPartSpace)
+ LayoutExpandPart(layoutInfo,bLeftNode, 0);
+ else
+ node.SetExpandPartRectangle(Rectangle.Empty);
+
+ node.SizeChanged=false;
+
+ // Calculate size and location of node column header if any
+ //if(node.NodesColumnHeaderVisible)
+ {
+ //layoutInfo.Left+=this.NodeLevelOffset;
+ LayoutColumnHeader(layoutInfo);
+ //layoutInfo.Left-=this.NodeLevelOffset;
+ }
+ }
+
+ ///
+ /// Returns true if given node has expand part.
+ ///
+ /// Layout context information.
+ ///
+ protected virtual bool HasExpandPart(NodeLayoutContextInfo layoutInfo)
+ {
+ Node node=layoutInfo.ContextNode;
+ if(node.ExpandVisibility==eNodeExpandVisibility.Auto)
+ {
+ if(IsRootNode(node) && !RootHasExpandedPart || !NodeOperations.GetAnyVisibleNodes(node))
+ return false;
+ return true;
+ }
+ else
+ return (node.ExpandVisibility==eNodeExpandVisibility.Visible);
+ }
+
+ ///
+ /// Returns whether given node has command part.
+ ///
+ /// Layout context information.
+ /// True if command part should be drawn otherwise false.
+ protected virtual bool HasCommandPart(NodeLayoutContextInfo layoutInfo)
+ {
+ return layoutInfo.ContextNode.CommandButton;
+ }
+
+ ///
+ /// Returns true if root node should have expanded part
+ ///
+ protected virtual bool RootHasExpandedPart
+ {
+ get {return true;}
+ }
+
+ ///
+ /// Returns true if expand part space should be accounted for even if they expand part is not visible or need to be displayed. Default value is false.
+ ///
+ protected virtual bool ReserveExpandPartSpace
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// Returns class responsible for cell layout.
+ ///
+ /// Cell layout class.
+ protected internal virtual CellLayout GetCellLayout()
+ {
+ if (m_CellLayout == null)
+ m_CellLayout = new CellLayout(this.LayoutSettings);
+ return m_CellLayout;
+ }
+
+ ///
+ /// Offsets node location and location of it's child nodes bounds.
+ ///
+ /// Node to offset.
+ /// Horizontal offset.
+ /// Vertical offset.
+ protected virtual void OffsetNodeLocation(Node node, int x, int y)
+ {
+ node.SetBounds(new Rectangle(node.BoundsRelative.X+x,node.BoundsRelative.Y+y,node.BoundsRelative.Width,node.BoundsRelative.Height));
+ if(node.Expanded)
+ node.ChildNodesBounds=new Rectangle(node.ChildNodesBounds.X+x,node.ChildNodesBounds.Y+y,node.ChildNodesBounds.Width,node.ChildNodesBounds.Height);
+ }
+
+ protected virtual NodeLayoutContextInfo GetDefaultNodeLayoutContextInfo(System.Drawing.Graphics graphics)
+ {
+ NodeLayoutContextInfo layoutInfo=new NodeLayoutContextInfo();
+ layoutInfo.ClientRectangle=m_ClientArea;
+ layoutInfo.DefaultColumns=this.GetDefaultColumnInfo();
+ layoutInfo.ChildColumns=null;
+ layoutInfo.Indent = m_Tree.Indent;
+ layoutInfo.Left=0;
+ layoutInfo.Top=0;
+ layoutInfo.LeftMargin = m_Tree.BackgroundStyle.PaddingLeft;
+ layoutInfo.DefaultFont=m_Tree.Font;
+ layoutInfo.LeftToRight=(this.LeftRight==System.Windows.Forms.LeftRightAlignment.Left);
+ layoutInfo.Graphics=graphics;
+ layoutInfo.Styles=m_Tree.Styles;
+ layoutInfo.FullRowBackgroundNodes = new ArrayList();
+ if(m_Tree.CellLayout!=eCellLayout.Default)
+ layoutInfo.CellLayout=m_Tree.CellLayout;
+ if(m_Tree.CellPartLayout!=eCellPartLayout.Default)
+ layoutInfo.CellPartLayout=m_Tree.CellPartLayout;
+
+ if(m_Tree.NodeStyle!=null)
+ layoutInfo.DefaultNodeStyle=m_Tree.NodeStyle;
+
+ if(m_Tree.CellStyleDefault!=null)
+ layoutInfo.DefaultCellStyle=m_Tree.CellStyleDefault;
+ else
+ layoutInfo.DefaultCellStyle=ElementStyle.GetDefaultCellStyle(layoutInfo.DefaultNodeStyle);
+
+ // Determine size of the default Column Header
+ if(m_Tree.ColumnStyleNormal!=null)
+ {
+ ElementStyleLayout.CalculateStyleSize(m_Tree.ColumnStyleNormal,layoutInfo.DefaultFont);
+ layoutInfo.DefaultHeaderSize=m_Tree.ColumnStyleNormal.Size;
+ }
+
+ if(layoutInfo.DefaultHeaderSize.IsEmpty)
+ layoutInfo.DefaultHeaderSize.Height=layoutInfo.DefaultFont.Height+4;
+
+ layoutInfo.ExpandPartWidth = Dpi.Width(this.Tree.ExpandWidth);
+ layoutInfo.View = this.Tree.View;
+ layoutInfo.TileSize = Dpi.Size(this.Tree.TileSize);
+ layoutInfo.ColumnStyle = this.Tree.ColumnStyleNormal;
+ layoutInfo.ExpandAreaWidth = Dpi.Width(this.LayoutSettings.ExpandAreaWidth);
+ return layoutInfo;
+ }
+
+ protected Node[] GetTopLevelNodes()
+ {
+ if(m_Tree.DisplayRootNode!=null)
+ return new Node[] {m_Tree.DisplayRootNode};
+ else
+ {
+ Node[] nodes=new Node[m_Tree.Nodes.Count];
+ m_Tree.Nodes.CopyTo(nodes);
+ return nodes;
+ }
+ }
+
+ protected bool IsRootNode(Node node)
+ {
+ return NodeOperations.IsRootNode(m_Tree,node);
+ }
+
+ protected virtual void EmptyBoundsUnusedNodes(Node[] topLevelNodes)
+ {
+ if(m_Tree.DisplayRootNode!=null)
+ {
+ Node node=m_Tree.DisplayRootNode.PrevVisibleNode;
+ while(node!=null)
+ {
+ node.SetBounds(Rectangle.Empty);
+ node=node.PrevVisibleNode;
+ }
+ node=m_Tree.DisplayRootNode.NextNode;
+ if(node==null)
+ {
+ node=m_Tree.DisplayRootNode.Parent;
+ while(node!=null)
+ {
+ if(node.NextNode!=null)
+ {
+ node=node.NextNode;
+ break;
+ }
+ else
+ node=node.Parent;
+ }
+ }
+ while(node!=null)
+ {
+ node.SetBounds(Rectangle.Empty);
+ node=node.NextVisibleNode;
+ }
+ }
+ else
+ {
+ for(int i=1;i
+ /// Initializes a new instance of the NodeColumnInfo structure.
+ ///
+ ///
+ ///
+ public NodeColumnInfo(List columnInfo, bool hasAutoSizeColumn)
+ {
+ ColumnInfo = columnInfo;
+ HasAutoSizeColumn = hasAutoSizeColumn;
+ }
+ ///
+ /// Gets or sets the list of column info object for the columns.
+ ///
+ public List ColumnInfo;
+ ///
+ /// Gets or sets whether columns have auto-size column.
+ ///
+ public bool HasAutoSizeColumn;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeLayoutContextInfo.cs b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeLayoutContextInfo.cs
new file mode 100644
index 00000000..3e970e5e
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeLayoutContextInfo.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Layout
+{
+ ///
+ /// Used to pass node contextual information used for layout of the node.
+ ///
+ internal class NodeLayoutContextInfo
+ {
+ public Node ContextNode=null;
+ public Rectangle ClientRectangle=Rectangle.Empty;
+ public int Left;
+ public int Top;
+ public int LeftMargin = 0;
+ public NodeColumnInfo DefaultColumns=null;
+ public NodeColumnInfo ChildColumns = null;
+ public ElementStyle DefaultCellStyle=null;
+ public ElementStyle DefaultNodeStyle=null;
+ public Size DefaultHeaderSize=Size.Empty;
+ public bool LeftToRight=true;
+ public bool HasExpandPart=true;
+ public System.Drawing.Graphics Graphics=null;
+ public ElementStyleCollection Styles=null;
+ public eCellLayout CellLayout=eCellLayout.Default;
+ public eCellPartLayout CellPartLayout=eCellPartLayout.Horizontal;
+ public bool MapPositionNear=false;
+ public bool ExpandPartAlignedLeft = false;
+ public ColumnHeaderCollection TreeColumns = null;
+ public ArrayList FullRowBackgroundNodes = null;
+ public int ExpandPartWidth = 0;
+ public int CurrentLineHeight = 0; // Used by tile layout
+ public int CurrentLevelLeft = 0; // Used by tile layout
+ public eView View = eView.Tree; // Current control view
+ public Size TileSize = Size.Empty; // Tile size
+ public bool IsViewGroupping = false; // Tile view grouping enabled
+ public ElementStyle ColumnStyle = null;
+ public int LayoutNodeExpandPartWidth = 0;
+ public int Indent = 0;
+ public int ExpandAreaWidth = 0; // Cached LayoutSettings.ExpandAreaWidth with DPI multipler applied.
+
+ private Font _DefaultFont = null;
+ public Font DefaultFont
+ {
+ get { return _DefaultFont; }
+ set
+ {
+ if (_DefaultFont != value)
+ {
+ _DefaultFont = value;
+ if (_DefaultFont != null)
+ DefaultFontHeight = _DefaultFont.Height;
+ else
+ DefaultFontHeight = 0;
+ }
+ }
+ }
+ public int DefaultFontHeight = 0;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeTileLayout.cs b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeTileLayout.cs
new file mode 100644
index 00000000..9a02205a
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeTileLayout.cs
@@ -0,0 +1,393 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+
+namespace DevComponents.AdvTree.Layout
+{
+ ///
+ /// Performs ListView Tile style layout.
+ ///
+ internal class NodeTileLayout : NodeLayout
+ {
+ public NodeTileLayout(AdvTree treeControl, Rectangle clientArea, LayoutSettings layoutSettings)
+ : base(treeControl, clientArea, layoutSettings)
+ {
+ }
+
+ public override void UpdateTopLevelColumnsWidth()
+ {
+ // Columns are not visible in tile layout
+ this.Tree.Columns.SetBounds(Rectangle.Empty);
+ }
+
+ ///
+ /// Returns default top-level columns for tree control.
+ ///
+ /// Returns array list of ColumnInfo objects.
+ protected override NodeColumnInfo GetDefaultColumnInfo()
+ {
+ // There are no columns in Tile view
+ List ci = new List();
+ NodeColumnInfo info = new NodeColumnInfo(ci, false);
+ return info;
+ }
+
+ protected override NodeLayoutContextInfo GetDefaultNodeLayoutContextInfo(System.Drawing.Graphics graphics)
+ {
+ NodeLayoutContextInfo context = base.GetDefaultNodeLayoutContextInfo(graphics);
+ context.IsViewGroupping = this.Groupping;
+ return context;
+ }
+
+ public override void PerformLayout()
+ {
+ this.PrepareStyles();
+ Rectangle area = Rectangle.Empty;
+ Graphics g=this.GetGraphics();
+ SmoothingMode sm = g.SmoothingMode;
+ TextRenderingHint th = g.TextRenderingHint;
+ if (m_Tree.AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ }
+
+ NodeLayoutContextInfo layoutInfo = GetDefaultNodeLayoutContextInfo(g);
+ layoutInfo.ExpandPartAlignedLeft = true;
+ layoutInfo.Left = ClientArea.X;
+ layoutInfo.Top = ClientArea.Y;
+
+ CellLayout cellLayout = this.GetCellLayout();
+ cellLayout.ResetCheckBoxSize();
+ if (this.Tree.CheckBoxImageChecked != null)
+ cellLayout.CheckBoxSize = this.Tree.CheckBoxImageChecked.Size;
+
+ LayoutTopLevelColumns(layoutInfo);
+
+ // Get default Columns
+ NodeColumnInfo defaultColInfoList = this.GetDefaultColumnInfo();
+ layoutInfo.DefaultColumns = defaultColInfoList;
+ try
+ {
+ // Loop through each top-level node
+ Node[] topLevelNodes=this.GetTopLevelNodes();
+ int defaultTop = layoutInfo.Top;
+ area = ProcessTopLevelNodes(area, layoutInfo, topLevelNodes);
+
+ //if (defaultColInfoList.HasAutoSizeColumn)
+ //{
+ // foreach (ColumnInfo columnInfo in defaultColInfoList.ColumnInfo)
+ // {
+ // if (columnInfo.AutoSize)
+ // {
+ // columnInfo.AutoSize = false;
+ // columnInfo.Width = columnInfo.MaxWidth;
+ // columnInfo.ColumnHeader.Width.SetAutoSizeWidth(columnInfo.MaxWidth);
+ // columnInfo.MaxWidth = 0;
+ // }
+ // }
+ // layoutInfo.ContextNode = null;
+ // LayoutTopLevelColumns(layoutInfo);
+ // layoutInfo.Top = defaultTop;
+ // area = ProcessTopLevelNodes(Rectangle.Empty, layoutInfo, topLevelNodes);
+ //}
+ }
+ finally
+ {
+ if (m_Tree.AntiAlias)
+ {
+ g.SmoothingMode = sm;
+ //g.TextRenderingHint = th;
+ }
+
+ if(this.DisposeGraphics)
+ g.Dispose();
+ }
+ if (layoutInfo.FullRowBackgroundNodes.Count > 0)
+ Tree.FullRowBackgroundNodes = layoutInfo.FullRowBackgroundNodes;
+ else
+ Tree.FullRowBackgroundNodes = null;
+
+ m_Width = area.Width;
+ m_Height = area.Height;
+ }
+
+ private void LayoutTopLevelColumns(NodeLayoutContextInfo layoutInfo)
+ {
+ // There are no columns in Tile view
+ this.Tree.SetColumnHeaderControlVisibility(false);
+ }
+
+ private Rectangle ProcessTopLevelNodes(Rectangle area, NodeLayoutContextInfo layoutInfo, Node[] topLevelNodes)
+ {
+ layoutInfo.CurrentLevelLeft = layoutInfo.Left;
+ bool isPreviousGroupNode = false;
+ foreach (Node childNode in topLevelNodes)
+ {
+ layoutInfo.ContextNode = childNode;
+ if (childNode.Visible)
+ {
+ if (_Groupping && childNode.HasChildNodes)
+ {
+ if (layoutInfo.CurrentLineHeight > 0)
+ layoutInfo.Top += layoutInfo.CurrentLineHeight + this.LayoutSettings.NodeVerticalSpacing;
+ layoutInfo.CurrentLineHeight = 0;
+ layoutInfo.Left = layoutInfo.CurrentLevelLeft;
+ isPreviousGroupNode = true;
+ }
+ else
+ {
+ if (isPreviousGroupNode)
+ {
+ if (layoutInfo.CurrentLineHeight > 0)
+ layoutInfo.Top += layoutInfo.CurrentLineHeight + this.LayoutSettings.NodeVerticalSpacing;
+ layoutInfo.CurrentLineHeight = 0;
+ layoutInfo.Left = layoutInfo.CurrentLevelLeft;
+ }
+ isPreviousGroupNode = false;
+ }
+ }
+
+ ProcessNode(layoutInfo);
+
+ if (childNode.Visible)
+ {
+ area = Rectangle.Union(area, childNode.BoundsRelative);
+ if (childNode.Expanded && childNode.HasChildNodes)
+ area = Rectangle.Union(area, childNode.ChildNodesBounds);
+ if (!(_Groupping && childNode.HasChildNodes))
+ layoutInfo.Left += childNode.BoundsRelative.Width + this.LayoutSettings.NodeHorizontalSpacing;
+ }
+ }
+ return area;
+ }
+
+ private Rectangle ProcessChildNodes(NodeLayoutContextInfo layoutInfo, Node node, int nodeVerticalSpacing, NodeColumnInfo childColumns)
+ {
+ Rectangle childNodesBounds = new Rectangle(layoutInfo.Left, layoutInfo.Top, 0, 0);
+ bool isPreviousGroupNode = false;
+
+ foreach (Node childNode in node.Nodes)
+ {
+ if (!childNode.Visible) continue;
+
+ if (_Groupping && childNode.HasChildNodes)
+ {
+ if (layoutInfo.CurrentLineHeight > 0)
+ layoutInfo.Top += layoutInfo.CurrentLineHeight + this.LayoutSettings.NodeVerticalSpacing;
+ layoutInfo.CurrentLineHeight = 0;
+ layoutInfo.Left = layoutInfo.CurrentLevelLeft;
+ isPreviousGroupNode = true;
+ }
+ else
+ {
+ if (isPreviousGroupNode)
+ {
+ if (layoutInfo.CurrentLineHeight > 0)
+ layoutInfo.Top += layoutInfo.CurrentLineHeight + this.LayoutSettings.NodeVerticalSpacing;
+ layoutInfo.CurrentLineHeight = 0;
+ layoutInfo.Left = layoutInfo.CurrentLevelLeft;
+ isPreviousGroupNode = false;
+ }
+ }
+
+ layoutInfo.ContextNode = childNode;
+ layoutInfo.ChildColumns = childColumns;
+ ProcessNode(layoutInfo);
+
+ if (!(_Groupping && childNode.HasChildNodes))
+ layoutInfo.Left += childNode.BoundsRelative.Width + this.LayoutSettings.NodeHorizontalSpacing;
+ if (isPreviousGroupNode)
+ {
+ childNodesBounds.Width = Math.Max(childNodesBounds.Width,
+ Math.Max(childNode.BoundsRelative.Width, (childNode.Expanded && childNode.ChildNodesBounds.Width > 0 ? childNode.ChildNodesBounds.Right - childNodesBounds.X : 0)));
+ childNodesBounds.Height += childNode.BoundsRelative.Height + (childNode.Expanded ? childNode.ChildNodesBounds.Height + childNode.ColumnHeaderHeight : 0) + nodeVerticalSpacing;
+ }
+ else
+ {
+ childNodesBounds = Rectangle.Union(childNodesBounds, childNode.BoundsRelative);
+ childNodesBounds.Height += nodeVerticalSpacing;
+ }
+ }
+ return childNodesBounds;
+ }
+
+
+ #region Node routines
+ private void ProcessNode(NodeLayoutContextInfo layoutInfo)
+ {
+ Node node=layoutInfo.ContextNode;
+ if (!node.Visible || node.Cells.Count == 0) return;
+
+ if (node.SizeChanged || _Groupping && node.HasChildNodes)
+ {
+ // Calculate size of the node itself...
+ LayoutNode(layoutInfo);
+ }
+ if (node.FullRowBackground)
+ layoutInfo.FullRowBackgroundNodes.Add(node);
+
+ // Position the node
+ if (_Groupping && node.HasChildNodes)
+ {
+ if (layoutInfo.CurrentLineHeight > 0)
+ layoutInfo.Top += layoutInfo.CurrentLineHeight + this.LayoutSettings.NodeVerticalSpacing;
+ layoutInfo.CurrentLineHeight = 0;
+ }
+ else
+ {
+ if (layoutInfo.Left + node.BoundsRelative.Width > this.ClientArea.Right)
+ {
+ layoutInfo.Left = layoutInfo.CurrentLevelLeft;
+ layoutInfo.Top += layoutInfo.CurrentLineHeight + this.LayoutSettings.NodeVerticalSpacing;
+ layoutInfo.CurrentLineHeight = 0;
+ }
+ }
+ layoutInfo.CurrentLineHeight = Math.Max(layoutInfo.CurrentLineHeight, node.BoundsRelative.Height);
+
+ if (node.BoundsRelative.X != layoutInfo.Left || node.BoundsRelative.Y != layoutInfo.Top)
+ {
+ // Adjust top position
+ node.SetBounds(new Rectangle(layoutInfo.Left,layoutInfo.Top,node.BoundsRelative.Width,node.BoundsRelative.Height));
+ }
+
+ // Position the node
+ if (_Groupping && node.HasChildNodes)
+ {
+ if (layoutInfo.CurrentLineHeight > 0)
+ layoutInfo.Top += layoutInfo.CurrentLineHeight + this.LayoutSettings.NodeVerticalSpacing;
+ layoutInfo.CurrentLineHeight = 0;
+ }
+
+ int nodeVerticalSpacing = this.LayoutSettings.NodeVerticalSpacing;
+ // Need to set the Top position properly
+ //layoutInfo.Top += (node.BoundsRelative.Height + nodeVerticalSpacing);
+ // No columns in tile view
+ //if (DevComponents.AdvTree.Display.NodeDisplay.HasColumnsVisible(node))
+ // layoutInfo.Top += node.ColumnHeaderHeight;
+
+ if(_Groupping && node.HasChildNodes && node.Expanded)
+ {
+ int originalLevelOffset=layoutInfo.Left;
+ int originalLevelLeft = layoutInfo.CurrentLevelLeft;
+ int childNodesTop = layoutInfo.Top;
+ layoutInfo.Left += this.NodeLevelOffset + node.NodesIndent;
+ layoutInfo.CurrentLevelLeft = layoutInfo.Left;
+ NodeColumnInfo parentColumns = layoutInfo.ChildColumns;
+ NodeColumnInfo childColumns = GetNodeColumnInfo(node);
+ Rectangle childNodesBounds = ProcessChildNodes(layoutInfo, node, nodeVerticalSpacing, childColumns);
+
+ //if (childColumns != null && childColumns.HasAutoSizeColumn)
+ //{
+ // foreach (ColumnInfo columnInfo in childColumns.ColumnInfo)
+ // {
+ // if (columnInfo.AutoSize)
+ // {
+ // columnInfo.Width = columnInfo.MaxWidth;
+ // columnInfo.ColumnHeader.Width.SetAutoSizeWidth(columnInfo.MaxWidth);
+ // columnInfo.AutoSize = false;
+ // columnInfo.MaxWidth = 0;
+ // }
+ // }
+ // layoutInfo.Top = originalTop;
+ // layoutInfo.Left = originalLevelOffset;
+ // layoutInfo.ContextNode = node;
+ // layoutInfo.ChildColumns = null;
+ // LayoutNode(layoutInfo);
+ // layoutInfo.Top = childNodesTop;
+ // layoutInfo.Left += this.NodeLevelOffset + node.NodesIndent;
+ // childNodesBounds = ProcessChildNodes(layoutInfo, node, nodeVerticalSpacing, childColumns);
+ //}
+
+ node.ChildNodesBounds = childNodesBounds;
+
+ layoutInfo.ChildColumns=parentColumns;
+
+ layoutInfo.ContextNode=node;
+ layoutInfo.Left=originalLevelOffset;
+ layoutInfo.CurrentLevelLeft = originalLevelLeft;
+ }
+ else
+ node.ChildNodesBounds = Rectangle.Empty;
+ }
+
+ ///
+ /// Gets whether the expand part of the node +/- is aligned to the left of the node in left-to-right layout.
+ ///
+ /// Node to get expand part alignment for
+ /// true if node expand part is aligned to the left in left-to-right layout.
+ private bool ExpandPartAlignedNear(Node node)
+ {
+ return true; // If changed LayoutExpandPart needs to be updated as well
+ }
+
+ ///
+ /// Returns column information for a given node.
+ ///
+ /// Node to return column information for
+ /// Returns array list of ColumnInfo objects or null if there are no columns defined.
+ protected override NodeColumnInfo GetNodeColumnInfo(Node node)
+ {
+ // No columns in tile-view
+ return null;
+ }
+
+ ///
+ /// Returns true if expand part space should be accounted for even if they expand part is not visible or need to be displayed. Default value is false.
+ ///
+ protected override bool ReserveExpandPartSpace
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// Returns true if given node has expand part.
+ ///
+ /// Layout context information.
+ ///
+ protected override bool HasExpandPart(NodeLayoutContextInfo layoutInfo)
+ {
+ Node node = layoutInfo.ContextNode;
+ if (node.ExpandVisibility == eNodeExpandVisibility.Auto)
+ {
+ if (!_Groupping || !NodeOperations.GetAnyVisibleNodes(node))
+ return false;
+ return true;
+ }
+ else
+ return (node.ExpandVisibility == eNodeExpandVisibility.Visible);
+ }
+
+
+ private bool _Groupping = true;
+ ///
+ /// Gets or sets whether parent/child node relationship is displayed as groups.
+ ///
+ public bool Groupping
+ {
+ get { return _Groupping; }
+ set
+ {
+ _Groupping = value;
+ }
+ }
+
+ private CellTileLayout _CellLayout = null;
+ ///
+ /// Returns class responsible for cell layout.
+ ///
+ /// Cell layout class.
+ protected internal override CellLayout GetCellLayout()
+ {
+ if (_CellLayout == null)
+ _CellLayout = new CellTileLayout(this.LayoutSettings);
+ return _CellLayout;
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeTreeLayout.cs b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeTreeLayout.cs
new file mode 100644
index 00000000..e800c105
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Layout/NodeTreeLayout.cs
@@ -0,0 +1,328 @@
+using System.Collections;
+using System.Drawing;
+using System.Windows.Forms;
+using System;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree.Layout
+{
+ ///
+ /// Performs classic TreeView layout.
+ ///
+ internal class NodeTreeLayout:NodeLayout
+ {
+ public NodeTreeLayout(AdvTree treeControl, Rectangle clientArea, LayoutSettings layoutSettings)
+ : base(treeControl, clientArea, layoutSettings)
+ {
+ }
+
+ public override void UpdateTopLevelColumnsWidth()
+ {
+ if (this.Tree.Columns.Count > 0)
+ {
+ Rectangle columnsBounds = DevComponents.DotNetBar.ElementStyleLayout.GetInnerRect(this.Tree.BackgroundStyle, this.Tree.ClientRectangle);
+ if (this.Tree.VScrollBar != null) columnsBounds.Width -= this.Tree.VScrollBar.Width;
+ columnsBounds.Height = this.Tree.Columns.Bounds.Height;
+ if(this.Tree.Columns.Bounds.Width 0)
+ Tree.FullRowBackgroundNodes = layoutInfo.FullRowBackgroundNodes;
+ else
+ Tree.FullRowBackgroundNodes = null;
+ //if (columnsVisible && layoutInfo.DefaultColumns != null && layoutInfo.DefaultColumns.Count > 0)
+ //{
+ // bool layoutColumns = false;
+ // for (int i = 0; i < layoutInfo.DefaultColumns.Count; i++)
+ // {
+ // ColumnInfo ci = (ColumnInfo)layoutInfo.DefaultColumns[i];
+ // if (ci.Width == 0 && ci.MaxWidth > 0)
+ // {
+ // ci.ColumnHeader.ContentWidth = ci.MaxWidth;
+ // layoutColumns = true;
+ // }
+ // }
+ // if (layoutColumns)
+ // {
+ // layoutInfo.ContextNode = null;
+ // layoutInfo.TreeColumns = this.Tree.Columns;
+ // Layout.ColumnHeaderLayout.LayoutColumnHeader(layoutInfo, ClientArea.X,
+ // ClientArea.Y, ClientArea.Width, this.GetCellLayout().CellHorizontalSpacing);
+ // }
+ //}
+
+ m_Width = area.Width;
+ m_Height = area.Height;
+ }
+
+ private void LayoutTopLevelColumns(NodeLayoutContextInfo layoutInfo)
+ {
+ // Layout tree columns
+ if (this.Tree.Columns.Count > 0)
+ {
+ Rectangle columnsBounds = m_ClientArea;// DevComponents.DotNetBar.ElementStyleLayout.GetInnerRect(this.Tree.BackgroundStyle, this.Tree.ClientRectangle);
+ //if (this.Tree.VScrollBar != null) columnsBounds.Width -= this.Tree.VScrollBar.Width;
+ layoutInfo.TreeColumns = this.Tree.Columns;
+ int columnHeight = Layout.ColumnHeaderLayout.LayoutColumnHeader(layoutInfo, 0,
+ 0, columnsBounds.Width, this.GetCellLayout().LayoutSettings.CellHorizontalSpacing);
+ columnHeight += this.LayoutSettings.NodeVerticalSpacing;
+ if (this.Tree.ColumnsVisible)
+ {
+ Rectangle headerBounds = layoutInfo.TreeColumns.Bounds;
+ if (headerBounds.Width > 0 && headerBounds.Width < columnsBounds.Width)
+ {
+ headerBounds.Width = columnsBounds.Width;
+ layoutInfo.TreeColumns.SetBounds(headerBounds);
+ }
+ layoutInfo.Top += columnHeight;
+ this.Tree.SetColumnHeaderControlVisibility(true);
+ }
+ else
+ this.Tree.SetColumnHeaderControlVisibility(false);
+ layoutInfo.TreeColumns = null;
+ }
+ else
+ this.Tree.SetColumnHeaderControlVisibility(false);
+ }
+
+ private Rectangle ProcessTopLevelNodes(Rectangle area, NodeLayoutContextInfo layoutInfo, Node[] topLevelNodes)
+ {
+ foreach (Node childNode in topLevelNodes)
+ {
+ layoutInfo.ContextNode = childNode;
+ ProcessNode(layoutInfo);
+ if (childNode.Visible)
+ {
+ area = Rectangle.Union(area, childNode.BoundsRelative);
+ if (childNode.Expanded)
+ area = Rectangle.Union(area, childNode.ChildNodesBounds);
+ }
+ }
+ return area;
+ }
+
+ #region Node routines
+ private void ProcessNode(NodeLayoutContextInfo layoutInfo)
+ {
+ Node node=layoutInfo.ContextNode;
+ if (!node.Visible) return;
+
+ int originalTop = layoutInfo.Top;
+
+ if (node.SizeChanged || node.HasColumns || layoutInfo.DefaultColumns!=null && layoutInfo.DefaultColumns.HasAutoSizeColumn || layoutInfo.ChildColumns!=null && layoutInfo.ChildColumns.HasAutoSizeColumn)
+ {
+ // Calculate size of the node itself...
+ LayoutNode(layoutInfo);
+ }
+ if (node.FullRowBackground)
+ layoutInfo.FullRowBackgroundNodes.Add(node);
+
+ if (node.BoundsRelative.X != layoutInfo.Left || node.BoundsRelative.Y != layoutInfo.Top)
+ {
+ // Adjust top position
+ node.SetBounds(new Rectangle(layoutInfo.Left,layoutInfo.Top,node.BoundsRelative.Width,node.BoundsRelative.Height));
+ //foreach(Cell c in node.Cells)
+ // c.SetBounds(new Rectangle(c.BoundsRelative.X + layoutInfo.Left, c.BoundsRelative.Y+layoutInfo.Top, c.BoundsRelative.Width, c.BoundsRelative.Height));
+ }
+
+ int nodeVerticalSpacing = this.LayoutSettings.NodeVerticalSpacing;
+ // Need to set the Top position properly
+ layoutInfo.Top += (node.BoundsRelative.Height + nodeVerticalSpacing);
+ if (DevComponents.AdvTree.Display.NodeDisplay.HasColumnsVisible(node))
+ layoutInfo.Top += node.ColumnHeaderHeight;
+
+ if(node.Expanded)
+ {
+ int originalLevelOffset=layoutInfo.Left;
+ int childNodesTop = layoutInfo.Top;
+ layoutInfo.Left += this.NodeLevelOffset + node.NodesIndent;
+ NodeColumnInfo parentColumns = layoutInfo.ChildColumns;
+ NodeColumnInfo childColumns = GetNodeColumnInfo(node);
+ Rectangle childNodesBounds = ProcessChildNodes(layoutInfo, node, nodeVerticalSpacing, childColumns);
+
+ if (childColumns != null && childColumns.HasAutoSizeColumn)
+ {
+ bool hasMinColumnAutoSizeWidth = false;
+ foreach (ColumnInfo columnInfo in childColumns.ColumnInfo)
+ {
+ if (columnInfo.AutoSize)
+ {
+ columnInfo.Width = columnInfo.MaxWidth;
+ columnInfo.ColumnHeader.Width.SetAutoSizeWidth(columnInfo.MaxWidth);
+ columnInfo.AutoSize = false;
+ columnInfo.MaxWidth = 0;
+ if (columnInfo.ColumnHeader.Width.AutoSizeMinHeader)
+ hasMinColumnAutoSizeWidth = true;
+ }
+ }
+ layoutInfo.Top = originalTop;
+ layoutInfo.Left = originalLevelOffset;
+ layoutInfo.ContextNode = node;
+ layoutInfo.ChildColumns = parentColumns;
+ LayoutNode(layoutInfo);
+ layoutInfo.Top = childNodesTop;
+ layoutInfo.Left += this.NodeLevelOffset + node.NodesIndent;
+
+ // Adjust the of auto sized columns in case minimum header width is used
+ if (hasMinColumnAutoSizeWidth)
+ {
+ foreach (ColumnInfo columnInfo in childColumns.ColumnInfo)
+ {
+ if (columnInfo.ColumnHeader.Width.AutoSize && columnInfo.ColumnHeader.Width.AutoSizeMinHeader)
+ {
+ columnInfo.Width = columnInfo.ColumnHeader.Bounds.Width;
+ }
+ }
+ }
+
+ childNodesBounds = ProcessChildNodes(layoutInfo, node, nodeVerticalSpacing, childColumns);
+ }
+
+ node.ChildNodesBounds = childNodesBounds;
+
+ layoutInfo.ChildColumns=parentColumns;
+
+ layoutInfo.ContextNode=node;
+ layoutInfo.Left=originalLevelOffset;
+ }
+ }
+
+ private Rectangle ProcessChildNodes(NodeLayoutContextInfo layoutInfo, Node node, int nodeVerticalSpacing, NodeColumnInfo childColumns)
+ {
+ Rectangle childNodesBounds = new Rectangle(layoutInfo.Left, layoutInfo.Top, 0, 0);
+
+ foreach (Node childNode in node.Nodes)
+ {
+ if (!childNode.Visible) continue;
+ layoutInfo.ContextNode = childNode;
+ layoutInfo.ChildColumns = childColumns;
+ ProcessNode(layoutInfo);
+ childNodesBounds.Width = Math.Max(childNodesBounds.Width,
+ Math.Max(childNode.BoundsRelative.Width, (childNode.Expanded && childNode.ChildNodesBounds.Width > 0 ? childNode.ChildNodesBounds.Right - childNodesBounds.X : 0)));
+ childNodesBounds.Height += childNode.BoundsRelative.Height + (childNode.Expanded ? childNode.ChildNodesBounds.Height + childNode.ColumnHeaderHeight : 0) + nodeVerticalSpacing;
+ }
+ return childNodesBounds;
+ }
+
+ ///
+ /// Returns true if expand part space should be accounted for even if they expand part is not visible or need to be displayed. Default value is false.
+ ///
+ protected override bool ReserveExpandPartSpace
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ ///
+ /// Gets whether the expand part of the node +/- is aligned to the left of the node in left-to-right layout.
+ ///
+ /// Node to get expand part alignment for
+ /// true if node expand part is aligned to the left in left-to-right layout.
+ private bool ExpandPartAlignedNear(Node node)
+ {
+ return true; // If changed LayoutExpandPart needs to be updated as well
+ }
+
+// private NodeCollection GetTopLevelNodes()
+// {
+// return m_Tree.Nodes;
+// }
+
+
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Node.cs b/PROMS/DotNetBar Source Code/AdvTree/Node.cs
new file mode 100644
index 00000000..363daf9a
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Node.cs
@@ -0,0 +1,3227 @@
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Windows.Forms;
+using DevComponents.AdvTree.Display;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents the Node in Tree control.
+ ///
+ [DesignTimeVisible(false), ToolboxItem(false), Designer("DevComponents.AdvTree.Design.NodeDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class Node : Component, IComparable
+ {
+ #region Events
+ ///
+ /// Occurs when the mouse pointer is over the node and a mouse button is pressed.
+ ///
+ public event MouseEventHandler NodeMouseDown;
+
+ ///
+ /// Occurs when the mouse pointer is over the node and a mouse button is released.
+ ///
+ public event MouseEventHandler NodeMouseUp;
+
+ ///
+ /// Occurs when the mouse pointer is moved over the node.
+ ///
+ public event MouseEventHandler NodeMouseMove;
+
+ ///
+ /// Occurs when the mouse enters the node.
+ ///
+ public event EventHandler NodeMouseEnter;
+
+ ///
+ /// Occurs when the mouse leaves the node.
+ ///
+ public event EventHandler NodeMouseLeave;
+
+ ///
+ /// Occurs when the mouse hovers over the node.
+ ///
+ public event EventHandler NodeMouseHover;
+
+ ///
+ /// Occurs when the node is clicked with left mouse button. If you need to know more information like if another mouse button is clicked etc. use
+ /// NodeMouseDown event.
+ ///
+ public event EventHandler NodeClick;
+
+ ///
+ /// Occurs when the node is double-clicked.
+ ///
+ public event EventHandler NodeDoubleClick;
+
+ ///
+ /// Occurs when hyperlink in text-markup is clicked.
+ ///
+ public event MarkupLinkClickEventHandler MarkupLinkClick;
+ #endregion
+
+ #region Private Variables
+ private Rectangle m_BoundsRelative = Rectangle.Empty;
+ private Rectangle m_ChildNodesBounds = Rectangle.Empty;
+ private Rectangle m_CellsBounds = Rectangle.Empty;
+ private Rectangle m_ContentBounds = Rectangle.Empty;
+ private Rectangle m_CommandBoundsRelative = Rectangle.Empty;
+ private NodeCollection m_Nodes = null;
+ //private LinkedNodesCollection m_LinkedNodes=null;
+ private CellCollection m_Cells = new CellCollection();
+ //private string m_Header="";
+ private ColumnHeaderCollection m_NodesColumns;
+ //private bool m_NodesColumnHeaderVisible=true;
+ private object m_Tag = null;
+ private object m_DataKey = null;
+ private string m_Text = "";
+ private bool m_Expanded = false;
+ private eNodeExpandVisibility m_ExpandVisibility = eNodeExpandVisibility.Auto;
+ private Rectangle m_ExpandPartRectangle = Rectangle.Empty;
+ private Node m_Parent = null;
+
+ private ElementStyle m_StyleExpanded = null;
+ private ElementStyle m_StyleSelected = null;
+ private ElementStyle m_StyleMouseOver = null;
+ private bool m_SizeChanged = true;
+ //private eNodeHeaderVisibility m_HeaderVisibility=eNodeHeaderVisibility.Automatic;
+ private int m_ColumnHeaderHeight = 0;
+ private eMapPosition m_MapSubRootPosition = eMapPosition.Default;
+ private int m_Offset = 0;
+ internal AdvTree internalTreeControl = null;
+ private ElementStyle m_Style = null;
+ private eMouseOverNodePart m_MouseOverNodePart = eMouseOverNodePart.None;
+ private NodeConnector m_ParentConnector = null;
+ private eCellLayout m_CellLayout = eCellLayout.Default;
+ private bool m_Visible = true;
+ private bool m_CommandButton = false;
+ private bool m_Editing = false;
+ private bool m_DragDropEnabled = true;
+ private string m_Name = "";
+ private ConnectorPointsCollection m_ParentConnectorPoints = null;
+ private bool m_SelectedConnectorMarker = false;
+ private eNodeRenderMode m_RenderMode = eNodeRenderMode.Default;
+ private TreeRenderer m_NodeRenderer = null;
+ private object m_ContextMenu = null;
+ #endregion
+
+ #region Constructor
+ /// Default Constructor.
+ public Node()
+ {
+ m_Cells.SetParentNode(this);
+ m_ParentConnectorPoints = new ConnectorPointsCollection();
+ m_ParentConnectorPoints.SetParentNode(this);
+
+ Cell defaultCell = new Cell();
+ this.Cells.Add(defaultCell);
+ }
+ ///
+ /// Creates node and initializes its text.
+ ///
+ public Node(string text)
+ : this()
+ {
+ this.Text = text;
+ }
+
+ ///
+ /// Creates node and initializes its text and Style property.
+ ///
+ public Node(string text, ElementStyle nodeStyle)
+ : this()
+ {
+ this.Text = text;
+ this.Style = nodeStyle;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (m_Nodes != null)
+ {
+ Node[] nodes = new Node[m_Nodes.Count];
+ m_Nodes.CopyTo(nodes);
+ foreach (Node node in nodes)
+ node.Dispose();
+ //m_Nodes.Clear();
+ }
+ foreach (Cell cell in this.Cells)
+ {
+ cell.Dispose();
+ }
+ //this.Cells.Clear();
+
+ if (m_Style != null)
+ m_Style.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (m_StyleSelected != null)
+ m_StyleSelected.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (m_StyleExpanded != null)
+ m_StyleExpanded.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (m_StyleMouseOver != null)
+ m_StyleMouseOver.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (m_ParentConnector != null)
+ m_ParentConnector.AppearanceChanged -= new EventHandler(this.ConnectorAppearanceChanged);
+
+ }
+ base.Dispose(disposing);
+ }
+ #endregion
+
+ #region Properties
+ ///
+ /// Gets whether node has child nodes.
+ ///
+ [Browsable(false)]
+ public bool HasChildNodes
+ {
+ get { return m_Nodes != null && m_Nodes.Count > 0; }
+ }
+
+ ///
+ /// Gets or sets the context menu assigned to this node. Standard Context Menus, VS.NET 2005 Context Menus and DotNetBar Suite context menus are supported.
+ /// Default value is null (Nothing) which indicates that no context menu is assigned.
+ ///
+ [Browsable(true), DefaultValue(null), Description("Indicates the context menu assigned to this node."), Editor("DevComponents.AdvTree.Design.NodeContextMenuTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ public object ContextMenu
+ {
+ get { return m_ContextMenu; }
+ set { m_ContextMenu = value; }
+ }
+
+ ///
+ /// Gets whether any of the cells inside the node has HostedControl property set.
+ ///
+ [Browsable(false)]
+ public bool HasHostedControls
+ {
+ get
+ {
+ foreach (Cell cell in m_Cells)
+ {
+ if (cell.HostedControl != null)
+ return true;
+ }
+ return false;
+ }
+ }
+ ///
+ /// Gets or sets custom node renderer. You can set this property to your custom renderer. When set the RenderMode should be set to custom to enable
+ /// your custom renderer. To choose one of the system renderer use RenderMode property. Default value is null.
+ ///
+ [Browsable(false), Category("Style"), DefaultValue(null), Description("Indicates render mode used to render the node.")]
+ internal TreeRenderer NodeRenderer
+ {
+ get { return m_NodeRenderer; }
+ set
+ {
+ m_NodeRenderer = value;
+ OnDisplayChanged();
+ }
+ }
+ ///
+ /// Gets or sets the render mode used to render the node. Default value is eNodeRenderMode.Default which indicates that system default renderer is used.
+ /// Note that if you specify custom renderer you need to set either AdvTree.NodeRenderer or Node.NodeRenderer property.
+ ///
+ [Browsable(true), Category("Style"), DefaultValue(eNodeRenderMode.Default), Description("Indicates render mode used to render the node.")]
+ internal eNodeRenderMode RenderMode
+ {
+ get { return m_RenderMode; }
+ set
+ {
+ m_RenderMode = value;
+ OnDisplayChanged();
+ }
+ }
+ ///
+ /// Gets or sets whether node is expanded. Expanded node shows it's child nodes.
+ ///
+ [Browsable(true), Category("Node State"), DefaultValue(false), Description("Indicates whether node is expanded."), DevCoSerialize()]
+ public bool Expanded
+ {
+ get { return m_Expanded; }
+ set
+ {
+ if (value)
+ this.Expand();
+ else
+ this.Collapse();
+ }
+ }
+ ///
+ /// Returns name of the node that can be used to identify it from the code.
+ ///
+ [Browsable(false), Category("Design"), Description("Indicates the name used to identify node."), DevCoSerialize()]
+ public string Name
+ {
+ get
+ {
+ if (this.Site != null)
+ m_Name = this.Site.Name;
+ return m_Name;
+ }
+ set
+ {
+ if (this.Site != null)
+ this.Site.Name = value;
+ if (value == null)
+ m_Name = "";
+ else
+ m_Name = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether node can be dragged and dropped. Default value is true.
+ ///
+ [Browsable(true), Category("Behavior"), Description("Indicates whether node can be dragged and dropped."), DefaultValue(true), DevCoSerialize()]
+ public bool DragDropEnabled
+ {
+ get { return m_DragDropEnabled; }
+ set { m_DragDropEnabled = value; }
+ }
+
+ ///
+ /// Gets or sets visibility of the expand button. Default value is Auto meaning that
+ /// expand button is displayed only if node has at least one child node.
+ ///
+ ///
+ /// You can use this property for example to dynamically load the child nodes when user
+ /// tries to expand the node. You could for example handle BeforeExpand event to load child
+ /// nodes into the node.
+ ///
+ [Category("Appearance"), Browsable(true), DefaultValue(eNodeExpandVisibility.Auto), Description("Indicates whether the expand button is always visible regardless of whether node contains child nodes or not."), DevCoSerialize()]
+ public eNodeExpandVisibility ExpandVisibility
+ {
+ get { return m_ExpandVisibility; }
+ set
+ {
+ m_ExpandVisibility = value;
+ this.SizeChanged = true;
+ }
+ }
+
+ ///
+ /// Gets or sets whether any operation on the node has been performed that would affect node's size. Size changed flag
+ /// internally indicates that node's size needs to be recalculated because it has changed
+ /// due to the changes in data.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool SizeChanged
+ {
+ get { return m_SizeChanged; }
+ set
+ {
+ m_SizeChanged = value;
+ OnSizeChanged();
+ }
+ }
+
+ ///
+ /// Gets the relative bounds of the tree node including the expand part of the node.
+ ///
+ [Browsable(false)]
+ internal Rectangle BoundsRelative
+ {
+ get
+ {
+ return m_BoundsRelative;
+ }
+ }
+
+ ///
+ /// Gets the absolute bounds of the tree node including the expand part of the node.
+ ///
+ [Browsable(false)]
+ public Rectangle Bounds
+ {
+ get
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ return NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, this, tree.NodeDisplay.Offset);
+ }
+ return Rectangle.Empty;
+ }
+ }
+
+ ///
+ /// Sets the bounds of the node.
+ ///
+ /// New location and size of the node.
+ internal void SetBounds(Rectangle r)
+ {
+ m_BoundsRelative = r;
+ }
+
+ ///
+ /// Sets the content bounds of the node. Content bound is bound for the the cells inside the node
+ /// and it excludes the expand rectangle. Bounds also include the node style padding and
+ /// reflect node margin.
+ ///
+ /// New location and size of the node.
+ internal void SetContentBounds(Rectangle r)
+ {
+ m_ContentBounds = r;
+ }
+
+ ///
+ /// Gets the node content bounds.
+ ///
+ internal Rectangle ContentBounds
+ {
+ get { return m_ContentBounds; }
+ }
+
+ ///
+ /// Gets the bounds for all the cells inside the node. The bounds do not include the expand part.
+ ///
+ [Browsable(false)]
+ internal Rectangle CellsBoundsRelative
+ {
+ get { return m_CellsBounds; }
+ }
+
+ ///
+ /// Gets the bounds for all the cells inside the node. The bounds do not include the expand part.
+ ///
+ [Browsable(false)]
+ public Rectangle CellsBounds
+ {
+ get
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ return NodeDisplay.GetNodeRectangle(eNodeRectanglePart.CellsBounds, this, tree.NodeDisplay.Offset);
+ }
+ return Rectangle.Empty;
+ }
+ }
+
+ ///
+ /// Sets cell bounds.
+ ///
+ /// New cells bounds.
+ internal void SetCellsBounds(Rectangle r)
+ {
+ m_CellsBounds = r;
+ }
+
+ ///
+ /// Sets node parent.
+ ///
+ /// Parent node object.
+ internal void SetParent(Node parent)
+ {
+ if (parent == null)
+ {
+ RemoveHostedControls(true);
+ }
+ if (m_Parent != parent)
+ {
+ m_Parent = parent;
+ foreach (Cell cell in m_Cells)
+ {
+ if (cell.HostedControl != null)
+ cell.AddHostedControlToTree();
+ }
+ OnParentChanged();
+ }
+ }
+
+ internal void InvokeOnParentChanged()
+ {
+ OnParentChanged();
+ }
+
+ ///
+ /// Called when Parent of the node has changed.
+ ///
+ protected virtual void OnParentChanged()
+ {
+ }
+
+ internal void RemoveHostedControls(bool enumChildren)
+ {
+ foreach (Cell cell in m_Cells)
+ {
+ if (cell.HostedControl != null && cell.HostedControl.Parent is AdvTree)
+ cell.RemoveHostedControlFromTree();
+ }
+ if (!enumChildren || m_Nodes == null) return;
+ foreach (Node item in m_Nodes)
+ {
+ item.RemoveHostedControls(true);
+ }
+ }
+
+ ///
+ /// Gets or sets the bounds of child nodes.
+ ///
+ internal Rectangle ChildNodesBounds
+ {
+ get { return m_ChildNodesBounds; }
+ set { m_ChildNodesBounds = value; }
+ }
+
+ ///
+ /// Gets the expand part rectangle. Expand part is used to expand/collapse node.
+ ///
+ [Browsable(false)]
+ internal Rectangle ExpandPartRectangleRelative
+ {
+ get { return m_ExpandPartRectangle; }
+ }
+
+ ///
+ /// Gets the expand part rectangle. Expand part is used to expand/collapse node.
+ ///
+ [Browsable(false)]
+ public Rectangle ExpandPartRectangle
+ {
+ get
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ return NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandBounds, this, tree.NodeDisplay.Offset);
+ }
+ return Rectangle.Empty;
+ }
+ }
+
+ ///
+ /// Sets the bounds of the expand part.
+ ///
+ /// New part bounds.
+ internal void SetExpandPartRectangle(Rectangle r)
+ {
+ m_ExpandPartRectangle = r;
+ }
+
+ private eVerticalAlign _ExpandPartVerticalAlignment = eVerticalAlign.Middle;
+ ///
+ /// Indicates vertical alignment within the node bounds of expand part of the node, if one is visible.
+ ///
+ [DefaultValue(eVerticalAlign.Middle), Category("Appearance"), Description("Indicates vertical alignment within the node bounds of expand part of the node, if one is visible.")]
+ public eVerticalAlign ExpandPartVerticalAlignment
+ {
+ get { return _ExpandPartVerticalAlignment; }
+ set
+ {
+ if (_ExpandPartVerticalAlignment != value)
+ {
+ _ExpandPartVerticalAlignment = value;
+ InvalidateLayout();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the Command part bounds if command part is visible.
+ ///
+ [Browsable(false)]
+ internal Rectangle CommandBounds
+ {
+ get
+ {
+ if (!m_CommandBoundsRelative.IsEmpty)
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ return NodeDisplay.GetNodeRectangle(eNodeRectanglePart.CommandBounds, this, tree.NodeDisplay.Offset);
+ }
+ }
+ return Rectangle.Empty;
+ }
+ }
+
+ internal Rectangle CommandBoundsRelative
+ {
+ get { return m_CommandBoundsRelative; }
+ set { m_CommandBoundsRelative = value; }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the tree node is in a checked state.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance"), Description("Indicates whether the tree node is in a checked state."), DevCoSerialize()]
+ public bool Checked
+ {
+ get
+ {
+ return m_Cells[0].Checked;
+ }
+ set
+ {
+ m_Cells[0].Checked = value;
+ }
+ }
+
+ ///
+ /// Sets the Checked or CheckState properties.
+ ///
+ /// New value for checked state.
+ /// Action source.
+ public void SetChecked(bool value, eTreeAction actionSource)
+ {
+ SetChecked(value ? CheckState.Checked : CheckState.Unchecked, actionSource);
+ }
+
+ ///
+ /// Sets the Checked or CheckState properties.
+ ///
+ /// New value for checked state.
+ /// Action source.
+ public void SetChecked(CheckState value, eTreeAction actionSource)
+ {
+ m_Cells[0].SetChecked(value, actionSource);
+ }
+
+ ///
+ /// Gets or sets the checkbox alignment in relation to the text displayed by first default cell.
+ ///
+ [Browsable(true), Category("Check-box Properties"), DefaultValue(eCellPartAlignment.Default), Description("Indicates checkbox alignment in relation to the text displayed by cell."), DevCoSerialize()]
+ public eCellPartAlignment CheckBoxAlignment
+ {
+ get
+ {
+ return m_Cells[0].CheckBoxAlignment;
+ }
+ set
+ {
+ m_Cells[0].CheckBoxAlignment = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether check box is visible inside the cell.
+ ///
+ [Browsable(true), Category("Check-box Properties"), DefaultValue(false), Description("Indicates whether check box is visible inside the cell."), DevCoSerialize()]
+ public bool CheckBoxVisible
+ {
+ get
+ {
+ return m_Cells[0].CheckBoxVisible;
+ }
+ set
+ {
+ m_Cells[0].CheckBoxVisible = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the appearance style of the item. Default value is CheckBox. Item can also assume the style of radio-button.
+ ///
+ [Browsable(true), DefaultValue(eCheckBoxStyle.CheckBox), Category("Check-box Properties"), Description("Indicates appearance style of the item. Default value is CheckBox. Item can also assume the style of radio-button.")]
+ public eCheckBoxStyle CheckBoxStyle
+ {
+ get { return m_Cells[0].CheckBoxStyle; }
+ set
+ {
+ m_Cells[0].CheckBoxStyle = value;
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the CheckBox will allow three check states rather than two. If the ThreeState property is set to true
+ /// CheckState property should be used instead of Checked property to set the extended state of the control.
+ ///
+ [Browsable(true), Category("Check-box Properties"), DefaultValue(false), Description("Indicates whether the CheckBox will allow three check states rather than two.")]
+ public bool CheckBoxThreeState
+ {
+ get { return m_Cells[0].CheckBoxThreeState; }
+ set { m_Cells[0].CheckBoxThreeState = value; }
+ }
+
+ ///
+ /// Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state.
+ ///
+ [Browsable(true), Category("Check-box Properties"), DefaultValue(CheckState.Unchecked), RefreshProperties(RefreshProperties.All), Description("Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state")]
+ public CheckState CheckState
+ {
+ get { return m_Cells[0].CheckState; }
+ set
+ {
+ m_Cells[0].CheckState = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether first cell content is editable when cell editing is enabled on tree control. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether first cell content is editable when cell editing is enabled on tree control.")]
+ public bool Editable
+ {
+ get { return m_Cells[0].Editable; }
+ set
+ {
+ m_Cells[0].Editable = value;
+ }
+ }
+
+ ///
+ /// Gets the path from the root tree node to the current tree node. The path consists of the labels of all the tree nodes that must be navigated to get to this tree node, starting at the root tree node. The node labels are separated by the delimiter character specified in the PathSeparator property of the Tree control that contains this node.
+ ///
+ [Browsable(false)]
+ public string FullPath
+ {
+ get
+ {
+ if (this.TreeControl == null)
+ return "";
+ return NodeOperations.GetFullPath(this, this.TreeControl.PathSeparator);
+ }
+ }
+
+ ///
+ /// Gets the zero based index of position of the tree node in the tree node collection. -1 is returned if node is not parented. If node is root node
+ /// the index of node in AdvTree.Nodes collection is returned.
+ ///
+ [Browsable(false)]
+ public int Index
+ {
+ get
+ {
+ return NodeOperations.GetNodeIndex(this);
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether the tree node is in an editable state. true if the tree node is in editable state; otherwise, false.
+ ///
+ [Browsable(false)]
+ public bool IsEditing
+ {
+ get { return m_Editing; }
+ }
+ ///
+ /// Sets whether node is in edit mode or not.
+ ///
+ /// True indicating that node is in edit mode false otherwise.
+ internal void SetEditing(bool b)
+ {
+ m_Editing = b;
+ }
+
+ ///
+ /// Gets whether left mouse button is pressed on any cell contained by this node.
+ ///
+ [Browsable(false)]
+ public bool IsMouseDown
+ {
+ get
+ {
+ foreach (Cell cell in this.Cells)
+ {
+ if (cell.IsMouseDown)
+ return true;
+ }
+ return false;
+ }
+ }
+
+ ///
+ /// Gets whether mouse cursor is over on any cell contained by this node.
+ ///
+ [Browsable(false)]
+ public bool IsMouseOver
+ {
+ get
+ {
+ foreach (Cell cell in this.Cells)
+ {
+ if (cell.IsMouseOver)
+ return true;
+ }
+ return false;
+ }
+ }
+
+ private bool _IsSelected = false;
+ ///
+ /// Gets a value indicating whether the tree node is in the selected state. true if the tree node is in the selected state; otherwise, false.
+ ///
+ [Browsable(false)]
+ public bool IsSelected
+ {
+ get
+ {
+ return _IsSelected;
+ //AdvTree tree=this.TreeControl;
+ //if(tree!=null)
+ //{
+ // if (tree.MultiSelect)
+ // {
+ // return tree.SelectedNodes.Contains(this);
+ // }
+ // else if(tree.SelectedNode==this)
+ // return true;
+ //}
+ //return false;
+ }
+ internal set
+ {
+ _IsSelected = value;
+ }
+ }
+
+ private bool _Selectable = true;
+ ///
+ /// Gets or sets whether node can be selected by user by clicking it with the mouse or using keyboard. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether node can be selected by user by clicking it with the mouse or using keyboard.")]
+ public bool Selectable
+ {
+ get { return _Selectable; }
+ set
+ {
+ _Selectable = value;
+ }
+ }
+
+ ///
+ /// Gets whether node can be selected. Node must be Visible, Enabled and Selectable in order for it to be selected.
+ ///
+ [Browsable(false)]
+ public bool CanSelect
+ {
+ get
+ {
+ return this.Enabled & this.Visible & this.Selectable;
+ }
+ }
+
+ ///
+ /// Sets selected cell and provides information on the action that caused the selection change.
+ ///
+ /// New selected cell.
+ /// Action source.
+ public void SetSelectedCell(Cell value, eTreeAction actionSource)
+ {
+ AdvTree tree = this.TreeControl;
+
+ if (!this.IsSelected && value != null)
+ {
+ if (tree != null)
+ tree.SelectedNode = this;
+ }
+
+ Cell previousSelectedCell = null;
+ Cell selectedCell = null;
+
+ foreach (Cell cell in m_Cells)
+ {
+ if (cell.IsSelected) previousSelectedCell = cell;
+ if (cell == value && cell.CanSelect)
+ {
+ selectedCell = cell;
+ cell.SetSelected(true, actionSource);
+ }
+ else
+ cell.SetSelected(false, actionSource);
+ }
+
+ if (tree != null)
+ {
+ tree.InvalidateNode(this);
+ if (value == null || previousSelectedCell != null && value != previousSelectedCell)
+ {
+ tree.InvokeCellUnselected(new AdvTreeCellEventArgs(actionSource, previousSelectedCell));
+ }
+
+ if (selectedCell != null && previousSelectedCell != selectedCell)
+ {
+ tree.InvokeCellSelected(new AdvTreeCellEventArgs(actionSource, selectedCell));
+ }
+ }
+ }
+ ///
+ /// Gets or sets a cell that is in selected state otherwise it returns null.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Cell SelectedCell
+ {
+ get
+ {
+ if (this.IsSelected)
+ {
+ return GetSelectedCell();
+ }
+ return null;
+ }
+ set
+ {
+ SetSelectedCell(value, eTreeAction.Code);
+ }
+ }
+
+ internal Cell GetSelectedCell()
+ {
+ foreach (Cell cell in m_Cells)
+ if (cell.IsSelected)
+ return cell;
+ return null;
+ }
+ internal void SelectFirstCell(eTreeAction actionSource)
+ {
+ foreach (Cell cell in m_Cells)
+ {
+ if (cell.CanSelect)
+ {
+ this.SetSelectedCell(cell, actionSource);
+ //cell.SetSelected(true);
+ break;
+ }
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether the tree node is visible. Node is considered to be visible when it's Visible property is set to true and path to the node is available i.e. all parent nodes are expanded.
+ ///
+ [Browsable(false)]
+ public bool IsVisible
+ {
+ get
+ {
+ return NodeOperations.GetIsNodeVisible(this);
+ }
+ }
+
+ ///
+ /// Returns whether node is displayed on the screen and visible to the user. When node is outside of the viewable area this property will return false. It will also return false if node is not visible.
+ ///
+ [Browsable(false)]
+ public bool IsDisplayed
+ {
+ get { return NodeOperations.GetIsNodeDisplayed(this); }
+ }
+
+ ///
+ /// Gets the last child tree node. The LastNode is the last child Node in the NodeCollection stored in the Nodes property of the current tree node. If the Node has no child tree node, the LastNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ [Browsable(false)]
+ public Node LastNode
+ {
+ get
+ {
+ return NodeOperations.GetLastNode(this);
+ }
+ }
+
+ ///
+ /// Gets the next sibling tree node. The NextNode is the next sibling Node in the NodeCollection stored in the Nodes property of the tree node's parent Node. If there is no next tree node, the NextNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ [Browsable(false)]
+ public Node NextNode
+ {
+ get
+ {
+ return NodeOperations.GetNextNode(this);
+ }
+ }
+
+ ///
+ /// Gets the next visible tree node. The NextVisibleNode can be a child, sibling, or a tree node from another branch. If there is no next tree node, the NextVisibleNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ [Browsable(false)]
+ public Node NextVisibleNode
+ {
+ get
+ {
+ return NodeOperations.GetNextVisibleNode(this);
+ }
+ }
+
+ ///
+ /// Gets the zero-based depth of the tree node in the tree control. The root node is considered the first level of nesting and returns 0.
+ ///
+ [Browsable(false)]
+ public int Level
+ {
+ get
+ {
+ int i = 0;
+ Node parent = this.Parent;
+ while (parent != null)
+ {
+ i++;
+ parent = parent.Parent;
+ }
+ return i;
+ }
+ }
+
+
+ ///
+ /// Gets the collection of Node objects assigned to the current tree node. The Nodes property can hold a collection of other Node objects. Each of the tree node in the collection has a Nodes property that can contain its own NodeCollection. Nesting of tree nodes can make it difficult to navigate a tree structure. The FullPath property makes it easier to determine your location in a tree.
+ ///
+ [Browsable(true), Category("Nodes"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public NodeCollection Nodes
+ {
+ get
+ {
+ if (m_Nodes == null)
+ {
+ m_Nodes = new NodeCollection();
+ m_Nodes.SetParentNode(this);
+ }
+ return m_Nodes;
+ }
+ }
+
+ /////
+ ///// Gets the collection of LinkedNode objects that describe nodes linked to this node.
+ /////
+ /////
+ ///// Linked nodes are nodes that are related to given node but do not have strict
+ ///// parent child relationship with the node. Each linked node must be already added as
+ ///// child node to some other node or it will not be displayed. Linked nodes are used in Map
+ ///// and Diagram layout styles to display relationships between nodes.
+ /////
+ //[Browsable(true),Category("Nodes"), Description("Collection of LinkedNode objects that describe nodes linked to this node")]
+ //public LinkedNodesCollection LinkedNodes
+ //{
+ // get
+ // {
+ // if(m_LinkedNodes==null)
+ // {
+ // m_LinkedNodes=new LinkedNodesCollection();
+ // }
+ // return m_LinkedNodes;
+ // }
+ //}
+
+ /////
+ ///// Gets whether Node has any linked nodes.
+ /////
+ //[Browsable(false)]
+ //public bool HasLinkedNodes
+ //{
+ // get {return (m_LinkedNodes!=null && m_LinkedNodes.Count>0);}
+ //}
+
+ ///
+ /// Gets whether there is at least one child node that has its Visible property set to true.
+ ///
+ [Browsable(false)]
+ public bool AnyVisibleNodes
+ {
+ get
+ {
+ return NodeOperations.GetAnyVisibleNodes(this);
+ }
+ }
+
+ ///
+ /// Gets the parent tree node of the current tree node. If the tree node is at the root level, the Parent property returns a null reference (Nothing in Visual Basic).
+ ///
+ [Browsable(false)]
+ public Node Parent
+ {
+ get
+ {
+ return m_Parent;
+ }
+ }
+
+ ///
+ /// Gets the previous sibling tree node. The PrevNode is the previous sibling Node in the NodeCollection stored in the Nodes property of the tree node's parent Node. If there is no previous tree node, the PrevNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ [Browsable(false)]
+ public Node PrevNode
+ {
+ get
+ {
+ return NodeOperations.GetPreviousNode(this);
+ }
+ }
+
+ ///
+ /// Gets the previous visible tree node. The PrevVisibleNode can be a child, sibling, or a tree node from another branch. If there is no previous tree node, the PrevVisibleNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ [Browsable(false)]
+ public Node PrevVisibleNode
+ {
+ get
+ {
+ return NodeOperations.GetPreviousVisibleNode(this);
+ }
+ }
+
+ ///
+ /// Gets or sets the object that contains data about the tree node. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ ///
+ [Browsable(false), DefaultValue(null), Category("Data"), Description("Indicates text that contains data about the tree node."), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public object Tag
+ {
+ get
+ {
+ return m_Cells[0].Tag;
+ }
+ set
+ {
+ m_Cells[0].Tag = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the object that contains data about the tree node. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ ///
+ [Browsable(true), DefaultValue(""), Category("Data"), Description("Indicates text that contains data about the tree node."), DevCoSerialize()]
+ public string TagString
+ {
+ get
+ {
+ return m_Cells[0].TagString;
+ }
+ set
+ {
+ m_Cells[0].TagString = value;
+ }
+ }
+
+ private int _BindingIndex = -1;
+ ///
+ /// Gets or sets the Binding index in CurrencyManager list if node is bound. You should not change this value directly since
+ /// it is used internally by the control for data binding scenarios.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int BindingIndex
+ {
+ get { return _BindingIndex; }
+ set
+ {
+ _BindingIndex = value;
+ }
+ }
+
+
+ ///
+ /// Gets or sets the object that contains additional data about the tree node. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ /// This property has same function as Tag property and provides you with additional separate storage of data.
+ ///
+ [Browsable(false), DefaultValue(null), Category("Data"), Description("Indicates text that contains data about the tree node."), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public object DataKey
+ {
+ get
+ {
+ return m_DataKey;
+ }
+ set
+ {
+ m_DataKey = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the object that contains additional data about the tree node. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ /// This property has same function as Tag property and provides you with additional separate storage of data.
+ ///
+ [Browsable(true), DefaultValue(""), Category("Data"), Description("Indicates text that contains data about the tree node."), DevCoSerialize()]
+ public string DataKeyString
+ {
+ get
+ {
+ if (m_DataKey == null)
+ return "";
+ return m_DataKey.ToString();
+ }
+ set
+ {
+ m_DataKey = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the format that is applied to the value of Text property for display purposes (applies to first cell in a node, i.e. Cells[0]). See "Formatting Overview" in MSDN
+ /// for description on available format strings. For example you can specify "C" to format text as currency, or "D" to format text as decimal number etc.
+ ///
+ ///
+ [Browsable(true), DefaultValue(""), Category("Appearance"), Description("Indicates format that is applied to the value of Text property for display purposes.")]
+ public string TextDisplayFormat
+ {
+ get { return this.Cells[0].TextDisplayFormat; }
+ set
+ {
+ this.Cells[0].TextDisplayFormat = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the text displayed in the tree node.
+ ///
+ [Browsable(true), DefaultValue(""), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Category("Appearance"), Localizable(true), Description("Indicates text displayed in the tree node."), DevCoSerialize()]
+ public string Text
+ {
+ get
+ {
+ return this.Cells[0].Text;
+ }
+ set
+ {
+ this.Cells[0].Text = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the control hosted inside of the first node cell.
+ ///
+ ///
+ /// When control is hosted inside of the cell, cell size is determined by the
+ /// size of the control hosted inside of it. The cell will not display its text but it will display any image assigned
+ /// or check box when control is hosted inside of it. The Style settings like Margin
+ /// and Padding will still apply.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates control hosted inside of the cell."), DefaultValue(null)]
+ public Control HostedControl
+ {
+ get { return this.Cells[0].HostedControl; }
+ set
+ {
+ this.Cells[0].HostedControl = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the item hosted inside of the first cell. Only items that do not generate
+ /// popups are supported. Note that cell can only host either HostedItem or HostedControl but not both.
+ ///
+ [DefaultValue(null), Category("Appearance"), Editor("DevComponents.AdvTree.Design.HostedItemTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates item hosted inside of the cell. Only items that do not generate popups are supported. Note that cell can only host either HostedItem or HostedControl but not both.")]
+ public BaseItem HostedItem
+ {
+ get { return this.Cells[0].HostedItem; }
+ set { this.Cells[0].HostedItem = value; }
+ }
+
+ ///
+ /// Gets the parent tree control that the tree node is assigned to.
+ ///
+ [Browsable(false)]
+ public AdvTree TreeControl
+ {
+ get
+ {
+ return this.GetTreeControl();
+ }
+ }
+
+ ///
+ /// Gets or sets the layout of the cells inside the node. Default value is Horizontal layout which
+ /// means that cell are positioned horizontally next to each other.
+ ///
+ [Browsable(true), DefaultValue(eCellLayout.Default), Category("Cells"), Description("Indicates layout of the cells inside the node."), DevCoSerialize()]
+ public eCellLayout CellLayout
+ {
+ get { return m_CellLayout; }
+ set
+ {
+ m_CellLayout = value;
+ this.SizeChanged = true;
+ }
+ }
+
+ private eHorizontalAlign _VerticalCellLayoutAlignment = eHorizontalAlign.Center;
+ ///
+ /// Gets or sets the cell alignment when CellLayout=Vertical. Default value is center which means that cells are center aligned.
+ ///
+ [DefaultValue(eHorizontalAlign.Center), Category("Cells"), Description("Indicates cell alignment when CellLayout=Vertical. Default value is center which means that cells are center aligned.")]
+ public eHorizontalAlign VerticalCellLayoutAlignment
+ {
+ get { return _VerticalCellLayoutAlignment; }
+ set { _VerticalCellLayoutAlignment = value; this.SizeChanged = true; }
+ }
+
+ ///
+ /// Gets or sets the layout of the cell parts like check box, image and text. Layout can be horizontal (default)
+ /// where parts of the cell are positioned next to each other horizontally, or vertical where
+ /// parts of the cell are positioned on top of each other vertically.
+ /// Alignment of the each part is controlled by alignment properties. This property affects only the first cell inside of the node.
+ /// Use Cell.Layout property to change the part layout on each cell contained by node.
+ ///
+ [Browsable(true), DefaultValue(eCellPartLayout.Default), Category("Cells"), Description("Indicates the layout of the cell parts like check box, image and text."), DevCoSerialize()]
+ public eCellPartLayout CellPartLayout
+ {
+ get { return m_Cells[0].Layout; }
+ set
+ {
+ if (m_Cells[0].Layout != value)
+ {
+ m_Cells[0].Layout = value;
+ }
+ }
+ }
+
+ ///
+ /// Gets/Sets informational text (tooltip) for the cell.
+ ///
+ [Browsable(true), DefaultValue(""), Category("Appearance"), Description("Indicates the text that is displayed when mouse hovers over the cell."), Localizable(true)]
+ public string Tooltip
+ {
+ get
+ {
+
+ return m_Cells[0].Tooltip;
+ }
+ set
+ {
+ m_Cells[0].Tooltip = value;
+ }
+ }
+
+ ///
+ /// Gets the collection of all Cells assigned to this node. There should be always at least one cell in a node which is default cell. Default
+ /// collection contains a single cell.
+ ///
+ [Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Cells"), Description("Collection of Cells assigned to this node.")]
+ public CellCollection Cells
+ {
+ get { return m_Cells; }
+ }
+
+ private bool _NodesColumnsHeaderVisible = true;
+ ///
+ /// Gets or sets whether column header for child nodes if defined is visible. Default value is true.
+ ///
+ [DefaultValue(true), Category("Columns"), Description("Indicates whether column header for child nodes if defined is visible.")]
+ public bool NodesColumnsHeaderVisible
+ {
+ get { return _NodesColumnsHeaderVisible; }
+ set
+ {
+ _NodesColumnsHeaderVisible = value;
+ SizeChanged = true;
+ OnDisplayChanged();
+ }
+ }
+
+ ///
+ /// Gets whether node has child nodes columns defined.
+ ///
+ [Browsable(false)]
+ public bool HasColumns
+ {
+ get
+ {
+ if (m_NodesColumns != null && m_NodesColumns.Count > 0) return true;
+ return false;
+ }
+ }
+
+ ///
+ /// Get collection of child node columns.
+ ///
+ [Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Columns"), Description("Defines the columns for the child nodes.")]
+ public ColumnHeaderCollection NodesColumns
+ {
+ get
+ {
+ if (m_NodesColumns == null)
+ {
+ m_NodesColumns = new ColumnHeaderCollection();
+ m_NodesColumns.SetParentNode(this);
+ }
+ return m_NodesColumns;
+ }
+ }
+
+ // ///
+ // /// Gets or sets whether child node column header is visible or not.
+ // ///
+ // [Browsable(true),DefaultValue(true),Category("Columns"),Description("Indicates whether child node column header is visible or not.")]
+ // public bool NodesColumnHeaderVisible
+ // {
+ // get {return m_NodesColumnHeaderVisible;}
+ // set
+ // {
+ // if(m_NodesColumnHeaderVisible!=value)
+ // {
+ // m_NodesColumnHeaderVisible=value;
+ // if(this.Expanded)
+ // this.OnChildNodesSizeChanged();
+ // }
+ // }
+ // }
+
+ /// Gets or sets the style of the cells when node is expanded.
+ ///
+ /// Reference to the style assigned to the node/cell or null value indicating that
+ /// default style setting from tree control is applied. Default value is null.
+ ///
+ ///
+ /// When node is expanded the style specified here will be used on all cells
+ /// associated with this node instead of the
+ /// Cell.StyleNormal. That way you can give
+ /// different appearance to your node's cells when node is expanded.
+ /// When property is set to null value the style setting from parent tree
+ /// controls is used. NodeStyleExpanded on
+ /// AdvTree control is a root style for a cell.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Style"), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the style for the child nodes when node is expanded.")]
+ public ElementStyle StyleExpanded
+ {
+ get { return m_StyleExpanded; }
+ set
+ {
+ if (m_StyleExpanded != value)
+ {
+ if (m_StyleExpanded != null)
+ m_StyleExpanded.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_StyleExpanded = value;
+ if (this.Expanded)
+ this.SizeChanged = true;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the expanded style name used by node. This member is provided for internal use only. To set or get the style use StyleExpanded property instead.
+ ///
+ [Browsable(false), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never), DevCoSerialize()]
+ public string StyleExpandedName
+ {
+ get
+ {
+ if (m_StyleExpanded != null)
+ return m_StyleExpanded.Name;
+ return "";
+ }
+ set
+ {
+ if (value.Length == 0)
+ {
+ TypeDescriptor.GetProperties(this)["StyleExpanded"].SetValue(this, null);
+ return;
+ }
+
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ TypeDescriptor.GetProperties(this)["StyleExpanded"].SetValue(this, tree.Styles[value]);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the style used when Node is selected. Default value is NULL (VB
+ /// Nothing)
+ ///
+ [Browsable(true), DefaultValue(null), Category("Style"), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the style for the nodes when node is selected.")]
+ public ElementStyle StyleSelected
+ {
+ get { return m_StyleSelected; }
+ set
+ {
+ if (m_StyleSelected != value)
+ {
+ if (m_StyleSelected != null)
+ m_StyleSelected.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_StyleSelected = value;
+ if (this.IsSelected)
+ this.SizeChanged = true;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the selected style name used by node. This member is provided for internal use only. To set or get the style use StyleSelected property instead.
+ ///
+ [Browsable(false), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never), DevCoSerialize()]
+ public string StyleSelectedName
+ {
+ get
+ {
+ if (m_StyleSelected != null)
+ return m_StyleSelected.Name;
+ return "";
+ }
+ set
+ {
+ if (value.Length == 0)
+ {
+ TypeDescriptor.GetProperties(this)["StyleSelected"].SetValue(this, null);
+ return;
+ }
+
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ TypeDescriptor.GetProperties(this)["StyleSelected"].SetValue(this, tree.Styles[value]);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the style used when mouse is over the Node. Default value is NULL
+ /// (VB Nothing)
+ ///
+ [Browsable(true), DefaultValue(null), Category("Style"), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the style for the nodes when node is selected.")]
+ public ElementStyle StyleMouseOver
+ {
+ get { return m_StyleMouseOver; }
+ set
+ {
+ if (m_StyleMouseOver != value)
+ {
+ if (m_StyleMouseOver != null)
+ m_StyleMouseOver.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_StyleMouseOver = value;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the mouse over style name used by node. This member is provided for internal use only. To set or get the style use StyleMouseOver property instead.
+ ///
+ [Browsable(false), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never), DevCoSerialize()]
+ public string StyleMouseOverName
+ {
+ get
+ {
+ if (m_StyleMouseOver != null)
+ return m_StyleMouseOver.Name;
+ return "";
+ }
+ set
+ {
+ if (value.Length == 0)
+ {
+ TypeDescriptor.GetProperties(this)["StyleMouseOver"].SetValue(this, null);
+ return;
+ }
+
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ TypeDescriptor.GetProperties(this)["StyleMouseOver"].SetValue(this, tree.Styles[value]);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the node style.
+ ///
+ ///
+ /// Reference to the style assigned to the node or null value indicating that default
+ /// style setting from tree control is applied. Default value is null.
+ ///
+ ///
+ /// Style specified by this property will be used as default style for the node.
+ /// Each cell within the node can also specify it's own style. Since node contains the
+ /// cells using this style property can you for example create a border around all cell
+ /// contained by the node.
+ /// When this property is set to null value (default value) NodeStyle
+ /// property on AdvTree control is used.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Style"), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the node style.")]
+ public ElementStyle Style
+ {
+ get { return m_Style; }
+ set
+ {
+ if (m_Style != value)
+ {
+ if (m_Style != null)
+ m_Style.StyleChanged -= new EventHandler(this.ElementStyleChanged);
+ if (value != null)
+ value.StyleChanged += new EventHandler(this.ElementStyleChanged);
+ m_Style = value;
+ this.SizeChanged = true;
+ this.Invalidate();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the style name used by node. This member is provided for internal use only. To set or get the style use Style property instead.
+ ///
+ [Browsable(false), DefaultValue(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never), DevCoSerialize()]
+ public string StyleName
+ {
+ get
+ {
+ if (m_Style != null)
+ return m_Style.Name;
+ return "";
+ }
+ set
+ {
+ if (value.Length == 0)
+ {
+ TypeDescriptor.GetProperties(this)["Style"].SetValue(this, null);
+ return;
+ }
+
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ TypeDescriptor.GetProperties(this)["Style"].SetValue(this, tree.Styles[value]);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the part of the node mouse is over.
+ ///
+ internal eMouseOverNodePart MouseOverNodePart
+ {
+ get { return m_MouseOverNodePart; }
+ set { m_MouseOverNodePart = value; }
+ }
+
+
+ ///
+ /// Gets or sets the node horizontal offset from the position determined by the layout manager.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), DefaultValue(0)]
+ internal int Offset
+ {
+ get { return m_Offset; }
+ set
+ {
+ m_Offset = value;
+ this.SizeChanged = true;
+ }
+ }
+
+ ///
+ /// Gets or sets the image alignment in relation to the text displayed by cell. This property affects only first default cell inside the node.
+ /// Property with same name is available on each cell and you can use it to affect each cell individually.
+ ///
+ [Browsable(true), Category("Image Properties"), DefaultValue(eCellPartAlignment.Default), Description("Gets or sets the image alignment in relation to the text displayed by cell."), DevCoSerialize()]
+ public eCellPartAlignment ImageAlignment
+ {
+ get
+ {
+ return m_Cells[0].ImageAlignment;
+ }
+ set
+ {
+ if (m_Cells[0].ImageAlignment != value)
+ {
+ m_Cells[0].ImageAlignment = value;
+ }
+ }
+ }
+
+ private bool _Enabled = true;
+ ///
+ /// Gets or sets whether node is enabled. Default value is true. Setting this value to false will set Enabled=false on all child cells.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior"), Description("Gets or sets whether node is enabled."), DevCoSerialize()]
+ public bool Enabled
+ {
+ get { return _Enabled; }
+ set
+ {
+ _Enabled = value;
+ foreach (Cell c in m_Cells)
+ {
+ c.Enabled = _Enabled;
+ }
+ }
+ }
+
+
+ ///
+ /// Gets or sets the image displayed when the tree node is disabled. If image is not specified control will create
+ /// gray-scale disabled image automatically.
+ ///
+ ///
+ /// Image specified will be used as image when node is disabled.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates image displayed when the tree node is disabled."), DefaultValue(null), DevCoSerialize()]
+ public System.Drawing.Image ImageDisabled
+ {
+ get { return m_Cells[0].Images.ImageDisabled; }
+ set
+ {
+ this.SizeChanged = true;
+ m_Cells[0].Images.ImageDisabled = value;
+ }
+ }
+ ///
+ /// Resets image to its default value. Windows Forms designer support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetImageDisabled()
+ {
+ TypeDescriptor.GetProperties(this)["ImageDisabled"].SetValue(this, null);
+ }
+ ///
+ /// Gets or sets the image-list index value of the disabled image.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image-list index value of the disabled image"), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), DefaultValue(-1), DevCoSerialize()]
+ public int ImageDisabledIndex
+ {
+ get { return this.Cells[0].Images.ImageDisabledIndex; }
+ set
+ {
+ this.SizeChanged = true;
+ this.Cells[0].Images.ImageDisabledIndex = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the image displayed when the tree node is in the unselected state.
+ ///
+ ///
+ /// Image specified will be used as a default image for any other node state where
+ /// different image is not specified.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates image displayed when the tree node is in the unselected state."), DefaultValue(null), DevCoSerialize()]
+ public System.Drawing.Image Image
+ {
+ get { return m_Cells[0].Images.Image; }
+ set
+ {
+ this.SizeChanged = true;
+ m_Cells[0].Images.Image = value;
+ }
+ }
+
+ ///
+ /// Resets image to its default value. Windows Forms designer support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetImage()
+ {
+ TypeDescriptor.GetProperties(this)["Image"].SetValue(this, null);
+ }
+
+ ///
+ /// Gets or sets the image-list key value of the default image that is displayed by the tree nodes.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image-list key value of the default image that is displayed by the tree nodes."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), DefaultValue(""), DevCoSerialize()]
+ public string ImageKey
+ {
+ get { return this.Cells[0].Images.ImageKey; }
+ set
+ {
+ this.SizeChanged = true;
+ this.Cells[0].Images.ImageKey = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the image-list index value of the default image that is displayed by the tree nodes.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image-list index value of the default image that is displayed by the tree nodes."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), DefaultValue(-1), DevCoSerialize()]
+ public int ImageIndex
+ {
+ get { return this.Cells[0].Images.ImageIndex; }
+ set
+ {
+ this.SizeChanged = true;
+ this.Cells[0].Images.ImageIndex = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the image displayed when mouse is over the tree node.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image displayed when mouse is over the tree node."), DefaultValue(null), DevCoSerialize()]
+ public System.Drawing.Image ImageMouseOver
+ {
+ get { return this.Cells[0].Images.ImageMouseOver; }
+ set
+ {
+ this.Cells[0].Images.ImageMouseOver = value;
+ this.SizeChanged = true;
+ }
+ }
+
+ ///
+ /// Resets ImageMouseOver to its default value. Windows Forms designer support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetImageMouseOver()
+ {
+ TypeDescriptor.GetProperties(this)["ImageMouseOver"].SetValue(this, null);
+ }
+
+ ///
+ /// Gets or sets the image-list index value of the image that is displayed by the tree nodes when mouse is over the node.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image-list index value of the image that is displayed by the tree nodes when mouse is over the node."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), DefaultValue(-1), DevCoSerialize()]
+ public int ImageMouseOverIndex
+ {
+ get { return this.Cells[0].Images.ImageMouseOverIndex; }
+ set
+ {
+ this.SizeChanged = true;
+ this.Cells[0].Images.ImageMouseOverIndex = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the image-list key value of the image that is displayed by the tree nodes when mouse is over the node.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image-list key value of the image that is displayed by the tree nodes when mouse is over the node."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), DefaultValue(""), DevCoSerialize()]
+ public string ImageMouseOverKey
+ {
+ get { return this.Cells[0].Images.ImageMouseOverKey; }
+ set
+ {
+ this.SizeChanged = true;
+ this.Cells[0].Images.ImageMouseOverKey = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the image displayed when node is expanded.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image displayed when node is expanded."), DefaultValue(null), DevCoSerialize()]
+ public System.Drawing.Image ImageExpanded
+ {
+ get { return this.Cells[0].Images.ImageExpanded; }
+ set
+ {
+ this.Cells[0].Images.ImageExpanded = value;
+ this.SizeChanged = true;
+ }
+ }
+
+ ///
+ /// Resets ImageExpanded to its default value. Windows Forms designer support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetImageExpanded()
+ {
+ TypeDescriptor.GetProperties(this)["ImageExpanded"].SetValue(this, null);
+ }
+
+ ///
+ /// Gets or sets the image-list index value of the image that is displayed by the tree nodes when node is expanded.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image-list index value of the image that is displayed by the tree nodes when node is expanded."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), DefaultValue(-1), DevCoSerialize()]
+ public int ImageExpandedIndex
+ {
+ get { return this.Cells[0].Images.ImageExpandedIndex; }
+ set
+ {
+ this.SizeChanged = true;
+ this.Cells[0].Images.ImageExpandedIndex = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the image-list key value of the image that is displayed by the tree nodes when node is expanded.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image-list key value of the image that is displayed by the tree nodes when node is expanded."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), DefaultValue(""), DevCoSerialize()]
+ public string ImageExpandedKey
+ {
+ get { return this.Cells[0].Images.ImageExpandedKey; }
+ set
+ {
+ this.SizeChanged = true;
+ this.Cells[0].Images.ImageExpandedKey = value;
+ }
+ }
+
+ ///
+ /// Property Editor support for ImageIndex selection
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public System.Windows.Forms.ImageList ImageList
+ {
+ get
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ {
+ return tree.ImageList;
+ }
+ return null;
+ }
+ }
+
+ /////
+ ///// Sets the node relative position form the root when map layout is used.
+ /////
+ ///// Relative node position.
+ //internal void SetMapSubRootPosition(eMapPosition pos)
+ //{
+ // m_MapSubRootPosition=pos;
+ //}
+
+ ///
+ /// Gets or sets the NodeConnector object that describes the type of the connector used for
+ /// displaying connection between current node and its parent node.
+ /// Default value is null which means that settings from AdvTree control are used.
+ ///
+ /// RootConnector Property (DevComponents.AdvTree.AdvTree)
+ /// NodesConnector Property (DevComponents.AdvTree.AdvTree)
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), Category("Connectors"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.NodeConnectorTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Indicates the nested nodes connector.")]
+ public NodeConnector ParentConnector
+ {
+ get { return m_ParentConnector; }
+ set
+ {
+ if (m_ParentConnector != value)
+ {
+ if (m_ParentConnector != null)
+ m_ParentConnector.AppearanceChanged -= new EventHandler(this.ConnectorAppearanceChanged);
+ if (value != null)
+ value.AppearanceChanged += new EventHandler(this.ConnectorAppearanceChanged);
+ m_ParentConnector = value;
+ this.OnDisplayChanged();
+ }
+ }
+ }
+
+ /////
+ ///// Gets the collection of the parent connector line relative points. By default this collection is empty which indicates that
+ ///// connector line is drawn using predefined path. Points added here are the points through which the connector line will travel to the
+ ///// parent node. The point coordinates added to this collection are relative from the top-left corner of this node.
+ /////
+ //[Browsable(true),Category("Connectors"),DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ //internal ConnectorPointsCollection ParentConnectorPoints
+ //{
+ // get {return m_ParentConnectorPoints;}
+ //}
+
+ ///
+ /// Gets or sets whether node is visible.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(true), Description("Indicated whether node is visible"), DevCoSerialize()]
+ public bool Visible
+ {
+ get { return m_Visible; }
+ set
+ {
+ m_Visible = value;
+ this.OnVisibleChanged();
+ this.SizeChanged = true;
+ }
+ }
+
+ ///
+ /// Gets or sets whether command button is visible. Default value is false.
+ /// Command button can be used to display for example popup menu with commands for node,
+ /// or to display the list of linked nodes.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Command Button"), Description("Indicates visibility of command button."), DevCoSerialize()]
+ internal bool CommandButton
+ {
+ get { return m_CommandButton; }
+ set
+ {
+ m_CommandButton = value;
+ this.OnDisplayChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets internal value that indicates that node is on "path" of the selected node.
+ ///
+ internal bool SelectedConnectorMarker
+ {
+ get { return m_SelectedConnectorMarker; }
+ set { m_SelectedConnectorMarker = value; }
+ }
+
+ public void InternalDeselected(eTreeAction action)
+ {
+ OnDeselected(action);
+ }
+
+ ///
+ /// Called after node has been deselected.
+ ///
+ /// Provides information on how selection was performed
+ protected virtual void OnDeselected(eTreeAction action)
+ {
+
+ }
+ ///
+ /// Called after node has been selected.
+ ///
+ /// Provides information on how selection was performed
+ protected virtual void OnSelected(eTreeAction action)
+ {
+
+ }
+ public void InternalSelected(eTreeAction action)
+ {
+ OnSelected(action);
+ }
+
+ private bool _IsDragNode = false;
+ ///
+ /// Gets whether node is a drag node being used for drag & drop preview.
+ ///
+ [Browsable(false)]
+ public bool IsDragNode
+ {
+ get { return _IsDragNode; }
+#if FRAMEWORK20
+ internal set
+#else
+ set
+#endif
+ {
+ if (_IsDragNode != value)
+ {
+ _IsDragNode = value;
+ if (m_Nodes != null)
+ {
+ foreach (Node n in this.Nodes)
+ {
+ n.IsDragNode = value;
+ }
+ }
+ }
+ }
+ }
+
+ private bool _IsSelectionVisible = true;
+ ///
+ /// Gets or sets whether node selection is visible in UI when node is selected. Default value is true. You can
+ /// set this value to false to temporary disable the display of selection for a node.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool IsSelectionVisible
+ {
+ get { return _IsSelectionVisible; }
+ set
+ {
+ if (_IsSelectionVisible != value)
+ {
+ _IsSelectionVisible = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ private int _NodesIndent = 0;
+ ///
+ /// Gets or sets the additional indent for the child nodes that is added to the AdvTree.Indent value when performing child node layout. Default value i 0.
+ ///
+ [DefaultValue(0), Category("Appearance"), Description("additional indent for the child nodes that is added to the AdvTree.Indent value when performing child node layout")]
+ public int NodesIndent
+ {
+ get { return _NodesIndent; }
+ set
+ {
+ _NodesIndent = value;
+ this.InvalidateLayout(true);
+ }
+ }
+
+ #endregion
+
+ #region Methods
+ ///
+ /// Returns cell within a node which contains specified coordinates.
+ ///
+ ///
+ ///
+ /// Cell which contains specified coordinates or null/nothing if no cell contains coordinates.
+ public Cell GetCellAt(int x, int y)
+ {
+ Cell cellAt = null;
+ foreach (Cell cell in m_Cells)
+ {
+ if (!cell.IsVisible) continue;
+ Rectangle rCell = cell.Bounds;
+ if (rCell.Contains(x, y))
+ {
+ cellAt = cell;
+ break;
+ }
+ }
+ return cellAt;
+ }
+
+ private bool _CellNavigationEnabled = true;
+ ///
+ /// Gets or sets whether Left/Right navigation through the cells when SingleCellSelection on tree is set is enabled. Default value is true.
+ ///
+ [DefaultValue(true), Browsable(false)]
+ public virtual bool CellNavigationEnabled
+ {
+ get
+ {
+ return _CellNavigationEnabled;
+ }
+ set
+ {
+ _CellNavigationEnabled = value;
+ }
+ }
+ internal void InternalKeyDown(KeyEventArgs e)
+ {
+ OnKeyDown(e);
+ }
+
+ protected virtual void OnKeyDown(KeyEventArgs e)
+ {
+
+ }
+
+ ///
+ /// Invalidates the layout for this node and causes the layout to be performed on next layout request.
+ ///
+ public void InvalidateLayout()
+ {
+ NodeOperations.InvalidateNodeLayout(this, false);
+ }
+ ///
+ /// Invalidates the layout for this node and causes the layout to be performed on next layout request.
+ ///
+ /// Indicates whether to invalidate layout for all child nodes as well.
+ public void InvalidateLayout(bool invalidateChildNodes)
+ {
+ NodeOperations.InvalidateNodeLayout(this, invalidateChildNodes);
+ }
+
+ ///
+ /// Invalidates node and causes a paint message to be sent to the tree.
+ ///
+ public void Invalidate()
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ tree.InvalidateNode(this);
+ }
+
+ /// Initiates the editing of node text.
+ ///
+ /// This method by default edits text stored in Node.Text. Call to this method is
+ /// same as calling the overload method BeginData(0) with zero as parameter. Use BeginData
+ /// overload method to begin editing the specific column for multi-column nodes.
+ ///
+ public void BeginEdit()
+ {
+ BeginEdit(0);
+ }
+
+ /// Initiates the editing of node text.
+ ///
+ /// The initial text to be entered into the edit TextBox. Specify null to use existing text.
+ ///
+ public void BeginEdit(string initialText)
+ {
+ BeginEdit(0, initialText);
+ }
+
+ /// Initiates text editing of certain Node column.
+ ///
+ /// Zero based index of a column to begin editing for. Column 0 always corresponds to
+ /// Node.Text property.
+ ///
+ public void BeginEdit(int iColumnIndex)
+ {
+ BeginEdit(iColumnIndex, null);
+ }
+
+ /// Initiates text editing of certain Node column.
+ ///
+ /// Zero based index of a column to begin editing for. Column 0 always corresponds to
+ /// Node.Text property.
+ ///
+ ///
+ /// The initial text to be entered into the edit TextBox. Specify null to edit existing text.
+ ///
+ public void BeginEdit(int iColumnIndex, string initialText)
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree == null)
+ return;
+ Cell cell = this.Cells[iColumnIndex];
+ if (!cell.IsEditable)
+ throw new InvalidOperationException("Cell is not editable, either Cell.Editable=false or ColumnHeader.Editable=false.");
+ tree.EditCell(this.Cells[iColumnIndex], eTreeAction.Code, initialText);
+ }
+ ///
+ /// Creates new instance of the node for the Copy() and DeepCopy() methods. Allows you to returns your own node type copy if you inherit from node to add custom properties.
+ ///
+ /// New instance of a node.
+ protected virtual Node CreateCopyInstance()
+ {
+ return new Node();
+ }
+ /// Makes a "shallow" copy of a Node.
+ ///
+ /// Shallow copy of a Node is a exact copy of Node but without copy
+ /// of all child nodes in Nodes collection.
+ ///
+ public virtual Node Copy()
+ {
+ Node n = CreateCopyInstance();
+ CopyTo(n);
+ return n;
+ }
+ ///
+ /// Copies this node properties to a node.
+ ///
+ /// Node top copy properties to.
+ protected virtual void CopyTo(Node n)
+ {
+ // TODO: Verify that all properties are copied
+ n.CellLayout = this.CellLayout;
+ n.Cells.Clear();
+ foreach (Cell c in this.Cells)
+ n.Cells.Add(c.Copy());
+ n.Checked = this.Checked;
+ n.CommandButton = this.CommandButton;
+ n.ExpandVisibility = this.ExpandVisibility;
+ n.Image = this.Image;
+ n.ImageDisabled = this.ImageDisabled;
+ n.ImageDisabledIndex = this.ImageDisabledIndex;
+ n.ImageExpanded = this.ImageExpanded;
+ n.ImageExpandedIndex = this.ImageExpandedIndex;
+ n.ImageIndex = this.ImageIndex;
+ n.ImageMouseOver = this.ImageMouseOver;
+ n.ImageMouseOverIndex = this.ImageMouseOverIndex;
+ n.Expanded = this.Expanded;
+ n.DragDropEnabled = this.DragDropEnabled;
+ n.CellLayout = this.CellLayout;
+ n.CellPartLayout = this.CellPartLayout;
+ n.CheckBoxAlignment = this.CheckBoxAlignment;
+ n.CheckBoxStyle = this.CheckBoxStyle;
+ n.CheckBoxThreeState = this.CheckBoxThreeState;
+ n.CheckBoxVisible = this.CheckBoxVisible;
+ n.CheckState = this.CheckState;
+ n.ContextMenu = this.ContextMenu;
+ n.DataKey = this.DataKey;
+ n.DragDropEnabled = this.DragDropEnabled;
+ n.Enabled = this.Enabled;
+ n.FullRowBackground = this.FullRowBackground;
+ n.ImageAlignment = this.ImageAlignment;
+ n.Selectable = this.Selectable;
+ //n.NodesColumnHeaderVisible=this.NodesColumnHeaderVisible;
+ foreach (ColumnHeader c in this.NodesColumns)
+ n.NodesColumns.Add(c.Copy());
+ n.ParentConnector = this.ParentConnector;
+ n.Style = this.Style;
+ n.StyleExpanded = this.StyleExpanded;
+ n.StyleMouseOver = this.StyleMouseOver;
+ n.StyleSelected = this.StyleSelected;
+ n.Tag = this.Tag;
+ n.DataKey = this.DataKey;
+ n.Text = this.Text;
+ n.Visible = this.Visible;
+ n.Name = this.Name;
+ //n.ParentConnectorPoints.AddRange(this.ParentConnectorPoints.ToArray());
+ }
+ /// Makes a "deep" copy of a node.
+ ///
+ /// Deep copy of Node is a exact copy of Node including exact copies of all child nodes
+ /// in this node's Nodes collection.
+ ///
+ public virtual Node DeepCopy()
+ {
+ Node n = this.Copy();
+ foreach (Node c in this.Nodes)
+ n.Nodes.Add(c.DeepCopy());
+ return n;
+ }
+
+ ///
+ /// Collapses the tree node.
+ ///
+ public void Collapse()
+ {
+ this.SetExpanded(false, eTreeAction.Code);
+ }
+
+ ///
+ /// Collapses the tree node.
+ ///
+ /// Action that caused the event
+ public void Collapse(eTreeAction action)
+ {
+ this.SetExpanded(false, action);
+ }
+
+ ///
+ /// Collapses all the child tree nodes.
+ ///
+ public void CollapseAll()
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ tree.BeginUpdate();
+ this.Collapse();
+ foreach (Node node in this.Nodes)
+ node.CollapseAll();
+ if (tree != null)
+ tree.EndUpdate();
+ }
+
+ ///
+ /// Ends the editing of the node text or column.
+ ///
+ /// true if the editing of the tree node label text was canceled without being saved; otherwise, false.
+ public void EndEdit(bool cancelChanges)
+ {
+ if (!this.IsEditing)
+ return;
+ AdvTree tree = this.TreeControl;
+ if (tree == null)
+ return;
+ if (cancelChanges)
+ tree.CancelCellEdit(eTreeAction.Code);
+ else
+ tree.EndCellEditing(eTreeAction.Code);
+ }
+
+ ///
+ /// Ensures that the node is visible, expanding nodes and scrolling the control as necessary.
+ ///
+ public void EnsureVisible()
+ {
+ NodeOperations.EnsureVisible(this, AdvTreeSettings.SelectedScrollIntoViewHorizontal);
+ }
+ ///
+ /// Ensures that the node is visible, expanding nodes and scrolling the control as necessary.
+ ///
+ /// Indicates the position within a tree visible area node is scrolled to
+ public void EnsureVisible(eEnsureVisibleOption ensureVisibleOption)
+ {
+ NodeOperations.EnsureVisible(this, AdvTreeSettings.SelectedScrollIntoViewHorizontal, ensureVisibleOption);
+ }
+
+ ///
+ /// Expands the node.
+ ///
+ ///
+ /// The Expand method expands the current Node down to the next level of nodes.
+ /// The state of a Node is persisted. For example, if the next level of child nodes was not collapsed previously, when the Expand method is called, the child nodes appear in their previously expanded state.
+ ///
+ public void Expand()
+ {
+ SetExpanded(true, eTreeAction.Code);
+ }
+
+ ///
+ /// Expands the node.
+ ///
+ ///
+ /// The Expand method expands the current Node down to the next level of nodes.
+ /// The state of a Node is persisted. For example, if the next level of child nodes was not collapsed previously, when the Expand method is called, the child nodes appear in their previously expanded state.
+ ///
+ /// Action that caused the event.
+ public void Expand(eTreeAction action)
+ {
+ SetExpanded(true, action);
+ }
+
+ ///
+ /// Expands all the child tree nodes.
+ ///
+ public void ExpandAll()
+ {
+ ExpandAll(eTreeAction.Code);
+ }
+ ///
+ /// Expands all the child tree nodes.
+ ///
+ public void ExpandAll(eTreeAction action)
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ tree.BeginUpdate();
+ try
+ {
+ if (!this.Expanded) this.Expand(action);
+ foreach (Node node in this.Nodes)
+ {
+ node.Expand(action);
+ node.ExpandAll(action);
+ }
+ }
+ finally
+ {
+ if (tree != null)
+ tree.EndUpdate();
+ }
+ }
+
+ ///
+ /// Removes the current node from the control.
+ ///
+ ///
+ /// When the Remove method is called, the node and any child nodes assigned to the Node are removed from the Tree. The removed child nodes are removed from the Tree, but are still attached to this node.
+ ///
+ public void Remove()
+ {
+ if (this.Parent != null)
+ this.Parent.Nodes.Remove(this);
+ else if (this.TreeControl != null && this.TreeControl.Nodes.Contains(this))
+ this.TreeControl.Nodes.Remove(this);
+ }
+
+ ///
+ /// Removes the current node from the control and provides information about source of action
+ ///
+ ///
+ /// When the Remove method is called, the node and any child nodes assigned to the Node are removed from the Tree. The removed child nodes are removed from the Tree, but are still attached to this node.
+ ///
+ public void Remove(eTreeAction source)
+ {
+ if (this.Parent != null)
+ {
+ this.Parent.Nodes.Remove(this, source);
+ }
+ else if (this.TreeControl != null && this.TreeControl.Nodes.Contains(this))
+ {
+ this.TreeControl.Nodes.Remove(this, source);
+ }
+ }
+
+ ///
+ /// Toggles the node to either the expanded or collapsed state.
+ ///
+ public void Toggle()
+ {
+ if (this.Expanded)
+ this.Collapse();
+ else
+ this.Expand();
+ }
+
+ ///
+ /// Toggles the node to either the expanded or collapsed state.
+ ///
+ /// Action that caused the event.
+ public void Toggle(eTreeAction action)
+ {
+ if (this.Expanded)
+ this.Collapse(action);
+ else
+ this.Expand(action);
+ }
+
+ /// Returns string representation of the Node.
+ public override string ToString()
+ {
+ System.Text.StringBuilder build = new System.Text.StringBuilder();
+ int c = this.Cells.Count;
+ for (int i = 0; i < c; i++)
+ {
+ build.Append(this.Cells[i].Text);
+ if (i + 1 < c) build.Append(", ");
+ }
+ return build.ToString();
+ }
+
+ private bool _FullRowBackground = false;
+ ///
+ /// Gets or sets whether style background that is applied to the node is drawn across the width of the tree control instead of only
+ /// behind the node content. Default value is false.
+ ///
+ [DefaultValue(false), Category("Appearance"), Description("Indicates whether style background that is applied to the node is drawn across the width of the tree control instead of only behind the node content.")]
+ public bool FullRowBackground
+ {
+ get { return _FullRowBackground; }
+ set
+ {
+ if (_FullRowBackground != value)
+ {
+ _FullRowBackground = value;
+ this.SizeChanged = true;
+ this.Invalidate();
+ }
+ }
+ }
+
+ internal void BeforeCellCheck(Cell cell, AdvTreeCellBeforeCheckEventArgs e)
+ {
+ OnBeforeCellCheck(cell, e);
+ }
+
+ protected virtual void OnBeforeCellCheck(Cell cell, AdvTreeCellBeforeCheckEventArgs e)
+ {
+ }
+ #endregion
+
+ #region Private Implementation
+ ///
+ /// Called after new cell has been added to Cells collection.
+ ///
+ /// Reference to the new cell added.
+ internal void OnCellInserted(Cell cell)
+ {
+ this.SizeChanged = true;
+ OnDisplayChanged();
+ }
+
+ ///
+ /// Called after cell has been removed from Cells collection.
+ ///
+ /// Reference to the removed cell.
+ internal void OnCellRemoved(Cell cell)
+ {
+ this.SizeChanged = true;
+ OnDisplayChanged();
+ }
+
+ ///
+ /// Gets or sets the child column header height.
+ ///
+ internal int ColumnHeaderHeight
+ {
+ get { return m_ColumnHeaderHeight; }
+ set { m_ColumnHeaderHeight = value; }
+ }
+
+ ///
+ /// Occurs when property on the node has changed that influences the size of the node.
+ ///
+ private void OnSizeChanged()
+ {
+ if (m_SizeChanged)
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null && !tree.IsUpdateSuspended)
+ {
+ tree.SetPendingLayout();
+ tree.Invalidate();
+ }
+ }
+ }
+
+ ///
+ /// Occurs when any image property for the cell has changed.
+ ///
+ internal void OnImageChanged()
+ {
+ if (m_SizeChanged) return;
+
+ if (this.Parent != null)
+ this.Parent.OnChildNodesSizeChanged();
+ else
+ this.SizeChanged = true;
+ OnDisplayChanged();
+ }
+
+ ///
+ /// Occurs when size of the child nodes has changed.
+ ///
+ internal void OnChildNodesSizeChanged()
+ {
+ foreach (Node node in this.Nodes)
+ {
+ node.SizeChanged = true;
+ node.OnChildNodesSizeChanged();
+ }
+ }
+ private void OnColumnHeaderSizeChanged(object sender, EventArgs e)
+ {
+ if (this.Expanded)
+ this.SizeChanged = true;
+ }
+ private void SetExpanded(bool e, eTreeAction action)
+ {
+ if (e == m_Expanded)
+ return;
+
+ INodeNotify notification = GetINodeNotify();
+ if (notification != null)
+ {
+ AdvTreeNodeCancelEventArgs cancelArgs = new AdvTreeNodeCancelEventArgs(action, this);
+ if (e)
+ notification.OnBeforeExpand(cancelArgs);
+ else
+ notification.OnBeforeCollapse(cancelArgs);
+ if (cancelArgs.Cancel)
+ return;
+ }
+#if TRIAL
+ if(NodeOperations.ColorCountExp==0)
+ return;
+#endif
+ OnExpandChanging(e, action);
+ m_Expanded = e;
+
+ if (notification != null)
+ notification.ExpandedChanged(this);
+
+ if (notification != null)
+ {
+ AdvTreeNodeEventArgs args = new AdvTreeNodeEventArgs(action, this);
+ if (e)
+ notification.OnAfterExpand(args);
+ else
+ notification.OnAfterCollapse(args);
+ }
+
+ foreach (Node node in this.Nodes)
+ {
+ node.OnParentExpandedChanged(m_Expanded);
+ }
+
+ this.SizeChanged = true;
+ this.OnDisplayChanged();
+ }
+ ///
+ /// Called before Expanded state of the node has changed.
+ ///
+ /// New Expand State
+ /// Action Source
+ protected virtual void OnExpandChanging(bool expanded, eTreeAction action)
+ {
+
+ }
+
+ internal void OnParentExpandedChanged(bool expanded)
+ {
+ foreach (Cell cell in this.Cells)
+ cell.OnParentExpandedChanged(expanded);
+ foreach (Node node in this.Nodes)
+ {
+ node.OnParentExpandedChanged(expanded);
+ }
+ }
+
+ private AdvTree GetTreeControl()
+ {
+ Node node = this;
+ while (node.Parent != null)
+ node = node.Parent;
+ return node.internalTreeControl;
+ }
+ private INodeNotify GetINodeNotify()
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null) return tree as INodeNotify;
+ return null;
+ }
+ private void ElementStyleChanged(object sender, EventArgs e)
+ {
+ this.SizeChanged = true;
+ this.OnDisplayChanged();
+ }
+ ///
+ /// Called when visual part of the node has changed due to the changes of its properties or properties of the cells contained by node.
+ ///
+ internal virtual void OnDisplayChanged()
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree != null && !tree.SuspendPaint)
+ {
+ if (this.SizeChanged)
+ {
+ if (!tree.IsRepositioningControls)
+ tree.RecalcLayout();
+ else
+ tree.SetPendingLayout();
+ }
+ tree.Invalidate(true);
+ }
+ }
+
+ private void ConnectorAppearanceChanged(object sender, EventArgs e)
+ {
+ this.OnDisplayChanged();
+ }
+
+ ///
+ /// Called after new node has been added to Nodes collection.
+ ///
+ /// Reference to the new node.
+ internal void OnChildNodeInserted(Node node)
+ {
+ SizeChanged = true;
+ if (node.Cells.Count > 1)
+ node.SizeChanged = true;
+ }
+
+ ///
+ /// Called after node has been removed from Nodes collection.
+ ///
+ /// Reference to the node that is removed.
+ internal void OnChildNodeRemoved(Node node)
+ {
+ SizeChanged = true;
+ if (node.IsSelected)
+ {
+ if (this.TreeControl != null)
+ this.TreeControl.SelectedNode = null;
+ }
+ }
+
+ internal void OnVisibleChanged()
+ {
+ foreach (Cell cell in this.Cells)
+ {
+ cell.OnVisibleChanged();
+ }
+
+ foreach (Node node in this.Nodes)
+ {
+ node.OnVisibleChanged();
+ }
+ }
+
+ ///
+ /// Creates new cells based on the columns defined on either parent node or the columns in tree control. Node
+ /// must be parented so it can get reference to a parent tree control.
+ ///
+ public void CreateCells()
+ {
+ AdvTree tree = this.TreeControl;
+ if (this.Parent == null && tree == null)
+ throw new NullReferenceException("Node must have a parent or be added to AdvTree.Nodes collection to use this method.");
+ Node parent = this.Parent;
+
+ int columnsCount = 0;
+ if (parent != null && parent.NodesColumns.Count > 0)
+ {
+ columnsCount = parent.NodesColumns.Count;
+ }
+ else if (tree != null && tree.Columns.Count > 0)
+ {
+ columnsCount = tree.Columns.Count;
+ }
+
+ if (columnsCount == 0) return;
+
+ for (int i = this.Cells.Count; i < columnsCount; i++)
+ {
+ this.Cells.Add(new Cell());
+ }
+ }
+
+ internal void OnNodesCleared()
+ {
+ this.SizeChanged = true;
+ }
+
+ internal bool IsKeyboardNavigationEnabled(KeyEventArgs e)
+ {
+ return CanKeyboardNavigate(e);
+ }
+
+ protected virtual bool CanKeyboardNavigate(KeyEventArgs e)
+ {
+ return true;
+ }
+
+ internal void InvokeKeyboardPaste(KeyEventArgs args)
+ {
+ OnKeyboardPaste(args);
+ }
+
+ protected virtual void OnKeyboardPaste(KeyEventArgs args)
+ {
+
+ }
+
+ internal void InvokeKeyboardCopy(KeyEventArgs args)
+ {
+ OnKeyboardCopy(args);
+ }
+
+ protected virtual void OnKeyboardCopy(KeyEventArgs args)
+ {
+
+ }
+
+ #endregion
+
+ #region Event Invocation
+ protected internal virtual void InvokeNodeMouseDown(object sender, MouseEventArgs e)
+ {
+ if (NodeMouseDown != null)
+ NodeMouseDown(this, e);
+
+ foreach (Cell cell in m_Cells)
+ {
+ cell.InvokeNodeMouseDown(sender, e);
+ }
+ }
+
+ protected internal virtual void InvokeNodeMouseUp(object sender, MouseEventArgs e)
+ {
+ if (NodeMouseUp != null)
+ NodeMouseUp(this, e);
+
+ foreach (Cell cell in m_Cells)
+ {
+ cell.InvokeNodeMouseUp(sender, e);
+ }
+ }
+
+ protected internal virtual void InvokeNodeMouseMove(object sender, MouseEventArgs e)
+ {
+ if (NodeMouseMove != null)
+ NodeMouseMove(this, e);
+
+ foreach (Cell cell in m_Cells)
+ {
+ cell.InvokeNodeMouseMove(sender, e);
+ }
+ }
+
+ ///
+ /// Raises the Click event on node and parent tree if available.
+ ///
+ public void RaiseClick()
+ {
+ AdvTree tree = this.TreeControl;
+ TreeNodeMouseEventArgs e = new TreeNodeMouseEventArgs(this, MouseButtons.None, 0, 0, 0, 0);
+ if (tree == null)
+ {
+ InvokeNodeClick(this, e);
+ }
+ else
+ {
+ tree.InternalInvokeNodeClick(e);
+ }
+ }
+
+ protected internal virtual void InvokeNodeClick(object sender, EventArgs e)
+ {
+ if (NodeClick != null)
+ NodeClick(this, e);
+
+ foreach (Cell cell in m_Cells)
+ {
+ cell.InvokeNodeClick(sender, e);
+ }
+ }
+
+ protected internal virtual void InvokeNodeDoubleClick(object sender, EventArgs e)
+ {
+ OnNodeDoubleClick(e);
+ }
+
+ protected virtual void OnNodeDoubleClick(EventArgs e)
+ {
+ if (NodeDoubleClick != null)
+ NodeDoubleClick(this, e);
+ }
+ protected internal virtual void InvokeNodeMouseEnter(object sender, EventArgs e)
+ {
+ if (NodeMouseEnter != null)
+ NodeMouseEnter(this, e);
+ }
+
+ protected internal virtual void InvokeNodeMouseLeave(object sender, EventArgs e)
+ {
+ if (NodeMouseLeave != null)
+ NodeMouseLeave(this, e);
+
+ foreach (Cell cell in m_Cells)
+ {
+ cell.InvokeNodeMouseLeave(sender, e);
+ }
+ }
+
+ protected internal virtual void InvokeNodeMouseHover(object sender, EventArgs e)
+ {
+ if (NodeMouseHover != null)
+ NodeMouseHover(this, e);
+
+ foreach (Cell cell in m_Cells)
+ {
+ if (cell.IsMouseOver)
+ {
+ cell.InvokeNodeMouseHover(sender, e);
+ }
+ }
+ }
+
+ internal bool FireHoverEvent
+ {
+ get { return NodeMouseHover != null || CellsHaveHostedItemOrTooltip; }
+ }
+
+ private bool CellsHaveHostedItemOrTooltip
+ {
+ get
+ {
+ foreach (Cell cell in m_Cells)
+ {
+ if (cell.HostedItem != null || !string.IsNullOrEmpty(cell.Tooltip)) return true;
+ }
+ return false;
+ }
+ }
+ protected internal virtual void InvokeMarkupLinkClick(Cell cell, MarkupLinkClickEventArgs args)
+ {
+ if (MarkupLinkClick != null)
+ MarkupLinkClick(cell, args);
+ AdvTree tree = this.TreeControl;
+ if (tree != null)
+ tree.InvokeMarkupLinkClick(cell, args);
+ }
+ #endregion
+
+ #region Accessibility
+ ///
+ /// Gets the AccessibleObject assigned to the item.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public virtual System.Windows.Forms.AccessibleObject AccessibleObject
+ {
+ get
+ {
+ return CreateAccessibilityInstance();
+ }
+ }
+ private NodeAccessibleObject _NodeAccessibleObject = null;
+ protected virtual System.Windows.Forms.AccessibleObject CreateAccessibilityInstance()
+ {
+ if (_NodeAccessibleObject == null)
+ _NodeAccessibleObject = new NodeAccessibleObject(this);
+ return _NodeAccessibleObject;
+ }
+
+ private string _AccessibleDefaultActionDescription = "";
+ ///
+ /// Gets or sets the default action description of the control for use by accessibility client applications.
+ ///
+ [Browsable(true), Category("Accessibility"),DefaultValue(""),Description("Gets or sets the default action description of the control for use by accessibility client applications.")]
+ public virtual string AccessibleDefaultActionDescription
+ {
+ get { return _AccessibleDefaultActionDescription; }
+ set { _AccessibleDefaultActionDescription = value; }
+ }
+
+ private string _AccessibleDescription = "";
+ ///
+ /// Gets or sets the description of the control used by accessibility client applications.
+ ///
+ [Browsable(true), Category("Accessibility"),DefaultValue(""),Description("Gets or sets the description of the control used by accessibility client applications.")]
+ public virtual string AccessibleDescription
+ {
+ get { return _AccessibleDescription; }
+ set
+ {
+ if (_AccessibleDescription != value)
+ {
+ _AccessibleDescription = value;
+ GenerateAccessibilityEvent(System.Windows.Forms.AccessibleEvents.DescriptionChange);
+ }
+ }
+ }
+
+ private string _AccessibleName = "";
+ ///
+ /// Gets or sets the name of the control used by accessibility client applications.
+ ///
+ [Browsable(true), Category("Accessibility"),Description("Gets or sets the name of the control used by accessibility client applications."),DefaultValue("")]
+ public virtual string AccessibleName
+ {
+ get { return _AccessibleName; }
+ set
+ {
+ if (_AccessibleName != value)
+ {
+ _AccessibleName = value;
+ GenerateAccessibilityEvent(System.Windows.Forms.AccessibleEvents.NameChange);
+ }
+ }
+ }
+
+ private System.Windows.Forms.AccessibleRole _AccessibleRole = System.Windows.Forms.AccessibleRole.OutlineItem;
+ ///
+ /// Gets or sets the accessible role of the item.
+ ///
+ [Browsable(true), Category("Accessibility"),Description("Gets or sets the accessible role of the item."),DefaultValue(System.Windows.Forms.AccessibleRole.OutlineItem)]
+ public virtual System.Windows.Forms.AccessibleRole AccessibleRole
+ {
+ get { return _AccessibleRole; }
+ set { _AccessibleRole = value; }
+ }
+
+ private bool _IsAccessible = true;
+ ///
+ /// Gets or sets a value indicating whether the node is visible to accessibility applications.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual bool IsAccessible
+ {
+ get { return _IsAccessible; }
+ set { _IsAccessible = value; }
+ }
+
+ internal void GenerateAccessibilityEvent(System.Windows.Forms.AccessibleEvents e)
+ {
+ AdvTree tree = this.TreeControl;
+ if (tree == null) return;
+
+ AdvTree.AdvTreeAccessibleObject a = tree.AccessibilityObject as AdvTree.AdvTreeAccessibleObject;
+ if (a != null)
+ a.GenerateEvent(this, e);
+ }
+ #endregion
+
+ #region IComparable Members
+ ///
+ /// Provides implementation for IComparable interface. This is used for sorting and it compares the Text property on nodes.
+ ///
+ ///
+ ///
+ public int CompareTo(object obj)
+ {
+ if (obj is Node)
+ {
+ Node node = obj as Node;
+ return Utilities.CompareAlphaNumeric(this.Text, node.Text);
+ }
+ return -1;
+ }
+
+ #endregion
+ }
+
+ #region ItemAccessibleObject
+ public class NodeAccessibleObject : System.Windows.Forms.AccessibleObject
+ {
+ private Node _Owner = null;
+ public NodeAccessibleObject(Node owner)
+ {
+ _Owner = owner;
+ }
+
+ internal Node Owner
+ {
+ get { return _Owner; }
+ }
+
+ public override string Name
+ {
+ get
+ {
+ if (_Owner == null)
+ return "";
+
+ if (_Owner.AccessibleName != "")
+ return _Owner.AccessibleName;
+
+ return _Owner.Text.Replace("&", "");
+ }
+ set
+ {
+ _Owner.AccessibleName = value;
+ }
+ }
+
+ public override string Description
+ {
+ get
+ {
+ if (_Owner == null)
+ return "";
+ if (_Owner.AccessibleDescription != "")
+ return _Owner.AccessibleDescription;
+ return Name + " Tree Node";
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleRole Role
+ {
+ get
+ {
+ if (_Owner == null || !_Owner.IsAccessible)
+ return System.Windows.Forms.AccessibleRole.None;
+
+ if (_Owner.AccessibleRole != System.Windows.Forms.AccessibleRole.Default)
+ return _Owner.AccessibleRole;
+ return AccessibleRole.OutlineItem;
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleStates State
+ {
+ get
+ {
+ if (_Owner == null)
+ return System.Windows.Forms.AccessibleStates.Unavailable;
+ System.Windows.Forms.AccessibleStates state = 0;
+
+ if (!_Owner.IsAccessible)
+ return System.Windows.Forms.AccessibleStates.Unavailable;
+
+ if (!_Owner.Visible)
+ state |= System.Windows.Forms.AccessibleStates.Invisible;
+ else
+ {
+ if (_Owner.IsSelected)
+ state = AccessibleStates.Selected;
+ if (_Owner.Expanded)
+ state |= System.Windows.Forms.AccessibleStates.Expanded;
+ else
+ state |= System.Windows.Forms.AccessibleStates.Collapsed;
+ }
+ return state;
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleObject Parent
+ {
+ get
+ {
+ if (_Owner == null)
+ return null;
+ if (_Owner.Parent != null)
+ {
+ return _Owner.Parent.AccessibleObject;
+ }
+
+ System.Windows.Forms.Control control = _Owner.TreeControl as System.Windows.Forms.Control;
+ if (control != null)
+ return control.AccessibilityObject;
+ return null;
+ }
+ }
+
+ public override System.Drawing.Rectangle Bounds
+ {
+ get
+ {
+ if (_Owner == null)
+ return System.Drawing.Rectangle.Empty;
+ System.Windows.Forms.Control objCtrl = _Owner.TreeControl as System.Windows.Forms.Control;
+ if (objCtrl != null)
+ return objCtrl.RectangleToScreen(_Owner.Bounds);
+ else
+ return _Owner.Bounds;
+ }
+ }
+
+ public override int GetChildCount()
+ {
+ if (_Owner == null || !_Owner.HasChildNodes)
+ return 0;
+ return _Owner.Nodes.Count;
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetChild(int iIndex)
+ {
+ if (_Owner == null)
+ return null;
+ return _Owner.Nodes[iIndex].AccessibleObject;
+ }
+
+ public override string DefaultAction
+ {
+ get
+ {
+ if (_Owner.AccessibleDefaultActionDescription != "")
+ return _Owner.AccessibleDefaultActionDescription;
+ if (_Owner.Expanded)
+ return "Collapse";
+ else if (_Owner.Nodes.Count > 0 || _Owner.ExpandVisibility == eNodeExpandVisibility.Visible)
+ return "Expand";
+ return "Press";
+ }
+ }
+
+ public override void DoDefaultAction()
+ {
+ if (_Owner == null)
+ return;
+ _Owner.Toggle();
+
+ base.DoDefaultAction();
+ }
+
+ public override string KeyboardShortcut
+ {
+ get
+ {
+ return ""; // _Owner.ShortcutString;
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetSelected()
+ {
+ if (_Owner == null)
+ return base.GetSelected();
+ if (_Owner.IsSelected)
+ return _Owner.AccessibleObject;
+
+ return base.GetSelected();
+ }
+
+ public override System.Windows.Forms.AccessibleObject HitTest(int x, int y)
+ {
+ if (_Owner == null)
+ return base.HitTest(x, y);
+
+ Point screen = new Point(x, y);
+ AdvTree tree = _Owner.TreeControl;
+ if (tree == null) return base.HitTest(x, y);
+
+ Point p = tree.PointToClient(screen);
+ Node node = tree.GetNodeAt(p);
+ if (node != null) return node.AccessibleObject;
+
+ return base.HitTest(x, y);
+ }
+
+ public override System.Windows.Forms.AccessibleObject Navigate(System.Windows.Forms.AccessibleNavigation navDir)
+ {
+ if (_Owner == null)
+ return base.Navigate(navDir);
+
+ Node item = null;
+
+ if (navDir == System.Windows.Forms.AccessibleNavigation.Down || navDir == System.Windows.Forms.AccessibleNavigation.Right
+ || navDir == System.Windows.Forms.AccessibleNavigation.Next)
+ {
+ item = NodeOperations.GetNextVisibleNode(_Owner);
+ }
+ else if (navDir == System.Windows.Forms.AccessibleNavigation.FirstChild)
+ {
+ item = GetFirstVisible(_Owner.Nodes, 0);
+ }
+ else if (navDir == System.Windows.Forms.AccessibleNavigation.LastChild)
+ {
+ item = GetFirstVisibleReverse(_Owner.Nodes, _Owner.Nodes.Count - 1);
+ }
+ else if (navDir == System.Windows.Forms.AccessibleNavigation.Up || navDir == System.Windows.Forms.AccessibleNavigation.Left
+ || navDir == System.Windows.Forms.AccessibleNavigation.Previous)
+ {
+ item = NodeOperations.GetPreviousVisibleNode(_Owner);
+ }
+
+ if (item != null)
+ return item.AccessibleObject;
+
+ return base.Navigate(navDir);
+ }
+
+ private Node GetFirstVisible(NodeCollection col, int startIndex)
+ {
+ int count = col.Count;
+
+ for (int i = startIndex; i < count; i++)
+ {
+ if (col[i].Visible)
+ return col[i];
+ }
+ return null;
+ }
+
+ private Node GetFirstVisibleReverse(NodeCollection col, int startIndex)
+ {
+ for (int i = startIndex; i >= 0; i--)
+ {
+ if (col[i].Visible)
+ return col[i];
+ }
+ return null;
+ }
+
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/NodeCollection.cs b/PROMS/DotNetBar Source Code/AdvTree/NodeCollection.cs
new file mode 100644
index 00000000..05a8957d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/NodeCollection.cs
@@ -0,0 +1,502 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents collection for Node objects.
+ ///
+ public class NodeCollection:CollectionBase
+ {
+ #region Private Variables
+ private Node m_ParentNode=null;
+ private AdvTree m_TreeControl=null;
+ private eTreeAction m_SourceAction=eTreeAction.Code;
+ private bool _PassiveCollection = false;
+ #endregion
+
+ #region Internal Implementation
+ public NodeCollection()
+ {
+ }
+ internal eTreeAction SourceAction
+ {
+ get
+ {
+ return m_SourceAction;
+ }
+ set
+ {
+ m_SourceAction = value;
+ }
+ }
+ internal bool PassiveCollection
+ {
+ get { return _PassiveCollection; }
+ set
+ {
+ _PassiveCollection = value;
+ }
+ }
+ ///
+ /// Gets or sets the node this collection is associated with.
+ ///
+ [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Node ParentNode
+ {
+ get {return m_ParentNode;}
+ }
+ ///
+ /// Sets the node collection belongs to.
+ ///
+ /// Node that is parent of this collection.
+ internal void SetParentNode(Node parent)
+ {
+ m_ParentNode=parent;
+ }
+
+ internal AdvTree TreeControl
+ {
+ get {return m_TreeControl;}
+ set {m_TreeControl=value;}
+ }
+
+ ///
+ /// Adds new object to the collection.
+ ///
+ /// Object to add.
+ /// Index of newly added object.
+ public virtual int Add(Node node)
+ {
+ return Add(node, eTreeAction.Code);
+ }
+
+ ///
+ /// Adds new object to the collection and provides information about the source of the command
+ ///
+ /// Node to add
+ /// Source action
+ ///
+ public virtual int Add(Node node, eTreeAction action)
+ {
+ m_SourceAction = action;
+ return List.Add(node);
+ }
+
+ ///
+ /// Adds an array of objects to the collection.
+ ///
+ /// Array of Node objects.
+ public virtual void AddRange(Node[] nodes)
+ {
+ foreach(Node node in nodes)
+ this.Add(node);
+ }
+
+ ///
+ /// Returns reference to the object in collection based on it's index.
+ ///
+ public Node this[int index]
+ {
+ get {return (Node)(List[index]);}
+ set {List[index] = value;}
+ }
+
+ ///
+ /// Inserts new object into the collection.
+ ///
+ /// Position of the object.
+ /// Object to insert.
+ public virtual void Insert(int index, Node value)
+ {
+ List.Insert(index, value);
+ }
+
+ ///
+ /// Inserts new object into the collection.
+ ///
+ /// Position of the object.
+ /// Object to insert.
+ /// Action that is causing the event
+ public virtual void Insert(int index, Node value, eTreeAction action)
+ {
+ m_SourceAction = action;
+ List.Insert(index, value);
+ }
+
+ ///
+ /// Returns index of the object inside of the collection.
+ ///
+ /// Reference to the object.
+ /// Index of the object.
+ public int IndexOf(Node value)
+ {
+ return List.IndexOf(value);
+ }
+
+ ///
+ /// Returns whether collection contains specified object.
+ ///
+ /// Object to look for.
+ /// true if object is part of the collection, otherwise false.
+ public bool Contains(Node value)
+ {
+ return List.Contains(value);
+ }
+
+ ///
+ /// Removes specified object from the collection.
+ ///
+ ///
+ public virtual void Remove(Node value)
+ {
+ List.Remove(value);
+ }
+
+ ///
+ /// Removes specified object from the collection and provides information about source of the command
+ ///
+ /// Node to remove
+ /// Source action
+ public virtual void Remove(Node node, eTreeAction action)
+ {
+ m_SourceAction = action;
+ List.Remove(node);
+ }
+
+ protected override void OnRemove(int index, object value)
+ {
+ if (!_PassiveCollection)
+ {
+ AdvTree tree = GetTreeControl();
+ if (tree != null)
+ tree.InvokeBeforeNodeRemove(m_SourceAction, value as Node, m_ParentNode);
+ }
+ base.OnRemove (index, value);
+ }
+
+
+ protected override void OnRemoveComplete(int index,object value)
+ {
+ base.OnRemoveComplete(index,value);
+ NodeRemoveComplete(index, value);
+ }
+
+ private void NodeRemoveComplete(int index, object value)
+ {
+ if (!_PassiveCollection)
+ {
+ Node node = value as Node;
+ node.SetParent(null);
+ node.internalTreeControl = null;
+ if (m_ParentNode != null) m_ParentNode.OnChildNodeRemoved(node);
+
+ AdvTree tree = GetTreeControl();
+ if (tree != null)
+ {
+ //tree.InvokeAfterNodeRemove(m_SourceAction, value as Node, m_ParentNode);
+ tree.NodeRemoved(m_SourceAction, value as Node, m_ParentNode, index);
+ }
+ }
+ }
+
+ protected override void OnSetComplete(int index, object oldValue, object newValue)
+ {
+ base.OnSetComplete(index, oldValue, newValue);
+
+ NodeRemoveComplete(index, oldValue);
+ NodeInsertComplete(newValue);
+ }
+
+ protected override void OnSet(int index, object oldValue, object newValue)
+ {
+ if (!_PassiveCollection)
+ {
+ AdvTree tree = GetTreeControl();
+
+ if (tree != null)
+ tree.InvokeBeforeNodeRemove(m_SourceAction, oldValue as Node, m_ParentNode);
+
+ if (tree != null)
+ tree.InvokeBeforeNodeInsert(m_SourceAction, newValue as Node, m_ParentNode);
+ }
+ base.OnSet(index, oldValue, newValue);
+ }
+
+ protected override void OnInsert(int index, object value)
+ {
+ if (!_PassiveCollection)
+ {
+ AdvTree tree = GetTreeControl();
+ if (tree != null)
+ tree.InvokeBeforeNodeInsert(m_SourceAction, value as Node, m_ParentNode);
+ }
+ base.OnInsert (index, value);
+ }
+
+ protected override void OnInsertComplete(int index,object value)
+ {
+ base.OnInsertComplete(index,value);
+ NodeInsertComplete(value);
+ }
+
+ private void NodeInsertComplete(object value)
+ {
+ if (!_PassiveCollection)
+ {
+ Node node = value as Node;
+ if (m_ParentNode != null)
+ {
+ if (node.Parent != null && node.Parent != m_ParentNode)
+ node.Remove();
+ node.SetParent(m_ParentNode);
+ if (m_ParentNode.NodesColumns.IsSorted)
+ {
+ AdvTree parentTree = m_TreeControl;
+ if (parentTree == null) parentTree = m_ParentNode.TreeControl;
+ if (parentTree != null)
+ parentTree.PushSortRequest(m_ParentNode);
+ }
+ }
+ else
+ {
+ if (node.Parent != null)
+ node.Remove();
+ else
+ node.InvokeOnParentChanged();
+ if (m_TreeControl != null && m_TreeControl.Columns.IsSorted)
+ {
+ m_TreeControl.PushSortRequest();
+ }
+ }
+ node.internalTreeControl = m_TreeControl;
+
+ if (m_ParentNode != null)
+ m_ParentNode.OnChildNodeInserted(node);
+ else
+ node.SizeChanged = true;
+
+ AdvTree tree = GetTreeControl();
+ if (tree != null)
+ tree.InvokeAfterNodeInsert(m_SourceAction, value as Node, m_ParentNode);
+ }
+ m_SourceAction = eTreeAction.Code;
+ }
+ ///
+ /// Copies collection into the specified array.
+ ///
+ /// Array to copy collection to.
+ /// Starting index.
+ public void CopyTo(Node[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ ///
+ /// Copies contained items to the Node array.
+ ///
+ /// Array to copy to.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void CopyTo(Node[] array)
+ {
+ List.CopyTo(array,0);
+ }
+
+ protected override void OnClear()
+ {
+ if (!_PassiveCollection)
+ {
+ foreach (Node node in this.List)
+ {
+ node.SetParent(null);
+ node.internalTreeControl = null;
+ }
+ }
+
+ base.OnClear();
+ }
+
+ protected override void OnClearComplete()
+ {
+ if (m_TreeControl != null && !PassiveCollection)
+ {
+ m_TreeControl.OnNodesCleared();
+ }
+ else if (m_ParentNode != null && !PassiveCollection)
+ m_ParentNode.OnNodesCleared();
+
+ AdvTree tree = GetTreeControl();
+ if (tree != null)
+ {
+ tree.ValidateSelectedNode();
+ }
+
+ base.OnClearComplete();
+ }
+
+ private AdvTree GetTreeControl()
+ {
+ if(m_TreeControl!=null)
+ return m_TreeControl;
+ if(m_ParentNode!=null)
+ return m_ParentNode.TreeControl;
+ return null;
+ }
+
+ ///
+ /// Sorts the elements in the entire collection using the IComparable implementation of each element.
+ ///
+ public virtual void Sort()
+ {
+ this.Sort(0, this.Count, Comparer.Default);
+ }
+ ///
+ /// Sorts the elements in the entire collection using the specified comparer.
+ ///
+ /// The IComparer implementation to use when comparing elements.-or- null to use the IComparable implementation of each element.
+ public virtual void Sort(IComparer comparer)
+ {
+ this.Sort(0, this.Count, comparer);
+ }
+ ///
+ /// Sorts the elements in a range of elements in collection using the specified comparer.
+ ///
+ ///
+ ///
+ ///
+ public virtual void Sort(int index, int count, IComparer comparer)
+ {
+ AdvTree tree = GetTreeControl();
+ if (!_PassiveCollection && tree != null)
+ tree.BeginUpdate();
+
+ this.InnerList.Sort(index, count, comparer);
+
+ if (tree != null && tree.DeepSort)
+ {
+ foreach (Node node in this.InnerList)
+ {
+ node.Nodes.Sort(0, node.Nodes.Count, comparer);
+ }
+ }
+
+ if (!_PassiveCollection && tree != null)
+ tree.EndUpdate();
+ }
+
+ ///
+ /// Finds the tree nodes with specified key, optionally searching sub-nodes.
+ ///
+ /// The name of the tree node to search for.
+ /// true to search child nodes of tree nodes; otherwise, false.
+ /// An array of Node objects whose Name property matches the specified key.
+ public Node[] Find(string name, bool searchAllChildren)
+ {
+ ArrayList list = new ArrayList();
+ NodeOperations.FindNodesByName(this, name, searchAllChildren, list);
+ Node[] nodes = new Node[list.Count];
+ if (list.Count > 0) list.CopyTo(nodes);
+ return nodes;
+ }
+
+ #endregion
+ }
+
+ #region Node Comparer
+ public class NodeComparer : IComparer
+ {
+ private int _ColumnIndex = 0;
+ ///
+ /// Creates new instance of NodeComparer class. You can use NodeComparer to sort the nodes by specific column/cell by calling
+ /// NodeCollection.Sort method and pass new instance of NodeComparer class.
+ ///
+ public NodeComparer()
+ {
+ }
+ ///
+ /// Creates new instance of NodeComparer class. You can use NodeComparer to sort the nodes by specific column/cell by calling
+ /// NodeCollection.Sort method and pass new instance of NodeComparer class.
+ ///
+ /// Column/Cell index to use for sorting.
+ public NodeComparer(int columnIndex)
+ {
+ _ColumnIndex = columnIndex;
+ }
+
+ ///
+ /// Gets or sets the Column/Cell index that is used for sorting.
+ ///
+ public int ColumnIndex
+ {
+ get { return _ColumnIndex; }
+ set { _ColumnIndex = value; }
+ }
+ #region IComparer Members
+
+ public virtual int Compare(object x, object y)
+ {
+ Node nx = (Node)x;
+ Node ny = (Node)y;
+ if (_ColumnIndex < nx.Cells.Count && _ColumnIndex < ny.Cells.Count)
+ {
+ if(AdvTreeSettings.UseSortAlphaComparer)
+ return Utilities.CompareAlpha(nx.Cells[_ColumnIndex].Text, ny.Cells[_ColumnIndex].Text);
+ else
+ return Utilities.CompareAlphaNumeric(nx.Cells[_ColumnIndex].Text, ny.Cells[_ColumnIndex].Text);
+ }
+ return 0;
+ }
+
+ #endregion
+ }
+ ///
+ /// Reverse sort nodes.
+ ///
+ public class NodeComparerReverse : NodeComparer
+ {
+ ///
+ /// Creates new instance of NodeComparer class. You can use NodeComparer to sort the nodes by specific column/cell by calling
+ /// NodeCollection.Sort method and pass new instance of NodeComparer class.
+ ///
+ /// Column/Cell index to use for sorting.
+ public NodeComparerReverse(int columnIndex) : base(columnIndex)
+ {
+ }
+
+ public override int Compare(object x, object y)
+ {
+ return base.Compare(y, x);
+ }
+ }
+ ///
+ /// Sort by flat node index.
+ ///
+ public class NodeFlatIndexComparer : IComparer
+ {
+ private AdvTree _TreeControl = null;
+ ///
+ /// Creates new instance of NodeComparer class. You can use NodeComparer to sort the nodes by specific column/cell by calling
+ /// NodeCollection.Sort method and pass new instance of NodeComparer class.
+ ///
+ public NodeFlatIndexComparer(AdvTree treeControl)
+ {
+ _TreeControl = treeControl;
+ }
+ #region IComparer Members
+
+ public virtual int Compare(object x, object y)
+ {
+ Node nx = (Node)x;
+ Node ny = (Node)y;
+
+ if (_TreeControl.GetNodeFlatIndex(nx) < _TreeControl.GetNodeFlatIndex(ny))
+ return -1;
+ else
+ return 1;
+ }
+
+ #endregion
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/NodeConnector.cs b/PROMS/DotNetBar Source Code/AdvTree/NodeConnector.cs
new file mode 100644
index 00000000..2ae2268e
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/NodeConnector.cs
@@ -0,0 +1,215 @@
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents node connector. Node connector is the line that is drawn to indicate connection between child and parent node.
+ ///
+ [ToolboxItem(false),System.ComponentModel.DesignTimeVisible(false),TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+ public class NodeConnector:Component
+ {
+ #region Private Variables
+ private int m_LineWidth=1;
+ private Color m_LineColor=SystemColors.Highlight;
+ private eNodeConnectorType m_ConnectorType=eNodeConnectorType.Line;
+ //private bool m_UnderlineNoBorderNode=true;
+ //private eConnectorCap m_EndCap=eConnectorCap.Ellipse;
+ //private eConnectorCap m_StartCap=eConnectorCap.None;
+ //private Size m_EndCapSize=new Size(5,5);
+ //private Size m_StartCapSize=new Size(5,5);
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs when appearance of the connector has changed as result of changed settings on the connector.
+ ///
+ public event EventHandler AppearanceChanged;
+ #endregion
+
+ #region Public Interface
+ ///
+ /// Default Constructor.
+ ///
+ public NodeConnector()
+ {
+ }
+
+ ///
+ /// Creates new instance of the object with specified parameters.
+ ///
+ /// Connector line width.
+ /// Connector type.
+ public NodeConnector(int lineWidth, eNodeConnectorType type)
+ {
+ this.LineWidth=lineWidth;
+ this.ConnectorType=type;
+ }
+
+ ///
+ /// Gets or sets the connector line width.
+ ///
+ [Browsable(true),DefaultValue(1),Category("Appearance"),Description("Indicates connector line width.")]
+ public int LineWidth
+ {
+ get {return m_LineWidth;}
+ set
+ {
+ m_LineWidth=value;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the color of the connector line.
+ ///
+ [Browsable(true),Category("Appearance"),Description("Indicates color of the connector line.")]
+ public Color LineColor
+ {
+ get {return m_LineColor;}
+ set
+ {
+ m_LineColor=value;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Returns true if editor should serialize LineColor property.
+ ///
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeLineColor()
+ {
+ return m_LineColor!=SystemColors.Highlight;
+ }
+
+ ///
+ /// Gets or sets the type of the connector.
+ ///
+ ///
+ /// See eNodeConnectorType enum for list of
+ /// available connectors.
+ ///
+ /// eNodeConnectorType Enumeration
+ [Browsable(false),DefaultValue(eNodeConnectorType.Line),Category("Appearance"),Description("Indicates visual type of the connector.")]
+ public eNodeConnectorType ConnectorType
+ {
+ get {return m_ConnectorType;}
+ set
+ {
+ m_ConnectorType=value;
+ OnAppearanceChanged();
+ }
+ }
+
+ private DashStyle _DashStyle = DashStyle.Dot;
+ ///
+ /// Gets or sets the DashStyle for the connector line. Default value is DashStyle.Dot.
+ ///
+ [DefaultValue(DashStyle.Dot), Category("Appearance"), Description("Indicates DashStyle for the connector line")]
+ public DashStyle DashStyle
+ {
+ get { return _DashStyle; }
+ set { _DashStyle = value; }
+ }
+
+ /////
+ ///// Gets or sets whether the child node without borders is underlined as a
+ ///// continuation of the connector from node's parent. Default value is true.
+ /////
+ /////
+ ///// To enhance visual appearance of the connectors that are connecting to the node
+ ///// with no borders assigned the connector is continued as a single line under the node
+ ///// when this property is set to true (default) value.
+ /////
+ //[Browsable(true), DefaultValue(true), Category("Behavior"), Description("Indicates whether connector is drawn under the nodes with no borders assigned.")]
+ //public bool UnderlineNoBorderNode
+ //{
+ // get { return m_UnderlineNoBorderNode; }
+ // set
+ // {
+ // m_UnderlineNoBorderNode = value;
+ // OnAppearanceChanged();
+ // }
+ //}
+
+ /////
+ ///// Gets or sets the type of the cap that connector is ended with. Note that connector starts with parent node and ends with the child node. Default value is Ellipse.
+ /////
+ //[Browsable(true),DefaultValue(eConnectorCap.Ellipse),Category("Appearance"),Description("Indicates type of the cap that connector is ended with.")]
+ //public eConnectorCap EndCap
+ //{
+ // get {return m_EndCap;}
+ // set
+ // {
+ // m_EndCap=value;
+ // OnAppearanceChanged();
+ // }
+ //}
+
+ /////
+ ///// Gets or sets the size of the end cap.
+ /////
+ //[Browsable(true),Category("Appearance"),Description("Indicates the size of the end cap.")]
+ //public System.Drawing.Size EndCapSize
+ //{
+ // get {return m_EndCapSize;}
+ // set
+ // {
+ // m_EndCapSize=value;
+ // OnAppearanceChanged();
+ // }
+ //}
+
+ /////
+ ///// Returns true if EndCapSize property should be serialized by editor.
+ /////
+ /////
+ //[Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ //public bool ShouldSerializeEndCapSize()
+ //{
+ // return (m_EndCapSize.Width!=5 || m_EndCapSize.Height!=5);
+ //}
+ #endregion
+
+ #region Private Implementation
+ private void OnAppearanceChanged()
+ {
+ if(AppearanceChanged!=null)
+ AppearanceChanged(this,new EventArgs());
+ }
+ #endregion
+
+// ///
+// /// Gets or sets the type of the cap that connector is started with. Note that connector starts with parent node and ends with the child node. Default value is None.
+// ///
+// [Browsable(true),DefaultValue(eConnectorCap.None),Category("Appearance"),Description("Indicates type of the cap that connector is starts with.")]
+// public eConnectorCap StartCap
+// {
+// get {return m_StartCap;}
+// set {m_StartCap=value;}
+// }
+//
+// ///
+// /// Gets or sets the size of the start cap.
+// ///
+// [Browsable(true),Category("Appearance"),Description("Indicates the size of the start cap.")]
+// public System.Drawing.Size StartCapSize
+// {
+// get {return m_StartCapSize;}
+// set {m_StartCapSize=value;}
+// }
+//
+// ///
+// /// Returns true if StartCapSize property should be serialized by editor.
+// ///
+// ///
+// [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+// public bool ShouldSerializeStartCapSize()
+// {
+// return (m_StartCapSize.Width!=5 || m_StartCapSize.Height!=5);
+// }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/NodeOperations.cs b/PROMS/DotNetBar Source Code/AdvTree/NodeOperations.cs
new file mode 100644
index 00000000..13e6cf47
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/NodeOperations.cs
@@ -0,0 +1,1700 @@
+using System;
+using System.Drawing;
+using System.Text;
+using DevComponents.AdvTree.Display;
+using System.Collections;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents node operations.
+ ///
+ internal class NodeOperations
+ {
+ ///
+ /// Returns full path to the given node.
+ ///
+ /// Node to return path to.
+ /// Full path to the node.
+ public static string GetFullPath(Node node,string pathSeparator)
+ {
+ if(node==null)
+ throw new ArgumentNullException("node");
+
+ StringBuilder sb=new StringBuilder(node.Text);
+ node=node.Parent;
+ while(node!=null)
+ {
+ sb.Insert(0, node.Text + pathSeparator);
+ node=node.Parent;
+ }
+
+ return sb.ToString();
+ }
+
+ ///
+ /// Gets the last child tree node. The LastNode is the last child Node in the NodeCollection stored in the Nodes property of the current tree node. If the Node has no child tree node, the LastNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ /// Reference node.
+ /// Last node if found or null if there is no last node.
+ public static Node GetLastNode(Node node)
+ {
+ if(node.Nodes.Count>0)
+ {
+ return node.Nodes[node.Nodes.Count-1];
+ }
+ return null;
+ }
+
+ ///
+ /// Returns last rendered node on screen.
+ ///
+ /// Tree control.
+ /// Last rendered node or null
+ public static Node GetLastDisplayedNode(AdvTree tree)
+ {
+ Rectangle r = tree.NodeLayout.ClientArea;
+ Node node = tree.SelectedNode;
+ if (node == null) node = GetFirstVisibleNode(tree);
+ Point scrollPos = Point.Empty;
+ if (tree.AutoScroll)
+ scrollPos = tree.GetAutoScrollPositionOffset();
+
+ // Find last fully rendered node
+ Node lastNode = null;
+ if (r.IntersectsWith(node.Bounds))
+ lastNode = node;
+ while (node != null)
+ {
+ node = NodeOperations.GetNextVisibleNode(node);
+ if (node != null && node.Selectable)
+ {
+ Rectangle nodeRect = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, scrollPos);
+ if (nodeRect.Bottom > r.Bottom)
+ break;
+ else if (r.IntersectsWith(nodeRect))
+ lastNode = node;
+ }
+ }
+
+ return lastNode;
+ }
+
+ ///
+ /// Returns first rendered node on screen.
+ ///
+ /// Tree control.
+ /// Last rendered node or null
+ public static Node GetFirstDisplayedNode(AdvTree tree)
+ {
+ Rectangle r = tree.GetInnerRectangle();
+ r.Y += tree.ColumnHeaderHeight;
+ r.Height -= tree.ColumnHeaderHeight;
+
+ Node node = tree.SelectedNode;
+ if (node == null) node = GetFirstVisibleNode(tree);
+ Point scrollPos = Point.Empty;
+ if (tree.AutoScroll)
+ scrollPos = tree.GetAutoScrollPositionOffset();
+ // Find last fully rendered node
+ Node lastNode = null;
+ if (r.IntersectsWith(node.Bounds))
+ lastNode = node;
+ while (node != null)
+ {
+ node = NodeOperations.GetPreviousVisibleNode(node);
+ if (node != null && node.Selectable)
+ {
+ Rectangle nodeRect = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, scrollPos);
+ if (r.IntersectsWith(nodeRect))
+ lastNode = node;
+ else if (nodeRect.Y < r.Y)
+ break;
+ }
+ }
+
+ return lastNode;
+ }
+
+ ///
+ /// Gets first visible node.
+ ///
+ /// Reference to tree.
+ /// Last visible node found or null
+ public static Node GetFirstVisibleNode(AdvTree tree)
+ {
+ if (tree.Nodes.Count == 0) return null;
+
+ Node node = tree.DisplayRootNode == null ? tree.Nodes[0] : tree.DisplayRootNode;
+ if (node.Visible)
+ return node;
+ return GetNextVisibleNode(node);
+ }
+
+ ///
+ /// Gets last visible node in tree control.
+ ///
+ /// Reference to tree.
+ /// Last visible node found or null
+ public static Node GetLastVisibleNode(AdvTree tree)
+ {
+ if (tree.Nodes.Count == 0) return null;
+
+ Node node = tree.DisplayRootNode == null ? tree.Nodes[tree.Nodes.Count - 1] : tree.DisplayRootNode;
+ if (node.Visible)
+ {
+ if (node.Nodes.Count > 0 && node.Expanded)
+ {
+ Node child = GetLastVisibleChildNode(node);
+ if (child != null)
+ {
+ while (child.Nodes.Count > 0 && child.Expanded)
+ {
+ Node child1 = GetLastVisibleChildNode(child);
+ if (child1 == null) return child;
+ child = child1;
+ }
+ return child;
+ }
+ }
+ return node;
+ }
+ return GetPreviousVisibleNode(node);
+ }
+
+ ///
+ /// Gets last visible top-level node in tree control.
+ ///
+ /// Reference to tree.
+ /// Last visible node found or null
+ public static Node GetLastVisibleTopLevelNode(AdvTree tree)
+ {
+ if (tree.Nodes.Count == 0) return null;
+
+ NodeCollection col = tree.Nodes;
+ if (tree.DisplayRootNode != null) col = tree.DisplayRootNode.Nodes;
+
+ for (int i = col.Count - 1; i >= 0; i--)
+ {
+ if (col[i].Visible)
+ return col[i];
+ }
+
+ return null;
+ }
+
+ ///
+ /// Gets the next sibling tree node. The NextNode is the next sibling Node in the NodeCollection stored in the Nodes property of the tree node's parent Node. If there is no next tree node, the NextNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ /// Reference node.
+ /// Node object or null if node cannot be found.
+ public static Node GetNextNode(Node node)
+ {
+ if(node==null)
+ return null;
+ NodeCollection parentNodes=null;
+ if(node.Parent!=null)
+ parentNodes=node.Parent.Nodes;
+ else if(node.internalTreeControl!=null)
+ parentNodes=node.internalTreeControl.Nodes;
+
+ if(parentNodes!=null)
+ {
+ int index=parentNodes.IndexOf(node);
+ if(index
+ /// Returns next visible sibling tree node.
+ ///
+ /// Reference node
+ /// Node object or null if next visible node cannot be found
+ public static Node GetNextVisibleSibling(Node node)
+ {
+ if(node==null)
+ return null;
+ Node ret = GetNextNode(node);
+ while(ret!=null && !ret.Visible)
+ ret = GetNextNode(ret);
+ return ret;
+ }
+
+ ///
+ /// Gets the next visible tree node. The NextVisibleNode can be a child, sibling, or a tree node from another branch. If there is no next tree node, the NextVisibleNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ /// Reference node.
+ /// Node object or null if node cannot be found.
+ public static Node GetNextVisibleNode(Node node)
+ {
+ Node nextVisibleNode=null;
+
+ // First see whether all parent nodes are expanded and if not find the first one that is
+ Node parent=node.Parent;
+ Node lastNotExpanded=null;
+ while(parent!=null)
+ {
+ if(!parent.Expanded)
+ lastNotExpanded=parent;
+ parent=parent.Parent;
+ }
+ if(lastNotExpanded!=null)
+ {
+ // Last parent node expanded
+ if(lastNotExpanded.Parent!=null)
+ lastNotExpanded=lastNotExpanded.Parent;
+ while (lastNotExpanded != null)
+ {
+ lastNotExpanded = GetNextNode(lastNotExpanded);
+ if (lastNotExpanded != null && lastNotExpanded.Visible) return lastNotExpanded;
+ }
+ }
+
+ // Walk into the child nodes
+ if (node.Expanded && node.Nodes.Count > 0)
+ {
+ foreach (Node n in node.Nodes)
+ {
+ if (n.Visible) return n;
+ }
+ //return null;
+ }
+
+ // Get next sibling
+ nextVisibleNode = GetAnyNextNode(node);
+ while (nextVisibleNode != null)
+ {
+ if (nextVisibleNode.Visible && nextVisibleNode.IsVisible)
+ return nextVisibleNode;
+ nextVisibleNode = GetAnyNextNode(nextVisibleNode);
+ }
+
+ // Walk-up...
+ //while (nextVisibleNode == null && node != null)
+ //{
+ // node = node.Parent;
+ // nextVisibleNode = GetAnyNextNode(node);
+ // if (nextVisibleNode != null && !nextVisibleNode.Visible)
+ // nextVisibleNode = null;
+ //}
+ return nextVisibleNode;
+ }
+
+ ///
+ /// Gets the next visible tree node. The NextVisibleNode can be a child, sibling, or a tree node from another branch. If there is no next tree node, the NextVisibleNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ /// Reference node.
+ /// Node object or null if node cannot be found.
+ public static Node GetAnyNextNode(Node node)
+ {
+ Node nextNode = null;
+
+ // Walk into the child nodes
+ if (node.Nodes.Count > 0)
+ {
+ return node.Nodes[0];
+ }
+
+ // Get next sibling
+ nextNode = GetNextNode(node);
+
+ // Walk-up...
+ if (nextNode == null)
+ {
+ while (nextNode == null && node != null)
+ {
+ node = node.Parent;
+ nextNode = GetNextNode(node);
+ }
+ }
+
+ return nextNode;
+ }
+
+ ///
+ /// Gets a value indicating whether the tree node is visible. Node is considered to be visible when it's Visible property is set to true and path to the node is available i.e. all parent nodes are expanded.
+ ///
+ ///
+ ///
+ public static bool GetIsNodeVisible(Node node)
+ {
+ if(!node.Visible)
+ return false;
+
+ Node n=node;
+ while(n.Parent!=null)
+ {
+ n=n.Parent;
+ if(!n.Expanded || !n.Visible)
+ return false;
+ }
+ return true;
+ }
+
+ ///
+ /// Returns whether node is displayed on the screen and visible to the user. When node is outside of the viewable area this property will return false. It will also return false if node is not visible.
+ ///
+ ///
+ ///
+ public static bool GetIsNodeDisplayed(Node node)
+ {
+ if(!node.Visible || !GetIsNodeVisible(node))
+ return false;
+ AdvTree tree=node.TreeControl;
+ if(tree!=null)
+ {
+ Rectangle r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds,node,tree.NodeDisplay.Offset);
+ return tree.ClientRectangle.IntersectsWith(r);
+ }
+ return false;
+ }
+
+ ///
+ /// Gets the zero based index of position of the tree node in the tree node collection. -1 is returned if node is not added to the nodes collection.
+ ///
+ /// Reference node.
+ /// Zero based index or -1 if node is not in collection.
+ public static int GetNodeIndex(Node node)
+ {
+ if (node.Parent == null)
+ {
+ AdvTree tree = node.TreeControl;
+ if (tree != null)
+ return tree.Nodes.IndexOf(node);
+ return -1;
+ }
+ return node.Parent.Nodes.IndexOf(node);
+ }
+
+ ///
+ /// Gets the previous sibling tree node. The PrevNode is the previous sibling Node in the NodeCollection stored in the Nodes property of the tree node's parent Node. If there is no previous tree node, the PrevNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ /// Reference node.
+ /// Node object or null if node cannot be found.
+ public static Node GetPreviousNode(Node node)
+ {
+ if(node==null)
+ return null;
+ NodeCollection parentNodes=null;
+ if(node.Parent!=null)
+ parentNodes=node.Parent.Nodes;
+ else if(node.internalTreeControl!=null)
+ parentNodes=node.internalTreeControl.Nodes;
+
+ if(parentNodes!=null)
+ {
+ int index=parentNodes.IndexOf(node);
+ if(index>0)
+ return parentNodes[index-1];
+ }
+
+ return null;
+ }
+
+ /////
+ ///// Gets the previous visible tree node. The PrevVisibleNode can be a child, sibling, or a tree node from another branch. If there is no previous tree node, the PrevVisibleNode property returns a null reference (Nothing in Visual Basic).
+ /////
+ ///// Reference node.
+ ///// Node object or null if node cannot be found.
+ //public static Node GetPreviousDisplayedNode(Node node)
+ //{
+ // Node referenceNode = node;
+ // do
+ // {
+ // referenceNode = GetPreviousVisibleNode(referenceNode);
+ // if (referenceNode != null && referenceNode.IsVisible) break;
+ // } while (referenceNode != null);
+ // return referenceNode;
+ //}
+
+ ///
+ /// Gets the previous visible tree node. The PrevVisibleNode can be a child, sibling, or a tree node from another branch. If there is no previous tree node, the PrevVisibleNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ /// Reference node.
+ /// Node object or null if node cannot be found.
+ public static Node GetPreviousVisibleNode(Node node)
+ {
+ Node prevVisibleNode=null;
+
+ // First see whether all parent nodes are expanded and if not find the first one that is
+ Node referenceNode=node.Parent;
+ Node lastNotExpanded=null;
+ while(referenceNode!=null)
+ {
+ if(!referenceNode.Expanded)
+ lastNotExpanded=referenceNode;
+ referenceNode=referenceNode.Parent;
+ }
+ if (lastNotExpanded != null)
+ {
+ if (lastNotExpanded.IsVisible) return lastNotExpanded;
+ referenceNode = lastNotExpanded;
+ }
+ else
+ referenceNode = node;
+
+ // Walk into the previous node parent
+ if(referenceNode.Parent!=null)
+ {
+ if (referenceNode.Parent.Nodes.IndexOf(referenceNode) > 0)
+ {
+ prevVisibleNode = GetAnyPreviousNode(referenceNode);
+ while (prevVisibleNode != null)
+ {
+ if (prevVisibleNode.IsVisible) break;
+ prevVisibleNode = GetAnyPreviousNode(prevVisibleNode);
+ }
+ if (prevVisibleNode != null) return prevVisibleNode;
+ }
+ else
+ {
+ while (referenceNode.Parent != null)
+ {
+ if (referenceNode.Parent.IsVisible)
+ return referenceNode.Parent;
+ referenceNode = referenceNode.Parent;
+ }
+ if (referenceNode.TreeControl != null)
+ prevVisibleNode = GetAnyPreviousNode(referenceNode);
+ }
+ }
+ else if (referenceNode.TreeControl != null)
+ {
+ prevVisibleNode = GetPreviousNode(referenceNode);
+ if (prevVisibleNode != null && (!prevVisibleNode.Visible || !prevVisibleNode.Selectable))
+ {
+ while (prevVisibleNode != null && (!prevVisibleNode.Visible || !prevVisibleNode.Selectable))
+ prevVisibleNode = GetPreviousNode(prevVisibleNode);
+ }
+ }
+ else
+ return null;
+
+ if(prevVisibleNode==null)
+ return null;
+
+ // Walk into the node
+ while(prevVisibleNode.Expanded && prevVisibleNode.Nodes.Count>0)
+ {
+ prevVisibleNode = prevVisibleNode.Nodes[prevVisibleNode.Nodes.Count - 1];
+ }
+
+ return prevVisibleNode;
+ }
+
+ ///
+ /// Gets the previous tree node. The Previous Node can be a child, sibling, or a tree node from another branch. If there is no previous tree node, the PrevNode property returns a null reference (Nothing in Visual Basic).
+ ///
+ /// Reference node.
+ /// Node object or null if node cannot be found.
+ public static Node GetAnyPreviousNode(Node node)
+ {
+ Node prevNode = null;
+
+ Node referenceNode = node;
+
+ // Walk into the previous node parent
+ if (referenceNode.Parent != null)
+ {
+ if (referenceNode.Parent.Nodes.IndexOf(referenceNode) > 0)
+ {
+ prevNode = GetPreviousNode(referenceNode);
+ }
+ else
+ {
+ return referenceNode.Parent;
+ }
+ }
+ else if (referenceNode.TreeControl != null)
+ prevNode = GetPreviousNode(referenceNode);
+ else
+ return null;
+
+ if (prevNode == null)
+ return null;
+
+ // Walk into the node
+ while (prevNode.Nodes.Count > 0)
+ {
+ prevNode = prevNode.Nodes[prevNode.Nodes.Count - 1];
+ }
+
+ return prevNode;
+ }
+
+ ///
+ /// Returns true if node passed is considered root node for display purposes.
+ ///
+ /// Reference to the tree control.
+ /// Node to test.
+ /// true if node is root node for display purposes otherwise false.
+ public static bool IsRootNode(AdvTree tree, Node node)
+ {
+ if(node.Parent==null || node==tree.DisplayRootNode)
+ return true;
+ return false;
+ }
+
+ ///
+ /// Ensures that the cell is visible, expanding nodes and scrolling the control as necessary.
+ ///
+ /// Cell to be made visible.
+ public static void EnsureVisible(Cell cell)
+ {
+ Node parentNode = cell.Parent;
+ if (parentNode == null) return;
+ AdvTree tree = parentNode.TreeControl;
+ if (tree == null) return;
+
+ EnsureVisible(parentNode, false);
+
+ Rectangle r = NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds, cell, tree.NodeDisplay.Offset);
+
+ if (tree != null && tree.AutoScroll)
+ {
+ if (tree.Zoom != 1)
+ {
+ r = tree.GetScreenRectangle(r);
+ }
+ Rectangle treeClientRectangle = tree.GetInnerRectangle();
+ if (tree.VScrollBar != null) treeClientRectangle.Width -= tree.VScrollBar.Width;
+ if (tree.HScrollBar != null) treeClientRectangle.Height -= tree.HScrollBar.Height;
+
+ if (!treeClientRectangle.Contains(r))
+ {
+ Point p = tree.NodeDisplay.Offset;
+ p.Y = tree.AutoScrollPosition.Y;
+ if (r.X < treeClientRectangle.X)
+ p.X -= r.X;
+ else if (r.X > treeClientRectangle.Right)
+ p.X += (r.Right - treeClientRectangle.Right);
+ // Scroll it to show the cell
+ if (!tree.IsLayoutPending)
+ tree.AutoScrollPosition = p;
+ }
+ }
+ }
+
+ ///
+ /// Ensures that the node is visible, expanding nodes and scrolling the control as necessary.
+ ///
+ /// Node to be made visible.
+ public static void EnsureVisible(Node reference, bool scrollHorizontally)
+ {
+ EnsureVisible(reference, scrollHorizontally, eEnsureVisibleOption.Middle);
+ }
+
+ ///
+ /// Ensures that the node is visible, expanding nodes and scrolling the control as necessary.
+ ///
+ /// Node to be made visible.
+ public static void EnsureVisible(Node reference, bool scrollHorizontally, eEnsureVisibleOption scrollPositionOption)
+ {
+ // First expand all parents
+ AdvTree tree = reference.TreeControl;
+ if (tree == null || tree.IsUpdateSuspended) return;
+
+ tree.SuspendPaint = true;
+ try
+ {
+ Node node = reference;
+ bool layout = false;
+ while (node.Parent != null)
+ {
+ if (!node.Parent.Expanded)
+ {
+ node.Parent.Expand();
+ layout = true;
+ }
+ node = node.Parent;
+ }
+
+ if (layout || tree.IsLayoutPending)
+ tree.RecalcLayoutInternal();
+
+ // Adjust for tree never being displayed but it has been scrolled
+ Point offset = tree.NodeDisplay.Offset;
+ if (offset.IsEmpty && tree.AutoScroll && !tree.AutoScrollPosition.IsEmpty)
+ offset = tree.GetAutoScrollPositionOffset();
+
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, reference, offset);
+ if (tree != null && tree.AutoScroll)
+ {
+ if (tree.Zoom != 1)
+ {
+ r = tree.GetScreenRectangle(r);
+ }
+ Rectangle treeClientRectangle = tree.GetInnerRectangle();
+ if (tree.VScrollBar != null) treeClientRectangle.Width -= tree.VScrollBar.Width;
+ if (tree.HScrollBar != null) treeClientRectangle.Height -= tree.HScrollBar.Height;
+ int treeColumnHeaderHeight = tree.ColumnHeaderHeight;
+ treeClientRectangle.Y += treeColumnHeaderHeight;
+ treeClientRectangle.Height -= treeColumnHeaderHeight;
+
+ if (!treeClientRectangle.Contains(r))
+ {
+ Point p = tree.AutoScrollPosition; // tree.NodeDisplay.Offset;
+ if (scrollHorizontally)
+ {
+ /*if (r.Right > treeClientRectangle.Right)
+ p.X -= r.Right - treeClientRectangle.Right;
+ else*/
+ if (r.X < treeClientRectangle.X)
+ p.X -= r.X;
+ if (p.X > 0) p.X = -p.X;
+ if (p.X > -10 && p.X < 0 || p.X < 11 && p.X > 0) p.X = 0; // Snap to left
+ }
+ if (r.Height > treeClientRectangle.Height * .8)
+ {
+ p.Y = -Math.Max(0, (r.Y - 4));
+ }
+ else if (r.Bottom > treeClientRectangle.Bottom)
+ {
+ if (scrollPositionOption == eEnsureVisibleOption.Bottom)
+ {
+ p.Y -= r.Bottom - treeClientRectangle.Bottom + r.Height;
+ }
+ else if (scrollPositionOption == eEnsureVisibleOption.Middle)
+ {
+ p.Y -= r.Bottom - (treeClientRectangle.Bottom - treeClientRectangle.Height / 2) + r.Height / 2;
+ }
+ else if (scrollPositionOption == eEnsureVisibleOption.Top)
+ {
+ p.Y -= r.Top - (treeClientRectangle.Bottom - treeClientRectangle.Height);
+ }
+ }
+ else if (r.Y < treeClientRectangle.Y)
+ {
+ if (scrollPositionOption == eEnsureVisibleOption.Top)
+ {
+ p.Y -= (r.Y - treeColumnHeaderHeight);
+ }
+ else if (scrollPositionOption == eEnsureVisibleOption.Middle)
+ {
+ p.Y -= r.Y - (treeColumnHeaderHeight + treeClientRectangle.Height/2 + r.Height/2);
+ }
+ else if (scrollPositionOption == eEnsureVisibleOption.Bottom)
+ {
+ p.Y -= (r.Y - (treeColumnHeaderHeight - treeClientRectangle.Height + r.Height));
+ }
+ }
+ if (p.Y > -10 && p.Y < 0 || /*p.Y < 11 &&*/ p.Y > 0) p.Y = 0; // Snap to top
+ // Scroll it to show the node
+ if (!tree.IsLayoutPending)
+ tree.AutoScrollPosition = p;
+ }
+ }
+ }
+ finally
+ {
+ if (tree != null)
+ tree.SuspendPaint = false;
+ }
+ }
+
+ ///
+ /// Returns number of visible child nodes for given node.
+ ///
+ /// Reference node.
+ /// Number of visible child nodes.
+ public static int GetVisibleNodesCount(Node node)
+ {
+ if(node.Nodes.Count==0)
+ return 0;
+ int count=0;
+ foreach(Node n in node.Nodes)
+ {
+ if(n.Visible)
+ count++;
+ }
+ return count;
+ }
+
+ ///
+ /// Returns true if node has at least single visible child node.
+ ///
+ /// Reference node.
+ /// True if at least single child node is visible otherwise false.
+ public static bool GetAnyVisibleNodes(Node node)
+ {
+ if (!node.HasChildNodes)
+ return false;
+ foreach(Node n in node.Nodes)
+ {
+ if(n.Visible)
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified location.
+ ///
+ /// The Node at the specified point, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// The Point to evaluate and retrieve the node from.
+ /// Tree control to find node at.
+ public static NodeHitTestInfo GetNodeAt(AdvTree tree, Point p)
+ {
+ return GetNodeAt(tree,p.X,p.Y);
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified location.
+ ///
+ /// The TreeNode at the specified location, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// The X position to evaluate and retrieve the node from.
+ /// The Y position to evaluate and retrieve the node from.
+ /// Tree control to find node at.
+ public static NodeHitTestInfo GetNodeAt(AdvTree tree, int x, int y)
+ {
+ return GetNodeAt(tree, x, y, false);
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified location.
+ ///
+ /// The TreeNode at the specified location, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// Tree control to find node at.
+ /// The X position to evaluate and retrieve the node from.
+ /// The Y position to evaluate and retrieve the node from.
+ /// Enumerates rendered nodes only.
+ public static NodeHitTestInfo GetNodeAt(AdvTree tree, int x, int y, bool paintedOnly)
+ {
+ return GetNodeAt(tree, x, y, paintedOnly, false);
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified location.
+ ///
+ /// The TreeNode at the specified location, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// Tree control to find node at.
+ /// The X position to evaluate and retrieve the node from.
+ /// The Y position to evaluate and retrieve the node from.
+ /// Enumerates rendered nodes only.
+ public static NodeHitTestInfo GetNodeAt(AdvTree tree, int x, int y, bool paintedOnly, bool isUserInterfaceHitTest)
+ {
+ NodeHitTestInfo info = new NodeHitTestInfo();
+ if (tree.Nodes.Count == 0 || !tree.DisplayRectangle.Contains(x, y) && tree.Zoom == 1)
+ return info;
+
+ Node node=tree.Nodes[0];
+ Node retNode=null;
+
+ bool displayRootSet = false;
+ if (tree.DisplayRootNode != null)
+ {
+ node = tree.DisplayRootNode;
+ displayRootSet = true;
+ }
+
+ Point displayOffset = tree.NodeDisplay.Offset;
+
+ // Enumerate painted nodes first
+ if(tree.DisplayRectangle.Contains(x, y))
+ {
+ ArrayList paintedNodes = tree.NodeDisplay.PaintedNodes;
+ foreach (Node paintedNode in paintedNodes)
+ {
+ if (!paintedNode.IsDisplayed) continue;
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, paintedNode, displayOffset);
+ if (r.Contains(x, y))
+ {
+ info.NodeAt = paintedNode;
+ return info;
+ }
+ else if (NodeDisplay.HasColumnsVisible(paintedNode))
+ {
+ Rectangle headerBounds = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ColumnsBounds, paintedNode, displayOffset);
+ if (headerBounds.Contains(x, y))
+ {
+ info.ColumnsAt = paintedNode.NodesColumns;
+ return info;
+ }
+ }
+ }
+ }
+ if (paintedOnly) return info;
+
+ while (node != null)
+ {
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, node, displayOffset);
+ if (r.Contains(x, y))
+ {
+ retNode = node;
+ break;
+ }
+ else if (NodeDisplay.HasColumnsVisible(node))
+ {
+ Rectangle headerBounds = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ColumnsBounds, node, displayOffset);
+ if (headerBounds.Contains(x, y))
+ {
+ info.ColumnsAt = node.NodesColumns;
+ return info;
+ }
+ }
+ if (r.Y > y) break;
+
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ChildNodeBounds, node, displayOffset);
+ if (!r.Contains(x, y))
+ node = GetNextVisibleSibling(node);
+ else
+ node = node.NextVisibleNode;
+
+ if (displayRootSet && !IsChildNode(tree.DisplayRootNode, node)) break;
+ }
+
+ info.NodeAt = retNode;
+ return info;
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified vertical location.
+ ///
+ /// The TreeNode at the specified location, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// The Y position to evaluate and retrieve the node from.
+ /// Tree control to find node at.
+ public static NodeHitTestInfo GetNodeAt(AdvTree tree, int y)
+ {
+ return GetNodeAt(tree, y, false);
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified vertical location.
+ ///
+ /// The TreeNode at the specified location, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// The Y position to evaluate and retrieve the node from.
+ /// Tree control to find node at.
+ /// Enumerates rendered nodes only.
+ public static NodeHitTestInfo GetNodeAt(AdvTree tree, int y, bool paintedOnly)
+ {
+ return GetNodeAt(tree, y, paintedOnly, false);
+ }
+
+ ///
+ /// Retrieves the tree node that is at the specified vertical location.
+ ///
+ /// The TreeNode at the specified location, in tree view coordinates.
+ ///
+ /// You can pass the MouseEventArgs.X and MouseEventArgs.Y coordinates of the
+ /// MouseDown event as the x and y parameters.
+ ///
+ /// The Y position to evaluate and retrieve the node from.
+ /// Tree control to find node at.
+ /// Enumerates rendered nodes only.
+ public static NodeHitTestInfo GetNodeAt(AdvTree tree, int y, bool paintedOnly, bool isUserInterfaceHitTest)
+ {
+ NodeHitTestInfo info = new NodeHitTestInfo();
+ if (tree.Nodes.Count == 0 || !tree.DisplayRectangle.Contains(1, y) && tree.Zoom == 1)
+ return info;
+ Point displayOffset = tree.NodeDisplay.Offset;
+
+ // Enumerate painted node first
+ if (tree.DisplayRectangle.Contains(1, y))
+ {
+ ArrayList paintedNodes = tree.NodeDisplay.PaintedNodes;
+ foreach (Node paintedNode in paintedNodes)
+ {
+ if (!paintedNode.IsDisplayed && !(paintedNode.Expanded && paintedNode.HasColumns)) continue;
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, paintedNode, displayOffset);
+ if (y >= r.Y && y <= r.Bottom)
+ {
+ info.NodeAt = paintedNode;
+ return info;
+ }
+ else if(NodeDisplay.HasColumnsVisible(paintedNode))
+ {
+ Rectangle headerBounds = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ColumnsBounds, paintedNode, displayOffset);
+ if (y >= headerBounds.Y && y <= headerBounds.Bottom)
+ {
+ info.ColumnsAt = paintedNode.NodesColumns;
+ return info;
+ }
+ }
+ }
+ }
+ if (paintedOnly) return info;
+
+ Node node = tree.Nodes[0];
+ Node retNode = null;
+ if (tree.DisplayRootNode != null)
+ node = tree.DisplayRootNode;
+ while (node != null)
+ {
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, node, displayOffset);
+ if (node.Visible && y >= r.Y && y <= r.Bottom)
+ {
+ retNode = node;
+ break;
+ }
+ else if (NodeDisplay.HasColumnsVisible(node))
+ {
+ Rectangle headerBounds = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ColumnsBounds, node, displayOffset);
+ if (y >= headerBounds.Y && y <= headerBounds.Bottom)
+ {
+ info.ColumnsAt = node.NodesColumns;
+ return info;
+ }
+ }
+ if (isUserInterfaceHitTest && (r.Bottom + 16 < y || r.Y + 16 > y))
+ break;
+ r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ChildNodeBounds, node, displayOffset);
+ if (!(y >= r.Y && y <= r.Bottom))
+ node = GetNextVisibleSibling(node);
+ else
+ node = node.NextVisibleNode;
+ }
+
+ info.NodeAt = retNode;
+ return info;
+ }
+
+ public static TreeAreaInfo GetTreeAreaInfo(AdvTree tree, int x, int y)
+ {
+ TreeAreaInfo areaInfo=new TreeAreaInfo();
+
+ if (tree.Nodes.Count == 0 || !tree.DisplayRectangle.Contains(x, y) && tree.Zoom == 1)
+ return null;
+
+ Node node=tree.Nodes[0];
+ if(tree.DisplayRootNode!=null)
+ node = tree.DisplayRootNode;
+
+ if (tree.DisplayRootNode != null)
+ node = tree.DisplayRootNode;
+
+ Node previousNode = null;
+ Rectangle previousRectangle = Rectangle.Empty;
+
+ if (tree.View == eView.Tile)
+ {
+ while (node != null)
+ {
+ if (!node.IsDisplayed)
+ {
+ node = node.NextVisibleNode;
+ continue;
+ }
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, node, tree.NodeDisplay.Offset);
+ if (r.Contains(x, y))
+ {
+ areaInfo.NodeAt = node;
+ break;
+ }
+ if (y >= r.Y && y <= r.Bottom && node.HasChildNodes)
+ {
+ areaInfo.NodeAt = node;
+ break;
+ }
+ else if (previousNode != null && y > previousRectangle.Bottom && y < r.Y)
+ {
+ // Covers the case if point is between two nodes in the vertical space between nodes due to node vertical spacing
+ areaInfo.NodeAt = previousNode;
+ break;
+ }
+
+ previousNode = node;
+ previousRectangle = r;
+
+ node = node.NextVisibleNode;
+ }
+
+ }
+ else
+ {
+ while (node != null)
+ {
+ if (!node.IsDisplayed)
+ {
+ node = node.NextVisibleNode;
+ continue;
+ }
+ Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds, node, tree.NodeDisplay.Offset);
+ if (y >= r.Y && y <= r.Bottom)
+ {
+ areaInfo.NodeAt = node;
+ break;
+ }
+ else if (previousNode != null && y > previousRectangle.Bottom && y < r.Y)
+ {
+ // Covers the case if point is between two nodes in the vertical space between nodes due to node vertical spacing
+ areaInfo.NodeAt = previousNode;
+ break;
+ }
+
+ previousNode = node;
+ previousRectangle = r;
+
+ node = node.NextVisibleNode;
+ }
+ }
+ return areaInfo;
+ }
+
+ ///
+ /// Gets the count of visible child nodes (Visible=true) for given node.
+ ///
+ /// Reference to Node object.
+ /// Number of visible nodes.
+ public static int GetVisibleChildNodesCount(Node parent)
+ {
+ int count = 0;
+ foreach(Node node in parent.Nodes)
+ {
+ if(node.Visible)
+ count++;
+ }
+ return count;
+ }
+
+ ///
+ /// Gets the first visible child node or returns null if node cannot be found.
+ ///
+ /// Reference to Node object.
+ /// First visible node or null if node cannot be found.
+ public static Node GetFirstVisibleChildNode(Node parent)
+ {
+ foreach(Node node in parent.Nodes)
+ {
+ if(node.Visible)
+ return node;
+ }
+ return null;
+ }
+
+ ///
+ /// Gets the last visible child node or returns null if node cannot be found.
+ ///
+ /// Reference to Node object.
+ /// Last visible node or null if node cannot be found.
+ public static Node GetLastVisibleChildNode(Node parent)
+ {
+ NodeCollection col = parent.Nodes;
+ int c = col.Count - 1;
+ for (int i = c; i >=0; i--)
+ {
+ Node node = col[i];
+ if (node.Visible)
+ return node;
+ }
+
+ return null;
+ }
+
+ ///
+ /// Gets whether any node from array is child node of parent on any level.
+ ///
+ /// Reference to parent node.
+ /// Reference to child nodes.
+ ///
+ public static bool IsChildNode(Node parent, Node[] childNodes)
+ {
+ foreach (Node childNode in childNodes)
+ {
+ if (IsChildNode(parent, childNode))
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Gets whether node is child node of parent on any level.
+ ///
+ /// Reference to parent node.
+ /// Reference to child node.
+ ///
+ public static bool IsChildNode(Node parent, Node child)
+ {
+ if (parent == child || child == null || parent == null) return false;
+ while (child.Parent != null)
+ {
+ if (child.Parent == parent) return true;
+ child = child.Parent;
+ }
+ return false;
+ }
+
+ ///
+ /// Returns true if child node is child of any parent node at any level.
+ ///
+ /// Parent nodes array
+ /// Child node
+ /// true if child otherwise false
+ public static bool IsChildOfAnyParent(Node[] parents, Node child)
+ {
+ foreach (Node parent in parents)
+ {
+ if (IsChildNode(parent, child)) return true;
+ }
+ return false;
+ }
+
+ #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}, 114
+ string[] parts = key.Split('-');
+ int test = 0;
+ for(int i=parts.Length-1;i>=0;i--)
+ {
+ if(parts[i]=="CD8F")
+ test += 12;
+ else if(parts[i]=="CAB39962FC1F")
+ test += 2;
+ else if(parts[i]=="A9E9")
+ test += 3;
+ else if(parts[i]=="4911")
+ test += 7;
+ else if(parts[i]=="F962CEC7")
+ test += 13;
+ }
+
+ keyValidated2 = test + 77;
+
+ if(test==23)
+ return false;
+
+ return true;
+ }
+#endif
+
+#if TRIAL
+ private static Color m_ColorExpFlag=Color.Empty;
+ internal static int ColorCountExp=0;
+ internal static bool ColorExpAlt()
+ {
+ Color clr=SystemColors.Control;
+ Color clr2;
+ Color clr3;
+ clr2=clr;
+ if(clr2.ToArgb()==clr.ToArgb())
+ {
+ clr3=clr2;
+ }
+ else
+ {
+ clr3=clr;
+ }
+
+ ColorCountExp=clr.A;
+
+ if(!m_ColorExpFlag.IsEmpty)
+ {
+ return (m_ColorExpFlag==Color.Black?false:true);
+ }
+ try
+ {
+ Microsoft.Win32.RegistryKey key=Microsoft.Win32.Registry.ClassesRoot;
+ key=key.CreateSubKey("CLSID\\{C0093B14-207D-4406-826D-7186EF33C7E5}\\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>30)
+ {
+ m_ColorExpFlag=Color.White;
+ key.SetValue("","windows3.dll");
+ key.Close();
+ key=null;
+ return true;
+ }
+ if(((TimeSpan)DateTime.Today.Subtract(date)).TotalDays<0)
+ {
+ m_ColorExpFlag=Color.White;
+ key.SetValue("","windows2.dll");
+ key.Close();
+ key=null;
+ return true;
+ }
+ }
+ }
+ finally
+ {
+ if(key!=null)
+ key.Close();
+ }
+ }
+ catch{}
+ m_ColorExpFlag=Color.Black;
+ return false;
+ }
+#endif
+ #endregion
+
+ ///
+ /// Finds the node based on the Node.Name property.
+ ///
+ /// Reference to a tree control.
+ /// Reference to a node with given name or null if node cannot be found.
+ public static Node FindNodeByName(AdvTree advTree, string name)
+ {
+ return FindNodeByName(advTree.Nodes, name);
+ }
+
+ public static Node FindNodeByName(NodeCollection col, string name)
+ {
+ foreach (Node node in col)
+ {
+ if (node.Name == name)
+ return node;
+ if (node.HasChildNodes)
+ {
+ Node n2 = FindNodeByName(node.Nodes, name);
+ if (n2 != null) return n2;
+ }
+ }
+ return null;
+ }
+
+ public static void FindNodesByName(NodeCollection col, string name, bool searchAllChildren, ArrayList listToPopulate)
+ {
+ foreach (Node node in col)
+ {
+ if (node.Name == name)
+ listToPopulate.Add(node);
+ if (searchAllChildren && node.HasChildNodes)
+ {
+ FindNodesByName(node.Nodes, name, true, listToPopulate);
+ }
+ }
+ }
+
+ ///
+ /// Finds the node based on the Node.DataKey property.
+ ///
+ /// Reference to a tree control.
+ /// Reference to a node with given key or null if node cannot be found.
+ public static Node FindNodeByDataKey(AdvTree advTree, object key)
+ {
+ return FindNodeByDataKey(advTree.Nodes, key);
+ }
+ public static Node FindNodeByDataKey(NodeCollection col, object key)
+ {
+ foreach (Node node in col)
+ {
+ if (object.Equals(node.DataKey, key))
+ return node;
+ if (node.HasChildNodes)
+ {
+ Node n2 = FindNodeByDataKey(node.Nodes, key);
+ if (n2 != null) return n2;
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Finds the node based on the Node.BindingIndex property.
+ ///
+ /// Reference to a tree control.
+ /// Index to look for
+ public static Node FindNodeByBindingIndex(AdvTree advTree, int bindingIndex)
+ {
+ return FindNodeByBindingIndex(advTree.Nodes, bindingIndex);
+ }
+ public static Node FindNodeByBindingIndex(NodeCollection col, int bindingIndex)
+ {
+ foreach (Node node in col)
+ {
+ if (node.BindingIndex == bindingIndex)
+ return node;
+ if (node.HasChildNodes)
+ {
+ Node n2 = FindNodeByBindingIndex(node.Nodes, bindingIndex);
+ if (n2 != null) return n2;
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Returns next visible cell in node.
+ ///
+ /// Reference to a node
+ /// The index at which to start search.
+ /// Reference to cell or null if there are no visible cells
+ public static Cell GetNextVisibleCell(Node node, int startIndex)
+ {
+ return GetVisibleCell(node, startIndex, 1);
+ }
+ ///
+ /// Returns previous visible cell in node.
+ ///
+ /// Reference to a node
+ /// The index at which to start search.
+ /// Reference to cell or null if there are no visible cells
+ public static Cell GetPreviousVisibleCell(Node node, int startIndex)
+ {
+ return GetVisibleCell(node, startIndex, -1);
+ }
+
+ public static Cell GetVisibleCell(Node node, int startIndex, int direction)
+ {
+ AdvTree tree = node.TreeControl;
+ if (tree != null && tree.AllowUserToReorderColumns && tree.Columns.Count > 0)
+ {
+ // Convert the startIndex to display index
+ startIndex = tree.Columns.GetDisplayIndex(tree.Columns[startIndex]);
+ startIndex += direction;
+
+ int c = direction > 0 ? tree.Columns.Count - 1 : 0;
+ int i = startIndex;
+ int loopCount = 0;
+ while (loopCount < 2)
+ {
+ if (i < 0)
+ {
+ i = tree.Columns.Count - 1;
+ loopCount++;
+ }
+ else if (i >= tree.Columns.Count)
+ {
+ i = 0;
+ loopCount++;
+ }
+ int cellIndex = tree.Columns.DisplayIndexMap[i];
+ if (node.Cells.Count>cellIndex && node.Cells[cellIndex].IsVisible) return node.Cells[cellIndex];
+ i += direction;
+ }
+ }
+ else
+ {
+ startIndex += direction;
+ int c = direction > 0 ? node.Cells.Count - 1 : 0;
+ int i = startIndex;
+ int loopCount = 0;
+ while (loopCount < 2)
+ {
+ if (i < 0)
+ {
+ i = node.Cells.Count - 1;
+ loopCount++;
+ }
+ else if (i >= node.Cells.Count)
+ {
+ i = 0;
+ loopCount++;
+ }
+
+ if (node.Cells[i].IsVisible) return node.Cells[i];
+ i += direction;
+ }
+ }
+
+ return null;
+ }
+
+ ///
+ /// Returns the zero based flat index of the node. Flat index is the index of the node as if tree structure
+ /// has been flattened into the list.
+ ///
+ /// Reference to parent tree control.
+ /// Reference to the node to return index for.
+ /// Zero based node index or -1 if index cannot be determined.
+ internal static int GetNodeFlatIndex(AdvTree tree, Node node)
+ {
+ if (node == null) throw new NullReferenceException("Parameter node cannot be null");
+ int count = 0;
+ Node currentNode = GetAnyPreviousNode(node);
+ while (currentNode != null)
+ {
+ count++;
+ currentNode = GetAnyPreviousNode(currentNode);
+ //if (currentNode != null && currentNode.Parent == null)
+ //{
+ // count += tree.Nodes.IndexOf(currentNode) + 1;
+ // break;
+ //}
+ }
+
+ return count;
+ }
+
+ ///
+ /// Returns node based on the flat index. Flat index is the index of the node as if tree structure
+ /// has been flattened into the list.
+ ///
+ /// Parent tree control.
+ /// Index to return node for.
+ /// Reference to a node or null if node at specified index cannot be found.
+ internal static Node GetNodeByFlatIndex(AdvTree advTree, int index)
+ {
+ if (index == -1 || advTree.Nodes.Count == 0) return null;
+
+ Node node = advTree.Nodes[0];
+ int count = 0;
+ while (node != null)
+ {
+ if (index == count)
+ return node;
+ node = GetAnyNextNode(node);
+ count++;
+ }
+
+ return null;
+ }
+
+ ///
+ /// Finds the first node that starts with the specified text. Node.Text property is searched.
+ ///
+ /// Parent tree control.
+ /// Partial text to look for
+ /// Reference node to start searching from
+ /// Gets or sets whether search ignores the letter case
+ /// Reference to a node or null if no node is found.
+ internal static Node FindNodeByText(AdvTree advTree, string text, Node startFromNode, bool ignoreCase)
+ {
+ if (startFromNode == null)
+ startFromNode = GetFirstVisibleNode(advTree);
+ else
+ startFromNode = GetAnyNextNode(startFromNode);
+ if (startFromNode == null) return null;
+
+ Node node = startFromNode;
+#if FRAMEWORK20
+ StringComparison comparison = ignoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture;
+ while (node != null)
+ {
+ if (node.Text.StartsWith(text, comparison))
+ return node;
+ node = GetAnyNextNode(node);
+ }
+#else
+ if(ignoreCase)
+ {
+ text = text.ToLower();
+ while (node != null)
+ {
+ if (node.Text.ToLower().StartsWith(text))
+ return node;
+ node = GetAnyNextNode(node);
+ }
+ }
+ else
+ {
+ while (node != null)
+ {
+ if (node.Text.StartsWith(text))
+ return node;
+ node = GetAnyNextNode(node);
+ }
+ }
+#endif
+ return null;
+ }
+
+ internal static Node FindNodeByCellText(
+ AdvTree advTree, string text, Node startFromNode, bool ignoreCase)
+ {
+ if (string.IsNullOrEmpty(text) == true)
+ return (null);
+
+ startFromNode = (startFromNode == null)
+ ? GetFirstVisibleNode(advTree) : GetAnyNextNode(startFromNode);
+
+ if (startFromNode == null)
+ return (null);
+
+ string[] s = text.Split(',');
+
+ for (int i = 0; i < s.Length; i++)
+ s[i] = s[i].Trim();
+
+ Node node = startFromNode;
+
+#if FRAMEWORK20
+ StringComparison comparison = (ignoreCase == true)
+ ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture;
+
+ while (node != null)
+ {
+ if (MatchedCell(node, s, comparison) == true)
+ return (node);
+
+ node = GetAnyNextNode(node);
+ }
+#else
+ if (ignoreCase == true)
+ {
+ for (int i = 0; i < s.Length; i++)
+ s[i] = s[i].ToLower();
+ }
+
+ while (node != null)
+ {
+ if (MatchedCell(node, s, ignoreCase) == true)
+ return (node);
+
+ node = GetAnyNextNode(node);
+ }
+#endif
+ return (null);
+ }
+
+#if FRAMEWORK20
+ private static bool MatchedCell(
+ Node node, string[] s, StringComparison comp)
+ {
+ for (int i = 0; i < s.Length; i++)
+ {
+ if (i >= node.Cells.Count)
+ break;
+
+ Cell cell = node.Cells[i];
+
+ if (cell.Text.StartsWith(s[i], comp) == false)
+ return (false);
+ }
+
+ return (true);
+ }
+#else
+ private static bool MatchedCell(Node node, string[] s, bool ignoreCase)
+ {
+ for (int i = 0; i < s.Length; i++)
+ {
+ if (i >= node.Cells.Count)
+ break;
+
+ Cell cell = node.Cells[i];
+
+ if (ignoreCase == true)
+ {
+ if (cell.Text.ToLower().StartsWith(s[i]) == false)
+ return (false);
+ }
+ else
+ {
+ if (cell.Text.StartsWith(s[i]) == false)
+ return (false);
+ }
+ }
+
+ return (true);
+ }
+#endif
+
+ internal static ColumnHeader GetCellColumnHeader(AdvTree tree, Cell cell)
+ {
+ int index = -1;
+ if (cell.Parent != null) index = cell.Parent.Cells.IndexOf(cell);
+
+ if (cell.Parent != null && cell.Parent.Parent != null && cell.Parent.Parent.NodesColumns.Count > 0 && index < cell.Parent.Parent.NodesColumns.Count)
+ {
+ return cell.Parent.Parent.NodesColumns[index];
+ }
+
+ if (tree != null && tree.Columns.Count > 0 && index < tree.Columns.Count)
+ return tree.Columns[index];
+
+ return null;
+ }
+
+ public static void InvalidateNodeLayout(Node node, bool invalidateChildNodes)
+ {
+ node.SizeChanged = true;
+ if (invalidateChildNodes && node.HasChildNodes)
+ {
+ foreach (Node item in node.Nodes)
+ {
+ InvalidateNodeLayout(item, true);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Returned as information about the node or its column header at given coordinates.
+ ///
+ internal class NodeHitTestInfo
+ {
+ public Node NodeAt = null;
+ public ColumnHeaderCollection ColumnsAt = null;
+ }
+
+ ///
+ /// Defines options for EnsureVisible method which brings node into the view.
+ ///
+ public enum eEnsureVisibleOption
+ {
+ ///
+ /// Scrolls the tree so node is displayed at the bottom of the tree, if possible.
+ ///
+ Bottom,
+ ///
+ /// Scrolls the tree so node is displayed in the middle of the tree, if possible.
+ ///
+ Middle,
+ ///
+ /// Scrolls the tree so node is displayed at the top of the tree, if possible.
+ ///
+ Top
+ }
+}
+
diff --git a/PROMS/DotNetBar Source Code/AdvTree/NodeStyles.cs b/PROMS/DotNetBar Source Code/AdvTree/NodeStyles.cs
new file mode 100644
index 00000000..1219088b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/NodeStyles.cs
@@ -0,0 +1,463 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Class that provides predefined styles for the nodes. Styles are defined as static memeber of the class
+ ///
+ public class NodeStyles
+ {
+ private static ElementStyle s_AppleStyle=null;
+ private static ElementStyle s_BlueStyle=null;
+ private static ElementStyle s_BlueLightStyle=null;
+ private static ElementStyle s_BlueNightStyle=null;
+ private static ElementStyle s_BlueMistStyle=null;
+ private static ElementStyle s_CyanStyle=null;
+ private static ElementStyle s_GreenStyle=null;
+ private static ElementStyle s_LemonStyle=null;
+ private static ElementStyle s_MagentaStyle=null;
+ private static ElementStyle s_OrangeStyle=null;
+ private static ElementStyle s_OrangeLightStyle=null;
+ private static ElementStyle s_PurpleStyle=null;
+ private static ElementStyle s_PurpleMistStyle=null;
+ private static ElementStyle s_RedStyle=null;
+ private static ElementStyle s_SilverStyle=null;
+ private static ElementStyle s_SilverMistStyle=null;
+ private static ElementStyle s_TanStyle=null;
+ private static ElementStyle s_TealStyle=null;
+ private static ElementStyle s_YellowStyle=null;
+ private static ElementStyle s_GrayStyle=null;
+
+ ///
+ /// Returns Apple element style
+ ///
+ public static ElementStyle Apple
+ {
+ get
+ {
+ if(s_AppleStyle==null)
+ s_AppleStyle = GetStyle(ePredefinedElementStyle.Apple);
+ return s_AppleStyle;
+ }
+ }
+
+ ///
+ /// Returns Blue element style
+ ///
+ public static ElementStyle Blue
+ {
+ get
+ {
+ if(s_BlueStyle==null)
+ s_BlueStyle= GetStyle(ePredefinedElementStyle.Blue);
+ return s_BlueStyle;
+ }
+ }
+
+ ///
+ /// Returns BlueLight element style
+ ///
+ public static ElementStyle BlueLight
+ {
+ get
+ {
+ if(s_BlueLightStyle==null)
+ s_BlueLightStyle= GetStyle(ePredefinedElementStyle.BlueLight);
+ return s_BlueLightStyle;
+ }
+ }
+
+ ///
+ /// Returns BlueNight element style
+ ///
+ public static ElementStyle BlueNight
+ {
+ get
+ {
+ if(s_BlueNightStyle==null)
+ s_BlueNightStyle= GetStyle(ePredefinedElementStyle.BlueNight);
+ return s_BlueNightStyle;
+ }
+ }
+
+ ///
+ /// Returns BlueMist element style
+ ///
+ public static ElementStyle BlueMist
+ {
+ get
+ {
+ if(s_BlueMistStyle==null)
+ s_BlueMistStyle= GetStyle(ePredefinedElementStyle.BlueMist);
+ return s_BlueMistStyle;
+ }
+ }
+
+ ///
+ /// Returns Cyan element style
+ ///
+ public static ElementStyle Cyan
+ {
+ get
+ {
+ if(s_CyanStyle==null)
+ s_CyanStyle= GetStyle(ePredefinedElementStyle.Cyan);
+ return s_CyanStyle;
+ }
+ }
+
+ ///
+ /// Returns Green element style
+ ///
+ public static ElementStyle Green
+ {
+ get
+ {
+ if(s_GreenStyle==null)
+ s_GreenStyle= GetStyle(ePredefinedElementStyle.Green);
+ return s_GreenStyle;
+ }
+ }
+
+ ///
+ /// Returns Lemon element style
+ ///
+ public static ElementStyle Lemon
+ {
+ get
+ {
+ if(s_LemonStyle==null)
+ s_LemonStyle= GetStyle(ePredefinedElementStyle.Lemon);
+ return s_LemonStyle;
+ }
+ }
+
+ ///
+ /// Returns Magenta element style
+ ///
+ public static ElementStyle Magenta
+ {
+ get
+ {
+ if(s_MagentaStyle==null)
+ s_MagentaStyle= GetStyle(ePredefinedElementStyle.Magenta);
+ return s_MagentaStyle;
+ }
+ }
+
+ ///
+ /// Returns Orange element style
+ ///
+ public static ElementStyle Orange
+ {
+ get
+ {
+ if(s_OrangeStyle==null)
+ s_OrangeStyle= GetStyle(ePredefinedElementStyle.Orange);
+ return s_OrangeStyle;
+ }
+ }
+
+ ///
+ /// Returns OrangeLight element style
+ ///
+ public static ElementStyle OrangeLight
+ {
+ get
+ {
+ if(s_OrangeLightStyle==null)
+ s_OrangeLightStyle= GetStyle(ePredefinedElementStyle.OrangeLight);
+ return s_OrangeLightStyle;
+ }
+ }
+
+ ///
+ /// Returns Purple element style
+ ///
+ public static ElementStyle Purple
+ {
+ get
+ {
+ if(s_PurpleStyle==null)
+ s_PurpleStyle= GetStyle(ePredefinedElementStyle.Purple);
+ return s_PurpleStyle;
+ }
+ }
+
+ ///
+ /// Returns PurpleMist element style
+ ///
+ public static ElementStyle PurpleMist
+ {
+ get
+ {
+ if(s_PurpleMistStyle==null)
+ s_PurpleMistStyle= GetStyle(ePredefinedElementStyle.PurpleMist);
+ return s_PurpleMistStyle;
+ }
+ }
+
+ ///
+ /// Returns Red element style
+ ///
+ public static ElementStyle Red
+ {
+ get
+ {
+ if(s_RedStyle==null)
+ s_RedStyle= GetStyle(ePredefinedElementStyle.Red);
+ return s_RedStyle;
+ }
+ }
+
+ ///
+ /// Returns Silver element style
+ ///
+ public static ElementStyle Silver
+ {
+ get
+ {
+ if(s_SilverStyle==null)
+ s_SilverStyle= GetStyle(ePredefinedElementStyle.Silver);
+ return s_SilverStyle;
+ }
+ }
+
+ ///
+ /// Returns SilverMist element style
+ ///
+ public static ElementStyle SilverMist
+ {
+ get
+ {
+ if(s_SilverMistStyle==null)
+ s_SilverMistStyle= GetStyle(ePredefinedElementStyle.SilverMist);
+ return s_SilverMistStyle;
+ }
+ }
+
+ ///
+ /// Returns Tan element style
+ ///
+ public static ElementStyle Tan
+ {
+ get
+ {
+ if(s_TanStyle==null)
+ s_TanStyle= GetStyle(ePredefinedElementStyle.Tan);
+ return s_TanStyle;
+ }
+ }
+
+ ///
+ /// Returns Teal element style
+ ///
+ public static ElementStyle Teal
+ {
+ get
+ {
+ if(s_TealStyle==null)
+ s_TealStyle= GetStyle(ePredefinedElementStyle.Teal);
+ return s_TealStyle;
+ }
+ }
+
+ ///
+ /// Returns Yellow element style
+ ///
+ public static ElementStyle Yellow
+ {
+ get
+ {
+ if(s_YellowStyle==null)
+ s_YellowStyle= GetStyle(ePredefinedElementStyle.Yellow);
+ return s_YellowStyle;
+ }
+ }
+
+ ///
+ /// Returns Gray element style
+ ///
+ public static ElementStyle Gray
+ {
+ get
+ {
+ if(s_GrayStyle==null)
+ s_GrayStyle= GetStyle(ePredefinedElementStyle.Gray);
+ return s_GrayStyle;
+ }
+ }
+
+ private static ElementStyle GetStyle(ePredefinedElementStyle c)
+ {
+ Color color1=Color.Empty;
+ Color color2=Color.Empty;
+ int gradientAngle = 90;
+ Color textColor=Color.Black;
+ Color borderColor = Color.DarkGray;
+
+ switch (c)
+
+ {
+ case ePredefinedElementStyle.Apple:
+ {
+ color1 = Color.FromArgb(232, 248, 224);
+ color2 = Color.FromArgb(173, 231, 146);
+ break;
+ }
+ case ePredefinedElementStyle.Blue:
+ {
+ color1 = Color.FromArgb(221, 230, 247);
+ color2 = Color.FromArgb(138, 168, 228);
+ break;
+ }
+ case ePredefinedElementStyle.BlueLight:
+ {
+ color1=Color.FromArgb(255,255,255);
+ color2=Color.FromArgb(210,224,252);
+ textColor=Color.FromArgb(69,84,115);
+ break;
+ }
+ case ePredefinedElementStyle.BlueMist:
+ {
+ color1 = Color.FromArgb(227, 236, 243);
+ color2 = Color.FromArgb(155, 187, 210);
+ break;
+ }
+ case ePredefinedElementStyle.BlueNight:
+ {
+ color1=Color.FromArgb(77,108,152);
+ color2=Color.Navy;
+ textColor=Color.White;
+ borderColor=Color.Navy;
+ break;
+ }
+ case ePredefinedElementStyle.Cyan:
+ {
+ color1 = Color.FromArgb(227, 236, 243);
+ color2 = Color.FromArgb(155, 187, 210);
+ break;
+ }
+ case ePredefinedElementStyle.Green:
+ {
+ color1 = Color.FromArgb(234, 240, 226);
+ color2 = Color.FromArgb(183, 201, 151);
+ break;
+ }
+ case ePredefinedElementStyle.Lemon:
+ {
+ color1 = Color.FromArgb(252, 253, 215);
+ color2 = Color.FromArgb(245, 249, 111);
+ break;
+ }
+ case ePredefinedElementStyle.Magenta:
+ {
+ color1 = Color.FromArgb(243, 229, 236);
+ color2 = Color.FromArgb(213, 164, 187);
+ break;
+ }
+ case ePredefinedElementStyle.Orange:
+ {
+ color1 = Color.FromArgb(252, 233, 217);
+ color2 = Color.FromArgb(246, 176, 120);
+ break;
+ }
+ case ePredefinedElementStyle.OrangeLight:
+ {
+ color1=Color.FromArgb(255,239,201);
+ color2=Color.FromArgb(242,210,132);
+ textColor=Color.FromArgb(117,83,2);
+ break;
+ }
+ case ePredefinedElementStyle.Purple:
+ {
+ color1 = Color.FromArgb(234, 227, 245);
+ color2 = Color.FromArgb(180, 158, 222);
+ break;
+ }
+ case ePredefinedElementStyle.PurpleMist:
+ {
+ color1 = Color.FromArgb(232, 227, 234);
+ color2 = Color.FromArgb(171, 156, 183);
+ break;
+ }
+ case ePredefinedElementStyle.Red:
+ {
+ color1 = Color.FromArgb(249, 225, 226);
+ color2 = Color.FromArgb(238, 149, 151);
+ break;
+ }
+ case ePredefinedElementStyle.Silver:
+ {
+ color1 = Color.FromArgb(225, 225, 232);
+ color2 = Color.FromArgb(149, 149, 170);
+ break;
+ }
+ case ePredefinedElementStyle.SilverMist:
+ {
+ color1 = Color.FromArgb(243,244,250);
+ color2=Color.FromArgb(155,153,183);
+ textColor=Color.FromArgb(87,86,113);
+ break;
+ }
+ case ePredefinedElementStyle.Tan:
+ {
+ color1 = Color.FromArgb(248, 242, 226);
+ color2 = Color.FromArgb(232, 209, 153);
+ break;
+ }
+ case ePredefinedElementStyle.Teal:
+ {
+ color1 = Color.FromArgb(205, 236, 240);
+ color2 = Color.FromArgb(78, 188, 202);
+ break;
+ }
+ case ePredefinedElementStyle.Yellow:
+ {
+ color1 = Color.FromArgb(255, 244, 213);
+ color2 = Color.FromArgb(255, 216, 105);
+ break;
+ }
+ case ePredefinedElementStyle.Gray:
+ {
+ color1 = Color.White;
+ color2 = ColorScheme.GetColor("E4E4F0");
+ break;
+ }
+ }
+
+ ElementStyle style=Utilities.CreateStyle(new ComponentFactory(),Enum.GetName(typeof(ePredefinedElementStyle),c),borderColor,color1, color2, gradientAngle,textColor);
+ return style;
+ }
+ }
+
+ ///
+ /// Indicates predefined element style.
+ ///
+ public enum ePredefinedElementStyle
+ {
+ Blue,
+ BlueLight,
+ BlueNight,
+ Yellow,
+ Green,
+ Red,
+ Purple,
+ Cyan,
+ Orange,
+ OrangeLight,
+ Magenta,
+ BlueMist,
+ PurpleMist,
+ Tan,
+ Lemon,
+ Apple,
+ Teal,
+ Silver,
+ SilverMist,
+ Gray
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/SelectedNodesCollection.cs b/PROMS/DotNetBar Source Code/AdvTree/SelectedNodesCollection.cs
new file mode 100644
index 00000000..94007432
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/SelectedNodesCollection.cs
@@ -0,0 +1,160 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents the selected nodes collection.
+ ///
+ public class SelectedNodesCollection : NodeCollection
+ {
+ #region Internal Implementation
+ internal AdvTree TreeSelectionControl = null;
+ internal bool SuspendEvents = false;
+ internal bool SuspendClearEvents = false;
+ ///
+ /// Initializes a new instance of the SelectedNodesCollection class.
+ ///
+ public SelectedNodesCollection()
+ {
+ PassiveCollection = true;
+ }
+
+ ///
+ /// Adds new object to the collection and provides information about the source of the command
+ ///
+ /// Node to add
+ /// Source action
+ ///
+ public override int Add(Node node, eTreeAction action)
+ {
+ if (this.List.Contains(node)) return -1;
+
+ if (TreeSelectionControl.MultiSelect)
+ {
+ if (TreeSelectionControl.MultiSelectRule == eMultiSelectRule.SameParent && this.Count>0)
+ {
+ if (this[0].Parent != node.Parent)
+ throw new InvalidOperationException("Node being added does not belong to the same parent as currently selected nodes. See AdvTree.MultiSelectRule property");
+ }
+ if (!SuspendEvents)
+ {
+ AdvTreeNodeCancelEventArgs cancelArgs = new AdvTreeNodeCancelEventArgs(action, node);
+ TreeSelectionControl.InvokeOnBeforeNodeSelect(cancelArgs);
+ if (cancelArgs.Cancel)
+ return -1;
+ }
+ }
+ return base.Add(node, action);
+ }
+
+ ///
+ /// Adds an array of objects to the collection.
+ ///
+ /// Array of Node objects.
+ public override void AddRange(Node[] nodes)
+ {
+ this.MultiNodeOperation = true;
+ base.AddRange(nodes);
+ this.MultiNodeOperation = false;
+ if (!SuspendEvents)
+ TreeSelectionControl.InvokeSelectionChanged(EventArgs.Empty);
+ }
+
+ protected override void OnInsertComplete(int index, object value)
+ {
+ if (TreeSelectionControl.MultiSelect)
+ {
+ Node node = value as Node;
+ node.IsSelected = true;
+ TreeSelectionControl.InvalidateNode(node);
+ if (node.SelectedCell == null)
+ {
+ node.SelectFirstCell(SourceAction);
+ }
+ AdvTreeNodeEventArgs args = new AdvTreeNodeEventArgs(SourceAction, node);
+ TreeSelectionControl.InvokeOnAfterNodeSelect(args);
+ node.InternalSelected(this.SourceAction);
+ if(!_MultiNodeOperation)
+ TreeSelectionControl.InvokeSelectionChanged(EventArgs.Empty);
+ }
+ base.OnInsertComplete(index, value);
+
+ }
+
+ protected override void OnRemoveComplete(int index, object value)
+ {
+ if (TreeSelectionControl.MultiSelect)
+ {
+ Node node = value as Node;
+ node.IsSelected = false;
+ TreeSelectionControl.InvalidateNode(node);
+ if (node.SelectedCell != null)
+ node.SelectedCell.SetSelected(false, SourceAction);
+
+ TreeSelectionControl.InvokeOnAfterNodeDeselect(new AdvTreeNodeEventArgs(this.SourceAction, node));
+ node.InternalDeselected(this.SourceAction);
+ if (!_MultiNodeOperation)
+ TreeSelectionControl.InvokeSelectionChanged(EventArgs.Empty);
+ }
+ base.OnRemoveComplete(index, value);
+ }
+
+ private int _NumberOfClearedNodes = 0;
+ protected override void OnClear()
+ {
+ if (TreeSelectionControl.MultiSelect)
+ {
+ _NumberOfClearedNodes = this.List.Count;
+ Node[] list = new Node[_NumberOfClearedNodes];
+ this.List.CopyTo(list, 0);
+ foreach (Node node in list)
+ {
+ node.IsSelected = false;
+ TreeSelectionControl.InvalidateNode(node);
+ if (node.SelectedCell == null)
+ node.Cells[0].SetSelected(false, SourceAction);
+ _ClearedEventArgsList.Add(new AdvTreeNodeEventArgs(this.SourceAction, node)); // Delay event notification to OnClearComplete so node is not in collection if collection is being tested
+ //TreeSelectionControl.InvokeOnAfterNodeDeselect(new AdvTreeNodeEventArgs(this.SourceAction, node));
+ node.InternalDeselected(this.SourceAction);
+ }
+ }
+ base.OnClear();
+ }
+ private List _ClearedEventArgsList = new List();
+ protected override void OnClearComplete()
+ {
+ if (TreeSelectionControl.MultiSelect)
+ {
+ if (TreeSelectionControl != null && !SuspendClearEvents)
+ {
+ // Invoke nodes deselected
+ foreach (AdvTreeNodeEventArgs advTreeNodeEventArgs in _ClearedEventArgsList)
+ {
+ TreeSelectionControl.InvokeOnAfterNodeDeselect(advTreeNodeEventArgs);
+ }
+ }
+ _ClearedEventArgsList.Clear();
+ if (!SuspendClearEvents && _NumberOfClearedNodes > 0)
+ TreeSelectionControl.InvokeSelectionChanged(EventArgs.Empty);
+ }
+ base.OnClearComplete();
+ }
+
+ private bool _MultiNodeOperation;
+ internal bool MultiNodeOperation
+ {
+ get
+ {
+ return _MultiNodeOperation;
+ }
+ set
+ {
+ _MultiNodeOperation = value;
+ }
+ }
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TextBoxEx.cs b/PROMS/DotNetBar Source Code/AdvTree/TextBoxEx.cs
new file mode 100644
index 00000000..8e03e717
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TextBoxEx.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.ComponentModel;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents the text box for editing cell's text.
+ ///
+ [Designer("System.Windows.Forms.Design.ControlDesigner, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"),ToolboxItem(false)]
+ internal class TextBoxEx:TextBox, ICellEditControl
+ {
+ #region Private variables
+ private bool m_WordWrap=false;
+ #endregion
+
+ #region Events
+ public event EventHandler EditComplete;
+ public event EventHandler CancelEdit;
+ #endregion
+
+ #region Constructor
+ public TextBoxEx():base()
+ {
+ this.AutoSize=false;
+ this.BorderStyle=System.Windows.Forms.BorderStyle.None;
+ }
+ #endregion
+
+ #region Internal Implementation
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ base.OnKeyDown(e);
+
+ if(e.KeyCode==Keys.Enter && !m_WordWrap || e.KeyCode==Keys.Enter && e.Modifiers==Keys.Control)
+ {
+ if(EditComplete!=null)
+ EditComplete(this, new EventArgs());
+ }
+ else if(e.KeyCode==Keys.Escape)
+ {
+ if(CancelEdit!=null)
+ CancelEdit(this,new EventArgs());
+ }
+ }
+#if FRAMEWORK20
+ protected override void OnKeyPress(KeyPressEventArgs e)
+ {
+ if (!m_WordWrap && _PreventEnterBeep && e.KeyChar == (char)Keys.Enter)
+ {
+ e.Handled = true;
+ }
+ base.OnKeyPress(e);
+ }
+#endif
+
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+ {
+ if (keyData == Keys.Tab)
+ {
+ if (EditComplete != null)
+ EditComplete(this, new EventArgs());
+ }
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+
+ protected override void OnTextChanged(EventArgs e)
+ {
+ base.OnTextChanged (e);
+ ResizeControl();
+ }
+
+ private void ResizeControl()
+ {
+ Graphics g=this.CreateGraphics();
+ SizeF size=g.MeasureString(this.Text,this.Font);
+ int width=(int)Math.Ceiling(size.Width);
+ int height=(int)Math.Ceiling(size.Height);
+ if (this.Parent != null && this.Right + (width - this.Width) > (this.Parent.ClientRectangle.Right - SystemInformation.VerticalScrollBarWidth - 2))
+ return;
+ if (width > this.Width)
+ this.Width = width;
+
+ if(m_WordWrap)
+ {
+ if(this.Parent!=null && this.Bottom+(height-this.Height)>this.Parent.Bottom)
+ return;
+ if(height>this.Height)
+ this.Height=height;
+ }
+ }
+ #endregion
+
+ #region Public Properties
+
+ ///
+ /// Gets or sets whether the editing is in word-wrap mode.
+ ///
+ public bool EditWordWrap
+ {
+ get {return m_WordWrap;}
+ set
+ {
+ m_WordWrap=value;
+ if(m_WordWrap)
+ {
+ this.Multiline=true;
+ this.ScrollBars=ScrollBars.None;
+ }
+ else
+ {
+ this.Multiline=false;
+ }
+ }
+ }
+
+ private bool _PreventEnterBeep = false;
+ ///
+ /// Gets or sets whether control prevents Beep sound when Enter key is pressed.
+ ///
+ [DefaultValue(false), Category("Behavior"), Description("Gets or sets whether control prevents Beep sound when Enter key is pressed.")]
+ public bool PreventEnterBeep
+ {
+ get { return _PreventEnterBeep; }
+ set
+ {
+ _PreventEnterBeep = value;
+ }
+ }
+
+ #endregion
+
+ #region ICellEditControl Members
+
+ public void BeginEdit()
+ {
+
+ }
+
+ public void EndEdit()
+ {
+
+ }
+
+ public object CurrentValue
+ {
+ get
+ {
+ return this.Text;
+ }
+ set
+ {
+ this.Text = value.ToString();
+ }
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeAreaInfo.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeAreaInfo.cs
new file mode 100644
index 00000000..1920c540
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeAreaInfo.cs
@@ -0,0 +1,60 @@
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Summary description for TreeAreaInfo.
+ ///
+ internal class TreeAreaInfo
+ {
+ ///
+ /// Reference to parent node in which child bounds the coordinates are. Can be null if no parent node contains given coordinates.
+ ///
+ public Node ParentAreaNode=null;
+ ///
+ /// Node which contains specified coordinates. Can be null if no node contains coordinates.
+ ///
+ public Node NodeAt=null;
+ ///
+ /// Previous reference node for given coordinates. If coordinates fall between two nodes this will indicate previous node or null.
+ ///
+ public Node PreviousNode=null;
+ ///
+ /// Next reference node for given coordinates. If coordinates fall between two nodes this will indicate next node or null.
+ ///
+ public Node NextNode=null;
+ }
+
+ internal class NodeDragInfo
+ {
+ ///
+ /// Gets or sets the parent node drag node will be added to. When null the drag node is being added as top-level node.
+ ///
+ public Node Parent = null;
+ ///
+ /// Gets or sets the insert index of drag node into the parent's node Nodes collection.
+ ///
+ public int InsertIndex = -1;
+
+ ///
+ /// Initializes a new instance of the NodeDragInfo class.
+ ///
+ public NodeDragInfo()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the NodeDragInfo class.
+ ///
+ ///
+ ///
+ public NodeDragInfo(Node parent, int insertIndex)
+ {
+ Parent = parent;
+ InsertIndex = insertIndex;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("NodeDragInfo-> Parent={0}, InsertIndex={1}", Parent, InsertIndex);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeCellCancelEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeCellCancelEventArgs.cs
new file mode 100644
index 00000000..9949412d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeCellCancelEventArgs.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Windows.Forms;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Provides data for AdvTree Cell events that can be canceled.
+ ///
+ public class TreeCellCancelEventArgs:AdvTreeCellEventArgs
+ {
+ ///
+ /// Default constructor for event data.
+ ///
+ /// Type of the action event is raised for.
+ /// Cell that event is raised for.
+ public TreeCellCancelEventArgs(eTreeAction action, Cell cell):base(action,cell)
+ {
+ }
+
+ ///
+ /// Indicates that event action should be canceled.
+ ///
+ public bool Cancel=false;
+ }
+
+ ///
+ /// Provides data for AdvTree.BeforeCheck event.
+ ///
+ public class AdvTreeCellBeforeCheckEventArgs : TreeCellCancelEventArgs
+ {
+ public CheckState NewCheckState = CheckState.Indeterminate;
+
+ ///
+ /// Initializes a new instance of the AdvTreeCellBeforeCheckEventArgs class.
+ ///
+ ///
+ public AdvTreeCellBeforeCheckEventArgs(eTreeAction action, Cell cell, CheckState newCheckState)
+ : base(action, cell)
+ {
+ NewCheckState = newCheckState;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeCellEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeCellEventArgs.cs
new file mode 100644
index 00000000..b5b25976
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeCellEventArgs.cs
@@ -0,0 +1,30 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Provides data for AdvTree Cell events.
+ ///
+ public class AdvTreeCellEventArgs:EventArgs
+ {
+ ///
+ /// Default constructor for event data.
+ ///
+ /// Type of the action event is raised for.
+ /// Cell that event is raised for.
+ public AdvTreeCellEventArgs(eTreeAction action, Cell cell)
+ {
+ this.Action=action;
+ this.Cell=cell;
+ }
+
+ ///
+ /// Indicates the type of the action performed on a cell.
+ ///
+ public eTreeAction Action=eTreeAction.Code;
+ ///
+ /// Indicates the cell that action is performed on.
+ ///
+ public DevComponents.AdvTree.Cell Cell=null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeDragDropEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeDragDropEventArgs.cs
new file mode 100644
index 00000000..88705986
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeDragDropEventArgs.cs
@@ -0,0 +1,48 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents event arguments for BeforeNodeDrop and AfterNodeDrop events
+ ///
+ public class TreeDragDropEventArgs : AdvTreeMultiNodeCancelEventArgs
+ {
+ public TreeDragDropEventArgs(eTreeAction action, Node[] nodes, Node oldParentNode, Node newParentNode, int insertPosition)
+ : base(action, nodes)
+ {
+ this.NewParentNode = newParentNode;
+ this.OldParentNode = oldParentNode;
+ this.InsertPosition = insertPosition;
+ }
+
+ public TreeDragDropEventArgs(eTreeAction action, Node[] nodes, Node oldParentNode, Node newParentNode, bool isCopy, int insertPosition)
+ : base(action, nodes)
+ {
+ this.NewParentNode = newParentNode;
+ this.OldParentNode = oldParentNode;
+ this.IsCopy = isCopy;
+ this.InsertPosition = insertPosition;
+ }
+
+ ///
+ /// Returns reference to the old parent node.
+ ///
+ public readonly Node OldParentNode=null;
+
+ ///
+ /// Reference to the new parent node if event is not cancelled.
+ ///
+ public readonly Node NewParentNode=null;
+
+ ///
+ /// Gets or sets whether drag node is being copied instead of moved.
+ ///
+ public bool IsCopy = false;
+
+ ///
+ /// Gets or sets the new insert position inside of NewParentNode.Nodes collection for the node being dragged. If InsertPosition is -1
+ /// the ParentNode refers to the current mouse over node and drag & drop node will be added as child node to it.
+ ///
+ public int InsertPosition = 0;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeDragFeedbackEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeDragFeedbackEventArgs.cs
new file mode 100644
index 00000000..5611b904
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeDragFeedbackEventArgs.cs
@@ -0,0 +1,129 @@
+using System;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Defines the data for NodeDragFeedback event.
+ ///
+ public class TreeDragFeedbackEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets whether this drop location is accepted. Default value is true. You can set this to false to disable drop at this location.
+ ///
+ public bool AllowDrop = true;
+ ///
+ /// Gets or sets the parent node for the node that is being dragged. This can be null/nothing value to indicate a root top-level node that
+ /// is in AdvTree.Nodes collection.
+ ///
+ public Node ParentNode = null;
+ ///
+ /// Gets or sets the new insert position inside of ParentNode.Nodes collection for the node being dragged. If InsertPosition is -1
+ /// the ParentNode refers to the current mouse over node and drag & drop node will be added as child node to it.
+ ///
+ public int InsertPosition = 0;
+
+ private Node _DragNode;
+ ///
+ /// Gets reference to the node being dragged.
+ ///
+ public Node DragNode
+ {
+ get { return _DragNode; }
+#if FRAMEWORK20
+ set
+ {
+ _DragNode = value;
+ }
+#endif
+ }
+
+ ///
+ /// Initializes a new instance of the TreeDragFeedbackEventArgs class.
+ ///
+ ///
+ ///
+ public TreeDragFeedbackEventArgs(Node parentNode, int insertPosition, Node dragNode)
+ {
+ ParentNode = parentNode;
+ InsertPosition = insertPosition;
+ _DragNode = dragNode;
+ }
+
+ ///
+ /// Initializes a new instance of the TreeDragFeedbackEventArgs class.
+ ///
+ ///
+ ///
+ public TreeDragFeedbackEventArgs(Node parentNode, int insertPosition, Node dragNode, DragDropEffects effect)
+ {
+ ParentNode = parentNode;
+ InsertPosition = insertPosition;
+ _DragNode = dragNode;
+ _Effect = effect;
+ }
+
+ ///
+ /// Initializes a new instance of the TreeDragFeedbackEventArgs class.
+ ///
+ public TreeDragFeedbackEventArgs()
+ {
+ }
+
+ internal bool EffectSet = false;
+ private DragDropEffects _Effect = DragDropEffects.None;
+ ///
+ /// Gets or sets the drop effect for the drag-drop operation.
+ ///
+ public DragDropEffects Effect
+ {
+ get { return _Effect; }
+ set
+ {
+ _Effect = value;
+ EffectSet = true;
+ }
+ }
+ }
+
+ public class MultiNodeTreeDragFeedbackEventArgs : TreeDragFeedbackEventArgs
+ {
+ ///
+ /// Initializes a new instance of the TreeDragFeedbackEventArgs class.
+ ///
+ ///
+ ///
+ public MultiNodeTreeDragFeedbackEventArgs(Node parentNode, int insertPosition, Node[] dragNodes) :
+ base(parentNode, insertPosition, dragNodes[0])
+ {
+ _DragNodes = dragNodes;
+ }
+
+ ///
+ /// Initializes a new instance of the TreeDragFeedbackEventArgs class.
+ ///
+ ///
+ ///
+ public MultiNodeTreeDragFeedbackEventArgs(Node parentNode, int insertPosition, Node[] dragNodes, DragDropEffects effect) :
+ base(parentNode, insertPosition, dragNodes[0], effect)
+ {
+ _DragNodes = dragNodes;
+ }
+
+ private Node[] _DragNodes;
+ ///
+ /// Gets reference to the node being dragged.
+ ///
+ public Node[] DragNodes
+ {
+ get { return _DragNodes; }
+#if FRAMEWORK20
+ set
+ {
+ _DragNodes = value;
+ }
+#endif
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeNodeCancelEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeNodeCancelEventArgs.cs
new file mode 100644
index 00000000..6f98877f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeNodeCancelEventArgs.cs
@@ -0,0 +1,46 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Provides data for AdvTree Node events that can be cancelled.
+ ///
+ public class AdvTreeNodeCancelEventArgs:AdvTreeNodeEventArgs
+ {
+ ///
+ /// Default constructor.
+ ///
+ /// Default action
+ /// Default node.
+ public AdvTreeNodeCancelEventArgs(eTreeAction action, Node node):base(action,node)
+ {
+ }
+
+ ///
+ /// Indicates that event action should be canceled.
+ ///
+ public bool Cancel=false;
+ }
+
+ ///
+ /// Provides data for AdvTree Node events that can be cancelled.
+ ///
+ public class AdvTreeMultiNodeCancelEventArgs : AdvTreeNodeCancelEventArgs
+ {
+ ///
+ /// Default constructor.
+ ///
+ /// Default action
+ /// Default node.
+ public AdvTreeMultiNodeCancelEventArgs(eTreeAction action, Node[] nodes)
+ : base(action, nodes[0])
+ {
+ Nodes = nodes;
+ }
+
+ ///
+ /// Indicates the array of nodes that action is performed on.
+ ///
+ public DevComponents.AdvTree.Node[] Nodes = null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeNodeCollectionEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeNodeCollectionEventArgs.cs
new file mode 100644
index 00000000..e1bf3a2a
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeNodeCollectionEventArgs.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents event arguments for NodeCollection based events, like BeforeNodeInsert, AfterNodeInsert etc.
+ ///
+ public class TreeNodeCollectionEventArgs : AdvTreeNodeEventArgs
+ {
+ ///
+ /// Creates new instance of the class.
+ ///
+ /// Source action
+ /// Affected node
+ /// Parent of the node if any
+ public TreeNodeCollectionEventArgs(eTreeAction action, Node node, Node parentNode):base(action, node)
+ {
+ this.ParentNode = parentNode;
+ }
+
+ ///
+ /// Indicates parent node of the affected node. For example if event handled is BeforeNodeInsert parent of the Node is has
+ /// not been set yet so this property provides information on the node that will become parent. If this property returns null
+ /// then node is being added or removed from the main AdvTree.Nodes collection.
+ ///
+ public DevComponents.AdvTree.Node ParentNode=null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeNodeEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeNodeEventArgs.cs
new file mode 100644
index 00000000..48d94091
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeNodeEventArgs.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Provides data for AdvTree Node events.
+ ///
+ public class AdvTreeNodeEventArgs:EventArgs
+ {
+ ///
+ /// Default constructor.
+ ///
+ /// Default action
+ /// Default node.
+ public AdvTreeNodeEventArgs(eTreeAction action, Node node)
+ {
+ this.Action = action;
+ this.Node = node;
+ }
+
+ ///
+ /// Indicates the type of the action performed on a node.
+ ///
+ public eTreeAction Action=eTreeAction.Code;
+
+ ///
+ /// Indicates the node that action is performed on.
+ ///
+ public DevComponents.AdvTree.Node Node=null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeNodeMouseEventArgs.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeNodeMouseEventArgs.cs
new file mode 100644
index 00000000..a4c994c4
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeNodeMouseEventArgs.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Windows.Forms;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents event arguments for node mouse based events.
+ ///
+ public class TreeNodeMouseEventArgs:EventArgs
+ {
+ public TreeNodeMouseEventArgs(Node node, MouseButtons button, int clicks, int delta, int x, int y)
+ {
+ this.Node = node;
+ this.Button = button;
+ this.Clicks = clicks;
+ this.Delta = delta;
+ this.X = x;
+ this.Y = y;
+ }
+
+ ///
+ /// Gets node affected by mouse action.
+ ///
+ public readonly Node Node;
+
+ ///
+ /// Gets which mouse button was pressed.
+ ///
+ public readonly MouseButtons Button;
+
+ ///
+ /// Gets the number of times the mouse button was pressed and released.
+ ///
+ public readonly int Clicks;
+
+ ///
+ /// Gets a signed count of the number of detents the mouse wheel has rotated. A detent is one notch of the mouse wheel.
+ ///
+ public readonly int Delta;
+
+ ///
+ /// Gets the x-coordinate of the mouse.
+ ///
+ public readonly int X;
+
+ ///
+ /// Gets the y-coordinate of the mouse.
+ ///
+ public readonly int Y;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/TreeSerializer.cs b/PROMS/DotNetBar Source Code/AdvTree/TreeSerializer.cs
new file mode 100644
index 00000000..c8917786
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/TreeSerializer.cs
@@ -0,0 +1,351 @@
+using System;
+using System.Xml;
+using System.IO;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Provides means for AdvTree serialization.
+ ///
+ public class TreeSerializer
+ {
+ #region Private Variables
+ private static string XmlNodeName="Node";
+ private static string XmlCellsName="Cells";
+ private static string XmlCellName="Cell";
+ private static string XmlCellImagesName="Images";
+ private static string XmlAdvTreeName="AdvTree";
+ private static string XmlCustomName = "Custom";
+ #endregion
+
+ #region Saving
+ ///
+ /// Saves Nodes to specified file.
+ ///
+ /// AdvTree to save
+ /// Target file name
+ public static void Save(AdvTree tree, string fileName)
+ {
+ XmlDocument document=Save(tree);
+ document.Save(fileName);
+ }
+
+ ///
+ /// Saves Nodes to stream.
+ ///
+ /// AdvTree to save
+ /// Stream to save nodes to.
+ public static void Save(AdvTree tree, Stream outStream)
+ {
+ XmlDocument document=Save(tree);
+ document.Save(outStream);
+ }
+
+ ///
+ /// Saves Nodes to TextWriter
+ ///
+ /// AdvTree to save
+ /// TextWriter to write nodes to.
+ public static void Save(AdvTree tree, TextWriter writer)
+ {
+ XmlDocument document=Save(tree);
+ document.Save(writer);
+ }
+
+ ///
+ /// Saves nodes to XmlWriter.
+ ///
+ /// AdvTree to save
+ /// XmlWriter to write nodes to
+ public static void Save(AdvTree tree, XmlWriter writer)
+ {
+ XmlDocument document=Save(tree);
+ document.Save(writer);
+ }
+
+ ///
+ /// Creates new XmlDocument and serializes AdvTree into it.
+ ///
+ /// AdvTree to serialize
+ /// New instance of XmlDocument/returns>
+ public static XmlDocument Save(AdvTree tree)
+ {
+ XmlDocument document=new XmlDocument();
+ Save(tree, document);
+ return document;
+ }
+
+ ///
+ /// Saves AdvTree to an existing XmlDocument. New node AdvTree is created in document and Nodes are serialized into it.
+ ///
+ /// AdvTree to serialize
+ /// XmlDocument instance.
+ public static void Save(AdvTree tree, XmlDocument document)
+ {
+ XmlElement parent = document.CreateElement(XmlAdvTreeName);
+ document.AppendChild(parent);
+ TreeSerializer.Save(tree, parent);
+ }
+
+ ///
+ /// Serializes AdvTree object to XmlElement object.
+ ///
+ /// Instance of AdvTree to serialize.
+ /// XmlElement to serialize to.
+ public static void Save(AdvTree tree, XmlElement parent)
+ {
+ NodeSerializationContext context = new NodeSerializationContext();
+ context.RefXmlElement = parent;
+ context.AdvTree = tree;
+ context.HasSerializeNodeHandlers = tree.HasSerializeNodeHandlers;
+ context.HasDeserializeNodeHandlers = tree.HasDeserializeNodeHandlers;
+
+ foreach(Node node in tree.Nodes)
+ {
+ Save(node, context);
+ }
+ }
+
+ ///
+ /// Serializes Node and all child nodes to XmlElement object.
+ ///
+ /// Node to serialize.
+ /// Provides serialization context.
+ public static void Save(Node node, NodeSerializationContext context)
+ {
+ XmlElement parent = context.RefXmlElement;
+
+ XmlElement xmlNode=parent.OwnerDocument.CreateElement(XmlNodeName);
+ parent.AppendChild(xmlNode);
+
+ ElementSerializer.Serialize(node, xmlNode);
+
+ if(context.HasSerializeNodeHandlers)
+ {
+ XmlElement customXml = parent.OwnerDocument.CreateElement(XmlCustomName);
+ SerializeNodeEventArgs e = new SerializeNodeEventArgs(node, xmlNode, customXml);
+ context.AdvTree.InvokeSerializeNode(e);
+ if (customXml.Attributes.Count > 0 || customXml.ChildNodes.Count > 0)
+ xmlNode.AppendChild(customXml);
+ }
+
+ if(node.Cells.Count>1)
+ {
+ XmlElement xmlCells = parent.OwnerDocument.CreateElement(XmlCellsName);
+ xmlNode.AppendChild(xmlCells);
+
+ for(int i=1; i
+ /// Load AdvTree Nodes from file.
+ ///
+ /// Reference to AdvTree to populate
+ /// File name.
+ public static void Load(AdvTree tree, string fileName)
+ {
+ XmlDocument document=new XmlDocument();
+ document.Load(fileName);
+ Load(tree, document);
+ }
+
+ ///
+ /// Load AdvTree Nodes from stream.
+ ///
+ /// Reference to AdvTree to populate
+ /// Reference to stream
+ public static void Load(AdvTree tree, Stream inStream)
+ {
+ XmlDocument document=new XmlDocument();
+ document.Load(inStream);
+ Load(tree, document);
+ }
+
+ ///
+ /// Load AdvTree Nodes from reader.
+ ///
+ /// Reference to AdvTree to populate
+ /// Reference to reader.
+ public static void Load(AdvTree tree, TextReader reader)
+ {
+ XmlDocument document=new XmlDocument();
+ document.Load(reader);
+ Load(tree, document);
+ }
+
+ ///
+ /// Load AdvTree Nodes from reader.
+ ///
+ /// Reference to AdvTree to populate
+ /// Reference to reader.
+ public static void Load(AdvTree tree, XmlReader reader)
+ {
+ XmlDocument document=new XmlDocument();
+ document.Load(reader);
+ Load(tree, document);
+ }
+
+ ///
+ /// Load AdvTree from XmlDocument that was created by Save method.
+ ///
+ /// Tree Control to load
+ /// XmlDocument to load control from
+ public static void Load(AdvTree tree, XmlDocument document)
+ {
+ foreach(XmlNode xmlNode in document.ChildNodes)
+ {
+ if(xmlNode.Name==XmlAdvTreeName && xmlNode is XmlElement)
+ {
+ Load(tree, xmlNode as XmlElement);
+ break;
+ }
+ }
+ }
+
+ ///
+ /// Load nodes from XmlElement.
+ ///
+ /// Reference to AdvTree to be populated.
+ /// XmlElement that tree was serialized to.
+ public static void Load(AdvTree tree, XmlElement parent)
+ {
+ tree.BeginUpdate();
+ tree.DisplayRootNode = null;
+ tree.Nodes.Clear();
+
+ NodeSerializationContext context = new NodeSerializationContext();
+ context.AdvTree = tree;
+ context.HasDeserializeNodeHandlers = tree.HasDeserializeNodeHandlers;
+ context.HasSerializeNodeHandlers = tree.HasSerializeNodeHandlers;
+
+ try
+ {
+ foreach(XmlNode xmlNode in parent.ChildNodes)
+ {
+ if(xmlNode.Name==XmlNodeName && xmlNode is XmlElement)
+ {
+ Node node=new Node();
+ tree.Nodes.Add(node);
+ context.RefXmlElement = xmlNode as XmlElement;
+ LoadNode(node, context);
+ }
+ }
+ }
+ finally
+ {
+ tree.EndUpdate();
+ }
+ }
+
+ ///
+ /// Load single node and it's child nodes if any.
+ ///
+ /// New instance of node that is populated with loaded data.
+ /// Provides deserialization context.
+ public static void LoadNode(Node nodeToLoad, NodeSerializationContext context)
+ {
+ XmlElement xmlNode = context.RefXmlElement;
+
+ ElementSerializer.Deserialize(nodeToLoad, xmlNode);
+
+ foreach(XmlNode xmlChild in xmlNode.ChildNodes)
+ {
+ XmlElement xmlElem = xmlChild as XmlElement;
+ if(xmlElem == null)
+ continue;
+ if(xmlElem.Name==XmlNodeName)
+ {
+ Node node=new Node();
+ nodeToLoad.Nodes.Add(node);
+ context.RefXmlElement = xmlElem;
+ LoadNode(node, context);
+ }
+ else if(xmlElem.Name == XmlCellsName)
+ {
+ LoadCells(nodeToLoad, xmlElem);
+ }
+ else if(xmlElem.Name == XmlCustomName)
+ {
+ if(context.HasDeserializeNodeHandlers)
+ {
+ SerializeNodeEventArgs e = new SerializeNodeEventArgs(nodeToLoad, xmlNode, xmlElem);
+ context.AdvTree.InvokeDeserializeNode(e);
+ }
+ }
+ }
+ context.RefXmlElement = xmlNode;
+ }
+
+ private static void LoadCells(Node parentNode, XmlElement xmlCells)
+ {
+ foreach(XmlNode xmlChild in xmlCells.ChildNodes)
+ {
+ if(xmlChild.Name==XmlCellName && xmlChild is XmlElement)
+ {
+ Cell cell=new Cell();
+ parentNode.Cells.Add(cell);
+ ElementSerializer.Deserialize(cell, xmlChild as XmlElement);
+ // Load images if any
+ foreach(XmlElement xmlImage in xmlChild.ChildNodes)
+ {
+ if(xmlImage.Name==XmlCellImagesName)
+ {
+ ElementSerializer.Deserialize(cell.Images, xmlImage);
+ break;
+ }
+ }
+ }
+ }
+ }
+ #endregion
+ }
+
+ ///
+ /// Provides context information for serialization.
+ ///
+ public class NodeSerializationContext
+ {
+ ///
+ /// Gets or sets reference to context parent XmlElement when serializing or actual Node element when deserializing.
+ ///
+ public System.Xml.XmlElement RefXmlElement = null;
+
+ ///
+ /// Gets or sets whether SerializeNode event handler has been defined and whether event should be fired.
+ ///
+ public bool HasSerializeNodeHandlers = false;
+
+ ///
+ /// Gets or sets whether DeserializeNode event handler has been defined and whether event should be fired.
+ ///
+ public bool HasDeserializeNodeHandlers = false;
+
+ ///
+ /// Provides access to serializer.
+ ///
+ public AdvTree AdvTree = null;
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AdvTree/Utilites.cs b/PROMS/DotNetBar Source Code/AdvTree/Utilites.cs
new file mode 100644
index 00000000..0d015014
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AdvTree/Utilites.cs
@@ -0,0 +1,329 @@
+using System;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.ComponentModel;
+using DevComponents.DotNetBar;
+using DevComponents.DotNetBar.Rendering;
+using System.Windows.Forms;
+
+namespace DevComponents.AdvTree
+{
+ ///
+ /// Represents class for static tree utilities.
+ ///
+ public class Utilities
+ {
+ ///
+ /// Initializes control with default settings for connectors and nodes.
+ ///
+ /// Control to initialize.
+ public static void InitializeTree(AdvTree tree)
+ {
+ InitializeTree(tree,new ComponentFactory());
+ }
+
+ ///
+ /// Initializes control with default settings for connectors and nodes.
+ ///
+ /// Control to initialize.
+ /// Factory to use to create new instances of objects.
+ public static void InitializeTree(AdvTree tree, ComponentFactory factory)
+ {
+ //tree.RootConnector=factory.CreateComponent(typeof(NodeConnector)) as NodeConnector;
+ //tree.RootConnector.LineWidth=1;
+ //tree.RootConnector.LineColor = SystemColors.ControlText;
+ tree.NodesConnector=factory.CreateComponent(typeof(NodeConnector)) as NodeConnector;
+ tree.NodesConnector.LineWidth=1;
+ tree.NodesConnector.LineColor=SystemColors.ControlText;
+ tree.BackColor = SystemColors.Window;
+ //eStyleBorderType border=eStyleBorderType.Solid;
+ ElementStyle style=factory.CreateComponent(typeof(ElementStyle)) as ElementStyle;
+
+ //style.BackColorSchemePart=eColorSchemePart.BarBackground;
+ //style.BackColor2SchemePart=eColorSchemePart.BarBackground2;
+ //style.BackColorGradientAngle=90;
+ //style.CornerDiameter=4;
+ //style.CornerType=eCornerType.Rounded;
+ //style.BorderLeft=border;
+ //style.BorderLeftWidth=1;
+ //style.BorderTop=border;
+ //style.BorderTopWidth=1;
+ //style.BorderBottom=border;
+ //style.BorderBottomWidth=1;
+ //style.BorderRight=border;
+ //style.BorderRightWidth=1;
+ //style.BorderColorSchemePart=eColorSchemePart.BarDockedBorder;
+ //style.PaddingBottom=3;
+ //style.PaddingLeft=3;
+ //style.PaddingRight=3;
+ //style.PaddingTop=3;
+ style.TextColor = SystemColors.ControlText;
+ tree.Styles.Add(style);
+
+ tree.NodeStyle=style;
+
+ tree.BackgroundStyle.Class = ElementStyleClassKeys.TreeBorderKey;
+ tree.AccessibleRole = AccessibleRole.Outline;
+ }
+
+ ///
+ /// Creates new style and adds it to styles collection
+ ///
+ /// Tree to assign style to
+ /// Style factory
+ ///
+ ///
+ ///
+ ///
+ internal static ElementStyle CreateStyle(ComponentFactory factory, string description, Color borderColor, Color backColor, Color backColor2, int gradientAngle, Color textColor)
+ {
+ eStyleBorderType border=eStyleBorderType.Solid;
+ ElementStyle style=factory.CreateComponent(typeof(ElementStyle)) as ElementStyle;
+
+ style.Description = description;
+ style.BackColor = backColor;
+ style.BackColor2=backColor2;
+ style.BackColorGradientAngle=gradientAngle;
+ style.CornerDiameter=4;
+ style.CornerType=eCornerType.Square;
+ style.BorderLeft=border;
+ style.BorderLeftWidth=1;
+ style.BorderTop=border;
+ style.BorderTopWidth=1;
+ style.BorderBottom=border;
+ style.BorderBottomWidth=1;
+ style.BorderRight=border;
+ style.BorderRightWidth=1;
+ style.BorderColor=borderColor;
+ style.PaddingBottom=1;
+ style.PaddingLeft=1;
+ style.PaddingRight=1;
+ style.PaddingTop=1;
+ style.TextColor=textColor;
+
+ return style;
+ }
+
+ ///
+ /// Returns reference to a node that is hosting given control.
+ ///
+ /// Reference to the AdvTree control instance
+ /// Control instance to look for
+ /// Reference to a node hosting control or null if node could not be found
+ public static Node FindNodeForControl(AdvTree tree, System.Windows.Forms.Control c)
+ {
+ if(tree==null || c==null || tree.Nodes.Count==0)
+ return null;
+
+ Node node = tree.Nodes[0];
+ while(node!=null)
+ {
+ foreach(Cell cell in node.Cells)
+ {
+ if(cell.HostedControl==c)
+ return node;
+ }
+ node = node.NextVisibleNode;
+ }
+
+ return null;
+ }
+
+ internal static int CompareAlpha(string t, string t2)
+ {
+ return string.Compare(t, t2, StringComparison.CurrentCulture);
+ }
+
+ internal static bool StartsWithNumber(string s)
+ {
+ if (s.Length > 0 && char.IsDigit(s[0]))
+ return true;
+ return false;
+ }
+
+ internal static int CompareAlphaNumeric(string t, string t2)
+ {
+ if (Utilities.StartsWithNumber(t) && Utilities.StartsWithNumber(t2))
+ {
+ long l = GetNumber(t), l2 = GetNumber(t2);
+ int i = l.CompareTo(l2);
+ if (i != 0)
+ return i;
+ }
+#if FRAMEWORK20
+ return string.Compare(t, t2, StringComparison.CurrentCulture);
+#else
+ return string.Compare(t, t2);
+#endif
+ }
+
+ internal static long GetNumber(string s)
+ {
+ long l = 0;
+ int start = 0, end = 0;
+ for (int i = 0; i < s.Length; i++)
+ {
+ if (char.IsDigit(s[i]))
+ {
+ end = i;
+ }
+ else
+ break;
+ }
+#if FRAMEWORK20
+ long.TryParse(s.Substring(start, end - start + 1), out l);
+#else
+ try
+ {
+ l = long.Parse(s.Substring(start, end - start + 1));
+ }
+ catch { }
+#endif
+ return l;
+ }
+
+ internal static string StripNonNumeric(string p)
+ {
+ string s = "";
+ string decimalSeparator = NumberDecimalSeparator;
+ string groupSeparator = NumberGroupSeparator;
+ for (int i = 0; i < p.Length; i++)
+ {
+ if (p[i].ToString() == decimalSeparator || p[i].ToString() == groupSeparator || p[i] >= '0' && p[i] <= '9' || i == 0 && p[i] == '-')
+ s += p[i];
+ else if (s.Length > 0) break;
+ }
+ return s;
+ }
+
+ private static string NumberDecimalSeparator
+ {
+ get
+ {
+#if FRAMEWORK20
+ return DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture().NumberFormat.NumberDecimalSeparator;
+#else
+ return System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
+#endif
+ }
+ }
+ private static string NumberGroupSeparator
+ {
+ get
+ {
+#if FRAMEWORK20
+ return DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture().NumberFormat.NumberGroupSeparator;
+#else
+ return System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator;
+#endif
+ }
+ }
+ }
+
+ #region ComponentFactory
+ ///
+ /// Represents internal component factory with design-time support.
+ ///
+ public class ComponentFactory
+ {
+ private IDesignerHost m_Designer=null;
+ ///
+ /// Creates new instance of the class.
+ ///
+ /// Reference to DesignerHost to use for creation of new components.
+ public ComponentFactory(IDesignerHost designer)
+ {
+ m_Designer=designer;
+ }
+
+ ///
+ /// Creates new instance of the class.
+ ///
+ public ComponentFactory() {}
+
+ ///
+ /// Creates component and returns reference to the new instance.
+ ///
+ /// Type that identifies component to create.
+ /// New instance of the component.
+ public object CreateComponent(Type type)
+ {
+ object o=null;
+ if(m_Designer!=null)
+ o=m_Designer.CreateComponent(type);
+ else
+ o=type.Assembly.CreateInstance(type.FullName);
+ return o;
+ }
+ }
+ #endregion
+
+ #region Padding Class
+ ///
+ /// Represents class that holds padding information for user interface elements.
+ ///
+ public class Padding
+ {
+ ///
+ /// Gets or sets padding on left side. Default value is 0
+ ///
+ public int Left = 0;
+ ///
+ /// Gets or sets padding on right side. Default value is 0
+ ///
+ public int Right = 0;
+ ///
+ /// Gets or sets padding on top side. Default value is 0
+ ///
+ public int Top = 0;
+ ///
+ /// Gets or sets padding on bottom side. Default value is 0
+ ///
+ public int Bottom = 0;
+
+ ///
+ /// Creates new instance of the class and initializes it.
+ ///
+ /// Left padding
+ /// Right padding
+ /// Top padding
+ /// Bottom padding
+ public Padding(int left, int right, int top, int bottom)
+ {
+ this.Left = left;
+ this.Right = right;
+ this.Top = top;
+ this.Bottom = bottom;
+ }
+
+ ///
+ /// Gets amount of horizontal padding (Left+Right)
+ ///
+ [Browsable(false)]
+ public int Horizontal
+ {
+ get { return this.Left + this.Right; }
+ }
+
+ ///
+ /// Gets amount of vertical padding (Top+Bottom)
+ ///
+ [Browsable(false)]
+ public int Vertical
+ {
+ get { return this.Top + this.Bottom; }
+ }
+
+ ///
+ /// Gets whether Padding is empty.
+ ///
+ public bool IsEmpty
+ {
+ get
+ {
+ return this.Left == 0 && this.Right == 0 && this.Top == 0 && this.Bottom == 0;
+ }
+ }
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/AnalogClock/AnalogClockControl.cs b/PROMS/DotNetBar Source Code/AnalogClock/AnalogClockControl.cs
new file mode 100644
index 00000000..cd633acd
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AnalogClock/AnalogClockControl.cs
@@ -0,0 +1,1101 @@
+using System;
+using System.ComponentModel;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Text;
+using System.Windows.Forms;
+using System.Drawing.Text;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Analog clock control.
+ ///
+ [Description("Analog Clock Control"), ToolboxBitmap(typeof(AnalogClockControl), "AnalogClock.AnalogClockControl.bmp"), DefaultEvent("ValueChanged"), DefaultProperty("Value")]
+ public class AnalogClockControl : Control
+ {
+ #region Private Vars
+
+ private const float _BaseSize = 100.0f;
+
+ private Point _EditLoc;
+ private eClockEditStates _EditState;
+ private Size _LastSize;
+ private Timer _Timer;
+ #endregion
+
+ #region Implementation
+ ///
+ /// Default minimum size. Defaults to 100, 100.
+ ///
+ protected override Size DefaultMinimumSize
+ {
+ get { return new Size(100, 100); }
+ }
+
+ private bool _AntiAlias;
+ ///
+ /// Gets or sets whether anti-aliasing is used when rendering the control. Default value is true.
+ ///
+ [DefaultValue(true),
+ Category("Appearance"),
+ Description("Indicates whether Anti-aliasing is used when rendering the control.")]
+ public bool AntiAlias
+ {
+ get { return _AntiAlias; }
+ set
+ {
+ _AntiAlias = value;
+ Invalidate();
+ }
+ }
+
+ private bool _AutomaticMode;
+ ///
+ /// Gets or sets the state for automatic mode. When true the clock will auto redraw once a second and display the current date/time. Default value is false.
+ ///
+ [DefaultValue(false),
+ Category("Behavior"),
+ Description("Toggles the state for automatic mode. When true the clock will auto redraw once a second and display the current date/time.")]
+ public bool AutomaticMode
+ {
+ get { return _AutomaticMode; }
+ set
+ {
+ _AutomaticMode = value;
+ if (_AutomaticMode)
+ {
+ _Value = DateTime.Now;
+ _IsEditable = false;
+ if (!DesignMode)
+ {
+ if (_Timer != null)
+ _Timer.Dispose();
+ _Timer = new Timer();
+ _Timer.Interval = 1000;
+ _Timer.Tick += Timer_Tick;
+ _Timer.Enabled = true;
+ }
+ }
+ else
+ {
+ if (_Timer != null)
+ {
+ _Timer.Enabled = false;
+ _Timer.Dispose();
+ _Timer = null;
+ }
+ }
+ Invalidate();
+ }
+ }
+
+ private eClockStyles _ClockStyle;
+ ///
+ /// Gets or sets clock style for this control.
+ ///
+ [DefaultValue(eClockStyles.Style1),
+ Category("Appearance"),
+ Description("The clock style for the control."),
+ RefreshProperties(RefreshProperties.All)]
+ public eClockStyles ClockStyle
+ {
+ get { return _ClockStyle; }
+ set
+ {
+ _ClockStyle = value;
+ if (_ClockStyle != eClockStyles.Custom)
+ {
+ if (_ClockStyleData != null)
+ {
+ _ClockStyleData.Parent = null;
+ _ClockStyleData.Dispose();
+ }
+ _ClockStyleData = new ClockStyleData(_ClockStyle, this);
+ }
+ Invalidate();
+ }
+ }
+
+ private ClockStyleData _ClockStyleData;
+ ///
+ /// Gets or sets the clock style data elements for this control.
+ ///
+ [Category("Appearance"),
+ Description("The clock style data for the control."),
+ RefreshProperties(RefreshProperties.All)]
+ public ClockStyleData ClockStyleData
+ {
+ get { return _ClockStyleData; }
+ set
+ {
+ if (_ClockStyleData != null) _ClockStyleData.Parent = null;
+ _ClockStyleData = value;
+ _ClockStyleData.Parent = this;
+ _ClockStyleData.Style = eClockStyles.Custom;
+ ClockStyle = eClockStyles.Custom;
+ Invalidate();
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetClockStyleData()
+ {
+ ClockStyle = eClockStyles.Style1;
+ }
+
+ private eClockIndicatorStyles _IndicatorStyle;
+ ///
+ /// Gets or sets a the indicator style the clock control. Default value is Ticks.
+ ///
+ [DefaultValue(eClockIndicatorStyles.Ticks),
+ Category("Appearance"),
+ Description("Indicates which indicator style the clock will use.")]
+ public eClockIndicatorStyles IndicatorStyle
+ {
+ get { return _IndicatorStyle; }
+ set
+ {
+ _IndicatorStyle = value;
+ Invalidate();
+ }
+ }
+
+ private bool _IsEditable;
+ ///
+ /// Gets or sets whether the time can be changed by moving the clock hands. Default value is false.
+ ///
+ [DefaultValue(false),
+ Category("Behavior"),
+ Description("Indicates whether the time can be changed by moving the clock hands. If AutomaticMode is enabled, this setting is ignored.")]
+ public bool IsEditable
+ {
+ get { return _IsEditable; }
+ set
+ {
+ if (!AutomaticMode)
+ _IsEditable = value;
+ Invalidate();
+ }
+ }
+
+ private bool _ShowGlassOverlay;
+ ///
+ /// Gets or sets a value indicating whether to display the glass overlay on the clock control. Default value is true.
+ ///
+ [DefaultValue(true),
+ Category("Appearance"),
+ Description("Indicates whether the glass overlay on the clock control will be displayed or not.")]
+ public bool ShowGlassOverlay
+ {
+ get { return _ShowGlassOverlay; }
+ set
+ {
+ _ShowGlassOverlay = value;
+ Invalidate();
+ }
+ }
+
+ private bool _ShowSecondHand;
+ ///
+ /// Gets or sets a value indicating whether to display the second hand on the clock control. Default value is true.
+ ///
+ [DefaultValue(true),
+ Category("Appearance"),
+ Description("Indicates whether the second hand on the clock control will be displayed or not.")]
+ public bool ShowSecondHand
+ {
+ get { return _ShowSecondHand; }
+ set
+ {
+ _ShowSecondHand = value;
+ Invalidate();
+ }
+ }
+
+ ///
+ /// Occurs while user is dragging the mouse in order to change time.
+ ///
+ [Description("Occurs while user is dragging the mouse in order to change time.")]
+ public event TimeValueChangingEventHandler ValueChanging;
+ ///
+ /// Raises ValueChanging event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnValueChanging(TimeValueChangingEventArgs e)
+ {
+ TimeValueChangingEventHandler handler = ValueChanging;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Occurs when Value i.e. time clock is displaying has changed.
+ ///
+ [Description("Occurs when Value i.e. time clock is displaying has changed.")]
+ public event EventHandler ValueChanged;
+ ///
+ /// Raises ValueChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnValueChanged(EventArgs e)
+ {
+ EventHandler handler = ValueChanged;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ private DateTime _Value;
+ ///
+ /// Gets or sets the current date/time value for this control.
+ ///
+ [Category("Behavior"),
+ Description("The current date/time value for this control. If AutomaticMode is enabled, assigned values are ignored.")]
+ public DateTime Value
+ {
+ get { return _Value; }
+ set
+ {
+ _Value = value;
+ OnValueChanged(EventArgs.Empty);
+ Invalidate();
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetValue()
+ {
+ Value = DateTime.Now;
+ }
+
+ /////
+ ///// Occurs when subproperty value has changed.
+ /////
+ //public event DevComponents.Schedule.Model.SubPropertyChangedEventHandler SubPropertyChanged;
+
+ ///
+ /// Initializes a new instance of the ClockControl class
+ ///
+ public AnalogClockControl()
+ {
+ SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
+ ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw |
+ ControlStyles.SupportsTransparentBackColor, true);
+
+ _AntiAlias = true;
+ _AutomaticMode = false;
+ _ClockStyle = eClockStyles.Style1;
+ _ClockStyleData = new ClockStyleData();
+ _ClockStyleData.Parent = this;
+ _EditState = eClockEditStates.None;
+ _IndicatorStyle = eClockIndicatorStyles.Ticks;
+ _IsEditable = false;
+ _ShowGlassOverlay = true;
+ _ShowSecondHand = true;
+ _Value = DateTime.Now;
+
+ MinimumSize = new Size((int)_BaseSize, (int)_BaseSize); ;
+ Size = MinimumSize;
+ }
+
+ ///
+ /// Releases all resources used by the class.
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ base.Dispose(disposing);
+ if (disposing)
+ {
+ if (_ClockStyleData != null)
+ {
+ _ClockStyleData.Parent = null;
+ _ClockStyleData.Dispose();
+ }
+
+ if (_Timer != null)
+ {
+ _Timer.Dispose();
+ _Timer = null;
+ }
+ }
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+
+ RectangleF rect;
+ float bezelWidth, angle;
+
+ if (e.Button != MouseButtons.Left || !_IsEditable)
+ return;
+
+ bezelWidth = _ClockStyleData.BezelWidth * (ClientRectangle.Width - 1);
+ rect = new RectangleF(ClientRectangle.X + bezelWidth,
+ ClientRectangle.Y + bezelWidth,
+ (ClientRectangle.Width - 1) - bezelWidth * 2.0f,
+ (ClientRectangle.Height - 1) - bezelWidth * 2.0f);
+
+ angle = RoundToExactHour((float)_Value.TimeOfDay.TotalHours * 30.0f);
+ if (_ClockStyleData.HourHandStyle.ContainsPoint(rect, angle, e.Location))
+ {
+ _LastMouseMoveHour = _Value.Hour;
+ _NewMouseMoveHour = _Value.Hour;
+ if (_Value.Hour > 12) _LastMouseMoveHour -= 12;
+ _EditState = eClockEditStates.Hour;
+ }
+ else
+ {
+ angle = (float)_Value.TimeOfDay.TotalMinutes * 6.0f;
+ if (_ClockStyleData.MinuteHandStyle.ContainsPoint(rect, angle, e.Location))
+ _EditState = eClockEditStates.Minute;
+ else
+ {
+ angle = (float)_Value.TimeOfDay.Seconds * 6.0f;
+ if (_ShowSecondHand && _ClockStyleData.SecondHandStyle.ContainsPoint(rect, angle, e.Location))
+ _EditState = eClockEditStates.Second;
+ }
+ }
+ if (_EditState != eClockEditStates.None)
+ _EditLoc = e.Location;
+ }
+
+ private int _LastMouseMoveHour = -1;
+ private int _NewMouseMoveHour = -1;
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+
+ RectangleF rect;
+ float bezelWidth, angle;
+
+ if (!_IsEditable)
+ return;
+
+ if (_EditState != eClockEditStates.None)
+ {
+ _EditLoc = e.Location;
+
+ // We need to record the direction of hour hand movement so AM/PM can be switched
+ if (_EditState == eClockEditStates.Hour)
+ {
+ int hour = GetHourFromPoint(_EditLoc);
+ if (hour == 1 && _LastMouseMoveHour == 12)
+ _LastMouseMoveHour = 0;
+ else if (hour == 12 && _LastMouseMoveHour == 1)
+ _LastMouseMoveHour = 13;
+ _NewMouseMoveHour += (hour - _LastMouseMoveHour);
+ if (_NewMouseMoveHour < 0)
+ _NewMouseMoveHour = 23;
+ else if (_NewMouseMoveHour > 23)
+ _NewMouseMoveHour = 0;
+ _LastMouseMoveHour = hour;
+
+ }
+
+ OnValueChanging(new TimeValueChangingEventArgs(GetCurrentMouseTime()));
+
+ Invalidate();
+ }
+ else
+ {
+ bezelWidth = _ClockStyleData.BezelWidth * (ClientRectangle.Width - 1);
+ rect = new RectangleF(ClientRectangle.X + bezelWidth,
+ ClientRectangle.Y + bezelWidth,
+ (ClientRectangle.Width - 1) - bezelWidth * 2.0f,
+ (ClientRectangle.Height - 1) - bezelWidth * 2.0f);
+
+ angle = RoundToExactHour((float)_Value.TimeOfDay.TotalHours * 30.0f);
+ if (_ClockStyleData.HourHandStyle.ContainsPoint(rect, angle, e.Location))
+ Cursor = Cursors.Hand;
+ else
+ {
+ angle = (float)_Value.TimeOfDay.TotalMinutes * 6.0f;
+ if (_ClockStyleData.MinuteHandStyle.ContainsPoint(rect, angle, e.Location))
+ Cursor = Cursors.Hand;
+ else
+ {
+ angle = (float)_Value.TimeOfDay.Seconds * 6.0f;
+ if (_ShowSecondHand && _ClockStyleData.SecondHandStyle.ContainsPoint(rect, angle, e.Location))
+ Cursor = Cursors.Hand;
+ else if (Cursor != Cursors.Default)
+ Cursor = Cursors.Default;
+ }
+ }
+ }
+ }
+
+ private float GetClockAngleFromPoint(Point p)
+ {
+ float angle = (float)MathHelper.GetDegrees(GetAngleFromPoint(p));
+ angle += 90.0f;
+ while (angle < 0)
+ angle += 360;
+ while (angle >= 360)
+ angle -= 360;
+ return angle;
+ }
+ private int GetHourFromPoint(Point p)
+ {
+ float angle = RoundToExactHour(GetClockAngleFromPoint(p));
+ int hour = (int)Math.Round(angle / 30.0, 0);
+ if (hour == 0) hour = 12;
+ return hour;
+ }
+ private int GetMinuteFromPoint(Point p)
+ {
+ float angle = GetClockAngleFromPoint(p);
+ int minute = (int)Math.Round(angle / 6.0, 0);
+ if (minute == 60)
+ minute = 0;
+ return minute;
+ }
+ private int GetSecondFromPoint(Point p)
+ {
+ float angle = GetClockAngleFromPoint(p);
+ int minute = (int)Math.Round(angle / 6.0, 0);
+ if (minute == 60)
+ minute = 0;
+ return minute;
+ }
+
+ private DateTime GetCurrentMouseTime()
+ {
+ DateTime time = _Value;
+ switch (_EditState)
+ {
+ case eClockEditStates.Hour:
+ time = new DateTime(_Value.Year, _Value.Month, _Value.Day, _NewMouseMoveHour, _Value.Minute, _Value.Second);
+ break;
+ case eClockEditStates.Minute:
+ time = new DateTime(_Value.Year, _Value.Month, _Value.Day, _Value.Hour, GetMinuteFromPoint(_EditLoc), _Value.Second);
+ break;
+ case eClockEditStates.Second:
+ time = new DateTime(_Value.Year, _Value.Month, _Value.Day, _Value.Hour, _Value.Minute, GetSecondFromPoint(_EditLoc));
+ break;
+ }
+
+ return time;
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ if (_EditState != eClockEditStates.None)
+ {
+ _EditLoc = e.Location;
+ Value = GetCurrentMouseTime();
+ _EditLoc = Point.Empty;
+ _EditState = eClockEditStates.None;
+ Cursor = Cursors.Default;
+ }
+ base.OnMouseUp(e);
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ base.OnPaint(e);
+ Graphics g;
+ RectangleF rect;
+ float bezelWidth;
+
+ g = e.Graphics;
+
+ TextRenderingHint textHint = g.TextRenderingHint;
+ SmoothingMode sm = g.SmoothingMode;
+ if (_AntiAlias)
+ {
+ g.TextRenderingHint = BarUtilities.AntiAliasTextRenderingHint;
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+ }
+
+ bezelWidth = _ClockStyleData.BezelWidth * (ClientRectangle.Width - 1);
+ rect = new RectangleF(ClientRectangle.X + bezelWidth,
+ ClientRectangle.Y + bezelWidth,
+ (ClientRectangle.Width - 1) - bezelWidth * 2.0f,
+ (ClientRectangle.Height - 1) - bezelWidth * 2.0f);
+
+
+ e.Graphics.TranslateTransform(rect.X + rect.Width * 0.5f, rect.Y + rect.Height * 0.5f);
+ switch (_IndicatorStyle)
+ {
+ case eClockIndicatorStyles.Ticks:
+ DrawTicks(g, rect);
+ break;
+ case eClockIndicatorStyles.Numbers:
+ DrawNumbers(g, rect);
+ break;
+ }
+
+ DrawHands(g, rect, false);
+ DrawCap(g, rect);
+ DrawHands(g, rect, true);
+
+ if (_ShowGlassOverlay)
+ DrawGlassOverlay(g, rect);
+
+ g.TextRenderingHint = textHint;
+ g.SmoothingMode = sm;
+ }
+
+ protected override void OnPaintBackground(PaintEventArgs pevent)
+ {
+ base.OnPaintBackground(pevent);
+ Graphics gfx;
+ RectangleF innerRect, outerRect;
+ GraphicsPath outerPath, innerPath;
+ Brush brush;
+ Pen pen;
+ RectangleF imageRect = new RectangleF();
+ float aspect, bezelWidth;
+ float scaleFactor;
+
+ gfx = pevent.Graphics;
+ gfx.SmoothingMode = _AntiAlias ? SmoothingMode.AntiAlias : SmoothingMode.Default;
+
+ Rectangle clientRectangle = ClientRectangle;
+ if (_ClockStyleData.BezelColor.BorderWidth > 0)
+ {
+ int borderInflateSize = (int)((_ClockStyleData.BezelColor.BorderWidth * Math.Min(clientRectangle.Width, clientRectangle.Height)) / 2);
+ clientRectangle.Inflate(-borderInflateSize, -borderInflateSize);
+ }
+
+ scaleFactor = Math.Min(clientRectangle.Width, clientRectangle.Height);
+ bezelWidth = _ClockStyleData.BezelWidth * (scaleFactor - 1);
+
+ innerRect = new RectangleF(clientRectangle.X + bezelWidth,
+ clientRectangle.Y + bezelWidth,
+ (clientRectangle.Width - 1) - bezelWidth * 2.0f,
+ (clientRectangle.Height - 1) - bezelWidth * 2.0f);
+ outerRect = new RectangleF(clientRectangle.X,
+ clientRectangle.Y,
+ clientRectangle.Width - 1,
+ clientRectangle.Height - 1);
+
+ outerPath = new GraphicsPath();
+ innerPath = new GraphicsPath();
+
+ switch (_ClockStyleData.ClockShape)
+ {
+ case eClockShapes.Round:
+ outerPath.AddEllipse(outerRect);
+ outerPath.CloseAllFigures();
+ innerPath.AddEllipse(innerRect);
+ innerPath.CloseAllFigures();
+ break;
+ default:
+ outerPath.AddRectangle(outerRect);
+ innerPath.AddRectangle(innerRect);
+ break;
+ }
+
+
+ if (_ClockStyleData.FaceBackgroundImage != null)
+ {
+ gfx.SetClip(outerPath);
+ if (_ClockStyleData.FaceBackgroundImage.Width < _ClockStyleData.FaceBackgroundImage.Height)
+ aspect = (float)innerRect.Width / (float)_ClockStyleData.FaceBackgroundImage.Width;
+ else
+ aspect = (float)innerRect.Height / (float)_ClockStyleData.FaceBackgroundImage.Height;
+ imageRect.X = innerRect.X + ((innerRect.Width / 2.0f) - (aspect * _ClockStyleData.FaceBackgroundImage.Width) / 2.0f);
+ imageRect.Y = innerRect.Y + ((innerRect.Height / 2.0f) - (aspect * _ClockStyleData.FaceBackgroundImage.Height) / 2.0f);
+ imageRect.Width = aspect * _ClockStyleData.FaceBackgroundImage.Width;
+ imageRect.Height = aspect * _ClockStyleData.FaceBackgroundImage.Height;
+ gfx.DrawImage(_ClockStyleData.FaceBackgroundImage, imageRect);
+
+ }
+
+ gfx.ResetClip();
+ gfx.SetClip(innerPath, CombineMode.Exclude);
+ brush = _ClockStyleData.BezelColor.GetBrush(outerPath);
+ gfx.FillPath(brush, outerPath);
+ brush.Dispose();
+ if (_ClockStyleData.BezelColor.BorderWidth > 0)
+ {
+ pen = _ClockStyleData.BezelColor.GetBorderPen(scaleFactor, PenAlignment.Center);
+ gfx.DrawPath(pen, outerPath);
+ pen.Dispose();
+ }
+
+ gfx.ResetClip();
+ if (_ClockStyleData.FaceBackgroundImage == null)
+ {
+ brush = _ClockStyleData.FaceColor.GetBrush(innerPath, new PointF(0.50f, 0.50f));
+ gfx.FillPath(brush, innerPath);
+ brush.Dispose();
+ }
+ if (_ClockStyleData.FaceColor.BorderWidth > 0)
+ {
+ pen = _ClockStyleData.FaceColor.GetBorderPen(scaleFactor, PenAlignment.Center);
+ gfx.DrawPath(pen, innerPath);
+ pen.Dispose();
+ }
+ innerPath.Dispose();
+ outerPath.Dispose();
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ //if (Width < 100)
+ //{
+ // Width = 100;
+ // Height = 100;
+ //}
+ //else
+ if (_LastSize.Width != Width)
+ Height = Width;
+ else
+ Width = Height;
+
+ _LastSize = Size;
+ }
+
+ ///
+ /// Renders the clock's center cap.
+ ///
+ /// Graphics object used for rendering.
+ /// Bounding rectangle.
+ protected virtual void DrawCap(Graphics gfx, RectangleF rect)
+ {
+ float scaleFactor;
+ GraphicsPath path;
+ RectangleF capRect;
+ Pen pen;
+ Brush brush;
+ float capSize;
+ scaleFactor = Math.Min(rect.Width, rect.Height);
+
+ capSize = _ClockStyleData.CapSize * scaleFactor;
+ capRect = new RectangleF(-capSize / 2.0f, -capSize / 2.0f, capSize, capSize);
+ path = new GraphicsPath();
+ path.AddEllipse(capRect);
+
+ brush = _ClockStyleData.CapColor.GetBrush(path);
+ gfx.FillPath(brush, path);
+ if (_ClockStyleData.CapColor.BorderWidth > 0)
+ {
+ pen = _ClockStyleData.CapColor.GetBorderPen(scaleFactor, PenAlignment.Outset);
+ gfx.DrawPath(pen, path);
+ pen.Dispose();
+ }
+ brush.Dispose();
+ path.Dispose();
+ }
+
+ ///
+ /// Renders the clock's glass overlay.
+ ///
+ /// Graphics object used for rendering.
+ /// Bounding rectangle.
+ protected virtual void DrawGlassOverlay(Graphics gfx, RectangleF rect)
+ {
+ GraphicsState gState;
+ PathGradientBrush brush;
+ GraphicsPath path, brushPath;
+ PointF[] curvePoints;
+ float radius;
+
+ gState = gfx.Save();
+ rect.Width *= 0.95f;
+ rect.Height *= 0.95f;
+ rect.X = -rect.Width / 2.0f;
+ rect.Y = -rect.Height / 2.0f;
+ radius = Math.Min(rect.Width, rect.Height) / 2.0f;
+
+ brushPath = new GraphicsPath();
+ brushPath.AddEllipse(rect);
+ brush = new PathGradientBrush(brushPath);
+ brush.CenterPoint = new PointF(0.0f, 0.0f);
+ brush.CenterColor = Color.FromArgb(192, Color.White);
+ brush.SurroundColors = new Color[] { Color.FromArgb(64, Color.White) };
+
+ path = new GraphicsPath();
+ path.AddArc(rect, 180, 180);
+ curvePoints = new PointF[5];
+ curvePoints[0].X = -radius;
+ curvePoints[0].Y = 0.0f;
+
+ curvePoints[1].X = -radius * 0.5f;
+ curvePoints[1].Y = -radius * 0.175f;
+
+ curvePoints[2].X = 0.0f;
+ curvePoints[2].Y = -radius * 0.25f;
+
+ curvePoints[3].X = radius * 0.5f;
+ curvePoints[3].Y = -radius * 0.175f;
+
+ curvePoints[4].X = radius;
+ curvePoints[4].Y = 0.0f;
+
+ path.AddCurve(curvePoints);
+ path.CloseAllFigures();
+
+ gfx.RotateTransform(_ClockStyleData.GlassAngle);
+ gfx.FillPath(brush, path);
+
+ gfx.Restore(gState);
+ brush.Dispose();
+ brushPath.Dispose();
+ path.Dispose();
+
+ }
+
+ private static float RoundToExactHour(float angle)
+ {
+ return (float)Math.Floor((angle / 30f)) * 30f;
+ }
+ ///
+ /// Renders the clock's hands.
+ ///
+ /// Graphics object used for rendering.
+ /// Bounding rectangle.
+ /// True if this is the rending pass after the cap has been rendered.
+ protected virtual void DrawHands(Graphics gfx, RectangleF rect, bool overCap)
+ {
+ GraphicsState gState;
+ GraphicsPath path;
+ Pen pen;
+ Brush brush;
+ float scaleFactor, angle;
+
+ scaleFactor = Math.Min(rect.Width, rect.Height);
+ gState = gfx.Save();
+ gfx.ResetTransform();
+
+ //Hour Hand
+ if (_ClockStyleData.HourHandStyle.DrawOverCap == overCap)
+ {
+ if (_EditState == eClockEditStates.Hour)
+ angle = (float)MathHelper.GetDegrees(GetAngleFromPoint(_EditLoc)) + 90.0f;
+ else
+ angle = (float)(_Value.TimeOfDay.TotalHours > 12 ? _Value.TimeOfDay.TotalHours - 12 : _Value.TimeOfDay.TotalHours) * 30.0f;
+
+ // When clock is editable round up the angle to point at the hour exactly
+ if (_IsEditable && !_AutomaticMode)
+ {
+ angle = RoundToExactHour(angle);
+ }
+ path = _ClockStyleData.HourHandStyle.GenerateHandPath(rect, angle);
+ brush = _ClockStyleData.HourHandStyle.HandColor.GetBrush(path, _ClockStyleData.HourHandStyle.HandColor.BrushAngle + angle);
+ gfx.FillPath(brush, path);
+ if (_ClockStyleData.HourHandStyle.HandColor.BorderWidth > 0)
+ {
+ pen = _ClockStyleData.HourHandStyle.HandColor.GetBorderPen(scaleFactor, PenAlignment.Outset);
+ gfx.DrawPath(pen, path);
+ pen.Dispose();
+ }
+ brush.Dispose();
+ path.Dispose();
+ }
+
+ //Minute Hand
+ if (_ClockStyleData.MinuteHandStyle.DrawOverCap == overCap)
+ {
+ if (_EditState == eClockEditStates.Minute)
+ angle = (float)MathHelper.GetDegrees(GetAngleFromPoint(_EditLoc)) + 90.0f;
+ else
+ angle = (float)_Value.TimeOfDay.TotalMinutes * 6.0f;
+ path = _ClockStyleData.MinuteHandStyle.GenerateHandPath(rect, angle);
+ brush = _ClockStyleData.MinuteHandStyle.HandColor.GetBrush(path, _ClockStyleData.MinuteHandStyle.HandColor.BrushAngle + angle);
+ gfx.FillPath(brush, path);
+ if (_ClockStyleData.MinuteHandStyle.HandColor.BorderWidth > 0)
+ {
+ pen = _ClockStyleData.MinuteHandStyle.HandColor.GetBorderPen(scaleFactor, PenAlignment.Outset);
+ gfx.DrawPath(pen, path);
+ pen.Dispose();
+ }
+ brush.Dispose();
+ path.Dispose();
+ }
+
+ //Second Hand
+ if (_ShowSecondHand && _ClockStyleData.SecondHandStyle.DrawOverCap == overCap)
+ {
+ if (_EditState == eClockEditStates.Second)
+ angle = (float)MathHelper.GetDegrees(GetAngleFromPoint(_EditLoc)) + 90.0f;
+ else
+ angle = (float)_Value.TimeOfDay.Seconds * 6.0f;
+ path = _ClockStyleData.SecondHandStyle.GenerateHandPath(rect, angle);
+ brush = _ClockStyleData.SecondHandStyle.HandColor.GetBrush(path, _ClockStyleData.SecondHandStyle.HandColor.BrushAngle + angle);
+ gfx.FillPath(brush, path);
+ if (_ClockStyleData.SecondHandStyle.HandColor.BorderWidth > 0)
+ {
+ pen = _ClockStyleData.SecondHandStyle.HandColor.GetBorderPen(scaleFactor, PenAlignment.Outset);
+ gfx.DrawPath(pen, path);
+ pen.Dispose();
+ }
+ brush.Dispose();
+ path.Dispose();
+ }
+ gfx.Restore(gState);
+ }
+
+ ///
+ /// Renders the clock's numeric hour indicators.
+ ///
+ /// Graphics object used for rendering.
+ /// Bounding rectangle.
+ protected virtual void DrawNumbers(Graphics gfx, RectangleF rect)
+ {
+ PointF center, txtCenter;
+ float scaleFactor, radius, tickIncrement, angle;
+ Brush brush;
+ StringFormat strFormat;
+ Font fnt;
+
+ strFormat = new StringFormat();
+ strFormat.Alignment = StringAlignment.Center;
+ strFormat.LineAlignment = StringAlignment.Center;
+
+ scaleFactor = Math.Min(rect.Width, rect.Height) / _BaseSize;
+ fnt = new Font(_ClockStyleData.NumberFont.FontFamily, _ClockStyleData.NumberFont.Size * scaleFactor, _ClockStyleData.NumberFont.Style, GraphicsUnit.Pixel);
+ center = new PointF(rect.X + rect.Width / 2.0f, rect.Y + rect.Height / 2.0f);
+ radius = (rect.Width / 2.0f) - (gfx.MeasureString("12", fnt).Height) / 1.25f;
+ tickIncrement = (float)MathHelper.GetRadians(30.0f);
+ angle = (float)MathHelper.GetRadians(-60.0f);
+ brush = new SolidBrush(_ClockStyleData.NumberColor);
+
+ txtCenter = new PointF();
+ for (int i = 1; i <= 12; i++)
+ {
+ txtCenter.X = (float)(radius * Math.Cos(angle));
+ txtCenter.Y = (float)(radius * Math.Sin(angle));
+ gfx.DrawString(i.ToString(), fnt, brush, txtCenter, strFormat);
+ angle += tickIncrement;
+ }
+
+ brush.Dispose();
+ fnt.Dispose();
+ }
+
+ ///
+ /// Renders the clock's tick hour/minute indicators.
+ ///
+ /// Graphics object used for rendering.
+ /// Bounding rectangle.
+ protected virtual void DrawTicks(Graphics gfx, RectangleF rect)
+ {
+ float scaleFactor;
+ PointF[] largePts, smallPts;
+ GraphicsState gState;
+ Brush largeBrush, smallBrush;
+ Pen largePen = null, smallPen = null;
+ GraphicsPath largePath, smallPath;
+
+ scaleFactor = Math.Min(rect.Width, rect.Height);
+
+ largePts = new PointF[4];
+ largePts[0].X = (-_ClockStyleData.LargeTickWidth * 0.5f) * scaleFactor;
+ largePts[0].Y = -0.45f * scaleFactor;
+
+ largePts[1].X = (-_ClockStyleData.LargeTickWidth * 0.5f) * scaleFactor;
+ largePts[1].Y = (-0.45f + _ClockStyleData.LargeTickLength) * scaleFactor;
+
+ largePts[2].X = (_ClockStyleData.LargeTickWidth * 0.5f) * scaleFactor;
+ largePts[2].Y = (-0.45f + _ClockStyleData.LargeTickLength) * scaleFactor;
+
+ largePts[3].X = (_ClockStyleData.LargeTickWidth * 0.5f) * scaleFactor;
+ largePts[3].Y = -0.45f * scaleFactor;
+
+ smallPts = new PointF[4];
+ smallPts[0].X = (-_ClockStyleData.SmallTickWidth * -0.5f) * scaleFactor;
+ smallPts[0].Y = -0.45f * scaleFactor;
+
+ smallPts[1].X = (-_ClockStyleData.SmallTickWidth * -0.5f) * scaleFactor;
+ smallPts[1].Y = (-0.45f + _ClockStyleData.SmallTickLength) * scaleFactor;
+
+ smallPts[2].X = (_ClockStyleData.SmallTickWidth * -0.5f) * scaleFactor;
+ smallPts[2].Y = (-0.45f + _ClockStyleData.SmallTickLength) * scaleFactor;
+
+ smallPts[3].X = (_ClockStyleData.SmallTickWidth * -0.5f) * scaleFactor;
+ smallPts[3].Y = -0.45f * scaleFactor;
+
+ largePath = new GraphicsPath();
+ largePath.AddPolygon(largePts);
+
+ smallPath = new GraphicsPath();
+ smallPath.AddPolygon(smallPts);
+
+ largeBrush = _ClockStyleData.LargeTickColor.GetBrush(largePath);
+ if (_ClockStyleData.LargeTickColor.BorderWidth > 0)
+ largePen = _ClockStyleData.LargeTickColor.GetBorderPen(scaleFactor, PenAlignment.Center);
+
+ smallBrush = _ClockStyleData.LargeTickColor.GetBrush(largePath);
+ if (_ClockStyleData.SmallTickColor.BorderWidth > 0)
+ smallPen = _ClockStyleData.SmallTickColor.GetBorderPen(scaleFactor, PenAlignment.Center);
+
+ gState = gfx.Save();
+ for (int i = 0; i < 12; i++)
+ {
+ gfx.FillPolygon(largeBrush, largePts);
+ if (largePen != null)
+ gfx.DrawPolygon(largePen, largePts);
+ for (int j = 0; j < 4; j++)
+ {
+ gfx.RotateTransform(6);
+ gfx.FillPolygon(smallBrush, smallPts);
+ if (smallPen != null)
+ gfx.DrawPolygon(smallPen, smallPts);
+ }
+ gfx.RotateTransform(6);
+ }
+ gfx.Restore(gState);
+
+ largePath.Dispose();
+ smallPath.Dispose();
+ largeBrush.Dispose();
+ smallBrush.Dispose();
+ if (largePen != null)
+ largePen.Dispose();
+ if (smallPen != null)
+ smallPen.Dispose();
+ }
+
+ private float GetAngleFromPoint(PointF pt)
+ {
+ float angle;
+ PointF center = new PointF(ClientRectangle.X + ClientRectangle.Width / 2.0f, ClientRectangle.Y + ClientRectangle.Height / 2.0f);
+ pt.X -= center.X;
+ pt.Y -= center.Y;
+ angle = (float)Math.Atan2((double)(pt.Y), (double)(pt.X));
+ return angle;
+ }
+
+ private void UpdateAutomaticTime()
+ {
+ if (_TimeZoneInfo != null)
+ Value = DevComponents.Schedule.TimeZoneInfo.ConvertTime(DateTime.Now, _TimeZoneInfo);
+ else
+ Value = DateTime.Now;
+ }
+
+ private void Timer_Tick(object sender, EventArgs e)
+ {
+ UpdateAutomaticTime();
+ }
+
+ private DevComponents.Schedule.TimeZoneInfo _TimeZoneInfo = null;
+ private string _TimeZone = string.Empty;
+ ///
+ /// Gets or sets the time-zone string identifier that is used to display the time when AutomaticMode=true and clock is displaying current time.
+ ///
+ [DefaultValue(""), Editor("DevComponents.DotNetBar.Design.TimeZoneSelectionEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Category("Behavior"), Description("Indicates time-zone string identifier that is used to display the time when AutomaticMode=true and clock is displaying current time.")]
+ public string TimeZone
+ {
+ get { return _TimeZone; }
+ set
+ {
+ if (value != _TimeZone)
+ {
+ DevComponents.Schedule.TimeZoneInfo timeZoneInfo = null;
+ if (!string.IsNullOrEmpty(value))
+ timeZoneInfo = DevComponents.Schedule.TimeZoneInfo.FindSystemTimeZoneById(value);
+ if (timeZoneInfo != null || string.IsNullOrEmpty(value))
+ {
+ string oldValue = _TimeZone;
+ _TimeZone = value;
+ _TimeZoneInfo = timeZoneInfo;
+ OnTimeZoneChanged(oldValue, value);
+ }
+ }
+ }
+ }
+ ///
+ /// Called when TimeZone property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnTimeZoneChanged(string oldValue, string newValue)
+ {
+ if (_AutomaticMode)
+ UpdateAutomaticTime();
+ //OnPropertyChanged(new PropertyChangedEventArgs("TimeZone"));
+ }
+
+ /////
+ ///// Raises the SubPropertyChanged event.
+ /////
+ ///// Event arguments
+ //public void OnSubPropertyChanged(DevComponents.Schedule.Model.SubPropertyChangedEventArgs e)
+ //{
+ // if (SubPropertyChanged != null)
+ // SubPropertyChanged(this, e);
+ // Invalidate();
+ //}
+
+ #endregion
+ }
+
+ ///
+ /// Enumeration containing the available hour/minute indicators.
+ ///
+ public enum eClockIndicatorStyles
+ {
+ ///
+ /// Control will use ticks for hour/minute indicators.
+ ///
+ Ticks,
+
+ ///
+ /// Control will use numbers for hour indicators.
+ ///
+ Numbers
+ }
+
+ ///
+ /// Enumeration containing the available mouse edit states.
+ ///
+ public enum eClockEditStates
+ {
+ ///
+ /// Control is not currently in an edit state.
+ ///
+ None,
+
+ ///
+ /// Control is currently in an hour edit state.
+ ///
+ Hour,
+
+ ///
+ /// Control is currently in an minute edit state.
+ ///
+ Minute,
+
+ ///
+ /// Control is currently in an second edit state.
+ ///
+ Second
+ }
+
+ ///
+ /// Provides event arguments for TimeValueChanging event.
+ ///
+ public class TimeValueChangingEventArgs : EventArgs
+ {
+ ///
+ /// Gets the current time represented by the control.
+ ///
+ public readonly DateTime Time;
+ ///
+ /// Initializes a new instance of the TimeValueChangingEventArgs class.
+ ///
+ ///
+ public TimeValueChangingEventArgs(DateTime time)
+ {
+ Time = time;
+ }
+
+ }
+ ///
+ /// Defines delegate for TimeValueChanging event.
+ ///
+ /// Source of event.
+ /// Event arguments
+ public delegate void TimeValueChangingEventHandler(object sender, TimeValueChangingEventArgs e);
+}
diff --git a/PROMS/DotNetBar Source Code/AnalogClock/ClockHandStyleData.cs b/PROMS/DotNetBar Source Code/AnalogClock/ClockHandStyleData.cs
new file mode 100644
index 00000000..5cb6fa93
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AnalogClock/ClockHandStyleData.cs
@@ -0,0 +1,305 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Data storage class for clock hand visual style.
+ ///
+ [Description("Clock Hand Style"),
+ TypeConverterAttribute(typeof(ExpandableObjectConverter))]
+ public class ClockHandStyleData : INotifyPropertyChanged
+ {
+ private bool _DrawOverCap;
+ ///
+ /// Gets or sets a value indicating whether the hand is drawn over the cap.
+ ///
+ [DefaultValue(false),
+ Category("Appearance"),
+ Description("Indicates whether the hand is drawn over the cap.")]
+ public bool DrawOverCap
+ {
+ get { return _DrawOverCap; }
+ set { _DrawOverCap = value; }
+ }
+
+ private void ColorPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ OnPropertyChanged(e);
+ }
+
+ private ColorData _HandColor;
+ ///
+ /// Gets or sets the hand color data for this hand.
+ ///
+ [Category("Appearance"),
+ Description("The hand color data for this hand.")]
+ public ColorData HandColor
+ {
+ get { return _HandColor; }
+ set
+ {
+ if (value != _HandColor)
+ {
+ if (_HandColor != null) _HandColor.PropertyChanged -= ColorPropertyChanged;
+ _HandColor = value;
+ if (_HandColor != null) _HandColor.PropertyChanged += ColorPropertyChanged;
+ OnPropertyChanged(new PropertyChangedEventArgs("HandColor"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetHandColor()
+ {
+ HandColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
+ }
+
+ private eHandStyles _HandStyle;
+ ///
+ /// Gets or sets the hand style for this clock hand. Default value is Style1.
+ ///
+ [DefaultValue(eHandStyles.Style1),
+ Category("Appearance"),
+ Description("The hand style for this clock hand.")]
+ public eHandStyles HandStyle
+ {
+ get { return _HandStyle; }
+ set
+ {
+ if (value != _HandStyle)
+ {
+ _HandStyle = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("HandStyle"));
+ }
+ }
+ }
+
+ private float _Length;
+ ///
+ /// Gets or sets the length of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle. Default value is 1.0.
+ ///
+ [DefaultValue(1.0f),
+ Category("Appearance"),
+ Description("The length of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle.")]
+ public float Length
+ {
+ get { return _Length; }
+ set
+ {
+ if (value != _Length)
+ {
+ _Length = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("Length"));
+ }
+ }
+ }
+
+ private float _Width;
+ ///
+ /// Gets or sets the width of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle. Default value is 0.1.
+ ///
+ [DefaultValue(0.1f),
+ Category("Appearance"),
+ Description("The width of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle.")]
+ public float Width
+ {
+ get { return _Width; }
+ set
+ {
+ if (value != _Width)
+ {
+ _Width = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("Width"));
+ }
+ }
+ }
+
+ ///
+ /// Occurs when property value has changed.
+ ///
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ ///
+ /// Initializes a new instance of the ClockHand class.
+ ///
+ public ClockHandStyleData()
+ {
+ _DrawOverCap = false;
+ _HandColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
+ _HandStyle = eHandStyles.Style1;
+ _Length = 1.0f;
+ _Width = 0.1f;
+ }
+
+ ///
+ /// Initializes a new instance of the ClockHand class.
+ ///
+ /// The hand style for this item.
+ /// The length of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle
+ /// The width of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle.
+ public ClockHandStyleData(eHandStyles handStyle, float length, float width)
+ {
+ _DrawOverCap = false;
+ _HandColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
+ _HandStyle = handStyle;
+ _Length = length;
+ _Width = width;
+ }
+
+ ///
+ /// Indicates whether the specified point is contained within the bounds of this hand.
+ ///
+ /// The bounding rectangle of the parent clock control.
+ /// The clockwise angle for this clock hand in degrees from the 12 o'clock position.
+ /// A Point that represents the point to test.
+ ///
+ public virtual bool ContainsPoint(RectangleF boundingRect, float angle, Point pt)
+ {
+ GraphicsPath path;
+ bool ret;
+
+ path = GenerateHandPath(boundingRect, angle);
+
+ ret = path.IsVisible(pt);
+ path.Dispose();
+ return ret;
+ }
+
+ ///
+ /// Generates a scaled and rotated graphics path based on the given style, rectangle and angle.
+ ///
+ /// The bounding rectangle of the parent clock control.
+ /// The clockwise angle for this clock hand in degrees from the 12 o'clock position.
+ ///
+ public GraphicsPath GenerateHandPath(RectangleF boundingRect, float angle)
+ {
+ GraphicsPath path = new GraphicsPath();
+ RectangleF rect;
+ Matrix matrix;
+ float scaleFactor;
+ PointF[] pts;
+
+ switch (_HandStyle)
+ {
+ case eHandStyles.Style1:
+ pts = new PointF[4];
+ pts[0].X = -0.5f;
+ pts[0].Y = 0.0f;
+
+ pts[1].X = -0.5f;
+ pts[1].Y = -1.0f;
+
+ pts[2].X = 0.5f;
+ pts[2].Y = -1.0f;
+
+ pts[3].X = 0.5f;
+ pts[3].Y = 0.0f;
+ path.AddPolygon(pts);
+ break;
+ case eHandStyles.Style2:
+ pts = new PointF[4];
+ pts[0].X = -0.4f;
+ pts[0].Y = 0.25f;
+
+ pts[1].X = -0.4f;
+ pts[1].Y = -1.0f;
+
+ pts[2].X = 0.4f;
+ pts[2].Y = -1.0f;
+
+ pts[3].X = 0.4f;
+ pts[3].Y = 0.25f;
+ path.AddPolygon(pts);
+ break;
+ case eHandStyles.Style3:
+ pts = new PointF[4];
+ pts[0].X = -0.5f;
+ pts[0].Y = 0.0f;
+
+ pts[1].X = -0.0125f;
+ pts[1].Y = -1.0f;
+
+ pts[2].X = 0.0125f;
+ pts[2].Y = -1.0f;
+
+ pts[3].X = 0.5f;
+ pts[3].Y = 0.0f;
+
+ path.AddPolygon(pts);
+ break;
+ case eHandStyles.Style4:
+ path.FillMode = FillMode.Winding;
+ pts = new PointF[4];
+ pts[0].X = -0.5f;
+ pts[0].Y = -0.05f;
+
+ pts[1].X = -0.5f;
+ pts[1].Y = -1.0f;
+
+ pts[2].X = 0.5f;
+ pts[2].Y = -1.0f;
+
+ pts[3].X = 0.5f;
+ pts[3].Y = -0.05f;
+ path.AddPolygon(pts);
+
+ rect = new RectangleF(-5.0f, -0.06f, 10.0f, 0.12f);
+ path.AddEllipse(rect);
+ break;
+ }
+ scaleFactor = Math.Min(boundingRect.Width, boundingRect.Height) / 2.0f;
+ matrix = new Matrix();
+ matrix.Translate(boundingRect.X + boundingRect.Width * 0.5f, boundingRect.Y + boundingRect.Width * 0.5f);
+ matrix.Rotate(angle);
+ matrix.Scale(scaleFactor * Width, scaleFactor * Length);
+ path.Transform(matrix);
+ matrix.Dispose();
+ return path;
+ }
+
+ ///
+ /// Raises the PropertyChanged event.
+ ///
+ /// Event arguments
+ protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
+ {
+ if (PropertyChanged != null)
+ PropertyChanged(this, e);
+ }
+ }
+
+ ///
+ /// Enumeration containing the available hand styles.
+ ///
+ public enum eHandStyles
+ {
+ ///
+ /// Style 1.
+ ///
+ Style1,
+
+ ///
+ /// Style 2.
+ ///
+ Style2,
+
+ ///
+ /// Style 3.
+ ///
+ Style3,
+
+ ///
+ /// Style 4.
+ ///
+ Style4,
+ }
+
+}
diff --git a/PROMS/DotNetBar Source Code/AnalogClock/ClockStyleData.cs b/PROMS/DotNetBar Source Code/AnalogClock/ClockStyleData.cs
new file mode 100644
index 00000000..b15808eb
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AnalogClock/ClockStyleData.cs
@@ -0,0 +1,659 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Text;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Data storage class for clock visual styles.
+ ///
+ [Description("Clock Style"),
+ TypeConverterAttribute(typeof(ExpandableObjectConverter))]
+ public class ClockStyleData : IDisposable, INotifyPropertyChanged
+ {
+
+ private eClockStyles _Style;
+ ///
+ /// Gets or sets the PredefinedStyles value for this style.
+ ///
+ [Browsable(false)]
+ public eClockStyles Style
+ {
+ get { return _Style; }
+ set
+ {
+ if (value != _Style)
+ {
+ _Style = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("Style"));
+ }
+ }
+ }
+
+
+ private eClockShapes _ClockShape;
+ ///
+ /// Gets or sets the clock shape value for this style.
+ ///
+ [DefaultValue(eClockShapes.Round),
+ Category("Appearance"),
+ Description("The clock shape for this style.")]
+ public eClockShapes ClockShape
+ {
+ get { return _ClockShape; }
+ set
+ {
+ if (value != _ClockShape)
+ {
+ _ClockShape = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("ClockShape"));
+ }
+ }
+ }
+
+ private void ColorPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (_Parent != null) _Parent.Invalidate();
+ }
+
+ private ColorData _BezelColor;
+ ///
+ /// Gets or sets the bezel color data for this style.
+ ///
+ [Category("Appearance"),
+ Description("The bezel color data for this style.")]
+ public ColorData BezelColor
+ {
+ get { return _BezelColor; }
+ set
+ {
+ if (value != _BezelColor)
+ {
+ if (_BezelColor != null) _BezelColor.PropertyChanged -= ColorPropertyChanged;
+ _BezelColor = value;
+ if (_BezelColor != null) _BezelColor.PropertyChanged += ColorPropertyChanged;
+ OnPropertyChanged(new PropertyChangedEventArgs("BezelColor"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBezelColor()
+ {
+ BezelColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(255, 255, 255), Color.FromArgb(152, 152, 152), Color.FromArgb(120, 120, 120), 1.0f, 45.0f);
+ }
+
+
+ private float _BezelWidth;
+ ///
+ /// Gets or sets the width of clock bezel as a percentage value ranging from 0.0 to 1.0.
+ ///
+ [DefaultValue(0.03f),
+ Category("Appearance"),
+ Description("The width of clock bezel as a percentage value ranging from 0.0 to 1.0.")]
+ public float BezelWidth
+ {
+ get { return _BezelWidth; }
+ set
+ {
+ if (value != _BezelWidth)
+ {
+ _BezelWidth = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("BezelWidth"));
+ }
+ }
+ }
+
+ private ColorData _FaceColor;
+ ///
+ /// Gets or sets the face color data for this style.
+ ///
+ [Category("Appearance"),
+ Description("The face color data for this style.")]
+ public ColorData FaceColor
+ {
+ get { return _FaceColor; }
+ set
+ {
+ if (value != _FaceColor)
+ {
+ if (_FaceColor != null) _FaceColor.PropertyChanged -= ColorPropertyChanged;
+ _FaceColor = value;
+ if (_FaceColor != null) _FaceColor.PropertyChanged += ColorPropertyChanged;
+ OnPropertyChanged(new PropertyChangedEventArgs("FaceColor"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetFaceColor()
+ {
+ FaceColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(191, 204, 213), Color.FromArgb(255, 255, 255), Color.FromArgb(135, 145, 161), 1.0f, 45.0f);
+ }
+
+ private Image _FaceBackgroundImage;
+ ///
+ /// Gets or sets the face background image for this style.
+ ///
+ [DefaultValue(null),
+ Category("Appearance"),
+ Description("The face background image for this style.")]
+ public Image FaceBackgroundImage
+ {
+ get { return _FaceBackgroundImage; }
+ set
+ {
+ if (value != _FaceBackgroundImage)
+ {
+ _FaceBackgroundImage = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("FaceBackgroundImage"));
+ }
+ }
+ }
+
+ private ClockHandStyleData _HourHandStyle;
+ ///
+ /// Gets or sets the hour hand style for this style.
+ ///
+ [Category("Appearance"),
+ Description("The hour hand style for this style.")]
+ public ClockHandStyleData HourHandStyle
+ {
+ get { return _HourHandStyle; }
+ set
+ {
+ if (value != _HourHandStyle)
+ {
+ if (_HourHandStyle != null) _HourHandStyle.PropertyChanged -= ColorPropertyChanged;
+ _HourHandStyle = value;
+ if (_HourHandStyle != null) _HourHandStyle.PropertyChanged += ColorPropertyChanged;
+ OnPropertyChanged(new PropertyChangedEventArgs("HourHandStyle"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetHourHandStyle()
+ {
+ HourHandStyle = new ClockHandStyleData(eHandStyles.Style1, 0.55f, 0.01f);
+ }
+
+ private ClockHandStyleData _MinuteHandStyle;
+ ///
+ /// Gets or sets the minute hand style for this style.
+ ///
+ [Category("Appearance"),
+ Description("The minute hand style for this style.")]
+ public ClockHandStyleData MinuteHandStyle
+ {
+ get { return _MinuteHandStyle; }
+ set
+ {
+ if (value != _MinuteHandStyle)
+ {
+ if (_MinuteHandStyle != null) _MinuteHandStyle.PropertyChanged -= ColorPropertyChanged;
+ _MinuteHandStyle = value;
+ if (_MinuteHandStyle != null) _MinuteHandStyle.PropertyChanged += ColorPropertyChanged;
+ OnPropertyChanged(new PropertyChangedEventArgs("MinuteHandStyle"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetMinuteHandStyle()
+ {
+ MinuteHandStyle = new ClockHandStyleData(eHandStyles.Style1, 0.8f, 0.01f);
+ }
+
+
+ private ClockHandStyleData _SecondHandStyle;
+ ///
+ /// Gets or sets the second hand style for this style.
+ ///
+ [Category("Appearance"),
+ Description("The second hand style for this style.")]
+ public ClockHandStyleData SecondHandStyle
+ {
+ get { return _SecondHandStyle; }
+ set
+ {
+ if (value != _SecondHandStyle)
+ {
+ if (_SecondHandStyle != null) _SecondHandStyle.PropertyChanged -= ColorPropertyChanged;
+ _SecondHandStyle = value;
+ if (_SecondHandStyle != null) _SecondHandStyle.PropertyChanged += ColorPropertyChanged;
+ OnPropertyChanged(new PropertyChangedEventArgs("SecondHandStyle"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSecondHandStyle()
+ {
+ SecondHandStyle = new ClockHandStyleData(eHandStyles.Style2, 0.8f, 0.005f);
+ }
+
+
+ private ColorData _CapColor;
+ ///
+ /// Gets or sets the center cap color data for this style.
+ ///
+ [Category("Appearance"),
+ Description("The center cap color data for this style.")]
+ public ColorData CapColor
+ {
+ get { return _CapColor; }
+ set
+ {
+ if (value != _CapColor)
+ {
+ if (_CapColor != null) _CapColor.PropertyChanged -= ColorPropertyChanged;
+ _CapColor = value;
+ if (_CapColor != null) _CapColor.PropertyChanged += ColorPropertyChanged;
+ OnPropertyChanged(new PropertyChangedEventArgs("CapColor"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetCapColor()
+ {
+ CapColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
+ }
+
+ private float _CapSize;
+ ///
+ /// Gets or sets the center cap diameter as a percentage value ranging from 0.0 to 1.0.
+ ///
+ [DefaultValue(0.03f),
+ Category("Appearance"),
+ Description("The center cap diameter as a percentage value ranging from 0.0 to 1.0.")]
+ public float CapSize
+ {
+ get { return _CapSize; }
+ set
+ {
+ if (value != _CapSize)
+ {
+ _CapSize = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("CapSize"));
+ }
+ }
+ }
+
+ private Color _NumberColor;
+ ///
+ /// Gets or sets the face number color for this style.
+ ///
+ [DefaultValue(typeof(Color), "139, 158, 168"),
+ Category("Appearance"),
+ Description("The face number color for this style.")]
+ public Color NumberColor
+ {
+ get { return _NumberColor; }
+ set
+ {
+ if (value != _NumberColor)
+ {
+ _NumberColor = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("NumberColor"));
+ }
+ }
+ }
+
+ private Font _NumberFont;
+ ///
+ /// Gets or sets the center cap color data for this style.
+ ///
+ [Category("Appearance"),
+ Description("The face number font for this style.")]
+ public Font NumberFont
+ {
+ get { return _NumberFont; }
+ set
+ {
+ if (value != _NumberFont)
+ {
+ _NumberFont = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("NumberFont"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetNumberFont()
+ {
+ _NumberFont = new Font("Microsoft Sans Serif", 8, FontStyle.Regular, GraphicsUnit.Pixel);
+ }
+
+ private ColorData _LargeTickColor;
+ ///
+ /// Gets or sets the large tick color data for this style.
+ ///
+ [Category("Appearance"),
+ Description("The large tick color data for this style.")]
+ public ColorData LargeTickColor
+ {
+ get { return _LargeTickColor; }
+ set
+ {
+ if (value != _LargeTickColor)
+ {
+ if (_LargeTickColor != null) _LargeTickColor.PropertyChanged -= ColorPropertyChanged;
+ _LargeTickColor = value;
+ if (_LargeTickColor != null) _LargeTickColor.PropertyChanged += ColorPropertyChanged;
+ OnPropertyChanged(new PropertyChangedEventArgs("LargeTickColor"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetLargeTickColor()
+ {
+ LargeTickColor = new ColorData(eBrushTypes.Centered, Color.FromArgb(122, 142, 154), Color.FromArgb(122, 142, 154), Color.FromArgb(255, 255, 255), 1.0f);
+ }
+
+ private float _LargeTickLength;
+ ///
+ /// Gets or sets the large tick length as a percentage value ranging from 0.0 to 1.0.
+ ///
+ [DefaultValue(0.06f),
+ Category("Appearance"),
+ Description("The large tick length as a percentage value ranging from 0.0 to 1.0.")]
+ public float LargeTickLength
+ {
+ get { return _LargeTickLength; }
+ set
+ {
+ if (value != _LargeTickLength)
+ {
+ _LargeTickLength = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("LargeTickLength"));
+ }
+ }
+ }
+
+ private float _LargeTickWidth;
+ ///
+ /// Gets or sets the large tick width as a percentage value ranging from 0.0 to 1.0.
+ ///
+ [DefaultValue(0.02f),
+ Category("Appearance"),
+ Description("The large tick width as a percentage value ranging from 0.0 to 1.0.")]
+ public float LargeTickWidth
+ {
+ get { return _LargeTickWidth; }
+ set
+ {
+ if (value != _LargeTickWidth)
+ {
+ _LargeTickWidth = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("LargeTickWidth"));
+ }
+ }
+ }
+
+ private ColorData _SmallTickColor;
+ ///
+ /// Gets or sets the small tick color data for this style.
+ ///
+ [Category("Appearance"),
+ Description("The small tick color data for this style.")]
+ public ColorData SmallTickColor
+ {
+ get { return _SmallTickColor; }
+ set
+ {
+ if (value != _SmallTickColor)
+ {
+ if (_SmallTickColor != null) _SmallTickColor.PropertyChanged -= ColorPropertyChanged;
+ _SmallTickColor = value;
+ if (_SmallTickColor != null) _SmallTickColor.PropertyChanged += ColorPropertyChanged;
+ OnPropertyChanged(new PropertyChangedEventArgs("SmallTickColor"));
+ }
+ }
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSmallTickColor()
+ {
+ SmallTickColor = new ColorData(eBrushTypes.Centered, Color.FromArgb(122, 142, 154), Color.FromArgb(122, 142, 154), Color.FromArgb(255, 255, 255), 1.0f);
+ }
+
+ private float _SmallTickLength;
+ ///
+ /// Gets or sets the small tick length as a percentage value ranging from 0.0 to 1.0.
+ ///
+ [DefaultValue(0.02f),
+ Category("Appearance"),
+ Description("The small tick length as a percentage value ranging from 0.0 to 1.0.")]
+ public float SmallTickLength
+ {
+ get { return _SmallTickLength; }
+ set
+ {
+ if (value != _SmallTickLength)
+ {
+ _SmallTickLength = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("SmallTickLength"));
+ }
+ }
+ }
+
+ private float _SmallTickWidth;
+ ///
+ /// Gets or sets the small tick width as a percentage value ranging from 0.0 to 1.0.
+ ///
+ [DefaultValue(0.02f),
+ Category("Appearance"),
+ Description("The small tick width as a percentage value ranging from 0.0 to 1.0.")]
+ public float SmallTickWidth
+ {
+ get { return _SmallTickWidth; }
+ set
+ {
+ if (value != _SmallTickWidth)
+ {
+ _SmallTickWidth = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("SmallTickWidth"));
+ }
+ }
+ }
+
+ private int _GlassAngle;
+ ///
+ /// Gets or sets the overlay glass angle, in degrees for this style.
+ ///
+ [DefaultValue(20),
+ Category("Appearance"),
+ Description("The overlay angle, in degrees for this style.")]
+ public int GlassAngle
+ {
+ get { return _GlassAngle; }
+ set
+ {
+ if (value != _GlassAngle)
+ {
+ _GlassAngle = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("_GlassAngle"));
+ }
+ }
+ }
+
+ ///
+ /// Occurs when property value has changed.
+ ///
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ ///
+ /// Initializes a new instance of the ClockStyle class.
+ ///
+ public ClockStyleData()
+ {
+ LoadStyle(eClockStyles.Style1);
+ }
+
+ private AnalogClockControl _Parent = null;
+ ///
+ /// Gets the parent of the style.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public AnalogClockControl Parent
+ {
+ get { return _Parent; }
+ internal set { _Parent = value; }
+ }
+
+ ///
+ /// Initializes a new instance of the ClockStyle class.
+ ///
+ /// Predefined style from the PredefinedStyles enum.
+ public ClockStyleData(eClockStyles style)
+ {
+ LoadStyle(style);
+ }
+
+ ///
+ /// Initializes a new instance of the ClockStyle class.
+ ///
+ /// Predefined style from the PredefinedStyles enum.
+ public ClockStyleData(eClockStyles style, AnalogClockControl parent)
+ {
+ LoadStyle(style);
+ _Parent = parent;
+ }
+
+ ///
+ /// Releases all resources used by the class.
+ ///
+ public void Dispose()
+ {
+ if (_FaceBackgroundImage != null)
+ _FaceBackgroundImage.Dispose();
+ if (_NumberFont != null)
+ _NumberFont.Dispose();
+ }
+
+ ///
+ /// Loads a predefined style
+ ///
+ /// The predefined style to load.
+ private void LoadStyle(eClockStyles style)
+ {
+ _Style = style;
+ switch (style)
+ {
+ case eClockStyles.Style1:
+ case eClockStyles.Custom:
+ _ClockShape = eClockShapes.Round;
+ BezelColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(255, 255, 255), Color.FromArgb(152, 152, 152), Color.FromArgb(120, 120, 120), 0.01f);
+ _BezelWidth = 0.03f;
+ FaceColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(191, 204, 213), Color.FromArgb(255, 255, 255), Color.FromArgb(135, 145, 161), 0.01f, 45.0f);
+ _FaceBackgroundImage = null;
+ HourHandStyle = new ClockHandStyleData(eHandStyles.Style1, 0.55f, 0.015f);
+ MinuteHandStyle = new ClockHandStyleData(eHandStyles.Style1, 0.8f, 0.01f);
+ SecondHandStyle = new ClockHandStyleData(eHandStyles.Style2, 0.8f, 0.005f);
+ CapColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
+ _CapSize = 0.03f;
+ _NumberColor = Color.FromArgb(139, 158, 168);
+ _NumberFont = new Font("Microsoft Sans Serif", 12, FontStyle.Regular, GraphicsUnit.Pixel);
+ LargeTickColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(122, 142, 154), Color.FromArgb(122, 142, 154), Color.FromArgb(128, 255, 255, 255), 0.01f);
+ _LargeTickLength = 0.06f;
+ _LargeTickWidth = 0.02f;
+ SmallTickColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(122, 142, 154), Color.FromArgb(122, 142, 154), Color.FromArgb(128, 255, 255, 255), 0.01f);
+ _SmallTickLength = 0.02f;
+ _SmallTickWidth = 0.02f;
+ _GlassAngle = -20;
+ break;
+ case eClockStyles.Style2:
+ _ClockShape = eClockShapes.Round;
+ BezelColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(80, 80, 80), Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0), 0.0f, 90.0f);
+ _BezelWidth = 0.03f;
+ FaceColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(225, 225, 225), Color.FromArgb(240, 240, 240), Color.FromArgb(0, 0, 0), 0.0f, 90.0f);
+ _FaceBackgroundImage = null;
+ HourHandStyle = new ClockHandStyleData(eHandStyles.Style3, 0.45f, 0.175f);
+ HourHandStyle.HandColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(0, 0, 0), Color.FromArgb(80, 80, 80), Color.FromArgb(64, 0, 0, 0), 0.01f, 90.0f);
+ MinuteHandStyle = new ClockHandStyleData(eHandStyles.Style3, 0.75f, 0.175f);
+ MinuteHandStyle.HandColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(0, 0, 0), Color.FromArgb(80, 80, 80), Color.FromArgb(64, 0, 0, 0), 0.01f, 90.0f);
+ SecondHandStyle = new ClockHandStyleData(eHandStyles.Style4, 0.9f, 0.01f);
+ SecondHandStyle.HandColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(255, 0, 0), Color.FromArgb(255, 0, 0), Color.FromArgb(128, 192, 0, 0), 0.01f);
+ _SecondHandStyle.DrawOverCap = true;
+ CapColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(255, 255, 255), Color.FromArgb(255, 255, 255), Color.FromArgb(223, 0, 0, 0), 0.01f);
+ _CapSize = 0.1f;
+ _NumberColor = Color.FromArgb(0, 0, 0);
+ _NumberFont = new Font("Trebuchet MS", 12, FontStyle.Regular, GraphicsUnit.Pixel);
+ LargeTickColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0), Color.FromArgb(64, 0, 0, 0), 0.01f);
+ _LargeTickLength = 0.06f;
+ _LargeTickWidth = 0.01f;
+ SmallTickColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0), Color.FromArgb(64, 0, 0, 0), 0.01f);
+ _SmallTickLength = 0.01f;
+ _SmallTickWidth = 0.01f;
+ _GlassAngle = 0;
+ break;
+ }
+ }
+
+ ///
+ /// Raises the PropertyChanged event.
+ ///
+ /// Event arguments
+ protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
+ {
+ if (PropertyChanged != null)
+ PropertyChanged(this, e);
+ if (_Parent != null) _Parent.Invalidate();
+ }
+ }
+
+ ///
+ /// Enumeration containing the predefined clock styles.
+ ///
+ public enum eClockStyles
+ {
+ ///
+ /// Style 1. Default style,
+ ///
+ Style1,
+
+ ///
+ /// Style 2.
+ ///
+ Style2,
+
+ ///
+ /// No predefined style.
+ ///
+ Custom
+ }
+
+ ///
+ /// Enumeration containing the predefined clock shapes.
+ ///
+ public enum eClockShapes
+ {
+ ///
+ /// Round clock shape.
+ ///
+ Round
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AnalogClock/ColorData.cs b/PROMS/DotNetBar Source Code/AnalogClock/ColorData.cs
new file mode 100644
index 00000000..b7031d9e
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AnalogClock/ColorData.cs
@@ -0,0 +1,442 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Data storage and utility class for defining gradient colors.
+ ///
+ [Description("Color Data Class"),
+ TypeConverterAttribute(typeof(ExpandableObjectConverter))]
+ public class ColorData : INotifyPropertyChanged
+ {
+ private Color _BorderColor;
+ ///
+ /// Gets or sets the border color for this item. Default value is white.
+ ///
+ [DefaultValue(typeof(Color), "255, 255, 255"),
+ Category("Appearance"),
+ Description("The border color for this item.")]
+ public Color BorderColor
+ {
+ get { return _BorderColor; }
+ set
+ {
+ if (value != _BorderColor)
+ {
+ _BorderColor = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("BorderColor"));
+ }
+ }
+ }
+
+ private float _BorderWidth;
+ ///
+ /// Gets or sets the border width for this item. Default value is 0.
+ ///
+ [DefaultValue(0.0f),
+ Category("Appearance"),
+ Description("The border width for this item.")]
+ public float BorderWidth
+ {
+ get { return _BorderWidth; }
+ set
+ {
+ if (value != _BorderWidth)
+ {
+ _BorderWidth = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("BorderWidth"));
+ }
+ }
+ }
+
+ private float _BrushAngle;
+ ///
+ /// Gets or sets the brush angle for this item. Only applies to Linear and Reflected brush types. Default value is 0.
+ ///
+ [DefaultValue(0.0f),
+ Category("Appearance"),
+ Description("The brush angle for this item. Only applies to Linear and Reflected brush types.")]
+ public float BrushAngle
+ {
+ get { return _BrushAngle; }
+ set
+ {
+ if (value != _BrushAngle)
+ {
+ _BrushAngle = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("BrushAngle"));
+ }
+ }
+ }
+
+ private float _BrushSBSFocus;
+ ///
+ /// Gets or sets the brush SigmaBellShape focus for this item. Only applies to Reflected brush types. Default value is 0.5.
+ ///
+ [DefaultValue(0.5f),
+ Category("Appearance"),
+ Description("The brush SigmaBellShape focus for this item. Only applies to Linear and Reflected brush types.")]
+ public float BrushSBSFocus
+ {
+ get { return _BrushSBSFocus; }
+ set
+ {
+ if (value != _BrushSBSFocus)
+ {
+ _BrushSBSFocus = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("BrushSBSFocus"));
+ }
+ }
+ }
+
+ private float _BrushSBSScale;
+ ///
+ /// Gets or sets the brush SigmaBellShape scale for this item. Only applies to Reflected brush types. Default value is 0.5.
+ ///
+ [DefaultValue(0.5f),
+ Category("Appearance"),
+ Description("The brush SigmaBellShape scale for this item. Only applies to Linear and Reflected brush types.")]
+ public float BrushSBSScale
+ {
+ get { return _BrushSBSScale; }
+ set
+ {
+ if (value != _BrushSBSScale)
+ {
+ _BrushSBSScale = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("BrushSBSScale"));
+ }
+ }
+ }
+
+ private eBrushTypes _BrushType;
+ ///
+ /// Gets or sets the brush type for this item. Default value is Solid.
+ ///
+ [DefaultValue(eBrushTypes.Solid),
+ Category("Appearance"),
+ Description("The brush type for this item.")]
+ public eBrushTypes BrushType
+ {
+ get { return _BrushType; }
+ set
+ {
+ if (value != _BrushType)
+ {
+ _BrushType = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("BrushType"));
+ }
+ }
+ }
+
+ private Color _Color1;
+ ///
+ /// Gets or sets the first color for this item. Default value is white.
+ ///
+ [DefaultValue(typeof(Color), "255, 255, 255"),
+ Category("Appearance"),
+ Description("The first color for this item.")]
+ public Color Color1
+ {
+ get { return _Color1; }
+ set
+ {
+ if (value != _Color1)
+ {
+ _Color1 = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("Color1"));
+ }
+ }
+ }
+
+ private Color _Color2;
+ ///
+ /// Gets or sets the second color for this item. Default value is white.
+ ///
+ [DefaultValue(typeof(Color), "255, 255, 255"),
+ Category("Appearance"),
+ Description("The second color for this item.")]
+ public Color Color2
+ {
+ get { return _Color2; }
+ set
+ {
+ if (value != _Color2)
+ {
+ _Color2 = value;
+ OnPropertyChanged(new PropertyChangedEventArgs("Color2"));
+ }
+ }
+ }
+
+ ///
+ /// Occurs when property value has changed.
+ ///
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ ///
+ /// Creates new instance of the object.
+ ///
+ public ColorData()
+ {
+ LoadData(eBrushTypes.Solid, Color.White, Color.White, Color.White, 0.0f, 0.0f, 0.5f, 1.0f);
+ }
+
+ ///
+ /// Creates new instance of the object.
+ ///
+ /// The first color for this entry.
+ /// The second color for this entry.
+ public ColorData(eBrushTypes brushType, Color color1, Color color2)
+ {
+ LoadData(brushType, color1, color2, Color.White, 0.0f, 0.0f, 0.5f, 1.0f);
+ }
+
+ ///
+ /// Creates new instance of the object.
+ ///
+ /// The first color for this entry.
+ /// The second color for this entry.
+ /// The border color for this entry.
+ /// The border width for this entry.
+ public ColorData(eBrushTypes brushType, Color color1, Color color2, Color borderColor, float borderWidth)
+ {
+ LoadData(brushType, color1, color2, borderColor, borderWidth, 0.0f, 0.5f, 1.0f);
+ }
+
+ ///
+ /// Creates new instance of the object.
+ ///
+ /// The first color for this entry.
+ /// The second color for this entry.
+ /// The border color for this entry.
+ /// The border width for this entry.
+ /// The gradient angle.
+ public ColorData(eBrushTypes brushType, Color color1, Color color2, Color borderColor, float borderWidth, float brushAngle)
+ {
+ LoadData(brushType, color1, color2, borderColor, borderWidth, brushAngle, 0.5f, 1.0f);
+ }
+
+ ///
+ /// Creates new instance of the object.
+ ///
+ /// The first color for this entry.
+ /// The second color for this entry.
+ /// The border color for this entry.
+ /// The border width for this entry.
+ /// The focus for the SigmaBellShape.
+ /// The scale for the SigmaBellShape.
+ public ColorData(eBrushTypes brushType, Color color1, Color color2, Color borderColor, float borderWidth, float brushSBSFocus, float brushSBSScale)
+ {
+ LoadData(brushType, color1, color2, borderColor, borderWidth, 0.0f, brushSBSFocus, brushSBSScale);
+ }
+
+ ///
+ /// Loads data into the class, called by constructors.
+ ///
+ /// The first color for this entry.
+ /// The second color for this entry.
+ /// The border color for this entry.
+ /// The border width for this entry.
+ /// The focus for the SigmaBellShape.
+ /// The scale for the SigmaBellShape.
+ protected void LoadData(eBrushTypes brushType, Color color1, Color color2, Color borderColor, float borderWidth, float brushAngle, float brushSBSFocus, float brushSBSScale)
+ {
+ _BorderColor = borderColor;
+ _BorderWidth = borderWidth;
+ _Color1 = color1;
+ _Color2 = color2;
+ _BrushType = brushType;
+ _BrushAngle = brushAngle;
+ _BrushSBSFocus = brushSBSFocus;
+ _BrushSBSScale = brushSBSScale;
+ }
+
+ ///
+ /// Creates Pen object using the BorderColor and BorderWidth properties.
+ ///
+ public Pen GetBorderPen(float scaleFactor, PenAlignment penAlignment)
+ {
+ Pen pen = new Pen(_BorderColor, (float)Math.Round(_BorderWidth * scaleFactor, 0));
+ pen.Alignment = penAlignment;
+ return pen;
+ }
+
+ ///
+ /// Creates a brush of the type specified by BrushType.
+ ///
+ /// The graphics path used to construct the brush.
+ public Brush GetBrush(GraphicsPath path)
+ {
+ return GetBrush(path, new PointF(0.5f, 0.5f), _BrushAngle);
+ }
+
+ ///
+ /// Creates a brush of the type specified by BrushType.
+ ///
+ /// The graphics path used to construct the brush.
+ /// The angle used for the gradients, allowing an override of BrushAngle
+ public Brush GetBrush(GraphicsPath path, float angle)
+ {
+ return GetBrush(path, new PointF(0.5f, 0.5f), angle);
+ }
+
+ ///
+ /// Creates a brush of the type specified by BrushType.
+ ///
+ /// The graphics path used to construct the brush.
+ /// The center point of the gradient as a percentage value typically ranging from 0.0 to 1.0.
+ public Brush GetBrush(GraphicsPath path, PointF center)
+ {
+ return GetBrush(path, center, _BrushAngle);
+ }
+
+ ///
+ /// Creates a brush of the type specified by BrushType.
+ ///
+ /// The graphics path used to construct the brush.
+ /// The center point of the gradient as a percentage value typically ranging from 0.0 to 1.0.
+ /// The angle used for the gradients, allowing an override of BrushAngle
+ public Brush GetBrush(GraphicsPath path, PointF center, float angle)
+ {
+ RectangleF rect;
+ switch (_BrushType)
+ {
+ case eBrushTypes.Solid:
+ return new SolidBrush(_Color1);
+ case eBrushTypes.Linear:
+ path.Flatten();
+ rect = path.GetBounds();
+ if (rect.Width > 0.0f && rect.Height > 0.0f)
+ return new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
+ else
+ return null;
+ case eBrushTypes.Reflected:
+ LinearGradientBrush lBrush = new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
+ lBrush.SetSigmaBellShape(_BrushSBSFocus, _BrushSBSScale);
+ return lBrush;
+ case eBrushTypes.Centered:
+ PointF pt = new PointF();
+ rect = path.GetBounds();
+ PathGradientBrush pBrush = new PathGradientBrush(path);
+ pt.X = rect.X + rect.Width * center.X;
+ pt.Y = rect.Y + rect.Height * center.Y;
+ pBrush.CenterPoint = pt;
+ pBrush.CenterColor = _Color1;
+ pBrush.SurroundColors = new Color[] { _Color2 };
+ return pBrush;
+ default:
+ return new SolidBrush(_Color1);
+ }
+ }
+
+ ///
+ /// Creates SolidBrushObject using Color1.
+ ///
+ public Brush GetSolidBrush()
+ {
+ return new SolidBrush(_Color1);
+ }
+
+ ///
+ /// Creates a LinearGradientBrush object.
+ ///
+ /// The graphics path used to construct the brush.
+ /// The gradient angle.
+ public LinearGradientBrush GetLinearBrush(GraphicsPath path, int angle)
+ {
+ return new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
+ }
+
+ ///
+ /// Creates a PathGradientBrush object.
+ ///
+ /// The graphics path used to construct the brush.
+ /// The center point of the gradient.
+ public PathGradientBrush GetCenteredBrush(GraphicsPath path, PointF center)
+ {
+ PathGradientBrush brush;
+
+ brush = new PathGradientBrush(path);
+ brush.CenterPoint = center;
+ brush.CenterColor = _Color1;
+ brush.SurroundColors = new Color[] { _Color2 };
+
+ return brush;
+ }
+
+ ///
+ /// Creates a LinearGradientBrush object.
+ ///
+ /// The graphics path used to construct the brush.
+ /// The gradient angle.
+ public LinearGradientBrush GetReflectedBrush(GraphicsPath path, int angle)
+ {
+ return GetReflectedBrush(path, angle, 0.5f, 1.0f);
+ }
+
+ ///
+ /// Creates a LinearGradientBrush object.
+ ///
+ /// The graphics path used to construct the brush.
+ /// The gradient angle.
+ /// The focus for the SigmaBellShape.
+ public LinearGradientBrush GetReflectedBrush(GraphicsPath path, int angle, float focus)
+ {
+ return GetReflectedBrush(path, angle, focus, 1.0f);
+ }
+
+ ///
+ /// Creates a LinearGradientBrush object.
+ ///
+ /// The graphics path used to construct the brush.
+ /// The gradient angle.
+ /// The focus for the SigmaBellShape.
+ /// The scale for the SigmaBellShape.
+ public LinearGradientBrush GetReflectedBrush(GraphicsPath path, int angle, float focus, float scale)
+ {
+ LinearGradientBrush brush = new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
+ brush.SetSigmaBellShape(focus, scale);
+ return brush;
+ }
+
+ ///
+ /// Raises the PropertyChanged event.
+ ///
+ /// Event arguments
+ protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
+ {
+ if (PropertyChanged != null)
+ PropertyChanged(this, e);
+ }
+ }
+
+ ///
+ /// Enumeration containing predefined brush types for the ColorData class.
+ ///
+ public enum eBrushTypes
+ {
+ ///
+ /// Solid brush.
+ ///
+ Solid,
+ ///
+ /// Linear gradient brush.
+ ///
+ Linear,
+
+ ///
+ /// Centered path gradient brush.
+ ///
+ Centered,
+
+ ///
+ /// Reflected linear gradient brush.
+ ///
+ Reflected
+ }
+
+}
diff --git a/PROMS/DotNetBar Source Code/AnalogClock/MathHelper.cs b/PROMS/DotNetBar Source Code/AnalogClock/MathHelper.cs
new file mode 100644
index 00000000..cf4d9307
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AnalogClock/MathHelper.cs
@@ -0,0 +1,30 @@
+using System;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Math helper class
+ ///
+ internal static class MathHelper
+ {
+ ///
+ /// Converts radians to degrees.
+ ///
+ /// Value to be converted in radians.
+ /// Converted value in degrees.
+ public static double GetDegrees(double radians)
+ {
+ return radians * (180.0 / Math.PI);
+ }
+
+ ///
+ /// Converts degrees to radians.
+ ///
+ /// Value to be converted in degrees.
+ /// Converted value in radians.
+ public static double GetRadians(double degrees)
+ {
+ return degrees * (Math.PI / 180.0);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Animation/Animation.cs b/PROMS/DotNetBar Source Code/Animation/Animation.cs
new file mode 100644
index 00000000..f3776b70
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Animation/Animation.cs
@@ -0,0 +1,772 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Reflection;
+using System.ComponentModel;
+using System.Windows.Forms;
+using DevComponents.DotNetBar;
+using System.Drawing;
+
+namespace DevComponents.DotNetBar.Animation
+{
+ internal abstract class Animation : Component
+ {
+ #region Events
+ ///
+ /// Occurs after animation has completed.
+ ///
+ public event EventHandler AnimationCompleted;
+ ///
+ /// Raises AnimationCompleted event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnAnimationCompleted(EventArgs e)
+ {
+ EventHandler handler = AnimationCompleted;
+ if (handler != null)
+ handler(this, e);
+ }
+ #endregion
+
+ #region Constructor
+ private BackgroundWorker _Worker = null;
+ private AnimationEasing _EasingFunction = AnimationEasing.EaseOutQuad;
+ private double _Duration = 300;
+ private EasingFunctionDelegate[] _AnimationFunctions;
+ private List _AnimationList = new List();
+
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public Animation(AnimationEasing animationEasing, int animationDuration)
+ :
+ this(new AnimationRequest[0], animationEasing, animationDuration)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public Animation(AnimationRequest animationRequest, AnimationEasing animationEasing, int animationDuration)
+ :
+ this(new AnimationRequest[] { animationRequest }, animationEasing, animationDuration)
+ {
+ }
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public Animation(AnimationRequest[] animationRequests, AnimationEasing animationEasing, int animationDuration)
+ {
+ if (animationRequests != null && animationRequests.Length > 0)
+ _AnimationList.AddRange(animationRequests);
+ _EasingFunction = animationEasing;
+ _Duration = (int)animationDuration;
+ InitializeAnimationFunctions();
+ }
+
+ private void InitializeAnimationFunctions()
+ {
+ _AnimationFunctions = new EasingFunctionDelegate[28];
+ _AnimationFunctions[(int)AnimationEasing.EaseInBounce] = new EasingFunctionDelegate(EaseInBounce);
+ _AnimationFunctions[(int)AnimationEasing.EaseInCirc] = new EasingFunctionDelegate(EaseInCirc);
+ _AnimationFunctions[(int)AnimationEasing.EaseInCubic] = new EasingFunctionDelegate(EaseInCubic);
+ _AnimationFunctions[(int)AnimationEasing.EaseInElastic] = new EasingFunctionDelegate(EaseInElastic);
+ _AnimationFunctions[(int)AnimationEasing.EaseInExpo] = new EasingFunctionDelegate(EaseInExpo);
+ _AnimationFunctions[(int)AnimationEasing.EaseInOutBounce] = new EasingFunctionDelegate(EaseInOutBounce);
+ _AnimationFunctions[(int)AnimationEasing.EaseInOutCirc] = new EasingFunctionDelegate(EaseInOutCirc);
+ _AnimationFunctions[(int)AnimationEasing.EaseInOutCubic] = new EasingFunctionDelegate(EaseInOutCubic);
+ _AnimationFunctions[(int)AnimationEasing.EaseInOutElastic] = new EasingFunctionDelegate(EaseInOutElastic);
+ _AnimationFunctions[(int)AnimationEasing.EaseInOutExpo] = new EasingFunctionDelegate(EaseInOutExpo);
+ _AnimationFunctions[(int)AnimationEasing.EaseInOutQuad] = new EasingFunctionDelegate(EaseInOutQuad);
+ _AnimationFunctions[(int)AnimationEasing.EaseInOutQuart] = new EasingFunctionDelegate(EaseInOutQuart);
+ _AnimationFunctions[(int)AnimationEasing.EaseInOutQuint] = new EasingFunctionDelegate(EaseInOutQuint);
+ _AnimationFunctions[(int)AnimationEasing.EaseInOutSine] = new EasingFunctionDelegate(EaseInOutSine);
+ _AnimationFunctions[(int)AnimationEasing.EaseInQuad] = new EasingFunctionDelegate(EaseInQuad);
+ _AnimationFunctions[(int)AnimationEasing.EaseInQuart] = new EasingFunctionDelegate(EaseInQuart);
+ _AnimationFunctions[(int)AnimationEasing.EaseInQuint] = new EasingFunctionDelegate(EaseInQuint);
+ _AnimationFunctions[(int)AnimationEasing.EaseInSine] = new EasingFunctionDelegate(EaseInSine);
+ _AnimationFunctions[(int)AnimationEasing.EaseOutBounce] = new EasingFunctionDelegate(EaseOutBounce);
+ _AnimationFunctions[(int)AnimationEasing.EaseOutCirc] = new EasingFunctionDelegate(EaseOutCirc);
+ _AnimationFunctions[(int)AnimationEasing.EaseOutCubic] = new EasingFunctionDelegate(EaseOutCubic);
+ _AnimationFunctions[(int)AnimationEasing.EaseOutElastic] = new EasingFunctionDelegate(EaseOutElastic);
+ _AnimationFunctions[(int)AnimationEasing.EaseOutExpo] = new EasingFunctionDelegate(EaseOutExpo);
+ _AnimationFunctions[(int)AnimationEasing.EaseOutQuad] = new EasingFunctionDelegate(EaseOutQuad);
+ _AnimationFunctions[(int)AnimationEasing.EaseOutQuart] = new EasingFunctionDelegate(EaseOutQuart);
+ _AnimationFunctions[(int)AnimationEasing.EaseOutQuint] = new EasingFunctionDelegate(EaseOutQuint);
+ _AnimationFunctions[(int)AnimationEasing.EaseOutSine] = new EasingFunctionDelegate(EaseOutSine);
+ _AnimationFunctions[(int)AnimationEasing.Linear] = new EasingFunctionDelegate(Linear);
+
+ }
+ #endregion
+
+ #region Implementation
+ private bool _AutoDispose = false;
+ ///
+ /// Gets or sets whether animation is auto-disposed once its completed. Default value is false.
+ ///
+ public bool AutoDispose
+ {
+ get { return _AutoDispose; }
+ set
+ {
+ _AutoDispose = value;
+ }
+ }
+
+ public List Animations
+ {
+ get
+ {
+ return _AnimationList;
+ }
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ //Console.WriteLine("{0} Animation DISPOSED", DateTime.Now);
+ Stop();
+ _IsDisposed = true;
+ base.Dispose(disposing);
+ }
+
+ private bool _IsDisposed = false;
+ public bool IsDisposed
+ {
+ get { return _IsDisposed; }
+ internal set
+ {
+ _IsDisposed = value;
+ }
+ }
+
+ ///
+ /// Stops animation if one is currently running.
+ ///
+ public void Stop()
+ {
+ BackgroundWorker worker = _Worker;
+ if (worker != null)
+ {
+ worker.DoWork -= new DoWorkEventHandler(WorkerDoWork);
+ worker.RunWorkerCompleted -= new RunWorkerCompletedEventHandler(RunWorkerCompleted);
+ worker.CancelAsync();
+ worker.Dispose();
+ _Worker = null;
+ }
+ }
+
+ public void Start()
+ {
+ Start(_AnimationList.ToArray());
+ }
+
+ protected void Start(AnimationRequest[] requests)
+ {
+ if (_Worker != null)
+ throw new InvalidOperationException("Animation is already running animations");
+ //Console.WriteLine("{0} Animation Started", DateTime.Now);
+ _IsCompleted = false;
+ _Worker = new BackgroundWorker();
+ _Worker.WorkerSupportsCancellation = true;
+ _Worker.DoWork += new DoWorkEventHandler(WorkerDoWork);
+ _Worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted);
+ _Worker.RunWorkerAsync(requests);
+ }
+
+ private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
+ {
+ //Console.WriteLine(string.Format("{0} RunWorkerCompleted", DateTime.Now));
+ BackgroundWorker worker = _Worker;
+ _Worker = null;
+ if (worker != null)
+ {
+ worker.DoWork -= new DoWorkEventHandler(WorkerDoWork);
+ worker.RunWorkerCompleted -= new RunWorkerCompletedEventHandler(RunWorkerCompleted);
+ worker.Dispose();
+ }
+
+ _IsCompleted = true;
+ OnAnimationCompleted(EventArgs.Empty);
+
+ if (_AutoDispose)
+ this.Dispose();
+ }
+
+ protected virtual void SetTargetPropertyValue(object target, PropertyInfo property, object value)
+ {
+ Control c = target as Control;
+ if (c != null)
+ {
+ c.Invoke(new MethodInvoker(delegate
+ {
+ property.SetValue(target, value, null);
+ if (c.Parent != null)
+ c.Parent.Update();
+ else
+ c.Update();
+ }));
+ }
+ else if (target is BaseItem)
+ {
+ if (_AnimationUpdateControl != null)
+ _AnimationUpdateControl.Invoke(new MethodInvoker(delegate { property.SetValue(target, value, null); if (value is Rectangle) _AnimationUpdateControl.Invalidate(); }));
+ else
+ {
+ if (target is DevComponents.DotNetBar.Metro.MetroTileItem && property.Name == "CurrentFrameOffset")
+ ((DevComponents.DotNetBar.Metro.MetroTileItem)target).CurrentFrameOffset = (int)value;
+ else
+ property.SetValue(target, value, null);
+ }
+ }
+ else
+ {
+ property.SetValue(target, value, null);
+ }
+ }
+ protected abstract object GetPropertyValueCorrectType(double value);
+
+ protected virtual void WorkerDoWork(object sender, DoWorkEventArgs e)
+ {
+ AnimationRequest[] requests = (AnimationRequest[])e.Argument;
+ double elapsedTime = 0;
+ DateTime startTime = DateTime.UtcNow;
+ double duration = _Duration;
+
+ bool firstPass = true;
+
+ if (_FixedStepCount <= 0)
+ {
+ while (elapsedTime <= duration)
+ {
+ try
+ {
+ foreach (AnimationRequest request in requests)
+ {
+ double toValue = request.GetToValue();
+ double fromValue = request.GetFromValue();
+ double change = toValue - fromValue;
+
+ if (firstPass)
+ SetTargetPropertyValue(request.Target, request.Property, request.From);
+
+ double r = _AnimationFunctions[(int)_EasingFunction](elapsedTime, fromValue, change, duration);
+ if (change < 0 && r < toValue || change > 0 && r > toValue) { r = toValue; e.Cancel = true; break; }
+ if (change < 0 && r > fromValue || change > 0 && r < fromValue) r = fromValue;
+
+ SetTargetPropertyValue(request.Target, request.Property, GetPropertyValueCorrectType(r));
+ elapsedTime = DateTime.UtcNow.Subtract(startTime).TotalMilliseconds;
+ if (e.Cancel) break;
+ }
+
+ if (e.Cancel) break;
+
+ ExecuteStepUpdateMethod();
+
+ if (_AnimationUpdateControl != null)
+ {
+ if (_AnimationUpdateControl.InvokeRequired)
+ _AnimationUpdateControl.BeginInvoke(new MethodInvoker(delegate { _AnimationUpdateControl.Update(); }));
+ else
+ _AnimationUpdateControl.Update();
+ }
+ if (e.Cancel) break;
+ firstPass = false;
+ }
+ catch (TargetInvocationException exc)
+ {
+ if (exc.InnerException is ObjectDisposedException) // Stop work if target has been disposed
+ return;
+ throw;
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ for (int i = 0; i < _FixedStepCount; i++)
+ {
+ foreach (AnimationRequest request in requests)
+ {
+ double toValue = request.GetToValue();
+ double fromValue = request.GetFromValue();
+ double change = toValue - fromValue;
+ double step = change / _FixedStepCount;
+
+ if (firstPass)
+ SetTargetPropertyValue(request.Target, request.Property, request.From);
+
+ double r = fromValue + step * (i + 1);
+ if (change < 0 && r < toValue || change > 0 && r > toValue) { r = toValue; e.Cancel = true; break; }
+ if (change < 0 && r > fromValue || change > 0 && r < fromValue) r = fromValue;
+
+ SetTargetPropertyValue(request.Target, request.Property, GetPropertyValueCorrectType(r));
+ if (e.Cancel) break;
+ if (_Duration > 0)
+ {
+ try
+ {
+ using (
+ System.Threading.ManualResetEvent wait =
+ new System.Threading.ManualResetEvent(false))
+ wait.WaitOne((int) _Duration);
+
+ //System.Threading.Thread.Sleep((int)_Duration);
+ }
+ catch
+ {
+ break;
+ }
+
+ }
+ }
+
+ if (e.Cancel) break;
+
+ ExecuteStepUpdateMethod();
+
+ if (_AnimationUpdateControl != null)
+ _AnimationUpdateControl.Update();
+ if (e.Cancel) break;
+ firstPass = false;
+ }
+ }
+ catch (TargetInvocationException exc)
+ {
+ if (exc.InnerException is ObjectDisposedException) // Stop work if target has been disposed
+ return;
+ throw;
+ }
+ }
+ // Make sure final to value is assigned
+ foreach (AnimationRequest request in requests)
+ {
+ try
+ {
+ SetTargetPropertyValue(request.Target, request.Property, request.To);
+ }
+ catch (TargetInvocationException exc)
+ {
+ if (exc.InnerException is ObjectDisposedException) // Stop work if target has been disposed
+ continue;
+ throw;
+ }
+ }
+ //System.Diagnostics.Debug.WriteLine(string.Format("{0} WorkerDoWork DONE", DateTime.Now));
+ }
+ private bool _IsCompleted;
+ ///
+ /// Gets whether animation run is complete.
+ ///
+ public bool IsCompleted
+ {
+ get { return _IsCompleted; }
+ }
+ ///
+ /// Gets the animation duration in milliseconds.
+ ///
+ public double Duration
+ {
+ get { return _Duration; }
+ internal set
+ {
+ _Duration = value;
+ }
+ }
+ ///
+ /// Gets the animation easing function.
+ ///
+ public AnimationEasing EasingFunction
+ {
+ get
+ {
+ return _EasingFunction;
+ }
+ }
+
+ protected EasingFunctionDelegate[] AnimationFunctions
+ {
+ get
+ {
+ return _AnimationFunctions;
+ }
+ }
+
+ protected virtual void ExecuteStepUpdateMethod()
+ {
+ if (_StepUpdateMethod != null)
+ _StepUpdateMethod.DynamicInvoke(null);
+ }
+
+ private Delegate _StepUpdateMethod = null;
+ ///
+ /// Sets the method which is called each time value on target object property is set. This method may execute the visual updates on animation client.
+ ///
+ /// Method to call
+ public void SetStepUpdateMethod(Delegate method)
+ {
+ _StepUpdateMethod = method;
+ }
+
+ protected delegate double EasingFunctionDelegate(double t, double b, double c, double d);
+
+ private Control _AnimationUpdateControl;
+ public Control AnimationUpdateControl
+ {
+ get { return _AnimationUpdateControl; }
+ set { _AnimationUpdateControl = value; }
+ }
+
+ private int _FixedStepCount = 0;
+ ///
+ /// Gets or sets the number of fixed steps animation will perform from star to finish instead of using the easing function in time.
+ /// Stepped animation executes specified number of steps always with Duration specifying delays between each step.
+ ///
+ public int FixedStepCount
+ {
+ get { return _FixedStepCount; }
+ set
+ {
+ _FixedStepCount = value;
+ }
+ }
+ #endregion
+
+ #region Easing Functions
+ private double EaseInOutQuad(double t, double b, double c, double d)
+ {
+ if ((t /= d / 2) < 1) return c / 2 * t * t + b;
+ return -c / 2 * ((--t) * (t - 2) - 1) + b;
+ }
+ private double EaseInQuad(double t, double b, double c, double d)
+ {
+ return c * (t /= d) * t + b;
+ }
+ private double EaseOutQuad(double t, double b, double c, double d)
+ {
+ return -c * (t /= d) * (t - 2) + b;
+ }
+ private double EaseInCubic(double t, double b, double c, double d)
+ {
+ return c * (t /= d) * t * t + b;
+ }
+ private double EaseOutCubic(double t, double b, double c, double d)
+ {
+ return c * ((t = t / d - 1) * t * t + 1) + b;
+ }
+ private double EaseInOutCubic(double t, double b, double c, double d)
+ {
+ if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
+ return c / 2 * ((t -= 2) * t * t + 2) + b;
+ }
+ private double EaseInQuart(double t, double b, double c, double d)
+ {
+ return c * (t /= d) * t * t * t + b;
+ }
+ private double EaseOutQuart(double t, double b, double c, double d)
+ {
+ return -c * ((t = t / d - 1) * t * t * t - 1) + b;
+ }
+ private double EaseInOutQuart(double t, double b, double c, double d)
+ {
+ if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
+ return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
+ }
+ private double EaseInQuint(double t, double b, double c, double d)
+ {
+ return c * (t /= d) * t * t * t * t + b;
+ }
+ private double EaseOutQuint(double t, double b, double c, double d)
+ {
+ return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
+ }
+ private double EaseInOutQuint(double t, double b, double c, double d)
+ {
+ if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
+ return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
+ }
+ private double EaseInSine(double t, double b, double c, double d)
+ {
+ return -c * Math.Cos(t / d * (Math.PI / 2)) + c + b;
+ }
+ private double EaseOutSine(double t, double b, double c, double d)
+ {
+ return c * Math.Sin(t / d * (Math.PI / 2)) + b;
+ }
+ private double EaseInOutSine(double t, double b, double c, double d)
+ {
+ return -c / 2 * (Math.Cos(Math.PI * t / d) - 1) + b;
+ }
+ private double EaseInExpo(double t, double b, double c, double d)
+ {
+ return (t == 0) ? b : c * Math.Pow(2, 10 * (t / d - 1)) + b;
+ }
+ private double EaseOutExpo(double t, double b, double c, double d)
+ {
+ return (t == d) ? b + c : c * (-Math.Pow(2, -10 * t / d) + 1) + b;
+ }
+ private double EaseInOutExpo(double t, double b, double c, double d)
+ {
+ if (t == 0) return b;
+ if (t == d) return b + c;
+ if ((t /= d / 2) < 1) return c / 2 * Math.Pow(2, 10 * (t - 1)) + b;
+ return c / 2 * (-Math.Pow(2, -10 * --t) + 2) + b;
+ }
+ private double EaseInCirc(double t, double b, double c, double d)
+ {
+ return -c * (Math.Sqrt(1 - (t /= d) * t) - 1) + b;
+ }
+ private double EaseOutCirc(double t, double b, double c, double d)
+ {
+ return c * Math.Sqrt(1 - (t = t / d - 1) * t) + b;
+ }
+ private double EaseInOutCirc(double t, double b, double c, double d)
+ {
+ if ((t /= d / 2) < 1) return -c / 2 * (Math.Sqrt(1 - t * t) - 1) + b;
+ return c / 2 * (Math.Sqrt(1 - (t -= 2) * t) + 1) + b;
+ }
+ private double EaseInElastic(double t, double b, double c, double d)
+ {
+ double s = 1.70158;
+ double p = 0;
+ double a = c;
+ if (t == 0)
+ return b;
+ if ((t /= d) == 1)
+ return b + c;
+ if (p == 0)
+ p = d * .3;
+ if (a < Math.Abs(c))
+ {
+ a = c;
+ s = p / 4;
+ }
+ else
+ s = p / (2 * Math.PI) * Math.Asin(c / a);
+ return -(a * Math.Pow(2, 10 * (t -= 1)) * Math.Sin((t * d - s) * (2 * Math.PI) / p)) + b;
+ }
+ private double EaseOutElastic(double t, double b, double c, double d)
+ {
+ double s = 1.70158;
+ double p = 0;
+ double a = c;
+ if (t == 0)
+ return b;
+ if ((t /= d) == 1)
+ return b + c;
+ if (p == 0) p = d * .3;
+ if (a < Math.Abs(c))
+ {
+ a = c;
+ s = p / 4;
+ }
+ else
+ s = p / (2 * Math.PI) * Math.Asin(c / a);
+ return a * Math.Pow(2, -10 * t) * Math.Sin((t * d - s) * (2 * Math.PI) / p) + c + b;
+ }
+ private double EaseInOutElastic(double t, double b, double c, double d)
+ {
+ double s = 1.70158;
+ double p = 0;
+ double a = c;
+ if (t == 0)
+ return b;
+ if ((t /= d / 2) == 2)
+ return b + c;
+ if (p == 0)
+ p = d * (.3 * 1.5);
+ if (a < Math.Abs(c))
+ {
+ a = c;
+ s = p / 4;
+ }
+ else
+ s = p / (2 * Math.PI) * Math.Asin(c / a);
+ if (t < 1)
+ return -.5 * (a * Math.Pow(2, 10 * (t -= 1)) * Math.Sin((t * d - s) * (2 * Math.PI) / p)) + b;
+ return a * Math.Pow(2, -10 * (t -= 1)) * Math.Sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
+ }
+
+ private double EaseInBounce(double t, double b, double c, double d)
+ {
+ return c - EaseOutBounce(d - t, 0, c, d) + b;
+ }
+ private double EaseOutBounce(double t, double b, double c, double d)
+ {
+ if ((t /= d) < (1 / 2.75))
+ {
+ return c * (7.5625 * t * t) + b;
+ }
+ else if (t < (2 / 2.75))
+ {
+ return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
+ }
+ else if (t < (2.5 / 2.75))
+ {
+ return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
+ }
+ else
+ {
+ return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
+ }
+ }
+ private double EaseInOutBounce(double t, double b, double c, double d)
+ {
+ if (t < d / 2) return EaseInBounce(t * 2, 0, c, d) * .5 + b;
+ return EaseOutBounce(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
+ }
+
+ private double Linear(double t, double b, double c, double d)
+ {
+ return (t / d) * c + b;
+ }
+ #endregion
+ }
+
+ internal class AnimationRequest
+ {
+ private PropertyInfo _TargetProperty = null;
+
+ ///
+ /// Initializes a new instance of the AnimationRequest class.
+ ///
+ /// Target object for animation.
+ /// Target property name for animation.
+ /// From value.
+ /// To value.
+ public AnimationRequest(object target, string targetPropertyName, object to)
+ {
+ _TargetProperty = target.GetType().GetProperty(targetPropertyName);
+ _Target = target;
+ From = _TargetProperty.GetValue(target, null);
+ To = to;
+ }
+
+ ///
+ /// Initializes a new instance of the AnimationRequest class.
+ ///
+ /// Target object for animation.
+ /// Target property name for animation.
+ /// From value.
+ /// To value.
+ public AnimationRequest(object target, string targetPropertyName, object from, object to)
+ {
+ _TargetProperty = target.GetType().GetProperty(targetPropertyName);
+ _Target = target;
+ From = from;
+ To = to;
+ }
+
+ private object _Target;
+ ///
+ /// Target object for animation.
+ ///
+ public object Target
+ {
+ get { return _Target; }
+ set { _Target = value; }
+ }
+
+ private object _From;
+ ///
+ /// Animation from value.
+ ///
+ public object From
+ {
+ get { return _From; }
+ set
+ {
+ _From = value;
+ _FromValue = GetDoubleValue(value);
+ }
+ }
+
+ private object _To;
+ ///
+ /// Animation to value.
+ ///
+ public object To
+ {
+ get { return _To; }
+ set
+ {
+ _To = value;
+ _ToValue = GetDoubleValue(value);
+ }
+ }
+
+ private static double GetDoubleValue(object value)
+ {
+ if (value is int)
+ return (double)(int)value;
+ else if (value is double)
+ return (double)value;
+ else if (value is long)
+ return (double)(long)value;
+ else if (value is float)
+ return (double)(float)value;
+
+ return double.NaN;
+ }
+
+ internal PropertyInfo Property
+ {
+ get
+ {
+ return _TargetProperty;
+ }
+ }
+
+ private double _ToValue = double.NaN;
+ internal double GetToValue()
+ {
+ return _ToValue;
+ }
+ private double _FromValue = double.NaN;
+ internal double GetFromValue()
+ {
+ return _FromValue;
+ }
+
+ }
+ ///
+ /// Specifies the animation easing function
+ ///
+ public enum AnimationEasing : int
+ {
+ EaseInOutQuad = 0,
+ EaseInQuad = 1,
+ EaseOutQuad = 2,
+ EaseInCubic = 3,
+ EaseOutCubic = 4,
+ EaseInOutCubic = 5,
+ EaseInQuart = 6,
+ EaseOutQuart = 7,
+ EaseInOutQuart = 8,
+ EaseInQuint = 9,
+ EaseOutQuint = 10,
+ EaseInOutQuint = 11,
+ EaseInSine = 12,
+ EaseOutSine = 13,
+ EaseInOutSine = 14,
+ EaseInExpo = 15,
+ EaseOutExpo = 16,
+ EaseInOutExpo = 17,
+ EaseInCirc = 18,
+ EaseOutCirc = 19,
+ EaseInOutCirc = 20,
+ EaseInElastic = 21,
+ EaseOutElastic = 22,
+ EaseInOutElastic = 23,
+ EaseInBounce = 24,
+ EaseOutBounce = 25,
+ EaseInOutBounce = 26,
+ Linear = 27
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Animation/AnimationDouble.cs b/PROMS/DotNetBar Source Code/Animation/AnimationDouble.cs
new file mode 100644
index 00000000..14dc9453
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Animation/AnimationDouble.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace DevComponents.DotNetBar.Animation
+{
+ internal class AnimationDouble : Animation
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationDouble(AnimationEasing animationEasing, int animationDuration)
+ :
+ base(new AnimationRequest[0], animationEasing, animationDuration)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationDouble(AnimationRequest animationRequest, AnimationEasing animationEasing, int animationDuration)
+ :
+ base(new AnimationRequest[] { animationRequest }, animationEasing, animationDuration)
+ {
+ }
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationDouble(AnimationRequest[] animationRequests, AnimationEasing animationEasing, int animationDuration)
+ :
+ base(animationRequests, animationEasing, animationDuration) { }
+ #endregion
+
+ protected override object GetPropertyValueCorrectType(double value)
+ {
+ return value;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Animation/AnimationInt.cs b/PROMS/DotNetBar Source Code/Animation/AnimationInt.cs
new file mode 100644
index 00000000..d9445eea
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Animation/AnimationInt.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace DevComponents.DotNetBar.Animation
+{
+ internal class AnimationInt : Animation
+ {
+
+ #region Constructor
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationInt(AnimationEasing animationEasing, int animationDuration)
+ :
+ base(new AnimationRequest[0], animationEasing, animationDuration)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationInt(AnimationRequest animationRequest, AnimationEasing animationEasing, int animationDuration)
+ :
+ base(new AnimationRequest[] { animationRequest }, animationEasing, animationDuration)
+ {
+ }
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationInt(AnimationRequest[] animationRequests, AnimationEasing animationEasing, int animationDuration)
+ :
+ base(animationRequests, animationEasing, animationDuration) { }
+ #endregion
+
+ protected override object GetPropertyValueCorrectType(double value)
+ {
+ return (int)value;
+ }
+
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Animation/AnimationPoint.cs b/PROMS/DotNetBar Source Code/Animation/AnimationPoint.cs
new file mode 100644
index 00000000..39b0fd1a
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Animation/AnimationPoint.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar.Animation
+{
+ internal class AnimationPoint : Animation
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationPoint(AnimationEasing animationEasing, int animationDuration)
+ :
+ base(new AnimationRequest[0], animationEasing, animationDuration)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationPoint(AnimationRequest animationRequest, AnimationEasing animationEasing, int animationDuration)
+ :
+ base(new AnimationRequest[] { animationRequest }, animationEasing, animationDuration)
+ {
+ }
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationPoint(AnimationRequest[] animationRequests, AnimationEasing animationEasing, int animationDuration)
+ :
+ base(animationRequests, animationEasing, animationDuration) { }
+ #endregion
+
+ #region Implementation
+ protected override void WorkerDoWork(object sender, DoWorkEventArgs e)
+ {
+ AnimationRequest[] requests = (AnimationRequest[])e.Argument;
+ double elapsedTime = 0;
+ DateTime startTime = DateTime.Now;
+ double duration = Duration;
+
+ bool firstPass = true;
+ while (elapsedTime <= duration)
+ {
+ foreach (AnimationRequest request in requests)
+ {
+ Point toValue = (Point)request.To;
+ Point fromValue = (Point)request.From;
+ Point change = new Point(toValue.X - fromValue.X, toValue.Y - fromValue.Y);
+ Point newValue = toValue;
+
+ if (firstPass)
+ SetTargetPropertyValue(request.Target, request.Property, request.From);
+
+ if (change.X != 0)
+ newValue.X = (int)AnimationFunctions[(int)EasingFunction](elapsedTime, fromValue.X, change.X, duration);
+ if (change.Y != 0)
+ newValue.Y = (int)AnimationFunctions[(int)EasingFunction](elapsedTime, fromValue.Y, change.Y, duration);
+
+ SetTargetPropertyValue(request.Target, request.Property, newValue);
+
+ elapsedTime = DateTime.Now.Subtract(startTime).TotalMilliseconds;
+
+ if (e.Cancel) return;
+ }
+
+ ExecuteStepUpdateMethod();
+
+ if (AnimationUpdateControl != null)
+ AnimationUpdateControl.Update();
+
+ firstPass = false;
+ }
+
+ // Make sure final to value is assigned
+ foreach (AnimationRequest request in requests)
+ {
+ SetTargetPropertyValue(request.Target, request.Property, request.To);
+ }
+ }
+
+ protected override object GetPropertyValueCorrectType(double value)
+ {
+ return (int)value;
+ }
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Animation/AnimationRectangle.cs b/PROMS/DotNetBar Source Code/Animation/AnimationRectangle.cs
new file mode 100644
index 00000000..5f5edc21
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Animation/AnimationRectangle.cs
@@ -0,0 +1,114 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Animation
+{
+ internal class AnimationRectangle : Animation
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationRectangle(AnimationEasing animationEasing, int animationDuration)
+ :
+ base(new AnimationRequest[0], animationEasing, animationDuration)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationRectangle(AnimationRequest animationRequest, AnimationEasing animationEasing, int animationDuration)
+ :
+ base(new AnimationRequest[] { animationRequest }, animationEasing, animationDuration)
+ {
+ }
+ ///
+ /// Initializes a new instance of the Animation class.
+ ///
+ /// Target object for animation
+ /// Target property name for animation
+ public AnimationRectangle(AnimationRequest[] animationRequests, AnimationEasing animationEasing, int animationDuration)
+ :
+ base(animationRequests, animationEasing, animationDuration) { }
+ #endregion
+
+ #region Implementation
+ protected override void WorkerDoWork(object sender, DoWorkEventArgs e)
+ {
+ AnimationRequest[] requests = (AnimationRequest[])e.Argument;
+ double elapsedTime = 0;
+ DateTime startTime = DateTime.Now;
+ double duration = Duration;
+
+ bool firstPass = true;
+ while (elapsedTime <= duration)
+ {
+ foreach (AnimationRequest request in requests)
+ {
+ Rectangle toValue = (Rectangle)request.To;
+ Rectangle fromValue = (Rectangle)request.From;
+ Rectangle change = new Rectangle(toValue.X - fromValue.X, toValue.Y - fromValue.Y,
+ toValue.Width - fromValue.Width, toValue.Height - fromValue.Height);
+ Rectangle newValue = toValue;
+ if (IsDisposed(request.Target)) return;
+ if (firstPass)
+ SetTargetPropertyValue(request.Target, request.Property, request.From);
+
+ if (change.X != 0)
+ newValue.X = (int)AnimationFunctions[(int)EasingFunction](elapsedTime, fromValue.X, change.X, duration);
+ if (change.Y != 0)
+ newValue.Y = (int)AnimationFunctions[(int)EasingFunction](elapsedTime, fromValue.Y, change.Y, duration);
+ if (change.Width != 0)
+ newValue.Width = (int)AnimationFunctions[(int)EasingFunction](elapsedTime, fromValue.Width, change.Width, duration);
+ if (change.Height != 0)
+ newValue.Height = (int)AnimationFunctions[(int)EasingFunction](elapsedTime, fromValue.Height, change.Height, duration);
+
+ SetTargetPropertyValue(request.Target, request.Property, newValue);
+
+ elapsedTime = DateTime.Now.Subtract(startTime).TotalMilliseconds;
+
+ if (e.Cancel) return;
+ }
+
+ ExecuteStepUpdateMethod();
+
+ //if (AnimationUpdateControl != null)
+ // AnimationUpdateControl.Invoke(new MethodInvoker(delegate { AnimationUpdateControl.Update(); }));
+
+ firstPass = false;
+ }
+
+ // Make sure final to value is assigned
+ foreach (AnimationRequest request in requests)
+ {
+ SetTargetPropertyValue(request.Target, request.Property, request.To);
+ }
+
+ //Console.WriteLine("{0} WorkerDoWork Complete", DateTime.Now);
+ }
+
+ private bool IsDisposed(object p)
+ {
+ if (p == null) return true;
+ if (p is Control && ((Control)p).IsDisposed) return true;
+ if (p is BaseItem && ((BaseItem)p).IsDisposed) return true;
+ return false;
+ }
+
+ protected override object GetPropertyValueCorrectType(double value)
+ {
+ return (int)value;
+ }
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Animation/Storyline.cs b/PROMS/DotNetBar Source Code/Animation/Storyline.cs
new file mode 100644
index 00000000..df0d65b2
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Animation/Storyline.cs
@@ -0,0 +1,155 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ComponentModel;
+using System.Threading;
+
+namespace DevComponents.DotNetBar.Animation
+{
+ internal class Storyline : Component
+ {
+ #region Events
+
+ #endregion
+
+ #region Constructor
+
+ #endregion
+
+ #region Implementation
+ private bool _IsDisposed = false;
+ ///
+ /// Returns whether Storyline is disposed.
+ ///
+ public bool IsDisposed
+ {
+ get
+ {
+ return _IsDisposed;
+ }
+ }
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ BackgroundWorker worker = _Worker;
+ if (worker != null)
+ {
+ worker.CancelAsync();
+ worker.Dispose();
+ _Worker = null;
+ }
+ }
+ _IsDisposed = true;
+ base.Dispose(disposing);
+ }
+
+ private List _Animations = new List();
+ ///
+ /// Gets the list of animations to run using this storyline.
+ ///
+ public List Animations
+ {
+ get
+ {
+ return _Animations;
+ }
+ }
+
+ private BackgroundWorker _Worker = null;
+ ///
+ /// Runs all animations from Animations list.
+ ///
+ public void Run()
+ {
+ if (_Worker != null)
+ throw new InvalidOperationException("Storyline is already running animations");
+
+ _Worker = new BackgroundWorker();
+ _Worker.WorkerReportsProgress = true;
+ _Worker.WorkerSupportsCancellation = true;
+ _Worker.DoWork += new DoWorkEventHandler(WorkerDoWork);
+ _Worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted);
+ _Worker.RunWorkerAsync();
+ }
+
+ void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
+ {
+ if (_RepeatStoryTimes > 0)
+ {
+ if (_Worker == null)
+ {
+ _RepeatStoryTimes = 0;
+ return;
+ }
+
+ _RepeatStoryTimes--;
+ _Worker.RunWorkerAsync();
+ }
+ else
+ {
+ if (_Worker != null)
+ _Worker.Dispose();
+ _Worker = null;
+ if (_AutoDispose && !_IsDisposed)
+ this.Dispose();
+ }
+ }
+
+ void WorkerDoWork(object sender, DoWorkEventArgs e)
+ {
+ int count = _Animations.Count;
+ for (int i = 0; i < count; i++)
+ {
+ if (e.Cancel) return;
+ _Animations[i].Start();
+ while (!_Animations[i].IsCompleted)
+ {
+ try
+ {
+ using (
+ System.Threading.ManualResetEvent wait =
+ new System.Threading.ManualResetEvent(false))
+ wait.WaitOne(50);
+ //Thread.Sleep(50);
+ }
+ catch
+ {
+ _Animations[i].Stop();
+ return;
+ }
+ if (e.Cancel)
+ {
+ _Animations[i].Stop();
+ return;
+ }
+ }
+ }
+ }
+
+ private int _RepeatStoryTimes = 0;
+ ///
+ /// Gets or sets number of times storyline is repeated. Default value is 0 which indicates that storyline is run only once meaning not repeated.
+ ///
+ public int RepeatStoryTimes
+ {
+ get { return _RepeatStoryTimes; }
+ set { _RepeatStoryTimes = value; }
+ }
+
+ private bool _AutoDispose = false;
+ ///
+ /// Gets or sets whether storyline is auto-disposed when finished.
+ ///
+ public bool AutoDispose
+ {
+ get { return _AutoDispose; }
+ set
+ {
+ _AutoDispose = value;
+ }
+ }
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AssemblyInfo_ORG.cs.sav b/PROMS/DotNetBar Source Code/AssemblyInfo_ORG.cs.sav
new file mode 100644
index 00000000..afe3e53d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AssemblyInfo_ORG.cs.sav
@@ -0,0 +1,58 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("DevComponents.DotNetBar")]
+[assembly: AssemblyDescription("DotNetBar is Toolbar, Menubar, Docking Component.")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("DevComponents.com")]
+[assembly: AssemblyProduct("DevComponents.DotNetBar")]
+[assembly: AssemblyCopyright("(c) 2002 by DevComponents.com, All Rights Reserved.")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Revision
+// Build Number
+//
+// You can specify all the value or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyFileVersion("14.1.0.37")]
+[assembly: AssemblyVersion("14.1.0.37")]
+
+//[assembly: AssemblyVersion("1.0.0.*")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing.
+//
+// Notes:
+// (*) If no key is specified - the assembly cannot be signed.
+// (*) KeyName refers to a key that has been installed in the Crypto Service
+// Provider (CSP) on your machine.
+// (*) If the key file and a key name attributes are both specified, the
+// following processing occurs:
+// (1) If the KeyName can be found in the CSP - that key is used.
+// (2) If the KeyName does not exist and the KeyFile does exist, the key
+// in the file is installed into the CSP and used.
+// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+// documentation for more information on this.
+//
+//[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyDelaySign(true)]
+[assembly: AssemblyKeyFile("dotnetbar.snk")]
+[assembly: AssemblyKeyName("")]
+[assembly: System.Security.AllowPartiallyTrustedCallers]
+// Uncomment for .NET Framework 4.0 compilation
+//[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/Attributes.cs b/PROMS/DotNetBar Source Code/Attributes.cs
new file mode 100644
index 00000000..bee1310d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Attributes.cs
@@ -0,0 +1,16 @@
+using System;
+
+namespace DevComponents.DotNetBar
+{
+ [AttributeUsage(AttributeTargets.Property|AttributeTargets.Method|AttributeTargets.Field)]
+ public class DevCoBrowsable : Attribute
+ {
+ public static readonly DevCoBrowsable Yes=new DevCoBrowsable(true);
+ public static readonly DevCoBrowsable No=new DevCoBrowsable(false);
+ public bool Browsable;
+ public DevCoBrowsable(bool browsable)
+ {
+ this.Browsable = browsable;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/AutoHidePanel.cs b/PROMS/DotNetBar Source Code/AutoHidePanel.cs
new file mode 100644
index 00000000..f3d3b7be
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/AutoHidePanel.cs
@@ -0,0 +1,1628 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+using System.Drawing.Text;
+
+namespace DevComponents.DotNetBar
+{
+ [System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), System.Runtime.InteropServices.ComVisible(false)]
+ public class AutoHidePanel : System.Windows.Forms.Control
+ {
+ private ArrayList m_Panels = new ArrayList(10);
+ private System.Windows.Forms.Timer m_Timer = null;
+
+ private eDotNetBarStyle m_Style = eDotNetBarStyle.OfficeXP;
+
+ private bool m_EnableHoverExpand = true;
+ private bool m_EnableFocusCollapse = true;
+
+ private int m_AutoHideShowTimeout = 800;
+ private ColorScheme m_ColorScheme = null;
+ private DotNetBarManager m_Owner = null;
+
+ public AutoHidePanel()
+ {
+ this.SetStyle(ControlStyles.Selectable, false);
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ //this.Font = SystemFonts.DefaultFont; // SystemInformation.MenuFont.Clone() as Font;
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ DestroyTimer();
+ foreach (PanelBar panel in m_Panels)
+ {
+ panel.Dispose();
+ }
+ m_Panels.Clear();
+ }
+ base.Dispose(disposing);
+ }
+
+ internal void SetOwner(DotNetBarManager owner)
+ {
+ m_Owner = owner;
+ }
+
+ private Size _FixedSize = Size.Empty;
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Size FixedSize
+ {
+ get { return _FixedSize; }
+ set { _FixedSize = value; }
+ }
+
+ private bool m_AntiAlias = false;
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting. Default value is false.
+ ///
+ [DefaultValue(false), Browsable(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting.")]
+ public bool AntiAlias
+ {
+ get { return m_AntiAlias; }
+ set
+ {
+ if (m_AntiAlias != value)
+ {
+ m_AntiAlias = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ protected override void OnPaint(PaintEventArgs p)
+ {
+ eTextFormat format = eTextFormat.Default | eTextFormat.VerticalCenter | eTextFormat.SingleLine;
+ Graphics g = p.Graphics;
+ ColorScheme scheme = null;
+
+ if (this.BackColor == Color.Transparent || this.BackgroundImage != null)
+ {
+ base.OnPaintBackground(p);
+ }
+
+ TextRenderingHint textHint = g.TextRenderingHint;
+ SmoothingMode sm = g.SmoothingMode;
+ if (m_AntiAlias)
+ {
+ g.TextRenderingHint = BarUtilities.AntiAliasTextRenderingHint;
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+ }
+ bool office2007Style = BarFunctions.IsOffice2007Style(m_Style);
+
+ if (office2007Style && m_ColorScheme == null && Rendering.GlobalManager.Renderer is Rendering.Office2007Renderer)
+ scheme = ((Rendering.Office2007Renderer)Rendering.GlobalManager.Renderer).ColorTable.LegacyColors;
+ else if (m_Owner != null && m_Owner.UseGlobalColorScheme)
+ scheme = m_Owner.ColorScheme;
+ else if (m_ColorScheme != null)
+ scheme = m_ColorScheme;
+ else
+ scheme = new ColorScheme(m_Style);
+
+ Rectangle clientRect = this.ClientRectangle;
+ clientRect.Inflate(1, 1);
+ if (scheme.AutoHidePanelBackgroundImage != null)
+ BarFunctions.PaintBackgroundImage(g, clientRect, scheme.AutoHidePanelBackgroundImage, eBackgroundImagePosition.Tile, 255);
+
+ if (!scheme.AutoHidePanelBackground.IsEmpty)
+ {
+ DisplayHelp.FillRectangle(g, clientRect, scheme.AutoHidePanelBackground, scheme.AutoHidePanelBackground2, 90);
+ }
+ else if (IsGradientStyle)
+ {
+ DisplayHelp.FillRectangle(g, clientRect, scheme.BarBackground, scheme.BarBackground2, scheme.BarBackgroundGradientAngle);
+ }
+ else
+ {
+ using (SolidBrush brush = new SolidBrush(ControlPaint.Light(this.BackColor)))
+ g.FillRectangle(brush, this.DisplayRectangle);
+ }
+
+ if (m_Style == eDotNetBarStyle.VS2005 || office2007Style)
+ {
+ VS2005TabDisplay td = StyleManager.IsMetro(m_Style) ? new VS2012TabDisplay(this, scheme) : new VS2005TabDisplay(this, scheme);
+ td.DisplayTextForActiveTabOnly = office2007Style;
+ td.Paint(g, m_Panels);
+
+
+ if (m_AntiAlias)
+ {
+ g.TextRenderingHint = textHint;
+ g.SmoothingMode = sm;
+ }
+
+ return;
+ }
+
+ const int margin = 2;
+ int width = this.Width - 2;
+ int height = this.Height - 2;
+
+ Color textColor = Color.Empty;
+ SolidBrush backBrush = null;
+ Pen linePen = null;
+ if (m_Style == eDotNetBarStyle.Office2003)
+ {
+ textColor = scheme.ItemText;
+ linePen = new Pen(scheme.ItemHotBorder, 1);
+ }
+ else if (m_Style == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(m_Style))
+ {
+ textColor = scheme.ItemText;
+ linePen = new Pen(scheme.MenuBorder, 1);
+ }
+ else
+ {
+ textColor = g.GetNearestColor(ControlPaint.DarkDark(this.BackColor));
+ backBrush = new SolidBrush(this.BackColor);
+ linePen = new Pen(g.GetNearestColor(ControlPaint.Dark(this.BackColor)), 1);
+ }
+
+ if (this.Dock == DockStyle.Top || this.Dock == DockStyle.Bottom || this.Dock == DockStyle.None)
+ {
+ int x = 2;
+ foreach (PanelBar panel in m_Panels)
+ {
+ for (int i = 0; i < panel.Tabs.Count; i++)
+ {
+ DockItemTab tab = panel.Tabs[i] as DockItemTab;
+ CompositeImage icon = tab.Icon;
+ tab.DisplayRectangle.X = x;
+ tab.DisplayRectangle.Y = 0;
+ tab.DisplayRectangle.Height = height;
+ x += PanelBar.TabPadding;
+ if (panel.ActiveTab == i || panel.BoundBar.AutoHideTabTextAlwaysVisible)
+ {
+ if (icon != null)
+ {
+
+ if (this.Dock == DockStyle.Top)
+ {
+ if ((m_Style == eDotNetBarStyle.Office2003 || m_Style == eDotNetBarStyle.VS2005) && !scheme.ItemPressedBackground2.IsEmpty)
+ {
+ using (LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(tab.DisplayRectangle.X, 0, icon.Width + panel.MaxTextWidth + PanelBar.TabPadding * 3, height), scheme.ItemPressedBackground, scheme.ItemPressedBackground2, scheme.ItemPressedBackgroundGradientAngle))
+ g.FillRectangle(gradient, tab.DisplayRectangle.X, 0, icon.Width + panel.MaxTextWidth + PanelBar.TabPadding * 3, height);
+
+ }
+ else if (backBrush != null)
+ g.FillRectangle(backBrush, tab.DisplayRectangle.X, 0, icon.Width + panel.MaxTextWidth + PanelBar.TabPadding * 3, height);
+ icon.DrawImage(g, new Rectangle(x, (height - icon.Height) / 2, icon.Width, icon.Height));
+ //g.DrawImage(icon,x,(height-icon.Height)/2,icon.Width,icon.Height);
+ }
+ else
+ {
+ if ((m_Style == eDotNetBarStyle.Office2003 || m_Style == eDotNetBarStyle.VS2005) && !scheme.ItemPressedBackground2.IsEmpty)
+ {
+ using (LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(tab.DisplayRectangle.X, margin, icon.Width + panel.MaxTextWidth + PanelBar.TabPadding * 3, height), scheme.ItemPressedBackground, scheme.ItemPressedBackground2, scheme.ItemPressedBackgroundGradientAngle))
+ g.FillRectangle(gradient, tab.DisplayRectangle.X, margin, icon.Width + panel.MaxTextWidth + PanelBar.TabPadding * 3, height);
+
+ }
+ else if (backBrush != null)
+ g.FillRectangle(backBrush, tab.DisplayRectangle.X, margin, icon.Width + panel.MaxTextWidth + PanelBar.TabPadding * 3, height);
+ icon.DrawImage(g, new Rectangle(x, (height - icon.Height) / 2 + margin, icon.Width, icon.Height));
+ //g.DrawImage(icon,x,(height-icon.Height)/2+margin,icon.Width,icon.Height);
+ }
+ x += (icon.Width + PanelBar.TabPadding);
+ }
+ else
+ {
+ if (this.Dock == DockStyle.Top)
+ {
+ if ((m_Style == eDotNetBarStyle.Office2003 || m_Style == eDotNetBarStyle.VS2005) && !scheme.ItemPressedBackground2.IsEmpty)
+ {
+ using (LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(tab.DisplayRectangle.X, 0, tab.TextSize.Width + PanelBar.TabPadding * 2, height), scheme.ItemPressedBackground, scheme.ItemPressedBackground2, scheme.ItemPressedBackgroundGradientAngle))
+ g.FillRectangle(gradient, tab.DisplayRectangle.X, 0, tab.TextSize.Width + PanelBar.TabPadding * 2, height);
+
+ }
+ else if (backBrush != null)
+ g.FillRectangle(backBrush, tab.DisplayRectangle.X, 0, tab.TextSize.Width + PanelBar.TabPadding * 2, height);
+ }
+ else
+ {
+ if ((m_Style == eDotNetBarStyle.Office2003 || m_Style == eDotNetBarStyle.VS2005) && !scheme.ItemPressedBackground2.IsEmpty)
+ {
+ using (LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(tab.DisplayRectangle.X, margin, tab.TextSize.Width + PanelBar.TabPadding * 2, height), scheme.ItemPressedBackground, scheme.ItemPressedBackground2, scheme.ItemPressedBackgroundGradientAngle))
+ g.FillRectangle(gradient, tab.DisplayRectangle.X, margin, tab.TextSize.Width + PanelBar.TabPadding * 2, height);
+
+ }
+ else if (backBrush != null)
+ g.FillRectangle(backBrush, tab.DisplayRectangle.X, margin, tab.TextSize.Width + PanelBar.TabPadding * 2, height);
+ }
+ }
+
+ TextDrawing.DrawStringLegacy(g, tab.Text, this.Font, textColor, new Rectangle(x, this.Dock == DockStyle.Top ? 0 : margin, (icon == null ? tab.TextSize.Width : panel.MaxTextWidth), height), format);
+ x += ((icon == null ? tab.TextSize.Width : panel.MaxTextWidth) + PanelBar.TabPadding);
+ tab.DisplayRectangle.Width = x - tab.DisplayRectangle.X;
+ if (this.Dock == DockStyle.Top)
+ tab.DisplayRectangle.Offset(0, -1);
+ else
+ {
+ tab.DisplayRectangle.Offset(0, 1);
+ tab.DisplayRectangle.Height += 2;
+ }
+ g.DrawRectangle(linePen, tab.DisplayRectangle);
+ }
+ else
+ {
+ if (icon != null)
+ {
+ if (this.Dock == DockStyle.Top)
+ {
+ if (backBrush != null)
+ g.FillRectangle(backBrush, tab.DisplayRectangle.X, 0, icon.Width + PanelBar.TabPadding * 2, height);
+ icon.DrawImage(g, new Rectangle(x, (height - icon.Height) / 2, icon.Width, icon.Height));
+ //g.DrawImage(icon,x,(height-icon.Height)/2,icon.Width,icon.Height);
+ }
+ else
+ {
+ if (backBrush != null)
+ g.FillRectangle(backBrush, tab.DisplayRectangle.X, margin, icon.Width + PanelBar.TabPadding * 2, height);
+ icon.DrawImage(g, new Rectangle(x, (height - icon.Height) / 2 + margin, icon.Width, icon.Height));
+ //g.DrawImage(icon,x,(height-icon.Height)/2+margin,icon.Width,icon.Height);
+ }
+ x += (icon.Width + PanelBar.TabPadding);
+ }
+ else
+ {
+ TextDrawing.DrawStringLegacy(g, tab.Text, this.Font, textColor, new Rectangle(x, this.Dock == DockStyle.Top ? 0 : margin, tab.TextSize.Width, height), format);
+ x += (tab.TextSize.Width + PanelBar.TabPadding);
+ }
+ tab.DisplayRectangle.Width = x - tab.DisplayRectangle.X;
+ if (this.Dock == DockStyle.Top)
+ tab.DisplayRectangle.Y--;
+ else
+ {
+ tab.DisplayRectangle.Y++;
+ tab.DisplayRectangle.Height += 2;
+ }
+ g.DrawRectangle(linePen, tab.DisplayRectangle);
+ }
+ if (x > this.Width)
+ break;
+ }
+ x += 4;
+ if (x > this.Width)
+ break;
+ }
+ }
+ else if (this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
+ {
+ int y = 2;
+ foreach (PanelBar panel in m_Panels)
+ {
+ for (int i = 0; i < panel.Tabs.Count; i++)
+ {
+ DockItemTab tab = panel.Tabs[i] as DockItemTab;
+ CompositeImage icon = tab.Icon;
+ tab.DisplayRectangle.X = 0;
+ tab.DisplayRectangle.Y = y;
+ tab.DisplayRectangle.Width = width;
+ y += PanelBar.TabPadding;
+ if (panel.ActiveTab == i || panel.BoundBar.AutoHideTabTextAlwaysVisible)
+ {
+ if (icon != null)
+ {
+ if (this.Dock == DockStyle.Left)
+ {
+ if ((m_Style == eDotNetBarStyle.Office2003 || m_Style == eDotNetBarStyle.VS2005) && !scheme.ItemPressedBackground2.IsEmpty)
+ {
+ using (LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(tab.DisplayRectangle.X, tab.DisplayRectangle.Y, width, icon.Height + panel.MaxTextWidth + PanelBar.TabPadding * 3), scheme.ItemPressedBackground, scheme.ItemPressedBackground2, scheme.ItemPressedBackgroundGradientAngle))
+ g.FillRectangle(gradient, tab.DisplayRectangle.X, tab.DisplayRectangle.Y, width, icon.Height + panel.MaxTextWidth + PanelBar.TabPadding * 3);
+
+ }
+ else if (backBrush != null)
+ g.FillRectangle(backBrush, tab.DisplayRectangle.X, tab.DisplayRectangle.Y, width, icon.Height + panel.MaxTextWidth + PanelBar.TabPadding * 3);
+ icon.DrawImage(g, new Rectangle((width - icon.Width - margin) / 2, y, icon.Width, icon.Height));
+ //g.DrawImage(icon,(width-icon.Width-margin)/2,y,icon.Width,icon.Height);
+ }
+ else
+ {
+ if ((m_Style == eDotNetBarStyle.Office2003 || m_Style == eDotNetBarStyle.VS2005) && !scheme.ItemPressedBackground2.IsEmpty)
+ {
+ using (LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(margin, tab.DisplayRectangle.Y, width, icon.Height + panel.MaxTextWidth + PanelBar.TabPadding * 3), scheme.ItemPressedBackground, scheme.ItemPressedBackground2, scheme.ItemPressedBackgroundGradientAngle))
+ g.FillRectangle(gradient, margin, tab.DisplayRectangle.Y, width, icon.Height + panel.MaxTextWidth + PanelBar.TabPadding * 3);
+
+ }
+ else if (backBrush != null)
+ g.FillRectangle(backBrush, margin, tab.DisplayRectangle.Y, width, icon.Height + panel.MaxTextWidth + PanelBar.TabPadding * 3);
+ icon.DrawImage(g, new Rectangle((width - icon.Width + margin) / 2, y, icon.Width, icon.Height));
+ //g.DrawImage(icon,(width-icon.Width+margin)/2,y,icon.Width,icon.Height);
+ }
+ y += (icon.Height + PanelBar.TabPadding);
+ }
+ else
+ {
+ if (this.Dock == DockStyle.Left)
+ {
+ if ((m_Style == eDotNetBarStyle.Office2003 || m_Style == eDotNetBarStyle.VS2005) && !scheme.ItemPressedBackground2.IsEmpty)
+ {
+ using (LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(tab.DisplayRectangle.X, tab.DisplayRectangle.Y, width, tab.TextSize.Width + PanelBar.TabPadding * 2), scheme.ItemPressedBackground, scheme.ItemPressedBackground2, scheme.ItemPressedBackgroundGradientAngle))
+ g.FillRectangle(gradient, tab.DisplayRectangle.X, tab.DisplayRectangle.Y, width, tab.TextSize.Width + PanelBar.TabPadding * 2);
+
+ }
+ else if (backBrush != null)
+ g.FillRectangle(backBrush, tab.DisplayRectangle.X, tab.DisplayRectangle.Y, width, tab.TextSize.Width + PanelBar.TabPadding * 2);
+ }
+ else
+ {
+ if ((m_Style == eDotNetBarStyle.Office2003 || m_Style == eDotNetBarStyle.VS2005) && !scheme.ItemPressedBackground2.IsEmpty)
+ {
+ using (LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(margin, tab.DisplayRectangle.Y, width, tab.TextSize.Width + PanelBar.TabPadding * 2), scheme.ItemPressedBackground, scheme.ItemPressedBackground2, scheme.ItemPressedBackgroundGradientAngle))
+ g.FillRectangle(gradient, margin, tab.DisplayRectangle.Y, width, tab.TextSize.Width + PanelBar.TabPadding * 2);
+
+ }
+ else if (backBrush != null)
+ g.FillRectangle(backBrush, margin, tab.DisplayRectangle.Y, width, tab.TextSize.Width + PanelBar.TabPadding * 2);
+ }
+ }
+ g.RotateTransform(90);
+ TextDrawing.DrawStringLegacy(g, tab.Text, this.Font, textColor, new Rectangle(y, -width, (icon == null ? tab.TextSize.Width : panel.MaxTextWidth), width), format);
+ g.ResetTransform();
+ y += ((icon == null ? tab.TextSize.Width : panel.MaxTextWidth) + PanelBar.TabPadding);
+ if (this.Dock == DockStyle.Left)
+ tab.DisplayRectangle.Offset(-1, 0);
+ else
+ tab.DisplayRectangle.Offset(1, 0);
+ tab.DisplayRectangle.Height = y - tab.DisplayRectangle.Y;
+ g.DrawRectangle(linePen, tab.DisplayRectangle);
+ }
+ else
+ {
+ if (icon != null)
+ {
+ if (this.Dock == DockStyle.Left)
+ {
+ if (backBrush != null)
+ g.FillRectangle(backBrush, tab.DisplayRectangle.X, tab.DisplayRectangle.Y, width, icon.Height + PanelBar.TabPadding * 2);
+ icon.DrawImage(g, new Rectangle((width - icon.Width - margin) / 2, y, icon.Width, icon.Height));
+ //g.DrawImage(icon,(width-icon.Width-margin)/2,y,icon.Width,icon.Height);
+ }
+ else
+ {
+ if (backBrush != null)
+ g.FillRectangle(backBrush, margin, tab.DisplayRectangle.Y, width, icon.Height + PanelBar.TabPadding * 2);
+ icon.DrawImage(g, new Rectangle((width - icon.Width + margin) / 2, y, icon.Width, icon.Height));
+ //g.DrawImage(icon,(width-icon.Width+margin)/2,y,icon.Width,icon.Height);
+ }
+ y += (icon.Height + PanelBar.TabPadding);
+ }
+ else
+ {
+ g.RotateTransform(90);
+ TextDrawing.DrawStringLegacy(g, tab.Text, this.Font, textColor, new Rectangle(y, -width, tab.TextSize.Width, width), format);
+ g.ResetTransform();
+ y += (tab.TextSize.Width + PanelBar.TabPadding);
+ }
+ tab.DisplayRectangle.Height = y - tab.DisplayRectangle.Y;
+ if (this.Dock == DockStyle.Left)
+ tab.DisplayRectangle.X--;
+ else
+ tab.DisplayRectangle.X++;
+ g.DrawRectangle(linePen, tab.DisplayRectangle);
+ }
+ if (y > this.Height)
+ break;
+ }
+ y += 4;
+ if (y > this.Height)
+ break;
+ }
+ }
+
+ linePen.Dispose();
+
+
+ if (m_AntiAlias)
+ {
+ g.TextRenderingHint = textHint;
+ g.SmoothingMode = sm;
+ }
+ }
+
+ private bool IsGradientStyle
+ {
+ get
+ {
+ if (m_Style == eDotNetBarStyle.Office2003 || m_Style == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(m_Style))
+ return true;
+ return false;
+ }
+ }
+ private DockItemTab _MouseOverTab = null;
+ private void SetMouseOverTab(AutoHidePanel.DockItemTab tab)
+ {
+ if (tab == _MouseOverTab) return;
+
+ if (_MouseOverTab != null)
+ {
+ _MouseOverTab.IsMouseOver = false;
+ this.Invalidate(_MouseOverTab.DisplayRectangle);
+ }
+
+ _MouseOverTab = tab;
+
+ if (_MouseOverTab != null)
+ {
+ _MouseOverTab.IsMouseOver = true;
+ this.Invalidate(_MouseOverTab.DisplayRectangle);
+ }
+ }
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ DockItemTab tab = HitTestTab(e.X, e.Y);
+ SetMouseOverTab(tab);
+
+ base.OnMouseMove(e);
+ }
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ base.OnMouseEnter(e);
+ CreateTimer();
+ }
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+ SetMouseOverTab(null);
+ if (m_Timer != null)
+ m_Timer.Interval = m_AutoHideShowTimeout;
+ }
+ private void CreateTimer()
+ {
+ if (m_Timer != null)
+ {
+ m_Timer.Start();
+ return;
+ }
+ m_Timer = new Timer();
+ m_Timer.Interval = m_AutoHideShowTimeout;
+ m_Timer.Tick += new EventHandler(this.TimerTick);
+ m_Timer.Start();
+ }
+ internal void StopTimer()
+ {
+ if (m_Timer != null)
+ m_Timer.Stop();
+ }
+ internal void StartTimer()
+ {
+ if (m_Timer != null)
+ m_Timer.Start();
+ }
+
+ private void TimerTick(object sender, EventArgs e)
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+
+ if (this.ClientRectangle.Contains(p))
+ {
+ IntPtr activeWnd = NativeFunctions.GetActiveWindow();
+ Form parentForm = this.FindForm();
+ if (parentForm != null && parentForm.Handle != activeWnd)
+ {
+ Control c = parentForm;
+ bool bExit = true;
+ while (c.Parent != null)
+ {
+ c = c.Parent;
+ if (c.Handle == activeWnd)
+ {
+ bExit = false;
+ break;
+ }
+ }
+ if (bExit)
+ return;
+ }
+ if (!m_EnableHoverExpand)
+ return;
+ if (parentForm != null)
+ {
+ Point mousePosition = Control.MousePosition;
+ Point parentPoint = parentForm.PointToClient(mousePosition);
+ Control childAtPoint = parentForm.GetChildAtPoint(parentPoint, GetChildAtPointSkip.Invisible | GetChildAtPointSkip.Transparent);
+ while (childAtPoint != null && !(childAtPoint is AutoHidePanel))
+ {
+ parentPoint = childAtPoint.PointToClient(mousePosition);
+ childAtPoint = childAtPoint.GetChildAtPoint(parentPoint, GetChildAtPointSkip.Invisible | GetChildAtPointSkip.Transparent);
+ }
+ if (!(childAtPoint is AutoHidePanel))
+ {
+ StopTimer();
+ return;
+ }
+ }
+ SelectPanel(p.X, p.Y);
+ }
+ else
+ {
+ PanelBar activePanel = ActivePanelBar;
+ if (activePanel != null && !activePanel.BoundBar.IsSizingWindow)
+ {
+ if (activePanel.BoundBar.Visible && !(!m_EnableFocusCollapse && IsBarActive(activePanel.BoundBar)))
+ {
+ p = activePanel.BoundBar.PointToClient(Control.MousePosition);
+ if (!activePanel.BoundBar.ClientRectangle.Contains(p))
+ {
+ if (AnimateHide(activePanel.BoundBar))
+ DestroyTimer();
+ }
+ }
+ }
+ }
+
+ }
+ private void DestroyTimer()
+ {
+ if (m_Timer == null)
+ return;
+ m_Timer.Stop();
+ m_Timer.Dispose();
+ m_Timer = null;
+ }
+ private bool IsBarActive(Bar bar)
+ {
+ if (bar == null)
+ return false;
+ Form form = this.FindForm();
+ if (form == null)
+ return false;
+ Control activeControl = form.ActiveControl;
+ if (activeControl == null)
+ return false;
+ while (activeControl != null)
+ {
+ if (bar == activeControl)
+ return true;
+ activeControl = activeControl.Parent;
+ }
+ return false;
+ }
+
+ ///
+ /// Gets or sets the timeout in milliseconds for auto hide/show action.
+ /// When timeout has elapsed and mouse has left the bar the bar will be automatically hidden.
+ /// If mouse is hovering over the collapsed bar and timeout has elapsed the bar will be displayed.
+ ///
+ [DefaultValue(800), Category("Behavior"), Description("Indicates timeout in milliseconds for auto hide/show action.")]
+ public int AutoHideShowTimeout
+ {
+ get { return m_AutoHideShowTimeout; }
+ set { m_AutoHideShowTimeout = value; }
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+ if (e.Button == MouseButtons.Left)
+ {
+ SelectPanel(e.X, e.Y);
+ }
+ }
+
+ public void SelectPanel(int x, int y)
+ {
+ foreach (PanelBar panel in m_Panels)
+ {
+ foreach (DockItemTab tab in panel.Tabs)
+ {
+ if (tab.DisplayRectangle.Contains(x, y))
+ {
+ PanelBar activePanel = ActivePanelBar;
+ if (activePanel != null)
+ {
+ if (activePanel != panel)
+ {
+ if (activePanel.BoundBar.IsSizingWindow)
+ return;
+ if (!AnimateHide(activePanel.BoundBar))
+ return;
+ }
+ else
+ {
+ if (panel.ActiveTab < panel.Tabs.Count)
+ {
+ if (panel.Tabs[panel.ActiveTab] == tab && panel.BoundBar.Visible)
+ return;
+ ((DockItemTab)activePanel.Tabs[activePanel.ActiveTab]).Item.Displayed = false;
+ }
+ }
+ }
+ if (panel.BoundBar.VisibleItemCount == 0)
+ throw new InvalidOperationException("Bar.Items collection must contain at least one visible DockContainerItem object so auto-hide functionality can function properly.");
+ panel.ActiveTab = panel.Tabs.IndexOf(tab);
+ if (panel.BoundBar.IsDisposed) return;
+ panel.BoundBar.SelectedDockTab = panel.BoundBar.Items.IndexOf(tab.Item);
+ PopupManager.CloseAllPopups();
+ AnimateShow(panel.BoundBar);
+ this.Refresh();
+ return;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Returns the reference to DockContainerItem tab if any under specified coordinates.
+ ///
+ /// X - client mouse coordinate
+ /// Y - client mouse coordinate
+ /// Reference to DockContainerItem whose tab is at specified coordinates or null if there is no tab at given coordinates
+ public DockContainerItem HitTest(int x, int y)
+ {
+ DockItemTab tab = HitTestTab(x, y);
+ if (tab != null)
+ return tab.Item;
+ return null;
+ }
+
+ private DockItemTab HitTestTab(int x, int y)
+ {
+ foreach (PanelBar panel in m_Panels)
+ {
+ foreach (DockItemTab tab in panel.Tabs)
+ {
+ if (tab.DisplayRectangle.Contains(x, y))
+ {
+ return tab;
+ }
+ }
+ }
+ return null;
+ }
+
+
+ internal DockContainerItem SelectedDockContainerItem
+ {
+ get
+ {
+ PanelBar panel = this.ActivePanelBar;
+ if (panel == null)
+ {
+ foreach (PanelBar p in m_Panels)
+ {
+ for (int i = 0; i < p.Tabs.Count; i++)
+ {
+ DockItemTab tab = p.Tabs[i] as DockItemTab;
+ if (p.ActiveTab == i)
+ return tab.Item;
+ }
+ }
+ return null;
+ }
+ try
+ {
+ DockItemTab tab = panel.Tabs[panel.ActiveTab] as DockItemTab;
+ return tab.Item;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ set
+ {
+ foreach (PanelBar panel in m_Panels)
+ {
+ foreach (DockItemTab tab in panel.Tabs)
+ {
+ if (tab.Item == value)
+ {
+ PanelBar activePanel = ActivePanelBar;
+ if (activePanel != null)
+ {
+ if (activePanel != panel)
+ {
+ if (activePanel.BoundBar.IsSizingWindow)
+ return;
+ if (!AnimateHide(activePanel.BoundBar))
+ return;
+ }
+ else
+ {
+ if (panel.Tabs[panel.ActiveTab] == tab && panel.BoundBar.Visible)
+ return;
+ ((DockItemTab)activePanel.Tabs[activePanel.ActiveTab]).Item.Displayed = false;
+ }
+ }
+ panel.ActiveTab = panel.Tabs.IndexOf(tab);
+ this.Refresh();
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether bars on auto-hide panel are displayed when mouse hovers over the tab.
+ ///
+ [DefaultValue(true), Browsable(true), Description("Indicates whether bars on auto-hide panel are displayed when mouse hovers over the tab.")]
+ public bool EnableHoverExpand
+ {
+ get { return m_EnableHoverExpand; }
+ set { m_EnableHoverExpand = value; }
+ }
+
+ ///
+ /// Gets or sets whether bars that have focus are collapsed automatically or not.
+ ///
+ [DefaultValue(true), Browsable(true), Description("Indicates whether bars that have focus are collapsed automatically or not.")]
+ public bool EnableFocusCollapse
+ {
+ get { return m_EnableFocusCollapse; }
+ set { m_EnableFocusCollapse = value; }
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ base.OnFontChanged(e);
+ RefreshPanels();
+ }
+
+ protected override void OnSystemColorsChanged(EventArgs e)
+ {
+ base.OnSystemColorsChanged(e);
+ Application.DoEvents();
+ this.Font = SystemFonts.DefaultFont; // SystemInformation.MenuFont.Clone() as Font;
+ }
+
+ private void RefreshPanels()
+ {
+ foreach (PanelBar panelbar in m_Panels)
+ panelbar.ReloadDockItems();
+ this.Invalidate();
+ }
+
+ internal void ShowBar(Bar bar)
+ {
+ PanelBar panel = null;
+ foreach (PanelBar panelbar in m_Panels)
+ {
+ if (panelbar.BoundBar == bar)
+ {
+ panel = panelbar;
+ break;
+ }
+ }
+ PanelBar activePanel = ActivePanelBar;
+ if (activePanel == panel)
+ return;
+
+ if (activePanel != null)
+ {
+ if (activePanel.BoundBar.IsSizingWindow)
+ return;
+ if (!AnimateHide(activePanel.BoundBar))
+ {
+ CreateTimer();
+ return;
+ }
+ }
+ panel.BoundBar.SelectedDockTab = panel.ActiveTab;
+ AnimateShow(panel.BoundBar);
+ this.Refresh();
+ CreateTimer();
+ }
+ internal void HideBar(Bar bar)
+ {
+ PanelBar activePanel = ActivePanelBar;
+ if (activePanel.BoundBar != bar)
+ return;
+ if (activePanel.BoundBar.Visible)
+ {
+ if (AnimateHide(activePanel.BoundBar))
+ DestroyTimer();
+ }
+ }
+
+ private bool AnimateHide(Bar bar)
+ {
+ return bar.AnimateHide();
+ }
+
+ private bool AnimateShow(Bar bar)
+ {
+ if (bar.Enabled)
+ return bar.AnimateShow();
+ return false;
+ }
+
+ private PanelBar ActivePanelBar
+ {
+ get
+ {
+ foreach (PanelBar panel in m_Panels)
+ {
+ if (panel.ActiveTab >= 0 && panel.BoundBar.Visible)
+ return panel;
+ }
+ return null;
+ }
+ }
+
+ ///
+ /// Sets bars position on the auto-hide panel.
+ ///
+ /// Bar for which position should be changed.
+ /// New indexed position of the bar.
+ public void SetBarPosition(Bar bar, int iIndex)
+ {
+ if (iIndex < m_Panels.Count)
+ {
+ for (int i = 0; i < m_Panels.Count; i++)
+ {
+ if (((PanelBar)m_Panels[i]).BoundBar == bar)
+ {
+ if (i != iIndex)
+ {
+ PanelBar panel = (PanelBar)m_Panels[i];
+ m_Panels.RemoveAt(i);
+ m_Panels.Insert(iIndex, panel);
+ this.Refresh();
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the style of auto-hide panel.
+ ///
+ public eDotNetBarStyle Style
+ {
+ get { return m_Style; }
+ set
+ {
+ m_Style = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets the ColorScheme object used by this panel. Default value is null which means that ColorScheme is
+ /// automatically created as specified by Style property. Note that if your DotNetBarManager has UseGlobalColorScheme set to true
+ /// ColorScheme from DotNetBarManager will be used.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public ColorScheme ColorScheme
+ {
+ get { return m_ColorScheme; }
+ set { m_ColorScheme = value; }
+ }
+
+ public void AddBar(Bar bar)
+ {
+ if (bar.Style == eDotNetBarStyle.Office2003)
+ m_Style = eDotNetBarStyle.Office2003;
+ else if (bar.Style == eDotNetBarStyle.VS2005)
+ m_Style = eDotNetBarStyle.VS2005;
+ else if (bar.Style == eDotNetBarStyle.Office2007)
+ m_Style = eDotNetBarStyle.Office2007;
+ else if (bar.Style == eDotNetBarStyle.Office2010)
+ m_Style = eDotNetBarStyle.Office2010;
+ else if (bar.Style == eDotNetBarStyle.Windows7)
+ m_Style = eDotNetBarStyle.Windows7;
+ else if (bar.Style == eDotNetBarStyle.StyleManagerControlled)
+ m_Style = bar.ItemsContainer.EffectiveStyle;
+ else
+ m_Style = eDotNetBarStyle.OfficeXP;
+
+ PanelBar panel = new PanelBar(this, bar);
+ m_Panels.Add(panel);
+ if (this.Dock == DockStyle.Right || this.Dock == DockStyle.Left)
+ {
+ if (panel.PanelSize.Height > this.Width)
+ this.Width = panel.PanelSize.Height;
+ }
+ else
+ {
+ if (panel.PanelSize.Height > this.Height)
+ this.Height = panel.PanelSize.Height;
+ }
+
+ if (!this.Visible)
+ {
+ BarFunctions.SetControlVisible(this, true);
+ }
+ else
+ this.Refresh();
+ this.Parent.PerformLayout();
+ this.Parent.Update();
+ }
+
+ public void RemoveBar(Bar bar)
+ {
+ foreach (PanelBar panel in m_Panels)
+ {
+ if (panel.BoundBar == bar)
+ {
+ m_Panels.Remove(panel);
+ panel.Dispose();
+ if (m_Panels.Count == 0)
+ {
+ this.Visible = false;
+ if (this.Dock == DockStyle.Right || this.Dock == DockStyle.Left)
+ {
+ this.Width = 0;
+ }
+ else
+ {
+ this.Height = 0;
+ }
+ }
+ else
+ this.Refresh();
+ break;
+ }
+ }
+ if (m_Panels.Count == 0)
+ DestroyTimer();
+ }
+
+ public void RefreshBar(Bar bar)
+ {
+ foreach (PanelBar panel in m_Panels)
+ {
+ if (panel.BoundBar == bar)
+ {
+ panel.ReloadDockItems();
+ break;
+ }
+ }
+ this.Refresh();
+ }
+
+ protected override void OnHandleDestroyed(EventArgs e)
+ {
+ base.OnHandleDestroyed(e);
+ DestroyTimer();
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ PanelBar panel = this.ActivePanelBar;
+ if (panel != null)
+ {
+ if (panel.BoundBar.Visible)
+ panel.BoundBar.SetAutoHideSize();
+ }
+ }
+
+ #region DockItemTab
+ private class DockItemTab : IDisposable
+ {
+ public Rectangle DisplayRectangle = new Rectangle(0, 0, 0, 0);
+ public DockContainerItem Item = null;
+ public Size TextSize = Size.Empty;
+ public Size IconSize = Size.Empty;
+ private string m_Text = "";
+ private PanelBar m_Parent = null;
+ public DockItemTab(PanelBar parent, DockContainerItem item)
+ {
+ this.Item = item;
+ m_Parent = parent;
+ item.TextChanged += new EventHandler(this.ItemTextChanged);
+ CompositeImage image = this.Icon;
+ if (image != null)
+ IconSize = image.Size;
+ }
+ public DockItemTab(PanelBar parent, string text)
+ {
+ m_Text = text;
+ m_Parent = parent;
+ }
+ public string Text
+ {
+ get
+ {
+ if (this.Item == null)
+ return m_Text;
+ else
+ return this.Item.Text;
+ }
+ }
+ public CompositeImage Icon
+ {
+ get
+ {
+ if (Item == null)
+ return null;
+ if (Item.Image != null)
+ {
+ return new CompositeImage(Item.Image, false);
+ }
+ if (Item.ImageIndex >= 0 && Item.ImageList != null)
+ return new CompositeImage(Item.ImageList.Images[Item.ImageIndex], false);
+ if (Item.Icon != null)
+ return new CompositeImage(Item.Icon, false);
+ return null;
+ }
+ }
+ private bool _IsMouseOver = false;
+ public bool IsMouseOver
+ {
+ get
+ {
+ return _IsMouseOver;
+ }
+ set
+ {
+ _IsMouseOver = value;
+ }
+ }
+ private void ItemTextChanged(object sender, EventArgs e)
+ {
+ Control container = ((BaseItem)sender).ContainerControl as Control;
+ if (container != null)
+ {
+ Graphics g = BarFunctions.CreateGraphics(container);
+ try
+ {
+ TextSize = TextDrawing.MeasureStringLegacy(g, ((BaseItem)sender).Text, m_Parent.Parent.Font, Size.Empty, eTextFormat.Default);
+ TextSize.Width += 4;
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ CompositeImage image = this.Icon;
+ if (image != null)
+ IconSize = image.Size;
+ else
+ IconSize = Size.Empty;
+ }
+ m_Parent.Refresh();
+ }
+ public void Dispose()
+ {
+ if (this.Item != null)
+ this.Item.TextChanged -= new EventHandler(this.ItemTextChanged);
+ }
+ }
+ #endregion
+
+ #region PanelBar
+ private class PanelBar : IDisposable
+ {
+ public ArrayList Tabs = new ArrayList(10);
+ public int ActiveTab = -1;
+ public Bar BoundBar = null;
+ private AutoHidePanel m_Parent = null;
+ public static int TabPadding = 4;
+ public static int TabTextVPadding = 4;
+ public static int TabIconVPadding = 3;
+ private Size m_PanelSize = Size.Empty;
+ private int m_MaxTextWidth = 0;
+
+ public PanelBar(AutoHidePanel parent, Bar bar)
+ {
+ m_Parent = parent;
+ BoundBar = bar;
+ ReloadDockItems();
+ }
+ public void ReloadDockItems()
+ {
+ foreach (DockItemTab tab in Tabs)
+ tab.Dispose();
+ Tabs.Clear();
+
+ Graphics g = BarFunctions.CreateGraphics(BoundBar);
+ try
+ {
+ if (BoundBar.LayoutType == eLayoutType.DockContainer)
+ {
+ foreach (BaseItem item in BoundBar.Items)
+ {
+ DockContainerItem dockItem = item as DockContainerItem;
+ if (dockItem != null && dockItem.Visible)
+ {
+ DockItemTab tab = new DockItemTab(this, dockItem);
+ this.Tabs.Add(tab);
+ tab.TextSize = TextDrawing.MeasureStringLegacy(g, dockItem.Text, m_Parent.Font, Size.Empty, eTextFormat.Default);
+ tab.TextSize.Width += 4;
+ }
+ }
+ }
+ if (this.Tabs.Count == 0)
+ {
+ DockItemTab tab = new DockItemTab(this, BoundBar.Text);
+ this.Tabs.Add(tab);
+ tab.TextSize = TextDrawing.MeasureStringLegacy(g, BoundBar.Text, m_Parent.Font, Size.Empty, eTextFormat.Default);
+ tab.TextSize.Width += 4;
+ }
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ m_PanelSize = CalcPanelSize();
+ if (BoundBar.SelectedDockTab >= 0)
+ this.ActiveTab = BoundBar.SelectedDockTab;
+ else
+ this.ActiveTab = 0;
+ }
+ public void Refresh()
+ {
+ m_PanelSize = CalcPanelSize();
+ m_Parent.Refresh();
+ }
+ public void Dispose()
+ {
+ foreach (DockItemTab tab in Tabs)
+ tab.Dispose();
+ Tabs.Clear();
+ BoundBar = null;
+ m_Parent = null;
+ }
+
+ public AutoHidePanel Parent
+ {
+ get { return m_Parent; }
+ }
+
+ public Size PanelSize
+ {
+ get
+ {
+ return m_PanelSize;
+ }
+ }
+
+ public int MaxTextWidth
+ {
+ get { return m_MaxTextWidth; }
+ }
+
+ private Size CalcPanelSize()
+ {
+ Size size = Size.Empty;
+ Size textSize = Size.Empty;
+
+ bool bHorizontal = true;
+
+ foreach (DockItemTab tab in Tabs)
+ {
+ if (!tab.IconSize.IsEmpty)
+ {
+ if (bHorizontal)
+ {
+ size.Width += (tab.IconSize.Width + PanelBar.TabPadding * 2);
+ size.Height = tab.IconSize.Height + TabIconVPadding * 2;
+ }
+ else
+ {
+ size.Height += (tab.IconSize.Height + PanelBar.TabPadding * 2);
+ size.Width = tab.IconSize.Width + TabIconVPadding * 2;
+ }
+ }
+ if (bHorizontal)
+ {
+ if (tab.TextSize.Width > textSize.Width)
+ textSize.Width = tab.TextSize.Width;
+ if (tab.TextSize.Height > textSize.Height)
+ textSize.Height = tab.TextSize.Height;
+ }
+ else
+ {
+ if (tab.TextSize.Width > textSize.Height)
+ textSize.Height = tab.TextSize.Width;
+ if (tab.TextSize.Height > textSize.Width)
+ textSize.Width = tab.TextSize.Height;
+ }
+ }
+ if (bHorizontal)
+ {
+ m_MaxTextWidth = textSize.Width;
+ textSize.Width += PanelBar.TabPadding;
+ textSize.Height += (PanelBar.TabTextVPadding * 2);
+ size = new Size(size.Width + textSize.Width, (size.Height > textSize.Height ? size.Height : textSize.Height));
+ if (StyleManager.IsMetro(StyleManager.Style))
+ size.Height += 6;
+ }
+ else
+ {
+ m_MaxTextWidth = textSize.Height;
+ textSize.Height += PanelBar.TabPadding;
+ textSize.Width += (PanelBar.TabTextVPadding * 2);
+ size = new Size((size.Width > textSize.Height ? size.Width : textSize.Height), size.Height + textSize.Width);
+ if (StyleManager.IsMetro(StyleManager.Style))
+ size.Width += 6;
+ }
+
+ if (m_Parent != null && !m_Parent.FixedSize.IsEmpty)
+ return m_Parent.FixedSize;
+ return size;
+ }
+ }
+ #endregion
+
+ #region VS2005TabDisplay
+ private class VS2005TabDisplay
+ {
+ protected AutoHidePanel m_AutoHidePanel = null;
+ private ColorScheme m_ColorScheme = null;
+ private int m_xTabOffset = 1;
+ private bool m_DisplayTextForActiveTabOnly = false;
+ ///
+ /// Creates new instance of the class.
+ ///
+ public VS2005TabDisplay(AutoHidePanel autoHidePanel, ColorScheme colorScheme)
+ {
+ m_AutoHidePanel = autoHidePanel;
+ m_ColorScheme = colorScheme;
+ }
+
+ public bool DisplayTextForActiveTabOnly
+ {
+ get { return m_DisplayTextForActiveTabOnly; }
+ set { m_DisplayTextForActiveTabOnly = value; }
+ }
+
+ public void Paint(Graphics g, ArrayList m_Panels)
+ {
+ ArrayList activeTabs = new ArrayList();
+ Point p = new Point(0, 0);
+
+ if (m_AutoHidePanel.Dock == DockStyle.Left || m_AutoHidePanel.Dock == DockStyle.Right)
+ {
+ p.Y = 2;
+ p.X = 1;
+ }
+ else
+ p.X = 2;
+
+ foreach (PanelBar panel in m_Panels)
+ {
+ for (int i = 0; i < panel.Tabs.Count; i++)
+ {
+ bool displayText = true;
+ if (m_DisplayTextForActiveTabOnly && panel.ActiveTab != i && !panel.BoundBar.AutoHideTabTextAlwaysVisible)
+ displayText = false;
+ DockItemTab tab = panel.Tabs[i] as DockItemTab;
+ if (m_AutoHidePanel.Dock == DockStyle.Left || m_AutoHidePanel.Dock == DockStyle.Right)
+ {
+ tab.DisplayRectangle = new Rectangle(p.X, p.Y, m_AutoHidePanel.Width - 2, tab.IconSize.Width + 2 +
+ (displayText || tab.IconSize.Width == 0 ? tab.TextSize.Width : 4));
+ p.Y += (tab.DisplayRectangle.Height + m_xTabOffset);
+ }
+ else
+ {
+ tab.DisplayRectangle = new Rectangle(p.X, p.Y, tab.IconSize.Width + 2 +
+ (displayText || tab.IconSize.Width == 0 ? tab.TextSize.Width : 4), m_AutoHidePanel.Height);
+ p.X += (tab.DisplayRectangle.Width + m_xTabOffset);
+ }
+
+ if (panel.ActiveTab == i)
+ activeTabs.Add(tab);
+ else
+ PaintTab(g, tab, false);
+ }
+ if (m_AutoHidePanel.Dock == DockStyle.Left || m_AutoHidePanel.Dock == DockStyle.Right)
+ p.Y += 2;
+ else
+ p.X += 2;
+ }
+
+ foreach (DockItemTab tab in activeTabs)
+ PaintTab(g, tab, true);
+ }
+
+ protected virtual void PaintTab(Graphics g, DockItemTab tab, bool selected)
+ {
+ GraphicsPath path = GetTabItemPath(tab);
+ TabColors colors = GetTabColors(tab, selected);
+
+ DrawTabItemBackground(tab, path, colors, g);
+
+ DrawTabText(tab, colors, g, selected);
+ }
+
+ protected virtual TabColors GetTabColors(DockItemTab tab, bool selected)
+ {
+ TabColors c = new TabColors();
+ if (tab.Item != null && BarFunctions.IsOffice2007Style(tab.Item.EffectiveStyle))
+ {
+ if (tab.Item.PredefinedTabColor == eTabItemColor.Default)
+ {
+ if (selected && !m_ColorScheme.AutoHideSelectedTabBackground.IsEmpty)
+ {
+ c.BackColor = m_ColorScheme.AutoHideSelectedTabBackground;
+ c.BackColor2 = m_ColorScheme.AutoHideSelectedTabBackground2;
+ c.BackColorGradientAngle = m_ColorScheme.AutoHideTabBackgroundGradientAngle;
+ c.TextColor = m_ColorScheme.AutoHideSelectedTabText;
+ c.BorderColor = m_ColorScheme.AutoHideSelectedTabBorder;
+ }
+ else if (!m_ColorScheme.AutoHideTabBackground.IsEmpty)
+ {
+ c.BackColor = m_ColorScheme.AutoHideTabBackground;
+ c.BackColor2 = m_ColorScheme.AutoHideTabBackground2;
+ c.BackColorGradientAngle = m_ColorScheme.AutoHideTabBackgroundGradientAngle;
+ c.TextColor = m_ColorScheme.AutoHideTabText;
+ c.BorderColor = m_ColorScheme.AutoHideTabBorder;
+ }
+ else
+ {
+ c.BackColor = m_ColorScheme.BarBackground;
+ c.BackColor2 = m_ColorScheme.BarBackground2;
+ c.BackColorGradientAngle = m_ColorScheme.BarBackgroundGradientAngle;
+ c.TextColor = m_ColorScheme.ItemText;
+ c.BorderColor = m_ColorScheme.BarDockedBorder;
+ }
+ }
+ else
+ {
+ Color c1, c2;
+ TabColorScheme.GetPredefinedColors(tab.Item.PredefinedTabColor, out c1, out c2);
+ c.BackColor = c1;
+ c.BackColor2 = c2;
+ c.BackColorGradientAngle = 90;
+ c.TextColor = m_ColorScheme.ItemText;
+ }
+
+ if (m_AutoHidePanel != null && (m_AutoHidePanel.Dock == DockStyle.Left || m_AutoHidePanel.Dock == DockStyle.Right))
+ {
+ c.BackColorGradientAngle -= 90;
+ }
+ }
+ else
+ {
+ c.BackColor = m_ColorScheme.DockSiteBackColor;
+ c.BackColor2 = m_ColorScheme.DockSiteBackColor;
+ c.TextColor = SystemColors.ControlText;
+ c.BorderColor = SystemColors.ControlDarkDark;
+ }
+
+ return c;
+ }
+
+ protected virtual void DrawTabItemBackground(DockItemTab tab, GraphicsPath path, TabColors colors, Graphics g)
+ {
+ RectangleF rf = path.GetBounds();
+ Rectangle tabRect = new Rectangle((int)rf.X, (int)rf.Y, (int)rf.Width, (int)rf.Height);
+
+ if (colors.BackColor2.IsEmpty)
+ {
+ if (!colors.BackColor.IsEmpty)
+ {
+ using (SolidBrush brush = new SolidBrush(colors.BackColor))
+ g.FillPath(brush, path);
+ }
+ }
+ else
+ {
+ using (SolidBrush brush = new SolidBrush(Color.White))
+ g.FillPath(brush, path);
+ using (LinearGradientBrush brush = CreateTabGradientBrush(tabRect, colors.BackColor, colors.BackColor2, colors.BackColorGradientAngle))
+ g.FillPath(brush, path);
+ }
+
+ if (!colors.BorderColor.IsEmpty)
+ {
+ using (Pen pen = new Pen(colors.BorderColor, 1))
+ g.DrawPath(pen, path);
+ }
+ }
+
+ protected virtual void DrawTabText(DockItemTab tab, TabColors colors, Graphics g, bool selected)
+ {
+ int MIN_TEXT_WIDTH = 12;
+ eTextFormat strFormat = eTextFormat.Default | eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter
+ | eTextFormat.EndEllipsis | eTextFormat.SingleLine;
+
+ Rectangle rText = tab.DisplayRectangle;
+ // Draw image
+ CompositeImage image = tab.Icon;
+ if (image != null && image.Width + 4 <= rText.Width)
+ {
+ if (m_AutoHidePanel.Dock == DockStyle.Top || m_AutoHidePanel.Dock == DockStyle.Bottom)
+ {
+ image.DrawImage(g, new Rectangle(rText.X + 3, rText.Y + (rText.Height - image.Height) / 2, image.Width, image.Height));
+ int offset = image.Width + 2;
+ rText.X += offset;
+ rText.Width -= offset;
+ }
+ else
+ {
+ image.DrawImage(g, new Rectangle(rText.X + (rText.Width - image.Width) / 2, rText.Y + 3, image.Width, image.Height));
+ int offset = image.Height + 2;
+ rText.Y += offset;
+ rText.Height -= offset;
+ }
+ }
+
+ bool drawTextAlways = false;
+ if (tab.Item != null && tab.Item.ContainerControl is Bar)
+ drawTextAlways = ((Bar)tab.Item.ContainerControl).AutoHideTabTextAlwaysVisible;
+ if (m_DisplayTextForActiveTabOnly && !drawTextAlways && !selected && image != null)
+ return;
+
+ // Draw text
+ //if(selected)
+ {
+ Font font = m_AutoHidePanel.Font;
+ rText.Inflate(-1, -1);
+
+ if ((m_AutoHidePanel.Dock == DockStyle.Left || m_AutoHidePanel.Dock == DockStyle.Right))
+ {
+ rText.Y += 2;
+ g.RotateTransform(90);
+ rText = new Rectangle(rText.Top, -rText.Right, rText.Height, rText.Width);
+ }
+
+ if (rText.Width > MIN_TEXT_WIDTH)
+ {
+ TextDrawing.DrawStringLegacy(g, tab.Text, font, colors.TextColor, rText, strFormat);
+ }
+
+ if ((m_AutoHidePanel.Dock == DockStyle.Left || m_AutoHidePanel.Dock == DockStyle.Right))
+ g.ResetTransform();
+ }
+ }
+
+ protected virtual LinearGradientBrush CreateTabGradientBrush(Rectangle r, Color color1, Color color2, int gradientAngle)
+ {
+ if (r.Width <= 0)
+ r.Width = 1;
+ if (r.Height <= 0)
+ r.Height = 1;
+ LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(r.X, r.Y - 1, r.Width, r.Height + 1), color1, color2, gradientAngle);
+ return brush;
+ }
+
+ protected virtual GraphicsPath GetTabItemPath(DockItemTab tab)
+ {
+ Rectangle r = tab.DisplayRectangle;
+ if (m_AutoHidePanel.Dock == DockStyle.Left)
+ r = new Rectangle(r.X - (r.Height - r.Width), r.Y, r.Height, r.Width);
+ else if (m_AutoHidePanel.Dock == DockStyle.Right)
+ r = new Rectangle(r.X, r.Y, r.Height, r.Width);
+
+ r.Offset(0, 1);
+
+ GraphicsPath path = new GraphicsPath();
+ int cornerSize = 2;
+ // Left line
+ //path.AddPath(GetLeftLine(r),true);
+ path.AddLine(r.X, r.Bottom, r.X, r.Y + cornerSize);
+
+ // Top line
+ path.AddLine(r.X + cornerSize, r.Y, r.Right - cornerSize, r.Y);
+
+ // Right line
+ //path.AddPath(GetRightLine(r),true);
+ path.AddLine(r.Right, r.Y + cornerSize, r.Right, r.Bottom);
+
+ // Bottom line
+ //path.AddLine(r.Right+m_xTabOffset,r.Bottom,r.X-m_xTabOffset,r.Bottom);
+ path.AddLine(r.Right, r.Bottom, r.X, r.Bottom);
+
+ path.CloseAllFigures();
+
+ if (m_AutoHidePanel.Dock == DockStyle.Top)
+ {
+ // Bottom
+ Matrix m = new Matrix();
+ m.RotateAt(180, new PointF(r.X + r.Width / 2, r.Y + r.Height / 2));
+ path.Transform(m);
+ }
+ else if (m_AutoHidePanel.Dock == DockStyle.Right)
+ {
+ // Left
+ Matrix m = new Matrix();
+ m.RotateAt(-90, new PointF(r.X, r.Bottom));
+ m.Translate(r.Height, r.Width - r.Height, MatrixOrder.Append);
+ path.Transform(m);
+ }
+ else if (m_AutoHidePanel.Dock == DockStyle.Left)
+ {
+ // Right
+ Matrix m = new Matrix();
+ m.RotateAt(90, new PointF(r.Right, r.Bottom));
+ m.Translate(-r.Height, r.Width - (r.Height - 1), MatrixOrder.Append);
+ path.Transform(m);
+ }
+
+ return path;
+ }
+
+ private GraphicsPath GetLeftLine(Rectangle r)
+ {
+ GraphicsPath path = new GraphicsPath();
+ // Left line
+ path.AddLine(r.X - m_xTabOffset, r.Bottom, r.X, r.Y + 5);
+ Point[] pc = new Point[3];
+ pc[0] = new Point(r.X, r.Y + 5);
+ pc[1] = new Point(r.X + 2, r.Y + 2);
+ pc[2] = new Point(r.X + 5, r.Y);
+ path.AddCurve(pc, .9f);
+ return path;
+ }
+
+ private GraphicsPath GetRightLine(Rectangle r)
+ {
+ GraphicsPath path = new GraphicsPath();
+ // Right line
+ Point[] pc = new Point[3];
+ pc[0] = new Point(r.Right - 5, r.Y);
+ pc[1] = new Point(r.Right - 2, r.Y + 2);
+ pc[2] = new Point(r.Right, r.Y + 5);
+ path.AddCurve(pc, .9f);
+ path.AddLine(r.Right, r.Y + 5, r.Right + m_xTabOffset, r.Bottom);
+ return path;
+ }
+ }
+ #endregion
+
+ #region VS2012 Tab Display
+ private class VS2012TabDisplay : VS2005TabDisplay
+ {
+ private const int BorderSize = 6;
+ ///
+ /// Creates new instance of the class.
+ ///
+ public VS2012TabDisplay(AutoHidePanel autoHidePanel, ColorScheme colorScheme)
+ : base(autoHidePanel, colorScheme)
+ {
+ }
+
+ protected override GraphicsPath GetTabItemPath(DockItemTab tab)
+ {
+ Rectangle r = tab.DisplayRectangle;
+ if (m_AutoHidePanel.Dock == DockStyle.Left)
+ r = new Rectangle(r.X - (r.Height - r.Width), r.Y, r.Height, r.Width);
+ else if (m_AutoHidePanel.Dock == DockStyle.Right)
+ r = new Rectangle(r.X, r.Y, r.Height, r.Width);
+
+ r.Offset(0, 1);
+
+ GraphicsPath path = new GraphicsPath();
+ path.AddRectangle(r);
+
+ return path;
+ }
+ protected override void DrawTabItemBackground(DockItemTab tab, GraphicsPath path, TabColors colors, Graphics g)
+ {
+ Rectangle tabRect = tab.DisplayRectangle;
+
+ if (!colors.BackColor.IsEmpty)
+ {
+ using (SolidBrush brush = new SolidBrush(colors.BackColor))
+ g.FillPath(brush, path);
+ }
+ if (!colors.BorderColor.IsEmpty)
+ {
+ Rectangle br = new Rectangle(tabRect.X, tabRect.Y, BorderSize, tabRect.Height);
+ if (m_AutoHidePanel.Dock == DockStyle.Right)
+ br = new Rectangle(tabRect.Right - BorderSize, tabRect.Y, BorderSize, tabRect.Height);
+ else if (m_AutoHidePanel.Dock == DockStyle.Top)
+ br = new Rectangle(tabRect.X, tabRect.Y, tabRect.Width, BorderSize);
+ else if (m_AutoHidePanel.Dock == DockStyle.Bottom)
+ br = new Rectangle(tabRect.X, tabRect.Bottom - BorderSize, tabRect.Width, BorderSize);
+ using (SolidBrush brush = new SolidBrush(colors.BorderColor))
+ g.FillRectangle(brush, br);
+ }
+ }
+ protected override TabColors GetTabColors(DockItemTab tab, bool selected)
+ {
+ selected = tab.IsMouseOver;
+ return base.GetTabColors(tab, selected);
+ }
+ }
+ #endregion
+ }
+}
+
diff --git a/PROMS/DotNetBar Source Code/Balloon.cs b/PROMS/DotNetBar Source Code/Balloon.cs
new file mode 100644
index 00000000..11c8adda
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Balloon.cs
@@ -0,0 +1,2060 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Drawing.Text;
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Indicates the Balloon tip position.
+ ///
+ public enum eTipPosition
+ {
+ ///
+ /// Tip is on the top.
+ ///
+ Top=0,
+ ///
+ /// Tip is on the left side.
+ ///
+ Left=1,
+ ///
+ /// Tip is on the right side.
+ ///
+ Right=2,
+ ///
+ /// Tip is on the bottom.
+ ///
+ Bottom=3
+ }
+
+ ///
+ /// Indicates the style of the balloon.
+ ///
+ public enum eBallonStyle
+ {
+ Balloon=0,
+ Alert=1,
+ Office2007Alert
+ }
+
+ ///
+ /// Indicates type of Alert animation performed when alert is displayed.
+ ///
+ public enum eAlertAnimation
+ {
+ ///
+ /// No animation take place when alert is displayed.
+ ///
+ None=0,
+ ///
+ /// Alert is animated from bottom to top. (Default)
+ ///
+ BottomToTop=1,
+ ///
+ /// Alert is animated from top to bottom.
+ ///
+ TopToBottom=2,
+ ///
+ /// Alert is animated from left to right.
+ ///
+ LeftToRight=3,
+ ///
+ /// Alert is animated from right to left.
+ ///
+ RightToLeft=4
+ }
+
+ ///
+ /// Delegate for custom paint event handler.
+ ///
+ public delegate void CustomPaintEventHandler(object sender, CustomPaintEventArgs e);
+
+ ///
+ /// Summary description for Balloon.
+ ///
+ [ToolboxItem(false), System.Runtime.InteropServices.ComVisible(false), Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+ public class Balloon : System.Windows.Forms.Form
+ {
+ private System.ComponentModel.IContainer components;
+ #region Event Definition
+ ///
+ /// Occurs when background is redrawn.
+ ///
+ public event CustomPaintEventHandler PaintBackground;
+ ///
+ /// Occurs when caption image is redrawn.
+ ///
+ public event CustomPaintEventHandler PaintCaptionImage;
+ ///
+ /// Occurs when caption text is redrawn.
+ ///
+ public event CustomPaintEventHandler PaintCaptionText;
+ ///
+ /// Occurs when text is redrawn.
+ ///
+ public event CustomPaintEventHandler PaintText;
+ ///
+ /// Occurs when close button is clicked.
+ ///
+ public event EventHandler CloseButtonClick;
+ ///
+ /// Occurs when TipPosition property has changed.
+ ///
+ public event EventHandler TipPositionChanged;
+ #endregion
+
+
+ private int m_TipLength=16;
+ private int m_CornerSize=8;
+ private int m_TipOffset=32;
+ private eTipPosition m_TipPosition=eTipPosition.Top;
+
+ private Color m_BackColor2=Color.Empty;
+ private int m_BackColorGradientAngle=90;
+
+ private eBackgroundImagePosition m_BackgroundImagePosition=eBackgroundImagePosition.Stretch;
+ private int m_BackgroundImageAlpha=255;
+
+ private Color m_BorderColor=SystemColors.InfoText;
+
+ private bool m_ShowCloseButton=true;
+ private ImageButton m_CloseButton=null;
+
+ private eBallonStyle m_Style=eBallonStyle.Balloon;
+
+ private Image m_CloseButtonNormal=null, m_CloseButtonHot=null, m_CloseButtonPressed=null;
+ private Image m_CaptionImage=null;
+ private Icon m_CaptionIcon=null;
+ private Font m_CaptionFont=null;
+ private string m_CaptionText="";
+ private StringAlignment m_CaptionAlignment=StringAlignment.Near;
+ private Color m_CaptionColor=SystemColors.InfoText;
+
+ private StringAlignment m_TextAlignment=StringAlignment.Near;
+ private StringAlignment m_TextLineAlignment=StringAlignment.Center;
+
+ // Layout rectangles
+ private Rectangle m_CaptionImageRectangle=Rectangle.Empty;
+ private Rectangle m_CaptionRectangle=Rectangle.Empty;
+ private Rectangle m_TextRectangle=Rectangle.Empty;
+
+ private bool m_AutoClose=true;
+ private int m_AutoCloseTimeOut=0;
+ private System.Windows.Forms.Timer m_Timer=null;
+
+ const int IMAGETEXT_SPACING=4;
+ const int TEXTCLOSE_SPACING=4;
+ const int CAPTIONTEXT_VSPACING=1;
+ const int CAPTIONALERT_VSPACING=1;
+
+ private Color m_BorderColor1=Color.FromArgb(241,239,226);
+ private Color m_BorderColor2=Color.White;
+ private Color m_BorderColor3=Color.FromArgb(236,233,216);
+ private Color m_BorderColor4=Color.FromArgb(172,168,153);
+ private Color m_BorderColor5=Color.FromArgb(113,111,100);
+
+ private eAlertAnimation m_AlertAnimation=eAlertAnimation.BottomToTop;
+ private int m_AlertAnimationDuration=200;
+ private bool m_AnimationInProgress=false;
+ private bool m_AntiAlias = true;
+
+ public Balloon()
+ {
+ CreateCloseButton();
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+ if(components==null)
+ this.components = new System.ComponentModel.Container();
+ m_CaptionFont=new Font(this.Font,FontStyle.Bold);
+
+ this.SetStyle(ControlStyles.UserPaint,true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);
+ //this.SetStyle(ControlStyles.Opaque,true);
+ this.SetStyle(ControlStyles.ResizeRedraw,true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag,true);
+ this.SetStyle(ControlStyles.ContainerControl,true);
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose( bool disposing )
+ {
+ DestroyAutoCloseTimer();
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+
+ if (BarUtilities.DisposeItemImages && !this.DesignMode)
+ {
+ BarUtilities.DisposeImage(ref m_CaptionIcon);
+ BarUtilities.DisposeImage(ref m_CaptionImage);
+ BarUtilities.DisposeImage(ref m_CloseButtonHot);
+ BarUtilities.DisposeImage(ref m_CloseButtonNormal);
+ BarUtilities.DisposeImage(ref m_CloseButtonPressed);
+ }
+ base.Dispose( disposing );
+ }
+
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting. Default value is false.
+ ///
+ [DefaultValue(true), Browsable(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting.")]
+ public bool AntiAlias
+ {
+ get { return m_AntiAlias; }
+ set
+ {
+ m_AntiAlias = value;
+ this.Invalidate();
+ }
+ }
+
+ #region Windows Form Designer generated code
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ //
+ // Balloon
+ //
+ this.AccessibleRole = System.Windows.Forms.AccessibleRole.HelpBalloon;
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.AutoScaleMode = AutoScaleMode.None;
+ this.BackColor = System.Drawing.SystemColors.Info; // ColorScheme.GetColor(0xFFFFBD);//
+ this.ClientSize = new System.Drawing.Size(192, 80);
+ this.ControlBox = false;
+ this.ForeColor = System.Drawing.SystemColors.InfoText;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "Balloon";
+ this.ShowInTaskbar = false;
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+
+ }
+ #endregion
+
+ protected override void OnClick(EventArgs e)
+ {
+ if(m_ShowCloseButton && m_CloseButton.Bounds.Contains(this.PointToClient(Control.MousePosition)))
+ return;
+ base.OnClick(e);
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ SmoothingMode sm = e.Graphics.SmoothingMode;
+ TextRenderingHint th = e.Graphics.TextRenderingHint;
+
+ if (m_AntiAlias)
+ {
+ e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+ e.Graphics.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ if(m_Style==eBallonStyle.Balloon)
+ PaintBalloon(e.Graphics);
+ else
+ PaintAlert(e.Graphics);
+
+ e.Graphics.SmoothingMode = sm;
+ e.Graphics.TextRenderingHint = th;
+ }
+
+ private void PaintAlert(Graphics g)
+ {
+ Rectangle client=this.GetAlertClientRect();
+ if(PaintBackground!=null)
+ PaintBackground(this,new CustomPaintEventArgs(g,client));
+ else
+ {
+ PaintBackgroundInternal(g);
+ if (m_Style == eBallonStyle.Alert)
+ {
+ // Paint Caption Background
+ Rectangle rCap = client;
+ rCap.Height = Math.Max(m_CaptionImageRectangle.Bottom, m_CaptionRectangle.Bottom) - rCap.Top;
+ rCap.Height += CAPTIONALERT_VSPACING;
+ if (rCap.Width > 0 && rCap.Height > 0)
+ {
+ using (LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(rCap, this.BackColor, m_BackColor2, m_BackColorGradientAngle))
+ {
+ Blend b = new Blend(4);
+ b.Positions = new float[] { 0f, .5f, .5f, 1f };
+ b.Factors = new float[] { 0f, 1f, 1f, 0f };
+ gradient.Blend = b;
+ g.FillRectangle(gradient, rCap);
+ }
+ }
+ }
+ }
+
+ // Draw Border
+ Rectangle r=this.DisplayRectangle;
+ if (m_Style == eBallonStyle.Office2007Alert)
+ {
+ DisplayHelp.DrawRectangle(g, m_BorderColor, r);
+ }
+ else
+ {
+ r.Width--;
+ r.Height--;
+ using (Pen pen = new Pen(m_BorderColor1, 1))
+ {
+ g.DrawLine(pen, r.X, r.Y, r.Right, r.Y);
+ g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom);
+ g.DrawLine(pen, r.X + 4, r.Bottom - 4, r.Right - 4, r.Bottom - 4);
+ g.DrawLine(pen, r.Right - 4, r.Y + 4, r.Right - 4, r.Bottom - 4);
+ }
+ using (Pen pen = new Pen(m_BorderColor2, 1))
+ {
+ g.DrawLine(pen, r.X + 1, r.Y + 1, r.Right - 1, r.Y + 1);
+ g.DrawLine(pen, r.X + 1, r.Y + 1, r.X + 1, r.Bottom - 1);
+ g.DrawLine(pen, r.X + 3, r.Bottom - 3, r.Right - 3, r.Bottom - 3);
+ g.DrawLine(pen, r.Right - 3, r.Y + 3, r.Right - 3, r.Bottom - 3);
+ }
+ using (Pen pen = new Pen(m_BorderColor3, 1))
+ {
+ g.DrawLine(pen, r.X + 2, r.Y + 2, r.Right - 2, r.Y + 2);
+ g.DrawLine(pen, r.X + 2, r.Y + 2, r.X + 2, r.Bottom - 2);
+ g.DrawLine(pen, r.X + 2, r.Bottom - 2, r.Right - 2, r.Bottom - 2);
+ g.DrawLine(pen, r.Right - 2, r.Y + 2, r.Right - 2, r.Bottom - 2);
+ }
+ using (Pen pen = new Pen(m_BorderColor4, 1))
+ {
+ g.DrawLine(pen, r.X + 3, r.Y + 3, r.Right - 3, r.Y + 3);
+ g.DrawLine(pen, r.X + 3, r.Y + 3, r.X + 3, r.Bottom - 3);
+ g.DrawLine(pen, r.X + 1, r.Bottom - 1, r.Right - 1, r.Bottom - 1);
+ g.DrawLine(pen, r.Right - 1, r.Y + 1, r.Right - 1, r.Bottom - 1);
+ }
+ using (Pen pen = new Pen(m_BorderColor5, 1))
+ {
+ g.DrawLine(pen, r.X + 4, r.Y + 4, r.Right - 4, r.Y + 4);
+ g.DrawLine(pen, r.X + 4, r.Y + 4, r.X + 4, r.Bottom - 4);
+ g.DrawLine(pen, r.X, r.Bottom, r.Right, r.Bottom);
+ g.DrawLine(pen, r.Right, r.Y, r.Right, r.Bottom);
+ }
+ }
+
+
+ if(m_CloseButton!=null)
+ m_CloseButton.Paint(g);
+
+ if(PaintCaptionImage!=null)
+ PaintCaptionImage(this,new CustomPaintEventArgs(g,m_CaptionImageRectangle));
+ else
+ {
+ CompositeImage image=this.ImageInternal;
+ if(image!=null && !m_CaptionImageRectangle.IsEmpty)
+ image.DrawImage(g,m_CaptionImageRectangle);
+ }
+
+ if(PaintCaptionText!=null)
+ PaintCaptionText(this,new CustomPaintEventArgs(g,m_CaptionRectangle));
+ else
+ {
+ if(m_CaptionText!="" && !m_CaptionRectangle.IsEmpty)
+ {
+ eTextFormat format = eTextFormat.Default | eTextFormat.WordBreak;
+ if (m_CaptionAlignment == StringAlignment.Center)
+ format |= eTextFormat.HorizontalCenter;
+ else if (m_CaptionAlignment == StringAlignment.Far)
+ format |= eTextFormat.Right;
+ Font font=m_CaptionFont;
+ if(font==null)
+ font=this.Font;
+ if (_CaptionTextMarkup != null)
+ {
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, m_CaptionColor, (this.RightToLeft == RightToLeft.Yes), r, true);
+ _CaptionTextMarkup.Arrange(m_CaptionRectangle, d);
+ _CaptionTextMarkup.Render(d);
+ }
+ else
+ TextDrawing.DrawString(g, m_CaptionText, font, m_CaptionColor, m_CaptionRectangle, format);
+ }
+ }
+
+ if(PaintText!=null)
+ PaintText(this,new CustomPaintEventArgs(g,m_TextRectangle));
+ else
+ {
+ if(this.Text!="")
+ {
+ eTextFormat format = eTextFormat.Default | eTextFormat.WordBreak;
+ if (m_TextAlignment == StringAlignment.Center)
+ format |= eTextFormat.HorizontalCenter;
+ else if (m_TextAlignment == StringAlignment.Far)
+ format |= eTextFormat.Right;
+ if (m_TextLineAlignment == StringAlignment.Center)
+ format |= eTextFormat.VerticalCenter;
+ else if (m_TextLineAlignment == StringAlignment.Far)
+ format |= eTextFormat.Bottom;
+ if (_TextMarkup != null)
+ {
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, this.Font, this.ForeColor,
+ (this.RightToLeft == RightToLeft.Yes), r, true);
+ _TextMarkup.Arrange(m_TextRectangle, d);
+ _TextMarkup.Render(d);
+ }
+ else
+ TextDrawing.DrawString(g, this.Text, this.Font, this.ForeColor, m_TextRectangle, format);
+ }
+ }
+ }
+
+ private void PaintBalloon(Graphics g)
+ {
+ Rectangle r = new Rectangle(0, 0, this.Width, this.Height); //this.DisplayRectangle;
+ GraphicsPath path=this.GetBalloonPath(r);
+ if(PaintBackground!=null)
+ PaintBackground(this,new CustomPaintEventArgs(g,r));
+ else
+ PaintBackgroundInternal(g);
+
+ using(Pen pen=new Pen(m_BorderColor,1))
+ {
+ pen.Alignment=PenAlignment.Inset;
+ g.DrawPath(pen,path);
+ }
+
+ if(m_CloseButton!=null)
+ m_CloseButton.Paint(g);
+
+ if(PaintCaptionImage!=null)
+ PaintCaptionImage(this,new CustomPaintEventArgs(g,m_CaptionImageRectangle));
+ else
+ {
+ CompositeImage image=this.ImageInternal;
+ if(image!=null && !m_CaptionImageRectangle.IsEmpty)
+ image.DrawImage(g,m_CaptionImageRectangle);
+ }
+
+ if(PaintCaptionText!=null)
+ PaintCaptionText(this,new CustomPaintEventArgs(g,m_CaptionRectangle));
+ else
+ {
+ if(m_CaptionText!="" && !m_CaptionRectangle.IsEmpty)
+ {
+ eTextFormat format = eTextFormat.Default | TextDrawing.TranslateHorizontal(m_CaptionAlignment) | eTextFormat.WordBreak;
+ Font font = m_CaptionFont;
+ if (font == null)
+ font = this.Font;
+
+
+ if (_CaptionTextMarkup != null)
+ {
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, m_CaptionColor, (this.RightToLeft == RightToLeft.Yes), r, true);
+ _CaptionTextMarkup.Arrange(m_CaptionRectangle, d);
+ _CaptionTextMarkup.Render(d);
+ }
+ else
+ TextDrawing.DrawString(g, m_CaptionText, font, m_CaptionColor, m_CaptionRectangle, format);
+ }
+ }
+
+ if(PaintText!=null)
+ PaintText(this,new CustomPaintEventArgs(g,m_TextRectangle));
+ else
+ {
+ if(this.Text!="")
+ {
+ eTextFormat format = eTextFormat.Default | TextDrawing.TranslateHorizontal(m_TextAlignment) |
+ TextDrawing.TranslateVertical(m_TextLineAlignment) | eTextFormat.WordBreak;
+ if (_TextMarkup != null)
+ {
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, this.Font, this.ForeColor,
+ (this.RightToLeft == RightToLeft.Yes), r, true);
+ _TextMarkup.Arrange(m_TextRectangle, d);
+ _TextMarkup.Render(d);
+ }
+ else
+ TextDrawing.DrawString(g, this.Text, this.Font, this.ForeColor, m_TextRectangle, format);
+ }
+ }
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ if(!m_AnimationInProgress)
+ this.RecalcLayout();
+ }
+ private int _MinimumBalloonWidth = 180;
+ ///
+ /// Gets or sets the minimum balloon width when auto sizing balloon. Default value is 180.
+ ///
+ [DefaultValue(180), Category("Appearance"), Description("Indicates minimum balloon width when auto sizing balloon.")]
+ public int MinimumBalloonWidth
+ {
+ get { return _MinimumBalloonWidth; }
+ set { _MinimumBalloonWidth = value; }
+ }
+
+ private TextMarkup.BodyElement _TextMarkup = null;
+ protected override void OnTextChanged(EventArgs e)
+ {
+ string text = this.Text;
+
+ if (_TextMarkup != null)
+ {
+ _TextMarkup.MouseLeave(this);
+ _TextMarkup.HyperLinkClick -= new EventHandler(TextMarkupLinkClicked);
+ _TextMarkup = null;
+ }
+
+ if (TextMarkup.MarkupParser.IsMarkup(ref text))
+ _TextMarkup = TextMarkup.MarkupParser.Parse(text);
+
+ if (_TextMarkup != null)
+ {
+ _TextMarkup.HyperLinkClick += new EventHandler(TextMarkupLinkClicked);
+ }
+ this.Invalidate();
+ base.OnTextChanged(e);
+ }
+
+ private void TextMarkupLinkClicked(object sender, EventArgs e)
+ {
+ TextMarkup.HyperLink link = sender as TextMarkup.HyperLink;
+ if (link != null)
+ {
+ OnMarkupLinkClick(new MarkupLinkClickEventArgs(link.Name, link.HRef));
+ }
+ }
+
+ ///
+ /// Occurs when text markup link is clicked. Markup links can be created using "a" tag, for example:
+ /// Markup link
+ ///
+ [Description("Occurs when text markup link is clicked. Markup links can be created using tag.")]
+ public event MarkupLinkClickEventHandler MarkupLinkClick;
+
+ protected virtual void OnMarkupLinkClick(MarkupLinkClickEventArgs e)
+ {
+ if (this.MarkupLinkClick != null)
+ MarkupLinkClick(this, e);
+ }
+
+ protected virtual Size ResizeMarkup(Graphics g, int containerWidth)
+ {
+ if (_TextMarkup != null)
+ {
+ Rectangle r= new Rectangle(0,0,containerWidth, 1);
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, this.Font, SystemColors.Control, (this.RightToLeft == RightToLeft.Yes));
+ _TextMarkup.Measure(r.Size, d);
+ //_TextMarkup.Arrange(r, d);
+ return _TextMarkup.Bounds.Size;
+ }
+ return Size.Empty;
+ }
+
+ protected virtual Size ResizeCaptionMarkup(Graphics g, int containerWidth)
+ {
+ if (_CaptionTextMarkup != null)
+ {
+ Rectangle r = new Rectangle(0, 0, containerWidth, 1);
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, this.Font, SystemColors.Control, (this.RightToLeft == RightToLeft.Yes));
+ _CaptionTextMarkup.Measure(r.Size, d);
+ //_TextMarkup.Arrange(r, d);
+ return _CaptionTextMarkup.Bounds.Size;
+ }
+ return Size.Empty;
+ }
+
+ ///
+ /// Auto resize balloon to the content. Balloon width is calculated so image and caption text can fit in single line.
+ ///
+ public void AutoResize()
+ {
+ System.Drawing.Size newSize = new Size(Dpi.Width(_MinimumBalloonWidth), 0);
+
+ Size strSize=Size.Empty;
+
+ // Calculates caption text rectangle height
+ Font font=m_CaptionFont;
+ if(font==null)
+ font=this.Font;
+ Graphics g=this.CreateGraphics();
+ try
+ {
+ if (_CaptionTextMarkup != null)
+ strSize = ResizeCaptionMarkup(g, 800);
+ else
+ strSize = TextDrawing.MeasureString(g,(m_CaptionText != "" ? m_CaptionText : " "), font);
+
+ newSize.Width = Math.Max(newSize.Width, strSize.Width);
+ if(m_CloseButton!=null)
+ newSize.Width+=Dpi.Width(m_CloseButton.Size.Width);
+ else
+ newSize.Width+=Dpi.Width18;
+ newSize.Width+=TEXTCLOSE_SPACING;
+
+ int imageHeight=0;
+ if(m_CaptionIcon!=null)
+ {
+ newSize.Width+=Dpi.Width(m_CaptionIcon.Width+IMAGETEXT_SPACING);
+ imageHeight = Dpi.Height(m_CaptionIcon.Height);
+ }
+ else if(m_CaptionImage!=null)
+ {
+ newSize.Width+=Dpi.Width(m_CaptionImage.Width+IMAGETEXT_SPACING);
+ imageHeight = Dpi.Height(m_CaptionImage.Height);
+ }
+
+ newSize.Height+=Math.Max(imageHeight,strSize.Height);
+ newSize.Height+=IMAGETEXT_SPACING*2;
+
+ if (_TextMarkup == null)
+ strSize = TextDrawing.MeasureString(g, (this.Text != "" ? this.Text : " "), this.Font, newSize.Width,
+ eTextFormat.Default | eTextFormat.WordBreak);
+ else
+ strSize = ResizeMarkup(g, newSize.Width);
+
+ newSize.Height+=strSize.Height;
+
+ newSize.Width+=m_CornerSize*2;
+ newSize.Height+=m_CornerSize*2;
+
+ if(m_Style==eBallonStyle.Balloon)
+ {
+ if(m_TipPosition==eTipPosition.Left || m_TipPosition==eTipPosition.Right)
+ newSize.Width+=Dpi.Width(m_TipLength);
+ else
+ newSize.Height+=Dpi.Height(m_TipLength);
+ }
+ else
+ newSize.Height+=(int)((float)newSize.Height*.3);
+ }
+ finally
+ {
+ g.Dispose();
+ }
+
+ this.Size=newSize;
+ }
+
+ ///
+ /// Recalculates layout of the balloon.
+ ///
+ public void RecalcLayout()
+ {
+ if(this.DisplayRectangle.Width==0 || this.DisplayRectangle.Height==0)
+ return;
+
+ Size closeButtonSize = Size.Empty;
+ if (m_CloseButton != null)
+ closeButtonSize = m_CloseButton.Size;
+ if(m_Style==eBallonStyle.Balloon)
+ {
+ Rectangle client=new Rectangle(m_CornerSize/2,m_CornerSize/2,this.Width-m_CornerSize,this.Height-m_CornerSize);
+ if(m_TipPosition==eTipPosition.Bottom)
+ client.Height-=m_TipLength;
+ else if(m_TipPosition==eTipPosition.Left)
+ {
+ client.X+=m_TipLength;
+ client.Width-=m_TipLength;
+ }
+ else if(m_TipPosition==eTipPosition.Right)
+ client.Width-=m_TipLength;
+ else
+ {
+ // TOP
+ client.Y+=m_TipLength;
+ client.Height-=m_TipLength;
+ }
+
+ System.Drawing.Size imageSize=System.Drawing.Size.Empty;
+ if(m_CaptionIcon!=null)
+ imageSize=Dpi.ImageSize(m_CaptionIcon.Size);
+ else if(m_CaptionImage!=null)
+ imageSize=Dpi.ImageSize(m_CaptionImage.Size);
+
+ m_CaptionRectangle=client;
+ if(!imageSize.IsEmpty)
+ {
+ m_CaptionRectangle.X+=(imageSize.Width+IMAGETEXT_SPACING);
+ m_CaptionRectangle.Width-=(imageSize.Width+IMAGETEXT_SPACING);
+ }
+
+ // Calculates position of the close button if visible
+ if(m_CloseButton!=null)
+ {
+ m_CloseButton.Location = new Point(client.Right - closeButtonSize.Width, client.Top);
+ m_CaptionRectangle.Width-=(closeButtonSize.Width+TEXTCLOSE_SPACING);
+ }
+
+ // Calculates caption text rectangle height
+ Font font=m_CaptionFont;
+ if(font==null)
+ font=this.Font;
+ Graphics g=this.CreateGraphics();
+ try
+ {
+ eTextFormat format = eTextFormat.Default | eTextFormat.WordBreak;
+ if (m_CaptionAlignment == StringAlignment.Center)
+ format = eTextFormat.HorizontalCenter;
+ else if (m_CaptionAlignment == StringAlignment.Far)
+ format = eTextFormat.Right;
+ Size strSize = Size.Empty;
+ if (_CaptionTextMarkup != null)
+ strSize = ResizeCaptionMarkup(g, m_CaptionRectangle.Width);
+ else
+ strSize = TextDrawing.MeasureString(g,(m_CaptionText!=""?m_CaptionText:" "),font,m_CaptionRectangle.Width,format);
+ m_CaptionRectangle.Height=strSize.Height;
+ }
+ finally
+ {
+ g.Dispose();
+ }
+
+ // Calculates position of the image rectangle
+ if(!imageSize.IsEmpty)
+ {
+ m_CaptionImageRectangle=new Rectangle(client.X,client.Y,imageSize.Width,imageSize.Height);
+ if(m_CaptionRectangle.Height>imageSize.Height)
+ m_CaptionImageRectangle.Y+=(int)(m_CaptionRectangle.Height-imageSize.Height)/2;
+ else if(imageSize.Height>m_CaptionRectangle.Height)
+ m_CaptionRectangle.Y+=(int)(imageSize.Height-m_CaptionRectangle.Height)/2;
+
+ }
+ else if(m_CloseButton!=null && closeButtonSize.Height>m_CaptionRectangle.Height)
+ m_CaptionRectangle.Y+=(int)(closeButtonSize.Height-m_CaptionRectangle.Height)/2;
+
+ // Calculates the rectangle for balloon text
+ if(m_CaptionRectangle.Bottom>m_CaptionImageRectangle.Bottom)
+ m_TextRectangle=new Rectangle(client.X,m_CaptionRectangle.Bottom+CAPTIONTEXT_VSPACING,client.Width,client.Bottom-(m_CaptionRectangle.Bottom+CAPTIONTEXT_VSPACING));
+ else
+ m_TextRectangle=new Rectangle(client.X,m_CaptionImageRectangle.Bottom+CAPTIONTEXT_VSPACING,client.Width,client.Bottom-(m_CaptionImageRectangle.Bottom+CAPTIONTEXT_VSPACING));
+
+ // Calculates and sets the balloon window region
+ GraphicsPath path=this.GetBalloonPath(this.DisplayRectangle);
+ GraphicsPath tmpPath = (GraphicsPath)path.Clone();
+ tmpPath.Widen(Pens.Black);
+ Region region = new Region(tmpPath);
+ region.Union(path);
+ this.Region=region;
+ path.Dispose();
+ tmpPath.Dispose();
+ }
+ else
+ {
+ Rectangle client=this.GetAlertClientRect();
+ System.Drawing.Size imageSize=System.Drawing.Size.Empty;
+
+ if(m_CaptionIcon!=null)
+ imageSize=Dpi.ImageSize(m_CaptionIcon.Size);
+ else if(m_CaptionImage!=null)
+ imageSize=Dpi.ImageSize(m_CaptionImage.Size);
+
+ m_CaptionRectangle=client;
+ if(!imageSize.IsEmpty)
+ {
+ m_CaptionRectangle.X+=(imageSize.Width+IMAGETEXT_SPACING*2);
+ m_CaptionRectangle.Width-=(imageSize.Width+IMAGETEXT_SPACING*2);
+ }
+
+ // Calculates position of the close button if visible
+ if(m_CloseButton!=null)
+ {
+ m_CloseButton.Location=new Point(client.Right-m_CloseButton.Bounds.Width-CAPTIONALERT_VSPACING,client.Top);
+ m_CaptionRectangle.Width-=(closeButtonSize.Width+TEXTCLOSE_SPACING+CAPTIONALERT_VSPACING);
+ }
+
+ // Calculates caption text rectangle height
+ Font font=m_CaptionFont;
+ if(font==null)
+ font=this.Font;
+ Graphics g=this.CreateGraphics();
+ try
+ {
+ eTextFormat format = eTextFormat.Default | eTextFormat.WordBreak;
+ if (m_CaptionAlignment == StringAlignment.Center)
+ format = eTextFormat.HorizontalCenter;
+ else if (m_CaptionAlignment == StringAlignment.Far)
+ format = eTextFormat.Right;
+ Size strSize = TextDrawing.MeasureString(g, (m_CaptionText != "" ? m_CaptionText : " "), font, m_CaptionRectangle.Width, format);
+ m_CaptionRectangle.Height=strSize.Height;
+ }
+ finally
+ {
+ g.Dispose();
+ }
+
+ // Calculates position of the image rectangle
+ if(!imageSize.IsEmpty)
+ {
+ m_CaptionImageRectangle=new Rectangle(client.X+IMAGETEXT_SPACING,client.Y,imageSize.Width,imageSize.Height);
+ if(m_CaptionRectangle.Height>imageSize.Height)
+ m_CaptionImageRectangle.Y+=(int)(m_CaptionRectangle.Height-imageSize.Height)/2;
+ else if(imageSize.Height>m_CaptionRectangle.Height)
+ {
+ m_CaptionRectangle.Y+=(int)(imageSize.Height+-m_CaptionRectangle.Height)/2;
+ }
+
+ }
+ else if(m_CloseButton!=null && closeButtonSize.Height>m_CaptionRectangle.Height)
+ m_CaptionRectangle.Y+=(int)(closeButtonSize.Height-m_CaptionRectangle.Height)/2;
+
+ m_CaptionRectangle.Offset(0,CAPTIONALERT_VSPACING);
+ m_CaptionImageRectangle.Offset(0,CAPTIONALERT_VSPACING);
+
+ if(m_CloseButton!=null)
+ {
+ m_CloseButton.Location=new Point(m_CloseButton.Location.X,m_CaptionRectangle.Y+(m_CaptionRectangle.Height-closeButtonSize.Height)/2);
+ }
+
+
+ // Calculates the rectangle for balloon text
+ if(m_CaptionRectangle.Bottom>m_CaptionImageRectangle.Bottom)
+ m_TextRectangle=new Rectangle(client.X,m_CaptionRectangle.Bottom+CAPTIONTEXT_VSPACING*4,client.Width,client.Bottom-(m_CaptionRectangle.Bottom+CAPTIONTEXT_VSPACING*4));
+ else
+ m_TextRectangle=new Rectangle(client.X,m_CaptionImageRectangle.Bottom+CAPTIONTEXT_VSPACING*4,client.Width,client.Bottom-(m_CaptionImageRectangle.Bottom+CAPTIONTEXT_VSPACING*4));
+
+ this.Region=new Region(this.DisplayRectangle);
+ }
+ }
+
+ private Rectangle GetAlertClientRect()
+ {
+ Rectangle r = new Rectangle(0, 0, this.Width, this.Height); // this.DisplayRectangle;
+ r.Inflate(-4,-4);
+ return r;
+ }
+
+ private GraphicsPath GetBalloonPath(Rectangle rect)
+ {
+ GraphicsPath path = new GraphicsPath();
+
+ Rectangle clipBounds=rect;
+ Rectangle balloonBounds=clipBounds;
+ int cornerDiameter=m_CornerSize*2;
+ Matrix matrix=new Matrix();
+ Point[] anchorPoints=new Point[3];
+ int tipOffset=m_TipOffset;
+
+ balloonBounds.Size=new Size(balloonBounds.Width-1,balloonBounds.Height-1);
+
+ bool adjustOffset = false;
+ if(m_TipPosition==eTipPosition.Bottom)
+ {
+ adjustOffset=true;
+ matrix.Translate(balloonBounds.Width, balloonBounds.Height);
+ matrix.Rotate(180);
+ }
+ else if (m_TipPosition == eTipPosition.Left && this.RightToLeft == RightToLeft.No ||
+ m_TipPosition == eTipPosition.Right && this.RightToLeft == RightToLeft.Yes)
+ {
+ adjustOffset = true;
+ balloonBounds.Size=new Size(balloonBounds.Height, balloonBounds.Width);
+ matrix.Translate(0, balloonBounds.Width);
+ matrix.Rotate(-90);
+ }
+ else if(m_TipPosition==eTipPosition.Right && this.RightToLeft == RightToLeft.No ||
+ m_TipPosition == eTipPosition.Left && this.RightToLeft == RightToLeft.Yes)
+ {
+ balloonBounds.Size=new Size(balloonBounds.Height, balloonBounds.Width);
+ matrix.Translate(balloonBounds.Height, 0);
+ matrix.Rotate(90);
+ }
+
+ int balloonEdgeCenter =((int)(balloonBounds.Width-(m_CornerSize*2))/2)+1;
+ int offsetFromEdge = m_CornerSize;
+ if(adjustOffset)
+ {
+ tipOffset=(balloonBounds.Width-(offsetFromEdge*2)-m_TipOffset)+1;
+ }
+ if(tipOffsetballoonEdgeCenter)
+ {
+ anchorPoints[0]=new Point(tipOffset-m_TipLength+offsetFromEdge,balloonBounds.Y+m_TipLength);
+ anchorPoints[1]=new Point(tipOffset+offsetFromEdge,balloonBounds.Y);
+ anchorPoints[2]=new Point(tipOffset+offsetFromEdge,balloonBounds.Y+m_TipLength);
+ }
+ else
+ {
+ anchorPoints[0]=new Point(tipOffset-m_TipLength+offsetFromEdge,balloonBounds.Y+m_TipLength);
+ anchorPoints[1]=new Point(tipOffset+offsetFromEdge,balloonBounds.Y);
+ anchorPoints[2]=new Point(tipOffset+m_TipLength+offsetFromEdge,balloonBounds.Y+m_TipLength);
+ }
+
+ path.AddArc(balloonBounds.Left,balloonBounds.Top+m_TipLength,cornerDiameter, cornerDiameter,180, 90);
+
+ path.AddLine(anchorPoints[0],anchorPoints[1]);
+ path.AddLine(anchorPoints[1],anchorPoints[2]);
+
+ path.AddArc(balloonBounds.Width-cornerDiameter,balloonBounds.Top+m_TipLength,cornerDiameter, cornerDiameter, -90, 90);
+ path.AddArc(balloonBounds.Width-cornerDiameter,balloonBounds.Bottom-cornerDiameter,cornerDiameter, cornerDiameter, 0, 90);
+ path.AddArc(balloonBounds.Left, balloonBounds.Bottom-cornerDiameter,cornerDiameter, cornerDiameter, 90, 90);
+
+ path.CloseFigure();
+
+ path.Transform(matrix);
+
+ return path;
+ }
+
+ private void PaintBackgroundInternal(Graphics g)
+ {
+ Rectangle r=this.ClientRectangle;
+ if(r.Width==0 || r.Height==0)
+ return;
+
+ if(m_BackColor2.IsEmpty)
+ {
+ using(SolidBrush brush=new SolidBrush(this.BackColor))
+ g.FillRectangle(brush,r);
+ }
+ else
+ {
+ using(LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(r,this.BackColor,m_BackColor2,m_BackColorGradientAngle))
+ {
+ if(m_Style==eBallonStyle.Alert)
+ {
+ Blend b=new Blend(4);
+ b.Positions=new float[]{0f,.25f,.4f,.5f,.5f,.85f,.85f,1f};
+ b.Factors=new float[] {0f,1f,1f,0f,0f,0f,0f,1f};
+ gradient.Blend=b;
+ }
+ g.FillRectangle(gradient,r);
+ }
+ }
+
+ if(this.BackgroundImage==null)
+ return;
+
+// System.Drawing.Imaging.ImageAttributes imageAtt=null;
+//
+// if(m_BackgroundImageAlpha!=255)
+// {
+// System.Drawing.Imaging.ColorMatrix colorMatrix=new System.Drawing.Imaging.ColorMatrix();
+// colorMatrix.Matrix33=255-m_BackgroundImageAlpha;
+// imageAtt=new System.Drawing.Imaging.ImageAttributes();
+// imageAtt.SetColorMatrix(colorMatrix,System.Drawing.Imaging.ColorMatrixFlag.Default,System.Drawing.Imaging.ColorAdjustType.Bitmap);
+// }
+
+ BarFunctions.PaintBackgroundImage(g,r,this.BackgroundImage,m_BackgroundImagePosition,m_BackgroundImageAlpha);
+
+// switch(m_BackgroundImagePosition)
+// {
+// case eBackgroundImagePosition.Stretch:
+// {
+// if(imageAtt!=null)
+// g.DrawImage(this.BackgroundImage,r,0,0,this.BackgroundImage.Width,this.BackgroundImage.Height,GraphicsUnit.Pixel,imageAtt);
+// else
+// g.DrawImage(this.BackgroundImage,r,0,0,this.BackgroundImage.Width,this.BackgroundImage.Height,GraphicsUnit.Pixel);
+// break;
+// }
+// case eBackgroundImagePosition.Center:
+// {
+// Rectangle destRect=new Rectangle(r.X,r.Y,this.BackgroundImage.Width,this.BackgroundImage.Height);
+// if(r.Width>this.BackgroundImage.Width)
+// destRect.X+=(r.Width-this.BackgroundImage.Width)/2;
+// if(r.Height>this.BackgroundImage.Height)
+// destRect.Y+=(r.Height-this.BackgroundImage.Height)/2;
+// if(imageAtt!=null)
+// g.DrawImage(this.BackgroundImage,destRect,0,0,this.BackgroundImage.Width,this.BackgroundImage.Height,GraphicsUnit.Pixel,imageAtt);
+// else
+// g.DrawImage(this.BackgroundImage,destRect,0,0,this.BackgroundImage.Width,this.BackgroundImage.Height,GraphicsUnit.Pixel);
+// break;
+// }
+// case eBackgroundImagePosition.TopLeft:
+// case eBackgroundImagePosition.TopRight:
+// case eBackgroundImagePosition.BottomLeft:
+// case eBackgroundImagePosition.BottomRight:
+// {
+// Rectangle destRect=new Rectangle(r.X,r.Y,this.BackgroundImage.Width,this.BackgroundImage.Height);
+// if(m_BackgroundImagePosition==eBackgroundImagePosition.TopRight)
+// destRect.X=r.Right-this.BackgroundImage.Width;
+// else if(m_BackgroundImagePosition==eBackgroundImagePosition.BottomLeft)
+// destRect.Y=r.Bottom-this.BackgroundImage.Height;
+// else if(m_BackgroundImagePosition==eBackgroundImagePosition.BottomRight)
+// {
+// destRect.Y=r.Bottom-this.BackgroundImage.Height;
+// destRect.X=r.Right-this.BackgroundImage.Width;
+// }
+//
+// if(imageAtt!=null)
+// g.DrawImage(this.BackgroundImage,destRect,0,0,this.BackgroundImage.Width,this.BackgroundImage.Height,GraphicsUnit.Pixel,imageAtt);
+// else
+// g.DrawImage(this.BackgroundImage,destRect,0,0,this.BackgroundImage.Width,this.BackgroundImage.Height,GraphicsUnit.Pixel);
+// break;
+// }
+// case eBackgroundImagePosition.Tile:
+// {
+// if(imageAtt!=null)
+// {
+// if(r.Width>this.BackgroundImage.Width || r.Height>this.BackgroundImage.Height)
+// {
+// int x=r.X,y=r.Y;
+// while(yr.Right)
+// destRect.Width=destRect.Width-(destRect.Right-r.Right);
+// if(destRect.Bottom>r.Bottom)
+// destRect.Height=destRect.Height-(destRect.Bottom-r.Bottom);
+// g.DrawImage(this.BackgroundImage,destRect,0,0,destRect.Width,destRect.Height,GraphicsUnit.Pixel,imageAtt);
+// x+=this.BackgroundImage.Width;
+// }
+// x=r.X;
+// y+=this.BackgroundImage.Height;
+// }
+// }
+// else
+// {
+// g.DrawImage(this.BackgroundImage,new Rectangle(0,0,this.BackgroundImage.Width,this.BackgroundImage.Height),0,0,this.BackgroundImage.Width,this.BackgroundImage.Height,GraphicsUnit.Pixel,imageAtt);
+// }
+// }
+// else
+// {
+// TextureBrush brush=new TextureBrush(this.BackgroundImage); //,r);
+// brush.WrapMode=System.Drawing.Drawing2D.WrapMode.Tile;
+// g.FillRectangle(brush,r);
+// brush.Dispose();
+// }
+// break;
+// }
+// }
+ }
+
+ ///
+ /// Gets or sets the target gradient background color.
+ ///
+ [Browsable(true),Description("Indicates the target gradient background color."),Category("Style")]
+ public Color BackColor2
+ {
+ get {return m_BackColor2;}
+ set
+ {
+ m_BackColor2=value;
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBackColor2()
+ {
+ return !m_BackColor2.IsEmpty;
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackColor2()
+ {
+ m_BackColor2=Color.Empty;
+ }
+
+ ///
+ /// Gets or sets gradient fill angle.
+ ///
+ [Browsable(true),Description("Indicates gradient fill angle."),Category("Style"),DefaultValue(90)]
+ public int BackColorGradientAngle
+ {
+ get {return m_BackColorGradientAngle;}
+ set
+ {
+ if(value!=m_BackColorGradientAngle)
+ {
+ m_BackColorGradientAngle=value;
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+ ///
+ /// Specifies the transparency of background image.
+ ///
+ [Browsable(true),DevCoBrowsable(true),Category("Appearance"),DefaultValue(255),Description("Specifies the transparency of background image.")]
+ public int BackgroundImageAlpha
+ {
+ get {return m_BackgroundImageAlpha;}
+ set
+ {
+ if(value<0)
+ value=0;
+ else if(value>255)
+ value=255;
+ if(m_BackgroundImageAlpha!=value)
+ {
+ m_BackgroundImageAlpha=value;
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+ ///
+ /// Specifies background image position when container is larger than image.
+ ///
+ [Browsable(true),DevCoBrowsable(true),Category("Appearance"),DefaultValue(eBackgroundImagePosition.Stretch),Description("Specifies background image position when container is larger than image.")]
+ public eBackgroundImagePosition BackgroundImagePosition
+ {
+ get {return m_BackgroundImagePosition;}
+ set
+ {
+ if(m_BackgroundImagePosition!=value)
+ {
+ m_BackgroundImagePosition=value;
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the border color..
+ ///
+ [Browsable(true),Description("Indicates border color."),Category("Style")]
+ public Color BorderColor
+ {
+ get {return m_BorderColor;}
+ set
+ {
+ m_BorderColor=value;
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBorderColor()
+ {
+ return m_BorderColor!=SystemColors.InfoText;
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBorderColor()
+ {
+ m_BorderColor=SystemColors.InfoText;
+ }
+
+ ///
+ /// Specifies balloon style.
+ ///
+ [Browsable(true),DevCoBrowsable(true),Category("Style"),DefaultValue(eBallonStyle.Balloon),Description("Specifies balloon style.")]
+ public eBallonStyle Style
+ {
+ get {return m_Style;}
+ set
+ {
+ m_Style=value;
+ if(m_Style==eBallonStyle.Alert)
+ {
+ this.BackColor=Color.FromArgb(207,221,244);
+ this.BackColor2=Color.White;
+ this.ForeColor=Color.FromArgb(102,114,196);
+ m_TextAlignment=StringAlignment.Center;
+ }
+ else if (m_Style == eBallonStyle.Office2007Alert)
+ {
+ Office2007ColorTable ct = GetOffice2007ColorTable();
+ ColorScheme cs = ct.LegacyColors;
+ if (ct.SuperTooltip.BackgroundColors.IsEmpty)
+ {
+ this.BackColor = cs.PanelBackground;
+ this.BackColor2 = cs.PanelBackground2;
+ this.ForeColor = cs.PanelText;
+ }
+ else
+ {
+ this.BackColor = ct.SuperTooltip.BackgroundColors.Start;
+ this.BackColor2 = ct.SuperTooltip.BackgroundColors.End;
+ this.ForeColor = ct.SuperTooltip.TextColor;
+ }
+ m_BorderColor = cs.PanelBorder;
+ m_TextAlignment = StringAlignment.Near;
+ }
+ else
+ {
+ m_TextAlignment = StringAlignment.Near;
+ m_BorderColor = SystemColors.InfoText;
+ }
+ if(m_ShowCloseButton)
+ this.CreateCloseButton();
+ this.RecalcLayout();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+
+ private Office2007ColorTable GetOffice2007ColorTable()
+ {
+ Office2007Renderer r = GlobalManager.Renderer as Office2007Renderer;
+ if (r != null)
+ return r.ColorTable;
+ return new Office2007ColorTable();
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+ if(m_CloseButton!=null)
+ m_CloseButton.OnMouseDown(e);
+ if(this.Focused)
+ this.Focus();
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if(m_CloseButton!=null)
+ m_CloseButton.OnMouseMove(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+ if(m_CloseButton!=null)
+ m_CloseButton.OnMouseUp(e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+ if(m_CloseButton!=null)
+ m_CloseButton.OnMouseLeave(e);
+ }
+
+ ///
+ /// Gets or sets whether the Close button is displayed.
+ ///
+ [Browsable(true),Description("Indicates whether the Close button is displayed."),Category("Behavior"),DefaultValue(true)]
+ public bool ShowCloseButton
+ {
+ get {return m_ShowCloseButton;}
+ set
+ {
+ if(value!=m_ShowCloseButton)
+ {
+ m_ShowCloseButton=value;
+ OnShowCloseButtonChanged();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ private void OnShowCloseButtonChanged()
+ {
+ if(m_ShowCloseButton)
+ {
+ CreateCloseButton();
+ RecalcLayout();
+ }
+ else
+ {
+ m_CloseButton=null;
+ }
+ }
+
+ private void CreateCloseButton()
+ {
+ if (m_CloseButtonNormal != null)
+ {
+ m_CloseButton = new ImageButton(this, new Rectangle(0, 0, Dpi.Width(m_CloseButtonNormal.Width), Dpi.Height(m_CloseButtonNormal.Height)));
+ if (m_CloseButton.Normal != null)
+ {
+ m_CloseButton.Normal.Dispose();
+ m_CloseButton.Normal = null;
+ }
+ m_CloseButton.Normal = m_CloseButtonNormal;
+ if (m_CloseButton.Hover != null)
+ {
+ m_CloseButton.Hover.Dispose();
+ m_CloseButton.Hover = null;
+ }
+ m_CloseButton.Hover = m_CloseButtonHot;
+ if (m_CloseButton.Pressed != null)
+ {
+ m_CloseButton.Pressed.Dispose();
+ m_CloseButton.Pressed = null;
+ }
+ m_CloseButton.Pressed = m_CloseButtonPressed;
+ }
+ else // Default Image Size is 18x18
+ {
+ if (m_Style == eBallonStyle.Balloon)
+ {
+ m_CloseButton = new ImageButton(this, new Rectangle(0, 0, Dpi.Width18, Dpi.Height18));
+ m_CloseButton.Normal = BarFunctions.LoadBitmap("BalloonImages.BalloonNormal.png");
+ m_CloseButton.Hover = BarFunctions.LoadBitmap("BalloonImages.BalloonHot.png");
+ m_CloseButton.Pressed = BarFunctions.LoadBitmap("BalloonImages.BalloonPress.png");
+ }
+ else
+ {
+ m_CloseButton = new ImageButton(this, new Rectangle(0, 0, Dpi.Width13, Dpi.Height13));
+ m_CloseButton.Normal = BarFunctions.LoadBitmap("BalloonImages.AlertNormal.png");
+ m_CloseButton.Hover = BarFunctions.LoadBitmap("BalloonImages.AlertHot.png");
+ m_CloseButton.Pressed = BarFunctions.LoadBitmap("BalloonImages.AlertPress.png");
+ }
+ }
+ m_CloseButton.Click+=new EventHandler(this.CloseButtonClickInternal);
+ }
+
+ private void CloseButtonClickInternal(object sender, EventArgs e)
+ {
+ if(CloseButtonClick!=null)
+ CloseButtonClick(this,new EventArgs());
+ if(m_AutoClose)
+ {
+ this.Hide();
+ this.Close();
+ }
+ }
+
+ ///
+ /// Gets or sets the animation type used to display Alert type balloon.
+ ///
+ [Browsable(true),Description("Gets or sets the animation type used to display Alert type balloon."),Category("Behavior"),DefaultValue(eAlertAnimation.BottomToTop)]
+ public eAlertAnimation AlertAnimation
+ {
+ get {return m_AlertAnimation;}
+ set {m_AlertAnimation=value;}
+ }
+
+ ///
+ /// Gets or sets the total time in milliseconds alert animation takes.
+ /// Default value is 200.
+ ///
+ [Browsable(true),Description("Gets or sets the total time in milliseconds alert animation takes."),Category("Behavior"),DefaultValue(200)]
+ public int AlertAnimationDuration
+ {
+ get {return m_AlertAnimationDuration;}
+ set {m_AlertAnimationDuration=value;}
+ }
+
+ ///
+ /// Gets or sets whether balloon will close automatically when user click the close button.
+ ///
+ [Browsable(true),Description("Indicates whether balloon will close automatically when user click the close button."),Category("Behavior"),DefaultValue(true)]
+ public bool AutoClose
+ {
+ get {return m_AutoClose;}
+ set {m_AutoClose=value;}
+ }
+
+ ///
+ /// Gets or sets time period in seconds after balloon closes automatically.
+ ///
+ [Browsable(true),Description("Indicates time period in seconds after balloon closes automatically."),Category("Behavior"),DefaultValue(0)]
+ public int AutoCloseTimeOut
+ {
+ get {return m_AutoCloseTimeOut;}
+ set
+ {
+ m_AutoCloseTimeOut=value;
+ OnAutoCloseTimeOutChanged();
+ }
+ }
+
+ protected void OnAutoCloseTimeOutChanged()
+ {
+ if(m_AutoCloseTimeOut>0 && !this.DesignMode)
+ {
+ if(m_Timer==null)
+ m_Timer=new System.Windows.Forms.Timer(components);
+ m_Timer.Enabled=false;
+ m_Timer.Interval=m_AutoCloseTimeOut*1000;
+ m_Timer.Tick+=new EventHandler(this.AutoCloseTimeOutEllapsed);
+ if(this.Visible)
+ {
+ m_Timer.Enabled=true;
+ m_Timer.Start();
+ }
+ }
+ else
+ {
+ DestroyAutoCloseTimer();
+ }
+ }
+
+ protected virtual void AutoCloseTimeOutEllapsed(object sender, EventArgs e)
+ {
+ if(this.IsDisposed)
+ return;
+ DestroyAutoCloseTimer();
+ this.Hide();
+ this.Close();
+ }
+
+ private void DestroyAutoCloseTimer()
+ {
+ if(m_Timer!=null)
+ {
+ m_Timer.Enabled=false;
+ m_Timer.Tick-=new EventHandler(this.AutoCloseTimeOutEllapsed);
+ components.Remove(m_Timer);
+ m_Timer.Dispose();
+ m_Timer=null;
+ }
+ }
+
+ protected override void OnVisibleChanged(EventArgs e)
+ {
+ base.OnVisibleChanged(e);
+ if(this.Visible)
+ {
+ if(m_Timer!=null && !m_Timer.Enabled)
+ {
+ m_Timer.Enabled=true;
+ m_Timer.Start();
+ }
+ }
+ else
+ {
+ if(m_Timer!=null && m_Timer.Enabled)
+ {
+ m_Timer.Stop();
+ m_Timer.Enabled=false;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the custom image for Close Button.
+ ///
+ [Browsable(true),Description("Indicates custom image for Close Button."),Category("Appearance")]
+ public Image CloseButtonNormal
+ {
+ get {return m_CloseButtonNormal;}
+ set
+ {
+ if(m_CloseButtonNormal!=value)
+ {
+ m_CloseButtonNormal=value;
+ OnShowCloseButtonChanged();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the custom image for Close Button when mouse is over the button.
+ ///
+ [Browsable(true),Description("Indicates custom image for Close Button when mouse is over the button."),Category("Appearance"),DefaultValue(null)]
+ public Image CloseButtonHot
+ {
+ get {return m_CloseButtonHot;}
+ set
+ {
+ if(m_CloseButtonHot!=value)
+ {
+ m_CloseButtonHot=value;
+ OnShowCloseButtonChanged();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the custom image for Close Button when button is pressed.
+ ///
+ [Browsable(true),Description("Indicates custom image for Close Button when button is pressed."),Category("Appearance"),DefaultValue(null)]
+ public Image CloseButtonPressed
+ {
+ get {return m_CloseButtonPressed;}
+ set
+ {
+ if(m_CloseButtonPressed!=value)
+ {
+ m_CloseButtonPressed=value;
+ OnShowCloseButtonChanged();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the Caption image.
+ ///
+ [Browsable(true),Description("Indicates Caption image."),Category("Appearance"),DefaultValue(null)]
+ public Image CaptionImage
+ {
+ get {return m_CaptionImage;}
+ set
+ {
+ if(m_CaptionImage!=value)
+ {
+ m_CaptionImage=value;
+ this.RecalcLayout();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the Caption icon. Icon is used to provide support for alpha-blended images in caption.
+ ///
+ [Browsable(true),Description("Indicates Caption icon. Icon is used to provide support for alpha-blended images in caption."),Category("Appearance"),DefaultValue(null)]
+ public Icon CaptionIcon
+ {
+ get {return m_CaptionIcon;}
+ set
+ {
+ if(m_CaptionIcon!=value)
+ {
+ m_CaptionIcon=value;
+ this.RecalcLayout();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ private CompositeImage ImageInternal
+ {
+ get
+ {
+ if(m_CaptionIcon!=null)
+ return new CompositeImage(m_CaptionIcon,false);
+ else if(m_CaptionImage!=null)
+ return new CompositeImage(m_CaptionImage,false);
+ return null;
+ }
+ }
+
+ ///
+ /// Gets or sets the Caption font.
+ ///
+ [Browsable(true),Description("Indicates Caption font."),Category("Appearance")]
+ public Font CaptionFont
+ {
+ get {return m_CaptionFont;}
+ set
+ {
+ if(m_CaptionFont!=value)
+ {
+ m_CaptionFont=value;
+ this.RecalcLayout();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ private TextMarkup.BodyElement _CaptionTextMarkup = null;
+ ///
+ /// Gets or sets text displayed in caption.
+ ///
+ [Browsable(true),Description("Indicates text displayed in caption."),Category("Appearance"),DefaultValue(""), Localizable(true)]
+ public string CaptionText
+ {
+ get {return m_CaptionText;}
+ set
+ {
+ if(m_CaptionText!=value)
+ {
+ m_CaptionText=value;
+
+ if (_CaptionTextMarkup != null)
+ {
+ _CaptionTextMarkup.MouseLeave(this);
+ _CaptionTextMarkup.HyperLinkClick -= TextMarkupLinkClicked;
+ _CaptionTextMarkup = null;
+ }
+
+ if (TextMarkup.MarkupParser.IsMarkup(ref m_CaptionText))
+ _CaptionTextMarkup = TextMarkup.MarkupParser.Parse(m_CaptionText);
+
+ if (_CaptionTextMarkup != null)
+ {
+ _CaptionTextMarkup.HyperLinkClick += TextMarkupLinkClicked;
+ }
+
+ this.RecalcLayout();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets color of caption text.
+ ///
+ [Browsable(true),Description("Indicates color of caption text"),Category("Appearance")]
+ public Color CaptionColor
+ {
+ get {return m_CaptionColor;}
+ set
+ {
+ if(m_CaptionColor!=value)
+ {
+ m_CaptionColor=value;
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or set position of the balloon tip.
+ ///
+ [Browsable(true),Description("Indicates position of the balloon tip."),Category("Appearance"),DefaultValue(eTipPosition.Top)]
+ public eTipPosition TipPosition
+ {
+ get {return m_TipPosition;}
+ set
+ {
+ if(m_TipPosition!=value)
+ {
+ m_TipPosition=value;
+ this.RecalcLayout();
+ if(TipPositionChanged!=null)
+ TipPositionChanged(this,new EventArgs());
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ private void InternalTipPositionChanged(eTipPosition newValue)
+ {
+ if(this.Controls.Count==0 || this.Style!=eBallonStyle.Balloon)
+ return;
+ if(newValue==eTipPosition.Top && m_TipPosition==eTipPosition.Bottom)
+ {
+ foreach(Control control in this.Controls)
+ {
+ control.Top+=m_TipLength;
+ }
+ }
+ else if(newValue==eTipPosition.Bottom && m_TipPosition==eTipPosition.Top)
+ {
+ foreach(Control control in this.Controls)
+ {
+ control.Top-=m_TipLength;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets tip distance from the edge of the balloon.
+ ///
+ [Browsable(true),Description("Indicates tip distance from the edge of the balloon."),Category("Appearance"),DefaultValue(32)]
+ public int TipOffset
+ {
+ get {return m_TipOffset;}
+ set
+ {
+ if(m_TipOffset!=value)
+ {
+ if(valuethis.Width-m_CornerSize-m_TipLength)
+ value=this.Width-m_CornerSize-m_TipLength;
+ else if((m_TipPosition==eTipPosition.Left || m_TipPosition==eTipPosition.Right) && value>this.Height-m_CornerSize-m_TipLength)
+ value=this.Height-m_CornerSize-m_TipLength;
+
+ m_TipOffset=value;
+ this.RecalcLayout();
+ if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Returns length of the tip.
+ ///
+ [Browsable(false),Description("Returns tip length"),Category("Appearance")]
+ public int TipLength
+ {
+ get {return m_TipLength;}
+ }
+
+ ///
+ /// Displays balloon using control to automatically calculate balloon location. Method is usually used display balloon that is showing information for the certain control.
+ ///
+ /// Control used for balloon positioning.
+ public void Show(Control referenceControl)
+ {
+ this.Show(referenceControl,true);
+ }
+
+ ///
+ /// Displays balloon using control to automatically calculate balloon location. Method is usually used display balloon that is showing information for the certain control.
+ ///
+ /// Control used for balloon positioning.
+ /// Indicates whether balloon receives input focus.
+ public void Show(Control referenceControl, bool balloonFocus)
+ {
+ if(referenceControl==null)
+ {
+ this.Show();
+ return;
+ }
+ Point scrLocCtrl=Point.Empty;
+
+ if(referenceControl.Parent!=null)
+ scrLocCtrl=referenceControl.Parent.PointToScreen(referenceControl.Location);
+ else
+ scrLocCtrl=referenceControl.Location;
+
+ this.Show(new Rectangle(scrLocCtrl,referenceControl.Size),balloonFocus);
+ }
+
+ ///
+ /// Displays balloon using rectangle to automatically calculate balloon location. Method is usually used display balloon that is showing information for the certain screen region.
+ ///
+ /// Rectangle in screen coordinates used for balloon positioning.
+ /// Indicates whether balloon receives input focus.
+ public void Show(Rectangle referenceScreenRect, bool balloonFocus)
+ {
+ if(referenceScreenRect.IsEmpty)
+ {
+ this.Show();
+ return;
+ }
+
+ int tipPositionOffset=m_TipLength+m_CornerSize*3;
+ int tipOffset=m_TipLength/2+m_CornerSize*3;
+ Point balloonLocation=Point.Empty;
+ ScreenInformation screen=BarFunctions.ScreenFromPoint(referenceScreenRect.Location);
+
+ if(referenceScreenRect.X+referenceScreenRect.Width/2+this.Width>screen.WorkingArea.Right)
+ {
+ balloonLocation.X=referenceScreenRect.X+referenceScreenRect.Width/2-this.Width+tipPositionOffset;
+ tipOffset=this.Width-tipPositionOffset;
+ }
+ else
+ balloonLocation.X=referenceScreenRect.X+referenceScreenRect.Width/2-tipPositionOffset;
+
+ if(referenceScreenRect.Y+referenceScreenRect.Height+this.Height>screen.WorkingArea.Bottom)
+ {
+ balloonLocation.Y=referenceScreenRect.Y-this.Height;
+ InternalTipPositionChanged(eTipPosition.Bottom);
+ this.TipPosition=eTipPosition.Bottom;
+ }
+ else
+ {
+ balloonLocation.Y=referenceScreenRect.Y+referenceScreenRect.Height;
+ InternalTipPositionChanged(eTipPosition.Top);
+ this.TipPosition=eTipPosition.Top;
+ }
+
+ this.TipOffset=tipOffset;
+ this.Location=balloonLocation;
+ this.Show(balloonFocus);
+ }
+
+ ///
+ /// Displays balloon using item to automatically calculate balloon location. Method is usually used display balloon that is showing information for the certain item.
+ ///
+ /// Item used for balloon positioning.
+ /// Indicates whether balloon receives input focus.
+ public void Show(BaseItem item, bool balloonFocus)
+ {
+ if(item==null || item.ContainerControl==null)
+ {
+ this.Show();
+ return;
+ }
+ Point loc=((Control)item.ContainerControl).PointToScreen(item.DisplayRectangle.Location);
+ this.Show(new Rectangle(loc,item.DisplayRectangle.Size),balloonFocus);
+ }
+
+ ///
+ /// Display balloon.
+ ///
+ /// Indicates whether balloon receives input focus.
+ public void Show(bool balloonFocus)
+ {
+ Rectangle rEnd=new Rectangle(this.Location,this.Size);
+ Rectangle rStart=GetAnimationRectangle();
+
+ if(!balloonFocus)
+ {
+ if(this.TopMost)
+ {
+ this.TopMost=false;
+ NativeFunctions.SetWindowPos(this.Handle,new IntPtr(NativeFunctions.HWND_TOP),0,0,0,0,NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE | NativeFunctions.SWP_NOMOVE | NativeFunctions.SWP_NOSIZE);
+ this.TopMost=true;
+ }
+ else
+ NativeFunctions.SetWindowPos(this.Handle,new IntPtr(NativeFunctions.HWND_TOP),0,0,0,0,NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE | NativeFunctions.SWP_NOMOVE | NativeFunctions.SWP_NOSIZE);
+ }
+
+ if(ShouldAnimate())
+ {
+ try
+ {
+ m_AnimationInProgress=true;
+ BarFunctions.AnimateControl(this,true,m_AlertAnimationDuration,rStart,rEnd);
+ }
+ finally
+ {
+ m_AnimationInProgress=false;
+ }
+ }
+ else
+ base.Show();
+ }
+
+ ///
+ /// Displays balloon.
+ ///
+ public new void Show()
+ {
+ this.Show(true);
+ }
+ ///
+ /// Called when balloon is hidden.
+ ///
+ protected virtual void HideBalloon()
+ {
+ DestroyAutoCloseTimer();
+ if (ShouldAnimate())
+ {
+ Rectangle rStart = new Rectangle(this.Location, this.Size);
+ Rectangle rEnd = GetAnimationRectangle();
+ try
+ {
+ m_AnimationInProgress = true;
+ BarFunctions.AnimateControl(this, false, m_AlertAnimationDuration, rStart, rEnd);
+ }
+ finally
+ {
+ m_AnimationInProgress = false;
+ }
+ }
+ else
+ base.Hide();
+ }
+
+ ///
+ /// Hides balloon.
+ ///
+ public new void Hide()
+ {
+ HideBalloon();
+ }
+
+ private bool ShouldAnimate()
+ {
+ if (m_Style != eBallonStyle.Balloon && m_AlertAnimation != eAlertAnimation.None && !this.DesignMode)
+ return true;
+ return false;
+ }
+
+ private Rectangle GetAnimationRectangle()
+ {
+ Rectangle r=new Rectangle(this.Location,this.Size);
+ if(m_AlertAnimation==eAlertAnimation.BottomToTop)// && bShowing || m_AlertAnimation==eAlertAnimation.TopToBottom && !bShowing)
+ {
+ r.Y=r.Bottom-1;
+ r.Height=1;
+ }
+ else if(m_AlertAnimation==eAlertAnimation.TopToBottom)
+ {
+ r.Height=1;
+ }
+ else if(m_AlertAnimation==eAlertAnimation.LeftToRight)
+ {
+ r.Width=2;
+ }
+ else if(m_AlertAnimation==eAlertAnimation.RightToLeft)
+ {
+ r.X=r.Right-1;
+ r.Width=1;
+ }
+ return r;
+ }
+
+ ///
+ /// Gets/Sets whether Balloon is visible.
+ ///
+ [DevCoBrowsable(true)]
+ public new bool Visible
+ {
+ get { return base.Visible;}
+ set
+ {
+ if(value)
+ this.Show();
+ else
+ this.Hide();
+ }
+ }
+
+ const int WM_MOUSEACTIVATE = 0x21;
+ const int MA_NOACTIVATE = 3;
+ protected override void WndProc(ref Message m)
+ {
+ if(m.Msg==WM_MOUSEACTIVATE)
+ {
+ m.Result=new System.IntPtr(MA_NOACTIVATE);
+ return;
+ }
+ base.WndProc(ref m);
+ }
+
+ private class ImageButton
+ {
+ private Rectangle m_Bounds=Rectangle.Empty;
+ private Control m_Parent=null;
+ private bool m_MouseOver=false;
+ private bool m_MouseDown=false;
+ public Image Normal=null;
+ public Image Hover=null;
+ public Image Pressed=null;
+
+ public event EventHandler Click;
+
+ public ImageButton(Control parent, Rectangle bounds)
+ {
+ m_Parent=parent;
+ m_Bounds=bounds;
+ }
+
+ public virtual void Paint(Graphics g)
+ {
+ Rectangle bounds = m_Bounds;
+ if(m_MouseDown)
+ {
+ if(Pressed!=null)
+ g.DrawImage(Pressed,bounds);
+ }
+ else if(m_MouseOver)
+ {
+ if(Hover!=null)
+ g.DrawImage(Hover,bounds);
+ }
+ else
+ {
+ if(Normal!=null)
+ g.DrawImage(Normal,bounds);
+ }
+ }
+
+ public virtual void OnMouseMove(MouseEventArgs e)
+ {
+ if(m_MouseDown)
+ return;
+
+ if(m_Bounds.Contains(e.X,e.Y))
+ {
+ if(!m_MouseOver)
+ {
+ m_MouseOver=true;
+ if(m_Parent!=null)
+ m_Parent.Invalidate(m_Bounds);
+ }
+ }
+ else if(m_MouseOver)
+ {
+ m_MouseOver=false;
+ if(m_Parent!=null)
+ m_Parent.Invalidate(m_Bounds);
+ }
+ }
+ public virtual void OnMouseDown(MouseEventArgs e)
+ {
+ if(m_Bounds.Contains(e.X,e.Y) && !m_MouseDown)
+ {
+ m_MouseDown=true;
+ if(m_Parent!=null)
+ m_Parent.Invalidate(m_Bounds);
+ }
+ }
+
+ public virtual void OnMouseUp(MouseEventArgs e)
+ {
+ if(m_Bounds.Contains(e.X,e.Y) && m_MouseDown)
+ {
+ m_MouseDown=false;
+ if(m_Parent!=null)
+ m_Parent.Invalidate(m_Bounds);
+ if(Click!=null)
+ Click(this,new EventArgs());
+ }
+ else if(m_MouseOver || m_MouseDown)
+ {
+ m_MouseDown=false;
+ m_MouseOver=false;
+ if(m_Parent!=null)
+ m_Parent.Invalidate(m_Bounds);
+ }
+ }
+
+ public virtual void OnMouseLeave(EventArgs e)
+ {
+ if(m_MouseOver && !m_MouseDown)
+ {
+ m_MouseOver=false;
+ if(m_Parent!=null)
+ m_Parent.Invalidate(m_Bounds);
+ }
+ }
+
+ public bool MouseDown
+ {
+ get {return m_MouseDown;}
+ }
+
+ public bool MouseOver
+ {
+ get {return m_MouseOver;}
+ }
+
+ public Rectangle Bounds
+ {
+ get {return m_Bounds;}
+ set {m_Bounds=value;}
+ }
+
+ public Point Location
+ {
+ get {return m_Bounds.Location;}
+ set {m_Bounds.Location=value;}
+ }
+
+ public System.Drawing.Size Size
+ {
+ get {return m_Bounds.Size;}
+ set {m_Bounds.Size=value;}
+ }
+ }
+ }
+
+ public class CustomPaintEventArgs:EventArgs
+ {
+ private System.Drawing.Graphics m_Graphics=null;
+ private Rectangle m_PaintRectangle=Rectangle.Empty;
+ public CustomPaintEventArgs(Graphics g, Rectangle r)
+ {
+ m_Graphics=g;
+ m_PaintRectangle=r;
+ }
+
+ public System.Drawing.Graphics Graphics
+ {
+ get {return m_Graphics;}
+ }
+
+ public Rectangle PaintRectangle
+ {
+ get {return m_PaintRectangle;}
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Balloon.resx b/PROMS/DotNetBar Source Code/Balloon.resx
new file mode 100644
index 00000000..ae7000b3
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Balloon.resx
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Balloon
+
+
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/BalloonImages/AlertHot.png b/PROMS/DotNetBar Source Code/BalloonImages/AlertHot.png
new file mode 100644
index 00000000..47868a00
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BalloonImages/AlertHot.png differ
diff --git a/PROMS/DotNetBar Source Code/BalloonImages/AlertNormal.png b/PROMS/DotNetBar Source Code/BalloonImages/AlertNormal.png
new file mode 100644
index 00000000..07f19054
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BalloonImages/AlertNormal.png differ
diff --git a/PROMS/DotNetBar Source Code/BalloonImages/AlertPress.png b/PROMS/DotNetBar Source Code/BalloonImages/AlertPress.png
new file mode 100644
index 00000000..50984e27
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BalloonImages/AlertPress.png differ
diff --git a/PROMS/DotNetBar Source Code/BalloonImages/BalloonHot.png b/PROMS/DotNetBar Source Code/BalloonImages/BalloonHot.png
new file mode 100644
index 00000000..f7f7ef6e
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BalloonImages/BalloonHot.png differ
diff --git a/PROMS/DotNetBar Source Code/BalloonImages/BalloonNormal.png b/PROMS/DotNetBar Source Code/BalloonImages/BalloonNormal.png
new file mode 100644
index 00000000..ef7ff150
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BalloonImages/BalloonNormal.png differ
diff --git a/PROMS/DotNetBar Source Code/BalloonImages/BalloonPress.png b/PROMS/DotNetBar Source Code/BalloonImages/BalloonPress.png
new file mode 100644
index 00000000..298a5c23
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BalloonImages/BalloonPress.png differ
diff --git a/PROMS/DotNetBar Source Code/BalloonTip.bmp b/PROMS/DotNetBar Source Code/BalloonTip.bmp
new file mode 100644
index 00000000..b7fd34ba
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BalloonTip.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BalloonTip.cs b/PROMS/DotNetBar Source Code/BalloonTip.cs
new file mode 100644
index 00000000..8d810096
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BalloonTip.cs
@@ -0,0 +1,670 @@
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Collections;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents a balloon style pop-up window that displays a brief description of a control's purpose when the mouse hovers over the control or when controls receives input focus.
+ ///
+ [ToolboxItem(true),ProvideProperty("BalloonCaption",typeof(Control)),
+ ProvideProperty("BalloonText",typeof(Control)),
+ System.Runtime.InteropServices.ComVisible(false)]
+ public class BalloonTip:Component, IExtenderProvider
+ {
+ ///
+ /// Occurs before balloon is displayed.
+ ///
+ [Description("Occurs before balloon is displayed.")]
+ public event EventHandler BalloonDisplaying;
+ ///
+ /// Occurs before balloon is closed and allows to cancel the action.
+ ///
+ [Description("Occurs before balloon is closed and allows to cancel the action.")]
+ public event CancelEventHandler BalloonClosing;
+
+ private bool m_BalloonFocus=false;
+ private bool m_Enabled=true;
+ private bool m_ShowAlways=false;
+ private eBallonStyle m_Style=eBallonStyle.Balloon;
+ private int m_InitialDelay=500;
+ private bool m_AutoClose=true;
+ private int m_AutoCloseTimeOut=5;
+ private eAlertAnimation m_AlertAnimation=eAlertAnimation.BottomToTop;
+ private int m_AlertAnimationDuration=200;
+ private bool m_ShowBalloonOnFocus=false;
+ private bool m_ShowCloseButton=true;
+
+ private Balloon m_BalloonControl=null;
+
+ private System.Drawing.Image m_CaptionImage=null;
+ private System.Drawing.Icon m_CaptionIcon=null;
+
+ private Hashtable m_BalloonsInfo=new Hashtable();
+
+ private Control m_MouseOverControl=null;
+ private Control m_FocusedControl=null;
+
+ private Timer m_DelayTimer=null;
+
+ private Control m_BalloonTriggerControl=null;
+ private int m_DefaultBalloonWidth=256;
+ private bool m_AntiAlias = true;
+ ///
+ /// Initializes a new instance of the BalloonTip class.
+ ///
+ public BalloonTip()
+ {
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ RemoveAll();
+ m_MouseOverControl=null;
+ m_FocusedControl=null;
+ m_BalloonTriggerControl=null;
+ if (BarUtilities.DisposeItemImages && !this.DesignMode)
+ {
+ BarUtilities.DisposeImage(ref m_CaptionImage);
+ BarUtilities.DisposeImage(ref m_CaptionIcon);
+ }
+ DestroyDelayTimer();
+ base.Dispose(disposing);
+ }
+
+ bool IExtenderProvider.CanExtend(object target)
+ {
+ if (target is Control)
+ return true;
+ return false;
+ }
+
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting. Default value is false.
+ ///
+ [DefaultValue(true), Browsable(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting.")]
+ public bool AntiAlias
+ {
+ get { return m_AntiAlias; }
+ set
+ {
+ m_AntiAlias = value;
+ }
+ }
+
+ ///
+ /// Retrieves the Balloon Caption text associated with the specified control.
+ ///
+ [DefaultValue(""), Localizable(true)]
+ public string GetBalloonCaption(Control control)
+ {
+ if(m_BalloonsInfo.Contains(control))
+ {
+ BalloonTipInfo info=m_BalloonsInfo[control] as BalloonTipInfo;
+ if(info!=null)
+ return info.Caption;
+ }
+ return "";
+ }
+
+ ///
+ /// Associates Balloon Caption text with the specified control.
+ ///
+ /// The Control to associate the Balloon Caption text with.
+ /// The Balloon Caption text to display on the Balloon.
+ [Localizable(true)]
+ public void SetBalloonCaption(Control control, string caption)
+ {
+ if(caption==null)
+ caption="";
+ if(m_BalloonsInfo.Contains(control))
+ {
+ BalloonTipInfo info=m_BalloonsInfo[control] as BalloonTipInfo;
+ if(info!=null)
+ {
+ info.Caption=caption;
+ if(info.Caption=="" && info.Text=="")
+ {
+ this.Remove(control);
+ }
+ }
+ }
+ else if(caption!="")
+ {
+ BalloonTipInfo info=new BalloonTipInfo();
+ info.Caption=caption;
+ this.AddControl(control,info);
+ }
+ }
+
+ ///
+ /// Retrieves the Balloon text associated with the specified control.
+ ///
+ [DefaultValue(""), Localizable(true)]
+ public string GetBalloonText(Control control)
+ {
+ if(m_BalloonsInfo.Contains(control))
+ {
+ BalloonTipInfo info=m_BalloonsInfo[control] as BalloonTipInfo;
+ if(info!=null)
+ return info.Text;
+ }
+ return "";
+ }
+
+ ///
+ /// Associates Balloon text with the specified control.
+ ///
+ /// The Control to associate the Balloon text with.
+ /// The Balloon text to display on the Balloon.
+ [Localizable(true)]
+ public void SetBalloonText(Control control, string text)
+ {
+ if(text==null)
+ text="";
+ if(m_BalloonsInfo.Contains(control))
+ {
+ BalloonTipInfo info=m_BalloonsInfo[control] as BalloonTipInfo;
+ if(info!=null)
+ {
+ info.Text=text;
+ if(info.Caption=="" && info.Text=="")
+ {
+ this.Remove(control);
+ }
+ }
+ }
+ else if(text!="")
+ {
+ BalloonTipInfo info=new BalloonTipInfo();
+ info.Text=text;
+ this.AddControl(control,info);
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the BalloonTip is currently active.
+ /// true if the BalloonTip is currently active; otherwise, false. The default is true.
+ ///
+ [DefaultValue(true),Category("Misc"),Description("Gets or sets a value indicating whether the BalloonTip is currently active.")]
+ public bool Enabled
+ {
+ get{return m_Enabled;}
+ set
+ {
+ m_Enabled=value;
+ }
+ }
+
+ ///
+ /// Removes all Balloon texts currently associated with the BalloonTip control.
+ ///
+ public void RemoveAll()
+ {
+ Control[] ctrls=new Control[m_BalloonsInfo.Keys.Count];
+
+ m_BalloonsInfo.Keys.CopyTo(ctrls,0);
+ foreach(Control c in ctrls)
+ {
+ this.Remove(c);
+ }
+ m_BalloonsInfo.Clear();
+ }
+
+ ///
+ /// Removes specific Balloon texts currently associated with the BalloonTip control.
+ ///
+ /// Control that has Balloon texts associated.
+ public void Remove(Control control)
+ {
+ if(m_BalloonsInfo.Contains(control))
+ {
+ // Remove event handlers
+ try
+ {
+ control.MouseEnter-=new EventHandler(this.ControlMouseEnter);
+ control.MouseLeave-=new EventHandler(this.ControlMouseLeave);
+ control.Enter-=new EventHandler(this.ControlGotFocus);
+ control.Leave-=new EventHandler(this.ControlLeave);
+ }
+ catch{}
+ m_BalloonsInfo.Remove(control);
+ }
+ }
+
+ private void AddControl(Control control, BalloonTipInfo info)
+ {
+ if(m_BalloonsInfo.Contains(control))
+ return;
+ m_BalloonsInfo.Add(control,info);
+ // Hook-up events
+ control.MouseEnter+=new EventHandler(this.ControlMouseEnter);
+ control.MouseLeave+=new EventHandler(this.ControlMouseLeave);
+ control.Enter+=new EventHandler(this.ControlGotFocus);
+ control.Leave+=new EventHandler(this.ControlLeave);
+ }
+
+ ///
+ /// Shows Balloon for specific control. Control must have Balloon already assigned to it.
+ ///
+ /// Control that has Balloon already assigned.
+ public virtual void ShowBalloon(Control control)
+ {
+ if(m_BalloonsInfo.Contains(control))
+ {
+ BalloonTipInfo info=m_BalloonsInfo[control] as BalloonTipInfo;
+ if(info!=null)
+ {
+ CloseBalloon();
+
+ // Closing of balloon was denied exit.
+ if(m_BalloonControl!=null)
+ {
+ return;
+ }
+
+ m_BalloonControl=CreateBalloonControl(info);
+ m_BalloonControl.Location=new System.Drawing.Point(0,0);
+ m_BalloonTriggerControl=control;
+
+ if(BalloonDisplaying!=null)
+ BalloonDisplaying(this,new EventArgs());
+
+ // If Balloon Control is still around
+ if(m_BalloonControl!=null)
+ {
+ Form parentForm=control.FindForm();
+ if(parentForm!=null)
+ m_BalloonControl.Owner=parentForm;
+ if(!m_BalloonControl.Location.IsEmpty)
+ m_BalloonControl.Show(m_BalloonFocus);
+ else
+ m_BalloonControl.Show(control,m_BalloonFocus);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Returns reference to the control that triggered balloon.
+ ///
+ public Control BalloonTriggerControl
+ {
+ get
+ {
+ return m_BalloonTriggerControl;
+ }
+ }
+
+ private int _MinimumBalloonWidth = 180;
+ ///
+ /// Gets or sets the minimum balloon width when auto sizing balloon. Default value is 180.
+ ///
+ [DefaultValue(180), Category("Appearance"), Description("Indicates minimum balloon width when auto sizing balloon.")]
+ public int MinimumBalloonWidth
+ {
+ get { return _MinimumBalloonWidth; }
+ set { _MinimumBalloonWidth = value; }
+ }
+
+ private Balloon CreateBalloonControl(BalloonTipInfo info)
+ {
+ Balloon b=new Balloon();
+ b.CaptionText=info.Caption;
+ b.Text=info.Text;
+ b.AutoClose=m_AutoClose;
+ b.AutoCloseTimeOut=m_AutoCloseTimeOut;
+ b.CaptionImage=this.CaptionImage;
+ b.CaptionIcon=this.CaptionIcon;
+ b.AlertAnimation=m_AlertAnimation;
+ b.AlertAnimationDuration=m_AlertAnimationDuration;
+ b.ShowCloseButton=m_ShowCloseButton;
+ b.Style=m_Style;
+ b.MinimumBalloonWidth = _MinimumBalloonWidth;
+ if(info.Caption=="" || info.Caption==null)
+ {
+ b.Width=this.DefaultBalloonWidth;
+ }
+ else
+ b.AutoResize();
+
+ return b;
+ }
+
+ ///
+ /// Closes Balloon control if visible.
+ ///
+ public virtual void CloseBalloon()
+ {
+ m_BalloonTriggerControl=null;
+
+ if(m_BalloonControl==null)
+ return;
+
+ CancelEventArgs e=new CancelEventArgs(false);
+ if(BalloonClosing!=null)
+ BalloonClosing(this,e);
+ if(e.Cancel)
+ return;
+
+ if(m_BalloonControl.Visible)
+ {
+ m_BalloonControl.Hide();
+ }
+
+ m_BalloonControl.Close();
+ m_BalloonControl.Dispose();
+ m_BalloonControl=null;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether Balloon receives input focus when displayed.
+ /// Default value is false.
+ ///
+ [DefaultValue(false),Category("Misc"),Description("Gets or sets a value indicating whether Balloon receives input focus when displayed.")]
+ public bool BalloonFocus
+ {
+ get {return m_BalloonFocus;}
+ set {m_BalloonFocus=value;}
+ }
+
+ ///
+ /// Gets or sets the time (in milliseconds) that passes before the BalloonTip appears.
+ ///
+ [DefaultValue(500),Category("Misc"),Description("Indicates the time (in milliseconds) that passes before the BalloonTip appears.")]
+ public int InitialDelay
+ {
+ get{return m_InitialDelay;}
+ set{m_InitialDelay=value;}
+ }
+
+ ///
+ /// Gets or sets a value indicating whether a Balloon window is displayed even when its parent form is not active. Default value is false.
+ ///
+ [DefaultValue(false),Category("Misc"),Description("Indicates whether a Balloon window is displayed even when its parent form is not active.")]
+ public bool ShowAlways
+ {
+ get{return m_ShowAlways;}
+ set{m_ShowAlways=value;}
+ }
+
+ ///
+ /// Gets or sets the internal Balloon control that is used to display Balloon.
+ /// This property will have valid value only during time Balloon is actually
+ /// displayed on the screen. Value will also be valid during BalloonDisplaying event.
+ /// You can use this property to further customize Balloon control before it is
+ /// displayed to the user. You can also set it to your own instance of the Balloon
+ /// control (or the control that is inheriting it) for ultimate customization options.
+ /// Note that new instance of Balloon control is created each time Balloon needs to be displayed.
+ /// Once Balloon is closed control is disposed.
+ ///
+ [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Balloon BalloonControl
+ {
+ get {return m_BalloonControl;}
+ set {m_BalloonControl=value;}
+ }
+
+ ///
+ /// Specifies balloon style.
+ ///
+ [Browsable(true),DevCoBrowsable(true),Category("Style"),DefaultValue(eBallonStyle.Balloon),Description("Specifies balloon style.")]
+ public eBallonStyle Style
+ {
+ get {return m_Style;}
+ set
+ {
+ if(m_Style!=value)
+ {
+ m_Style=value;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the animation type used to display Alert type balloon.
+ ///
+ [Browsable(true),Description("Gets or sets the animation type used to display Alert type balloon."),Category("Behavior"),DefaultValue(eAlertAnimation.BottomToTop)]
+ public eAlertAnimation AlertAnimation
+ {
+ get {return m_AlertAnimation;}
+ set {m_AlertAnimation=value;}
+ }
+
+ ///
+ /// Gets or sets the total time in milliseconds alert animation takes.
+ /// Default value is 200.
+ ///
+ [Browsable(true),Description("Gets or sets the total time in milliseconds alert animation takes."),Category("Behavior"),DefaultValue(200)]
+ public int AlertAnimationDuration
+ {
+ get {return m_AlertAnimationDuration;}
+ set {m_AlertAnimationDuration=value;}
+ }
+
+ ///
+ /// Gets or sets whether balloon will close automatically when user click the close button.
+ ///
+ [Browsable(true),Description("Indicates whether balloon will close automatically when user click the close button."),Category("Behavior"),DefaultValue(true)]
+ public bool AutoClose
+ {
+ get {return m_AutoClose;}
+ set {m_AutoClose=value;}
+ }
+
+ ///
+ /// Gets or sets time period in seconds after balloon closes automatically.
+ ///
+ [Browsable(true),Description("Indicates time period in seconds after balloon closes automatically."),Category("Behavior"),DefaultValue(5)]
+ public int AutoCloseTimeOut
+ {
+ get {return m_AutoCloseTimeOut;}
+ set
+ {
+ m_AutoCloseTimeOut=value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether Balloon is shown after control receives input focus. Default value is false. When set to true Balloon will not be displayed on mouse hover.
+ ///
+ [Browsable(true),Description("Indicates whether Balloon is shown after control receives input focus."),Category("Behavior"),DefaultValue(false)]
+ public bool ShowBalloonOnFocus
+ {
+ get {return m_ShowBalloonOnFocus;}
+ set
+ {
+ if(m_ShowBalloonOnFocus!=value)
+ {
+ m_ShowBalloonOnFocus=value;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether the Balloon Close button is displayed.
+ ///
+ [Browsable(true),Description("Indicates whether the Balloon Close button is displayed."),Category("Behavior"),DefaultValue(true)]
+ public bool ShowCloseButton
+ {
+ get {return m_ShowCloseButton;}
+ set
+ {
+ if(value!=m_ShowCloseButton)
+ {
+ m_ShowCloseButton=value;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets default balloon width. Usually the width of the balloon is calculated based on the width of the caption text. If caption text is not set then this value will be used as default width of the balloon.
+ ///
+ [Browsable(true),Description("Indicates default balloon width. Usually the width of the balloon is calculated based on the width of the caption text. If caption text is not set then this value will be used as default width of the balloon."),Category("Appearance"),DefaultValue(256)]
+ public int DefaultBalloonWidth
+ {
+ get {return m_DefaultBalloonWidth;}
+ set {m_DefaultBalloonWidth=value;}
+ }
+
+ ///
+ /// Gets or sets the Balloon Caption image.
+ ///
+ [Browsable(true),Description("Indicates Balloon Caption image."),Category("Appearance"),DefaultValue(null)]
+ public System.Drawing.Image CaptionImage
+ {
+ get {return m_CaptionImage;}
+ set
+ {
+ if(m_CaptionImage!=value)
+ {
+ m_CaptionImage=value;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the Balloon Caption icon. Icon is used to provide support for alpha-blended images in caption.
+ ///
+ [Browsable(true),Description("Indicates Balloon Caption icon. Icon is used to provide support for alpha-blended images in caption."),Category("Appearance"),DefaultValue(null)]
+ public System.Drawing.Icon CaptionIcon
+ {
+ get {return m_CaptionIcon;}
+ set
+ {
+ if(m_CaptionIcon!=value)
+ {
+ m_CaptionIcon=value;
+ }
+ }
+ }
+
+ private void DestroyDelayTimer()
+ {
+ if(m_DelayTimer!=null)
+ {
+ m_DelayTimer.Stop();
+ m_DelayTimer.Tick-=new EventHandler(this.DelayTimerTick);
+ m_DelayTimer.Dispose();
+ m_DelayTimer=null;
+ }
+ }
+
+ private void DelayTimerTick(object sender, EventArgs e)
+ {
+ m_DelayTimer.Enabled=false;
+ DestroyDelayTimer();
+
+ if (m_Enabled)
+ {
+ if (m_ShowBalloonOnFocus && m_FocusedControl != null)
+ ShowBalloon(m_FocusedControl);
+ else if (!m_ShowBalloonOnFocus && m_MouseOverControl != null)
+ ShowBalloon(m_MouseOverControl);
+ }
+ }
+
+ private void ShowBalloonDelayed(Control control)
+ {
+ if(control==null || !m_Enabled)
+ return;
+
+ if(!m_ShowAlways)
+ {
+ Form parentForm=control.FindForm();
+ if(parentForm.IsMdiChild)
+ {
+ if(parentForm.MdiParent!=null && parentForm.MdiParent.ActiveMdiChild!=parentForm)
+ return;
+ }
+ else
+ {
+ if(Form.ActiveForm!=parentForm)
+ return;
+ }
+ }
+
+ if(m_InitialDelay==0)
+ {
+ ShowBalloon(control);
+ return;
+ }
+
+ if(m_DelayTimer==null)
+ {
+ m_DelayTimer=new Timer();
+ m_DelayTimer.Tick+=new EventHandler(this.DelayTimerTick);
+ m_DelayTimer.Interval=m_InitialDelay;
+ m_DelayTimer.Start();
+ }
+ }
+
+ private void OnMouseEnter()
+ {
+ if(!m_Enabled || m_MouseOverControl==null || m_ShowBalloonOnFocus || !m_BalloonsInfo.Contains(m_MouseOverControl))
+ return;
+
+ ShowBalloonDelayed(m_MouseOverControl);
+ }
+
+ private void OnMouseLeave()
+ {
+ if(!m_ShowBalloonOnFocus)
+ {
+ DestroyDelayTimer();
+ CloseBalloon();
+ }
+ }
+
+ private void OnControlGotFocus()
+ {
+ if(!m_Enabled || m_FocusedControl==null || !m_ShowBalloonOnFocus || !m_BalloonsInfo.Contains(m_FocusedControl))
+ return;
+
+ ShowBalloonDelayed(m_FocusedControl);
+ }
+
+ private void OnControlLeave()
+ {
+ if(m_ShowBalloonOnFocus)
+ {
+ DestroyDelayTimer();
+ CloseBalloon();
+ }
+ }
+
+ private void ControlMouseEnter(object sender, EventArgs e)
+ {
+ m_MouseOverControl=sender as Control;
+ OnMouseEnter();
+ }
+
+ private void ControlMouseLeave(object sender, EventArgs e)
+ {
+ m_MouseOverControl=null;
+ OnMouseLeave();
+ }
+
+ private void ControlGotFocus(object sender, EventArgs e)
+ {
+ m_FocusedControl=sender as Control;
+ OnControlGotFocus();
+ }
+
+ private void ControlLeave(object sender, EventArgs e)
+ {
+ m_FocusedControl=null;
+ OnControlLeave();
+ }
+
+ private class BalloonTipInfo
+ {
+ public string Caption;
+ public string Text;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Bar.bmp b/PROMS/DotNetBar Source Code/Bar.bmp
new file mode 100644
index 00000000..1bfca562
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Bar.bmp differ
diff --git a/PROMS/DotNetBar Source Code/Bar.cs b/PROMS/DotNetBar Source Code/Bar.cs
new file mode 100644
index 00000000..c064f59c
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Bar.cs
@@ -0,0 +1,14246 @@
+namespace DevComponents.DotNetBar
+{
+ using System;
+ using System.Windows.Forms;
+ using System.Drawing;
+ using System.ComponentModel;
+ using System.Collections;
+ using System.Resources;
+ using System.Drawing.Drawing2D;
+ using System.ComponentModel.Design;
+ using DevComponents.DotNetBar.Rendering;
+ using System.Runtime.InteropServices;
+ using System.Drawing.Text;
+ using System.Collections.Generic;
+
+ ///
+ /// Represents bar control.
+ ///
+ [ToolboxBitmap(typeof(Bar), "Bar.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.BarDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false), DefaultEvent("ItemClick")]
+ public class Bar : Control, IDockInfo, IBarImageSize, IOwner, IOwnerMenuSupport,
+ IMessageHandlerClient, ISupportInitialize, IBarDesignerServices,
+ ICustomSerialization, IRenderingSupport, IAccessibilitySupport, IOwnerLocalize
+ {
+ #region Events Definitions
+ ///
+ /// Occurs after bar state has changed, like selected dock tab has changed, bar has closed, bar has been docked or undocked etc.
+ ///
+ [Description("Occurs after bar state has changed, like selected dock tab has changed, bar has closed, bar has been docked or undocked etc.")]
+ public event BarStateChangedEventHandler BarStateChanged;
+ ///
+ /// Raises BarStateChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnBarStateChanged(BarStateChangedEventArgs e)
+ {
+ BarStateChangedEventHandler handler = BarStateChanged;
+ if (handler != null)
+ handler(this, e);
+
+ DotNetBarManager manager = this.Owner as DotNetBarManager;
+ if (manager != null)
+ manager.InvokeOnBarStateChanged(e);
+ }
+ ///
+ /// Occurs when Item is clicked.
+ ///
+ [System.ComponentModel.Description("Occurs when Item is clicked."), Category("Item")]
+ public event EventHandler ItemClick;
+ ///
+ /// Occurs after Bar is docked.
+ ///
+ [System.ComponentModel.Description("Occurs after Bar is docked.")]
+ public event EventHandler BarDock;
+
+ ///
+ /// Occurs after Bar is undocked.
+ ///
+ [System.ComponentModel.Description("Occurs after Bar is undocked.")]
+ public event EventHandler BarUndock;
+
+ ///
+ /// Occurs after Bar definition is loaded.
+ ///
+ [System.ComponentModel.Description("Occurs after Bar definition is loaded.")]
+ public event EventHandler DefinitionLoaded;
+
+ ///
+ /// Occurs when current Dock tab has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when current Dock tab has changed.")]
+ public event DotNetBarManager.DockTabChangeEventHandler DockTabChange;
+
+ ///
+ /// Occurs when bar visibility has changed as a result of user action.
+ ///
+ [System.ComponentModel.Description("Occurs when bar visibility has changed as a result of user action.")]
+ public event EventHandler UserVisibleChanged;
+
+ ///
+ /// Occurs when bar auto hide state has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when bar auto hide state has changed.")]
+ public event EventHandler AutoHideChanged;
+
+ ///
+ /// Occurs when Bar is about to be closed as a result of user clicking the Close button on the bar.
+ ///
+ [System.ComponentModel.Description("Occurs when Bar is about to be closed as a result of user clicking the Close button on the bar.")]
+ public event DotNetBarManager.BarClosingEventHandler Closing;
+
+ ///
+ /// Occurs when Bar in auto-hide state is about to be displayed.
+ ///
+ [System.ComponentModel.Description("Occurs when Bar in auto-hide state is about to be displayed.")]
+ public event DotNetBarManager.AutoHideDisplayEventHandler AutoHideDisplay;
+
+ ///
+ /// Occurs when popup item is closing. Event is fired only when Bar is used independently of DotNetBarManager.
+ ///
+ [System.ComponentModel.Description("Occurs when popup item is closing."), Category("Item")]
+ public event EventHandler PopupClose;
+
+ ///
+ /// Occurs when popup of type container is loading. Event is fired only when Bar is used independently of DotNetBarManager.
+ ///
+ [System.ComponentModel.Description("Occurs when popup of type container is loading."), Category("Item")]
+ public event EventHandler PopupContainerLoad;
+
+ ///
+ /// Occurs when popup of type container is unloading. Event is fired only when Bar is used independently of DotNetBarManager.
+ ///
+ [System.ComponentModel.Description("Occurs when popup of type container is unloading."), Category("Item")]
+ public event EventHandler PopupContainerUnload;
+
+ ///
+ /// Occurs when popup item is about to open. Event is fired only when Bar is used independently of DotNetBarManager.
+ ///
+ [System.ComponentModel.Description("Occurs when popup item is about to open."), Category("Item")]
+ public event DotNetBarManager.PopupOpenEventHandler PopupOpen;
+
+ ///
+ /// Occurs just before popup window is shown. Event is fired only when Bar is used independently of DotNetBarManager.
+ ///
+ [System.ComponentModel.Description("Occurs just before popup window is shown."), Category("Item")]
+ public event EventHandler PopupShowing;
+
+ ///
+ /// Occurs before dock tab is displayed.
+ ///
+ [System.ComponentModel.Description("Occurs before dock tab is displayed.")]
+ public event EventHandler BeforeDockTabDisplayed;
+
+ ///
+ /// Occurs when caption button is clicked. Caption button is button displayed on bars with grab handle style task pane.
+ ///
+ [System.ComponentModel.Description("Occurs when caption button is clicked on bars with grab handle style task pane.")]
+ public event EventHandler CaptionButtonClick;
+
+ ///
+ /// Occurs on dockable bars when end-user attempts to close the individual DockContainerItem objects using system buttons on dock tab.
+ /// Event can be canceled by setting the Cancel property of event arguments to true. This even will occur only after user presses the
+ /// X button on tab that is displaying the dockable windows/documents.
+ ///
+ [System.ComponentModel.Description("Occurs on dockable bars when end-user attempts to close the individual DockContainerItem objects using system buttons on dock tab.")]
+ public event DockTabClosingEventHandler DockTabClosing;
+
+ ///
+ /// Occurs on dockable bars after DockContainerItem is closed by end-user. This action cannot be cancelled.
+ ///
+ [System.ComponentModel.Description("Occurs on dockable bars after DockContainerItem is closed by end-user. This action cannot be cancelled.")]
+ public event DockTabClosingEventHandler DockTabClosed;
+
+ ///
+ /// Occurs after an item has been serialized to XmlElement and provides you with opportunity to add any custom data
+ /// to serialized XML. This allows you to serialize any data with the item and load it back up in DeserializeItem event.
+ ///
+ ///
+ /// To serialize custom data to XML definition control creates handle this event and use CustomXmlElement
+ /// property on SerializeItemEventArgs to add new nodes or set attributes with custom data you want saved.
+ ///
+ public event SerializeItemEventHandler SerializeItem;
+
+ ///
+ /// Occurs after an item has been de-serialized (load) from XmlElement and provides you with opportunity to load any custom data
+ /// you have serialized during SerializeItem event.
+ ///
+ ///
+ /// To de-serialize custom data from XML definition handle this event and use CustomXmlElement
+ /// property on SerializeItemEventArgs to retrive any data you saved in SerializeItem event.
+ ///
+ public event SerializeItemEventHandler DeserializeItem;
+
+ ///
+ /// Occurs after the TabStrip style which used on dockable windows has changed. This event gives you opportunity to
+ /// change the style of the tab strip by accessing Bar.DockTabControl.Style property.
+ ///
+ public event EventHandler TabStripStyleChanged;
+
+ ///
+ /// Occurs before the bar control is rendered. This event is fired once for each part of the bar control being rendered. Check the Part property of the event arguments to identify the part being rendered.
+ /// You can cancel internal rendering by setting Cancel property.
+ ///
+ public event RenderBarEventHandler PreRender;
+
+ ///
+ /// Occurs after the bar control is rendered and allows you to render on top of the default rendering provided by the control.
+ ///
+ public event RenderBarEventHandler PostRender;
+
+ ///
+ /// Occurs when DotNetBar is looking for translated text for one of the internal text that are
+ /// displayed on menus, toolbars and customize forms. You need to set Handled=true if you want
+ /// your custom text to be used instead of the built-in system value.
+ ///
+ public event DotNetBarManager.LocalizeStringEventHandler LocalizeString;
+ #endregion
+
+ #region System Buttons class
+ private class System_Buttons
+ {
+ public System_Buttons(Rectangle closerect, Rectangle custrect, bool mouseoverclose, bool mouseovercustomize, bool mousednclose, bool mousedncust)
+ {
+ this.CloseButtonRect = closerect;
+ this.CustomizeButtonRect = custrect;
+ this.MouseOverClose = mouseoverclose;
+ this.MouseOverCustomize = mouseovercustomize;
+ this.MouseDownClose = mousednclose;
+ this.MouseDownCustomize = mousedncust;
+ this.MouseOverAutoHide = false;
+ this.MouseDownAutoHide = false;
+ this.AutoHideButtonRect = Rectangle.Empty;
+ this.ButtonSize = new Size(Dpi.Width14, Dpi.Height14);
+ }
+ public event EventHandler MouseOverCloseChanged;
+ public event EventHandler MouseOverMaximizeChanged;
+ public event EventHandler MouseOverCustomizeChanged;
+ public event EventHandler MouseOverAutoHideChanged;
+ public event EventHandler MouseDownCloseChanged;
+ public event EventHandler MouseDownMaximizeChanged;
+ public event EventHandler MouseDownCustomizeChanged;
+ public event EventHandler MouseDownAutoHideChanged;
+ public event EventHandler MouseOverCaptionChanged;
+ public event EventHandler MouseDownCaptionChanged;
+ public Rectangle CloseButtonRect;
+ public Rectangle CustomizeButtonRect;
+ public Rectangle AutoHideButtonRect;
+ public Rectangle CaptionButtonRect;
+ public Rectangle MaximizeButtonRect;
+ public System.Drawing.Size ButtonSize = new Size(14, 14);
+ private bool m_MouseOverClose = false;
+ private bool m_MouseOverMaximize = false;
+ private bool m_MouseOverCustomize = false;
+ private bool m_MouseDownClose = false;
+ private bool m_MouseDownMaximize = false;
+ private bool m_MouseDownCustomize = false;
+ private bool m_MouseOverAutoHide = false;
+ private bool m_MouseDownAutoHide = false;
+ private bool m_MouseOverCaption = false;
+ private bool m_MouseDownCaption = false;
+
+ public bool MouseOverClose
+ {
+ get { return m_MouseOverClose; }
+ set
+ {
+ if (m_MouseOverClose != value)
+ {
+ m_MouseOverClose = value;
+ if (MouseOverCloseChanged != null)
+ MouseOverCloseChanged(this, new EventArgs());
+ }
+ }
+ }
+ public bool MouseOverMaximize
+ {
+ get { return m_MouseOverMaximize; }
+ set
+ {
+ if (m_MouseOverMaximize != value)
+ {
+ m_MouseOverMaximize = value;
+ if (MouseOverMaximizeChanged != null)
+ MouseOverMaximizeChanged(this, new EventArgs());
+ }
+ }
+ }
+ public bool MouseOverCaption
+ {
+ get { return m_MouseOverCaption; }
+ set
+ {
+ if (m_MouseOverCaption != value)
+ {
+ m_MouseOverCaption = value;
+ if (MouseOverCaptionChanged != null)
+ MouseOverCaptionChanged(this, new EventArgs());
+ }
+ }
+ }
+ public bool MouseOverCustomize
+ {
+ get { return m_MouseOverCustomize; }
+ set
+ {
+ if (m_MouseOverCustomize != value)
+ {
+ m_MouseOverCustomize = value;
+ if (MouseOverCustomizeChanged != null)
+ MouseOverCustomizeChanged(this, new EventArgs());
+ }
+ }
+ }
+ public bool MouseDownClose
+ {
+ get { return m_MouseDownClose; }
+ set
+ {
+ if (m_MouseDownClose != value)
+ {
+ m_MouseDownClose = value;
+ if (MouseDownCloseChanged != null)
+ MouseDownCloseChanged(this, new EventArgs());
+ }
+ }
+ }
+ public bool MouseDownMaximize
+ {
+ get { return m_MouseDownMaximize; }
+ set
+ {
+ if (m_MouseDownMaximize != value)
+ {
+ m_MouseDownMaximize = value;
+ if (MouseDownMaximizeChanged != null)
+ MouseDownMaximizeChanged(this, new EventArgs());
+ }
+ }
+ }
+ public bool MouseDownCaption
+ {
+ get { return m_MouseDownCaption; }
+ set
+ {
+ if (m_MouseDownCaption != value)
+ {
+ m_MouseDownCaption = value;
+ if (MouseDownCaptionChanged != null)
+ MouseDownCaptionChanged(this, new EventArgs());
+ }
+ }
+ }
+ public bool MouseDownCustomize
+ {
+ get { return m_MouseDownCustomize; }
+ set
+ {
+ if (m_MouseDownCustomize != value)
+ {
+ m_MouseDownCustomize = value;
+ if (MouseDownCustomizeChanged != null)
+ MouseDownCustomizeChanged(this, new EventArgs());
+ }
+ }
+ }
+ public bool MouseOverAutoHide
+ {
+ get { return m_MouseOverAutoHide; }
+ set
+ {
+ if (m_MouseOverAutoHide != value)
+ {
+ m_MouseOverAutoHide = value;
+ if (MouseOverAutoHideChanged != null)
+ MouseOverAutoHideChanged(this, new EventArgs());
+ }
+ }
+ }
+ public bool MouseDownAutoHide
+ {
+ get { return m_MouseDownAutoHide; }
+ set
+ {
+ if (m_MouseDownAutoHide != value)
+ {
+ m_MouseDownAutoHide = value;
+ if (MouseDownAutoHideChanged != null)
+ MouseDownAutoHideChanged(this, new EventArgs());
+ }
+ }
+ }
+ }
+ #endregion
+
+ #region Constants
+ private struct ThemeMargin
+ {
+ public int Left;
+ public int Top;
+ public int Right;
+ public int Bottom;
+ public bool IsEmpty
+ {
+ get
+ { return (Left == 0 && Top == 0 && Right == 0 && Bottom == 0); }
+ }
+ }
+
+ const int WM_MOUSEACTIVATE = 0x21;
+ const int MA_NOACTIVATE = 3;
+ const int MA_NOACTIVATEANDEAT = 4;
+ const long WS_POPUP = 0x80000000L;
+ const long WS_CLIPSIBLINGS = 0x04000000L;
+ const long WS_CLIPCHILDREN = 0x02000000L;
+ const long WS_EX_TOPMOST = 0x00000008L;
+ const long WS_EX_TOOLWINDOW = 0x00000080L;
+ const long WS_VISIBLE = 0x10000000L;
+ const int WM_WINDOWPOSCHANGING = 0x0046;
+ const int WM_WINDOWPOSCHANGED = 0x0047;
+
+ const int SIZE_W = 1;
+ const int SIZE_E = 2;
+ const int SIZE_N = 3;
+ const int SIZE_S = 4;
+ const int SIZE_NWN = 5;
+ const int SIZE_NWS = 6;
+ const int SIZE_NEN = 7;
+ const int SIZE_NES = 8;
+ const int SIZE_HSPLITRIGHT = 9;
+ const int SIZE_HSPLITLEFT = 10;
+ const int SIZE_VSPLITTOP = 11;
+ const int SIZE_VSPLITBOTTOM = 12;
+ const int SIZE_HSPLIT = 13;
+ const int SIZE_VSPLIT = 14;
+ const int SIZE_PARENTRESIZE = 15;
+
+ const int DRAGRECTANGLE_WIDTH = 3;
+
+ const int GrabHandleDotNetWidth = 7;
+ const int GrabHandleOfficeWidth = 7;
+ const int GrabHandleResizeWidth = 17;
+ const int GrabHandleTaskPaneHeight = 23;
+ const int GrabHandleCaptionHeight = 20;
+
+ const int DOCKTABSTRIP_HEIGHT = 25;
+ #endregion
+
+ #region Private Variables
+ private BaseItem m_ParentItem;
+ private Point m_ParentItemScreenPos;
+ private object m_OldContainer;
+ private Rectangle m_ClientRect;
+ private SideBarImage m_SideBarImage;
+ private Rectangle m_SideBarRect;
+ private GenericItemContainer m_ItemContainer;
+ //private BaseItem m_OldParent;
+ private int m_InitialContainerWidth;
+ private eBarState m_BarState;
+ private eGrabHandleStyle m_GrabHandleStyle;
+ private Rectangle m_GrabHandleRect;
+
+ // IDockInfo members
+ private int m_DockOffset;
+ private int m_DockLine;
+
+ private object m_Owner;
+ private Point m_MouseDownPt;
+ private Size m_MouseDownSize;
+ private bool m_MoveWindow;
+ private int m_DockTabTearOffIndex = -1; // Used if dock tab is being torn-off but bar cannot float so processing needs to be done after the drop is complete
+
+ private Rectangle m_FloatingRect;
+ private Size m_DockedSizeH = Size.Empty, m_DockedSizeV = Size.Empty;
+ private int m_SizeWindow;
+ // Used when show window content when dragging is not set
+ private DockSiteInfo m_DragDockInfo = new DockSiteInfo();
+ private Rectangle m_LastDragRect;
+ internal DockSiteInfo m_LastDockSiteInfo = new DockSiteInfo();
+ private bool m_WrapItemsDock;
+ private bool m_WrapItemsFloat;
+ private bool m_MenuBar;
+ private bool m_DockStretch;
+ private FloatingContainer m_Float;
+ private bool m_DockingInProgress;
+ private IntPtr m_LastFocusWindow;
+ private bool m_CanDockLeft = true, m_CanDockRight = true, m_CanDockTop = true, m_CanDockBottom = true, m_CanUndock, m_CanTearOffTabs = true, m_CanReorderTabs = true;
+ private bool m_CanDockTab = true;
+ private bool m_CanDockDocument = false;
+ private bool m_CanHide = false;
+ private bool m_CloseSingleTab = false;
+ private bool m_AcceptDropItems = true;
+ private eBorderType m_DockedBorder = eBorderType.None;
+ private Color m_SingleLineColor = SystemColors.ControlDark;
+ private bool m_CustomBar = false;
+ private System_Buttons m_SystemButtons = new System_Buttons(Rectangle.Empty, Rectangle.Empty, false, false, false, false);
+ private ePopupAnimation m_PopupAnimation = ePopupAnimation.ManagerControlled;
+ private PopupShadow m_DropShadow = null;
+ private eBarImageSize m_ImageSize = eBarImageSize.Default;
+ private Color m_CaptionBackColor = Color.Empty;
+ private Color m_CaptionForeColor = Color.Empty;
+ private PopupItem m_CustomizeMenu = null;
+ private TabStrip m_TabDockItems = null;
+ private bool m_AutoHideState = false, m_CanAutoHide = true;
+ private bool m_HasFocus = false;
+ private bool m_SystemPrefChanged = false, m_CustomFont = false;
+ private bool m_LockDockPosition = false;
+ private ColorScheme m_ColorScheme = null;
+ internal bool PassiveBar = false;
+ private bool m_ThemeAware = false;
+ private ThemeMargin m_ThemeWindowMargins = new ThemeMargin();
+ //private int m_MinClientSize=64; // Minimum Parent Dockable size
+
+ // Theme Caching Support
+ private ThemeWindow m_ThemeWindow = null;
+ private ThemeRebar m_ThemeRebar = null;
+ private ThemeToolbar m_ThemeToolbar = null;
+ private ThemeHeader m_ThemeHeader = null;
+ private ThemeScrollBar m_ThemeScrollBar = null;
+ private ThemeProgress m_ThemeProgress = null;
+
+ // Support for same line docked windows
+ // internal int _SplitDockWidth=0;
+ // internal int _SplitDockHeight=0;
+ private int m_SplitDockWidthPercent = 0;
+ private int m_SplitDockHeightPercent = 0;
+
+ // While docking is in progress this will hold the tabbed bar that this bar was added to if any
+ private Bar m_TempTabBar = null;
+
+ // Tabbed Dockable Windows Tab Control position
+ private eTabStripAlignment m_DockTabAlignment = eTabStripAlignment.Bottom;
+
+ // TODO: Menu Merge Implementation - Item Merge Support
+ //private bool m_MergeEnabled=false;
+ private bool m_HideFloatingInactive = true;
+
+ private Point m_ResizeOffset = Point.Empty;
+ private bool m_TabNavigation = false;
+
+ internal bool m_AccessibleObjectCreated = false;
+
+ private bool m_BarDefinitionLoading = false;
+ private bool m_ParentMsgHandlerRegistered = false;
+
+ private BaseItem m_DoDefaultActionItem = null;
+
+ private int m_AutoHideAnimationTime = 100;
+
+ private eBackgroundImagePosition m_BackgroundImagePosition = eBackgroundImagePosition.Stretch;
+ private byte m_BackgroundImageAlpha = 255;
+
+ private bool m_ShowToolTips = true;
+ private bool m_IgnoreAnimation = true;
+
+ protected ToolTip m_ToolTipWnd = null;
+
+ private int m_DockSideDelayed = -1;
+
+ private bool m_AnimationInProgress = false;
+
+ private bool m_EnableRedraw = true;
+
+ private bool m_AlwaysDisplayDockTab = false;
+ private bool m_MenuEventSupport = false;
+ private bool m_MenuFocus = false;
+
+ private int m_BarShowIndex = -1; // Used to control bar Z-Order if WinForms change it...
+ private bool m_AlwaysDisplayKeyAccelerators = false;
+
+ private bool m_AutoCreateCaptionMenu = true;
+ private PopupItem m_CaptionMenu = null;
+ private bool m_AutoSyncBarCaption = false;
+
+ private bool m_SaveLayoutChanges = true;
+ private bool m_TabsRearranged = false;
+
+ private IBarItemDesigner m_BarDesigner = null;
+ private bool m_LoadingHideFloating = false;
+ private bool m_DesignerSelection = false;
+ internal Hashtable PropertyBag = new Hashtable();
+
+ private int m_CornerSize = 3;
+ private bool m_FadeEffect = false;
+ private bool m_AntiAlias = false;
+ private eBarType m_BarType = eBarType.Toolbar;
+ private bool m_RoundCorners = true;
+ private bool m_AutoHideTextAlwaysVisible = false;
+ private bool m_DockTabCloseButtonVisible = false;
+ #endregion
+
+ ///
+ /// Initializes a new instance of the Bar class.
+ ///
+ public Bar()
+ {
+ if (!ColorFunctions.ColorsLoaded)
+ {
+ NativeFunctions.RefreshSettings();
+ NativeFunctions.OnDisplayChange();
+ ColorFunctions.LoadColors();
+ }
+
+ m_ColorScheme = new ColorScheme();
+ m_ParentItem = null;
+ m_OldContainer = null;
+ m_ClientRect = Rectangle.Empty;
+ m_SideBarRect = Rectangle.Empty;
+ m_SideBarImage = new SideBarImage();
+ m_ItemContainer = new GenericItemContainer();
+ m_ItemContainer.GlobalItem = false;
+ m_ItemContainer.ContainerControl = this;
+ m_ItemContainer.WrapItems = true;
+ m_ItemContainer.Stretch = false;
+ m_ItemContainer.Displayed = true;
+ m_ItemContainer.SystemContainer = true;
+ //m_ItemContainer.SetSystemItem(true);
+ //m_OldParent=null;
+ m_InitialContainerWidth = 164;
+ //m_BarState=eBarState.Popup;
+ m_BarState = eBarState.Docked;
+
+ m_DockOffset = 0;
+ m_DockLine = 0;
+ m_GrabHandleStyle = eGrabHandleStyle.None;
+ m_GrabHandleRect = Rectangle.Empty;
+ m_Owner = null;
+ m_MouseDownPt = Point.Empty;
+ m_MouseDownSize = new Size(0, 0);
+ m_MoveWindow = false;
+ m_FloatingRect = Rectangle.Empty;
+ m_SizeWindow = 0;
+
+ m_LastDragRect = Rectangle.Empty;
+
+ m_WrapItemsDock = false;
+ m_WrapItemsFloat = true;
+ m_DockStretch = false;
+ m_MenuBar = false;
+ this.Text = "";
+
+ m_Float = null;
+ m_DockingInProgress = false;
+
+ this.SetStyle(ControlStyles.Selectable, false);
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
+
+ this.TabStop = false;
+ base.Font = SystemFonts.MenuFont; // System.Windows.Forms.SystemInformation.MenuFont.Clone() as Font;
+
+ m_CanDockLeft = true;
+ m_CanDockRight = true;
+ m_CanDockTop = true;
+ m_CanDockBottom = true;
+ m_CanUndock = true;
+
+ Microsoft.Win32.SystemEvents.UserPreferenceChanged += new Microsoft.Win32.UserPreferenceChangedEventHandler(PreferenceChanged);
+
+ this.IsAccessible = true;
+
+ m_SystemButtons.MouseDownAutoHideChanged += new EventHandler(this.SysButtonHideTooltip);
+ m_SystemButtons.MouseDownCloseChanged += new EventHandler(this.SysButtonHideTooltip);
+ m_SystemButtons.MouseDownCustomizeChanged += new EventHandler(this.SysButtonHideTooltip);
+ m_SystemButtons.MouseOverAutoHideChanged += new EventHandler(this.SysButtonMouseOverAutoHide);
+ m_SystemButtons.MouseOverCustomizeChanged += new EventHandler(this.SysButtonMouseOverCustomize);
+ m_SystemButtons.MouseOverCloseChanged += new EventHandler(this.SysButtonMouseOverClose);
+
+ StyleManager.Register(this);
+ }
+
+ ///
+ /// Called by StyleManager to notify control that style on manager has changed and that control should refresh its appearance if
+ /// its style is controlled by StyleManager.
+ ///
+ /// New active style.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void StyleManagerStyleChanged(eDotNetBarStyle newStyle)
+ {
+ if (m_ItemContainer == null || this.IsDisposed) return;
+ if(this.Style == eDotNetBarStyle.StyleManagerControlled)
+ this.Style = eDotNetBarStyle.StyleManagerControlled;
+ this.Invalidate();
+ }
+ private void PreferenceChanged(object sender, Microsoft.Win32.UserPreferenceChangedEventArgs e)
+ {
+ if (!m_SystemPrefChanged && !m_CustomFont)
+ {
+ m_SystemPrefChanged = true;
+ NativeFunctions.PostMessage(this.Handle, NativeFunctions.WM_USER + 102, IntPtr.Zero, IntPtr.Zero);
+ }
+ }
+
+ protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
+ {
+ if(Dpi.RecordScalePerControl)
+ Dpi.SetScaling(factor);
+ if (m_ItemContainer != null)
+ m_ItemContainer.NotifyScaleItem(factor);
+ m_SystemButtons.ButtonSize = Dpi.Size(m_SystemButtons.ButtonSize, factor);
+ base.ScaleControl(factor, specified);
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance()
+ {
+ return new BarAccessibleObject(this);
+ }
+
+ private void SetupAccessibility()
+ {
+ if (this.Text != "")
+ this.AccessibleName = this.Text;
+ else
+ this.AccessibleName = "DotNetBar Bar";
+ this.AccessibleDescription = this.AccessibleName + " (" + this.Name + ")";
+ if (this.MenuBar)
+ this.AccessibleRole = AccessibleRole.MenuBar;
+ else
+ {
+ if (this.LayoutType == eLayoutType.DockContainer)
+ this.AccessibleRole = AccessibleRole.Grouping;
+ else if (this.GrabHandleStyle == eGrabHandleStyle.ResizeHandle)
+ this.AccessibleRole = AccessibleRole.StatusBar;
+ else
+ this.AccessibleRole = AccessibleRole.ToolBar;
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the Control class.
+ ///
+ /// Bar Caption
+ public Bar(string BarCaption)
+ : this()
+ {
+ this.Text = BarCaption;
+ }
+
+ ///
+ /// Gets/Sets the owner of the Bar object.
+ ///
+ [System.ComponentModel.Browsable(false), DefaultValue(null), DevCoBrowsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public object Owner
+ {
+ get
+ {
+ if (m_ParentItem is CustomizeItem)
+ return m_ParentItem.GetOwner();
+ if (this.Parent != null && !(this.Parent is FloatingContainer) && !(this.Parent is DockSite) && !this.AutoHide && !m_DesignerParent || this.Parent == null && m_Owner == null)
+ return this;
+ return m_Owner;
+ }
+ set
+ {
+ m_Owner = value;
+ if (this.DesignMode && this.Site != null && m_TabDockItems != null)
+ this.RefreshDockTab(false);
+ }
+ }
+ internal bool IsDisposing = false;
+ protected override void Dispose(bool disposing)
+ {
+ StyleManager.Unregister(this);
+ IsDisposing = true;
+ if (m_ParentMsgHandlerRegistered)
+ {
+ DotNetBarManager.UnRegisterOwnerParentMsgHandler(this, null);
+ m_ParentMsgHandlerRegistered = false;
+ }
+ if (m_Float != null && disposing)
+ {
+ try
+ {
+ if (m_Float.Controls.Contains(this))
+ m_Float.Controls.Remove(this);
+ m_Float.Close();
+ m_Float.Dispose();
+ m_Float = null;
+ }
+ catch (Exception)
+ { }
+ }
+
+ if (m_Owner is DotNetBarManager && ((DotNetBarManager)m_Owner).IgnoreLoadedControlDispose)
+ this.Controls.Clear();
+
+ if (this.Parent != null)
+ {
+ try
+ {
+ this.Parent.Controls.Remove(this);
+ }
+ catch (Exception)
+ { }
+ }
+ Microsoft.Win32.SystemEvents.UserPreferenceChanged -= new Microsoft.Win32.UserPreferenceChangedEventHandler(PreferenceChanged);
+ if (m_TabDockItems != null)
+ {
+ m_TabDockItems.Dispose();
+ m_TabDockItems = null;
+ }
+ if (m_DropShadow != null)
+ {
+ m_DropShadow.Hide();
+ m_DropShadow.Dispose();
+ m_DropShadow = null;
+ }
+ if (m_FilterInstalled)
+ {
+ MessageHandler.UnregisterMessageClient(this);
+ m_FilterInstalled = false;
+ }
+
+ RestoreContainer();
+ m_Owner = null;
+ m_ParentItem = null;
+ m_OldContainer = null;
+ //m_OldParent=null;
+ if (m_ItemContainer != null)
+ m_ItemContainer.Dispose();
+ m_ItemContainer = null;
+
+ base.Dispose(disposing);
+ IsDisposing = false;
+ }
+
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ CreateParams p = base.CreateParams;
+ if (PassiveBar)
+ return p;
+ if (m_BarState == eBarState.Popup && (m_ParentItem == null || (m_ParentItem.Site == null || !m_ParentItem.Site.DesignMode)))
+ {
+ p.Style = unchecked((int)(WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN));
+ p.ExStyle = (int)(WS_EX_TOPMOST | WS_EX_TOOLWINDOW);
+ }
+ //else if(m_BarState==eBarState.Floating)
+ //{
+ // p.style=(int)(WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
+ // p.exStyle=(int)(WS_EX_TOOLWINDOW);
+ //}
+ p.Caption = "";
+ return p;
+ }
+ }
+
+ internal bool HasFocus
+ {
+ get { return m_HasFocus; }
+ }
+
+ internal void SetHasFocus(bool b)
+ {
+ m_HasFocus = b;
+ if (this.DockSide == eDockSide.None && this.LayoutType == eLayoutType.DockContainer && this.Owner is DotNetBarManager)
+ {
+ DotNetBarManager manager = this.Owner as DotNetBarManager;
+ if (b)
+ manager.InternalDockContainerActivated(this.SelectedDockContainerItem);
+ else
+ manager.InternalDockContainerDeactivated(this.SelectedDockContainerItem);
+ }
+ this.Refresh();
+ }
+
+ protected override void OnLeave(EventArgs e)
+ {
+ base.OnLeave(e);
+ if (m_HasFocus)
+ {
+ m_HasFocus = false;
+ if (m_GrabHandleStyle == eGrabHandleStyle.Caption && (m_BarState == eBarState.Docked || m_BarState == eBarState.AutoHide))
+ this.Invalidate();
+
+ if (m_BarState == eBarState.AutoHide)
+ {
+ GetAutoHidePanel(m_LastDockSiteInfo.DockSide).StartTimer();
+ }
+ }
+ }
+
+ protected override void OnEnter(EventArgs e)
+ {
+ base.OnEnter(e);
+ if (!m_HasFocus)
+ {
+ m_HasFocus = true;
+ if (m_GrabHandleStyle == eGrabHandleStyle.Caption && (m_BarState == eBarState.Docked || m_BarState == eBarState.AutoHide))
+ this.Invalidate();
+ if (m_BarState == eBarState.AutoHide)
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ if (this.ClientRectangle.Contains(p))
+ GetAutoHidePanel(m_LastDockSiteInfo.DockSide).StopTimer();
+ }
+ }
+ }
+
+ protected override bool IsInputKey(Keys keyData)
+ {
+ if (keyData == System.Windows.Forms.Keys.Left || keyData == System.Windows.Forms.Keys.Right || keyData == System.Windows.Forms.Keys.Up || keyData == System.Windows.Forms.Keys.Down || keyData == System.Windows.Forms.Keys.Enter || keyData == System.Windows.Forms.Keys.Return || keyData == System.Windows.Forms.Keys.Tab || keyData == System.Windows.Forms.Keys.Escape)
+ return true;
+ return base.IsInputKey(keyData);
+ }
+
+ internal bool EnableRedraw
+ {
+ get
+ {
+ return m_EnableRedraw;
+ }
+ set
+ {
+ if (m_EnableRedraw != value && this.Visible)
+ {
+ m_EnableRedraw = value;
+ if (m_EnableRedraw)
+ NativeFunctions.SendMessage(this.Handle, NativeFunctions.WM_SETREDRAW, 1, 0);
+ else
+ NativeFunctions.SendMessage(this.Handle, NativeFunctions.WM_SETREDRAW, 0, 0);
+ }
+ }
+ }
+
+#if FRAMEWORK20
+ protected override void OnBindingContextChanged(EventArgs e)
+ {
+ base.OnBindingContextChanged(e);
+ if (m_ItemContainer != null)
+ m_ItemContainer.UpdateBindings();
+ }
+#endif
+
+ protected override void WndProc(ref Message m)
+ {
+ if (m.Msg == WM_MOUSEACTIVATE && (m_BarState == eBarState.Popup || m_BarState == eBarState.Floating && m_ItemContainer.LayoutType == eLayoutType.TaskList))// && m_BarState!=eBarState.Docked)
+ {
+ m.Result = new System.IntPtr(MA_NOACTIVATE);
+ return;
+ }
+ else if (m.Msg == NativeFunctions.WM_USER + 101)
+ {
+ if (!m_DockingInProgress && m_BarState == eBarState.Floating)
+ NativeFunctions.SetWindowPos(this.Handle, new IntPtr(NativeFunctions.HWND_TOP), 0, 0, 0, 0, NativeFunctions.SWP_NOMOVE | NativeFunctions.SWP_NOSIZE | NativeFunctions.SWP_NOACTIVATE);
+ }
+ else if (m.Msg == NativeFunctions.WM_USER + 102)
+ {
+ if (this.Name == "StatusBar")
+ this.Name = this.Name;
+ if (this.LayoutType != eLayoutType.DockContainer)
+ this.Font = SystemFonts.MenuFont; // System.Windows.Forms.SystemInformation.MenuFont.Clone() as Font;
+ this.RecalcLayout();
+ m_SystemPrefChanged = false;
+ }
+ else if (m.Msg == NativeFunctions.WM_USER + 107)
+ {
+ if (m_DoDefaultActionItem != null)
+ {
+ m_DoDefaultActionItem.DoAccesibleDefaultAction();
+ m_DoDefaultActionItem = null;
+ }
+
+ }
+ else if (m.Msg == NativeFunctions.WM_SETFOCUS)
+ {
+ IntPtr wnd = m.WParam;
+ Control objCtrl = Control.FromChildHandle(wnd);
+ if (objCtrl != null && !(objCtrl is DevComponents.DotNetBar.Bar) && !(objCtrl is MenuPanel) && !(objCtrl is Controls.TextBoxX))
+ {
+ Form form = objCtrl.FindForm();
+ if (form == this.FindForm())
+ m_LastFocusWindow = m.WParam;
+ else if (form != null)
+ m_LastFocusWindow = m.WParam;
+ }
+ }
+ else if (m.Msg == NativeFunctions.WM_KILLFOCUS)
+ {
+ bool bLostFocus = false;
+ Control objCtrl = Control.FromChildHandle(m.WParam);
+ if (objCtrl != null)
+ {
+ while (objCtrl.Parent != null)
+ objCtrl = objCtrl.Parent;
+ if (objCtrl != this && (m_ItemContainer != null && !m_ItemContainer.IsAnyOnHandle(objCtrl.Handle)))
+ bLostFocus = true;
+ }
+ else
+ bLostFocus = true;
+
+ if (bLostFocus && m_ItemContainer != null)
+ m_ItemContainer.ContainerLostFocus(false);
+ }
+ else if (m.Msg == NativeFunctions.WM_THEMECHANGED)
+ {
+ this.RefreshThemes();
+ this.RefreshThemeMargins();
+ Themes.RefreshIsThemeActive();
+ }
+ //else if (m.Msg == (int)WinApi.WindowsMessages.WM_NCHITTEST)
+ //{
+ // Form form = this.FindForm();
+ // Rectangle resizeRect = GetResizeHandleRectangle();
+ // if (form != null && form.WindowState == FormWindowState.Normal && !resizeRect.IsEmpty)
+ // {
+ // int mouseX = WinApi.LOWORD(m.LParam);
+ // int mouseY = WinApi.HIWORD(m.LParam);
+ // if (resizeRect.Contains(this.PointToClient(new Point(mouseX, mouseY))))
+ // {
+ // IntPtr formHandle = form.Handle;
+ // if (formHandle != IntPtr.Zero)
+ // {
+ // WinApi.POINT point1;
+ // WinApi.RECT rect1 = new WinApi.RECT(0, 0, form.ClientRectangle.Right, form.ClientRectangle.Bottom);
+ // if (this.RightToLeft == RightToLeft.Yes)
+ // {
+ // point1 = new WinApi.POINT(resizeRect.Left, resizeRect.Bottom);
+ // }
+ // else
+ // {
+ // point1 = new WinApi.POINT(resizeRect.Right, resizeRect.Bottom);
+ // }
+ // WinApi.MapWindowPoints(this.Handle, formHandle, ref point1, 1);
+ // int num3 = Math.Abs((int)(rect1.Bottom - point1.y));
+ // int num4 = Math.Abs((int)(rect1.Right - point1.x));
+ // if (this.RightToLeft != RightToLeft.Yes)
+ // {
+ // m.Result = new IntPtr((int)WinApi.WindowHitTestRegions.BottomRightSizeableCorner);
+ // return;
+ // }
+ // }
+ // }
+
+ // }
+ //}
+ base.WndProc(ref m);
+ }
+
+ protected override void OnSystemColorsChanged(EventArgs e)
+ {
+ base.OnSystemColorsChanged(e);
+ Application.DoEvents();
+ //m_ColorScheme.Refresh(null,true);
+ this.GetColorScheme().Refresh(null, true);
+ this.Refresh();
+ }
+
+ ///
+ /// Gets or sets the item default accessibility action will be performed on.
+ ///
+ BaseItem IAccessibilitySupport.DoDefaultActionItem
+ {
+ get { return m_DoDefaultActionItem; }
+ set { m_DoDefaultActionItem = value; }
+ }
+
+ ///
+ /// Releases the focus from the bar and selects the control that had focus before bar was selected. If control that had focus could not be determined focus will stay on the bar.
+ /// This method is used by internal DotNetBar implementation and you should not use it.
+ ///
+ public void ReleaseFocus()
+ {
+ if (this.Focused && m_LastFocusWindow != IntPtr.Zero)
+ {
+ Control ctrl = Control.FromChildHandle(m_LastFocusWindow);
+ if (ctrl != null)
+ {
+ ctrl.Select();
+ if (!ctrl.Focused)
+ NativeFunctions.SetFocus(m_LastFocusWindow);
+ }
+ else
+ {
+ NativeFunctions.SetFocus(m_LastFocusWindow);
+ }
+ m_LastFocusWindow = IntPtr.Zero;
+ m_ItemContainer.AutoExpand = false;
+ }
+ }
+
+ ///
+ /// Returns the reference to the control that last had input focus. This property should be used to
+ /// determine which control had input focus before bar gained the focus. Use it to apply
+ /// the menu command to active control.
+ ///
+ [Browsable(false), DevCoBrowsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Control LastFocusControl
+ {
+ get
+ {
+ if (this.Focused && m_LastFocusWindow != IntPtr.Zero)
+ {
+ Control ctrl = Control.FromChildHandle(m_LastFocusWindow);
+ return ctrl;
+ }
+ return null;
+ }
+ }
+
+ internal void SetSystemFocus()
+ {
+ if (!this.Focused)
+ {
+ m_ItemContainer.SetSystemFocus();
+ this.Focus();
+ }
+ }
+
+ private Color[] _BorderColors = null;
+ ///
+ /// Indicates the array of colors that when set are used to draw the border of the item.
+ ///
+ [DefaultValue(null), Category("Appearance"), Description("Indicates the array of colors that when set are used to draw the border of the item."), TypeConverter(typeof(ArrayConverter))]
+ internal Color[] BorderColors
+ {
+ get
+ {
+ return _BorderColors;
+ }
+ set
+ {
+ if (_BorderColors != value)
+ {
+ _BorderColors = value;
+ //OnPropertyChanged(new PropertyChangedEventArgs("Colors"));
+ this.Invalidate();
+ }
+ }
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (m_ItemContainer == null || this.IsDisposed)
+ return;
+
+ if (this.BackColor == Color.Transparent)
+ {
+ base.OnPaintBackground(e);
+ }
+
+ Graphics g = e.Graphics;
+ g.PageUnit = GraphicsUnit.Pixel;
+ // Support for the design-time when insert position is drawn
+#if TRIAL
+ if(NativeFunctions.ColorExpAlt())
+ {
+ g.Clear(Color.White);
+ g.DrawString("Your DotNetBar Trial has expired :-(",this.Font,SystemBrushes.ControlText,0,0);
+ }
+ else
+ {
+ if(m_ItemContainer.EffectiveStyle==eDotNetBarStyle.Office2000)
+ PaintOffice(g);
+ else
+ PaintDotNet(e);
+ }
+#else
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ PaintOffice(g);
+ else
+ PaintDotNet(e);
+#endif
+
+ if (_BorderColors != null && _BorderColors.Length > 0)
+ {
+ g.ResetClip();
+ DisplayHelp.DrawRoundedRectangle(g, this.ClientRectangle, _BorderColors, 0);
+ }
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ if (m_AnimationInProgress || this.Width == 0 || this.Height == 0)
+ return;
+
+ if (!(this.Parent is DockSite || this.Parent is FloatingContainer) && m_BarState == eBarState.Docked && !m_LayoutSuspended)
+ this.RecalcLayout();
+ ResizeDockTab();
+ }
+
+ private void PaintBackgroundImage(Graphics g)
+ {
+ if (this.BackgroundImage == null)
+ return;
+ Rectangle r = this.ClientRectangle;
+ BarFunctions.PaintBackgroundImage(g, r, this.BackgroundImage, m_BackgroundImagePosition, m_BackgroundImageAlpha);
+ }
+
+ private bool IsGradientStyle
+ {
+ get
+ {
+ return (this.Style == eDotNetBarStyle.Office2003 || this.Style == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(this.Style));
+ }
+ }
+
+ ///
+ /// Creates the Graphics object for the control.
+ ///
+ /// The Graphics object for the control.
+ public new Graphics CreateGraphics()
+ {
+ Graphics g = base.CreateGraphics();
+ if (m_AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+#if FRAMEWORK20
+ if (!SystemInformation.IsFontSmoothingEnabled)
+#endif
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+ return g;
+ }
+
+ #region Rendering Support
+ private Rendering.BaseRenderer m_DefaultRenderer = null;
+ private Rendering.BaseRenderer m_Renderer = null;
+ private eRenderMode m_RenderMode = eRenderMode.Global;
+ ///
+ /// Returns the renderer control will be rendered with.
+ ///
+ /// The current renderer.
+ public virtual Rendering.BaseRenderer GetRenderer()
+ {
+ if (m_RenderMode == eRenderMode.Global && Rendering.GlobalManager.Renderer != null)
+ return Rendering.GlobalManager.Renderer;
+ else if (m_RenderMode == eRenderMode.Custom && m_Renderer != null)
+ return m_Renderer;
+
+ if (m_DefaultRenderer == null)
+ {
+ if (BarFunctions.IsOffice2007Style(this.Style))
+ m_DefaultRenderer = new Rendering.Office2007Renderer();
+ }
+
+ return m_Renderer;
+ }
+
+ ///
+ /// Gets or sets the redering mode used by control. Default value is eRenderMode.Global which means that static GlobalManager.Renderer is used. If set to Custom then Renderer property must
+ /// also be set to the custom renderer that will be used.
+ ///
+ [Browsable(false), DefaultValue(eRenderMode.Global)]
+ public eRenderMode RenderMode
+ {
+ get { return m_RenderMode; }
+ set
+ {
+ if (m_RenderMode != value)
+ {
+ m_RenderMode = value;
+ this.Invalidate(true);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the custom renderer used by the items on this control. RenderMode property must also be set to eRenderMode.Custom in order renderer
+ /// specified here to be used.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public DevComponents.DotNetBar.Rendering.BaseRenderer Renderer
+ {
+ get
+ {
+ return m_Renderer;
+ }
+ set { m_Renderer = value; }
+ }
+ #endregion
+
+ internal ItemPaintArgs GetItemPaintArgs(Graphics g)
+ {
+ ItemPaintArgs pa = new ItemPaintArgs(m_Owner as IOwner, this, g, this.GetColorScheme());
+ pa.DesignerSelection = m_DesignerSelection;
+ pa.Renderer = GetRenderer();
+
+ if (m_BarState == eBarState.Popup && m_ParentItem != null && m_ParentItem.DesignMode)
+ {
+ ISite site = this.GetSite();
+ if (site != null && site.DesignMode)
+ pa.DesignerSelection = true;
+ }
+
+ return pa;
+ }
+
+ protected void PaintDotNet(PaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+ SmoothingMode sm = g.SmoothingMode;
+ TextRenderingHint th = g.TextRenderingHint;
+ RenderBarEventArgs re = null;
+
+ if (m_AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ m_SystemButtons.CustomizeButtonRect = Rectangle.Empty;
+ m_SystemButtons.CloseButtonRect = Rectangle.Empty;
+ m_SystemButtons.AutoHideButtonRect = Rectangle.Empty;
+ m_SystemButtons.CaptionButtonRect = Rectangle.Empty;
+ m_SystemButtons.MaximizeButtonRect = Rectangle.Empty;
+ ColorScheme cs = this.GetColorScheme();
+
+ ItemPaintArgs pa = GetItemPaintArgs(g);
+ pa.ClipRectangle = e.ClipRectangle;
+ Pen p;
+ if (m_BarState == eBarState.Popup)
+ p = new Pen(pa.Colors.BarPopupBorder, 1);
+ else
+ p = new Pen(pa.Colors.BarFloatingBorder);
+
+ if (this.DisplayShadow && !this.AlphaShadow && m_ParentItem != null && !BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle))
+ SetupRegion();
+
+ if (m_BarState == eBarState.Popup)
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.ClientRectangle);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ if (m_ParentItem != null && BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle) && GetRenderer() != null)
+ {
+ ToolbarRendererEventArgs tre = new ToolbarRendererEventArgs(this, g, this.DisplayRectangle);
+ tre.ItemPaintArgs = pa;
+ GetRenderer().DrawPopupToolbarBackground(tre);
+ }
+ else
+ {
+ using (SolidBrush brush = new SolidBrush(pa.Colors.BarPopupBackground))
+ g.FillRectangle(brush, this.DisplayRectangle);
+ PaintBackgroundImage(pa.Graphics);
+
+ PaintSideBar(g);
+
+ Rectangle borderRectangle = this.ClientRectangle;
+ if (this.DisplayShadow && !this.AlphaShadow)
+ borderRectangle = new Rectangle(0, 0, this.ClientSize.Width - 2, this.ClientSize.Height - 2);
+
+ if (m_ParentItem != null && BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle))
+ DisplayHelp.DrawRoundedRectangle(g, p, borderRectangle, m_CornerSize);
+ else
+ NativeFunctions.DrawRectangle(g, p, borderRectangle);
+
+ if (this.DisplayShadow && !this.AlphaShadow)
+ {
+ // Shadow
+ p.Dispose();
+ p = new Pen(SystemColors.ControlDark, 2);
+ Point[] pt = new Point[3];
+ pt[0].X = 2;
+ pt[0].Y = this.ClientSize.Height - 1;
+ pt[1].X = this.ClientSize.Width - 1;
+ pt[1].Y = this.ClientSize.Height - 1;
+ pt[2].X = this.ClientSize.Width - 1;
+ pt[2].Y = 2;
+ g.DrawLines(p, pt);
+ }
+ if (m_ParentItem != null && !BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle) && m_ParentItem is ButtonItem && m_ParentItem.Displayed)
+ {
+ // Determine where to draw the line based on parent position
+ if (m_ParentItemScreenPos.Y < this.Location.Y)
+ {
+ Point p1 = new Point((m_ParentItemScreenPos.X - this.Location.X) + 1, 0);
+ Point p2 = new Point(p1.X + m_ParentItem.WidthInternal - 5, 0);
+ DisplayHelp.DrawLine(g, p1, p2, pa.Colors.ItemExpandedBackground, 1);
+ //g.DrawLine(new Pen(pa.Colors.ItemExpandedBackground, 1), p1, p2);
+ }
+ }
+ }
+ }
+ }
+ else if (m_BarState == eBarState.Floating)
+ {
+ bool drawCaptionText = true;
+
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.ClientRectangle);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ if (BarFunctions.IsOffice2007Style(this.Style) && this.GetRenderer() != null)
+ {
+ ToolbarRendererEventArgs tre = new ToolbarRendererEventArgs(this, g, this.DisplayRectangle);
+ tre.ItemPaintArgs = pa;
+ this.GetRenderer().DrawToolbarBackground(tre);
+ }
+ else
+ {
+ sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.Default;
+ if (this.MenuBar)
+ DisplayHelp.FillRectangle(g, this.ClientRectangle, pa.Colors.MenuBarBackground, pa.Colors.MenuBarBackground2, pa.Colors.MenuBarBackgroundGradientAngle);
+ else
+ DisplayHelp.FillRectangle(g, this.ClientRectangle, pa.Colors.BarBackground, pa.Colors.BarBackground2, pa.Colors.BarBackgroundGradientAngle);
+
+ PaintBackgroundImage(pa.Graphics);
+ g.SmoothingMode = sm;
+ }
+ }
+
+ Rectangle r = new Rectangle(0, 0, this.Width, this.Height);
+
+ ThemeWindow theme = null;
+ ThemeWindowParts part = ThemeWindowParts.SmallFrameLeft;
+ ThemeWindowStates state = ThemeWindowStates.FrameActive;
+
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.Caption, Rectangle.Empty);
+
+ if (this.DrawThemedCaption)
+ {
+ re.Bounds = new Rectangle(0, 0, this.Width, m_ThemeWindowMargins.Top + 1);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ theme = this.ThemeWindow;
+ if (this.LayoutType == eLayoutType.DockContainer && !m_HasFocus)
+ state = ThemeWindowStates.FrameInactive;
+
+ theme.DrawBackground(g, part, state, new Rectangle(0, 0, m_ThemeWindowMargins.Left, this.Height));
+ part = ThemeWindowParts.SmallFrameRight;
+ theme.DrawBackground(g, part, state, new Rectangle(this.Width - m_ThemeWindowMargins.Right, 0, m_ThemeWindowMargins.Left, this.Height));
+ part = ThemeWindowParts.SmallFrameBottom;
+ theme.DrawBackground(g, part, state, new Rectangle(0, this.Height - m_ThemeWindowMargins.Bottom, this.Width, m_ThemeWindowMargins.Bottom));
+
+ if (this.LayoutType == eLayoutType.DockContainer && !m_HasFocus)
+ state = ThemeWindowStates.CaptionInactive;
+ part = ThemeWindowParts.SmallCaption;
+ }
+ r = new Rectangle(0, 0, this.Width, m_ThemeWindowMargins.Top + 1);
+ theme.DrawBackground(g, part, state, r);
+ r.Offset(0, 1);
+ }
+ else if (m_GrabHandleStyle == eGrabHandleStyle.Caption && this.LayoutType == eLayoutType.DockContainer && this.Style == eDotNetBarStyle.Office2000)
+ {
+ Rectangle rback = new Rectangle(3, 3, this.Width - 6, GetGrabHandleCaptionHeight());
+ re.Bounds = rback;
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ ControlPaint.DrawBorder3D(g, r, Border3DStyle.Raised, Border3DSide.All);
+ eDrawCaption flags = eDrawCaption.DC_SMALLCAP | eDrawCaption.DC_GRADIENT | eDrawCaption.DC_TEXT;
+ if (m_HasFocus) flags |= eDrawCaption.DC_ACTIVE;
+ IntPtr hdc = g.GetHdc();
+ NativeFunctions.RECT rect = new NativeFunctions.RECT(rback.X, rback.Y, rback.Right, rback.Bottom);
+ try
+ {
+ NativeFunctions.DrawCaption(this.Handle, hdc, ref rect, flags);
+ }
+ finally
+ {
+ g.ReleaseHdc(hdc);
+ }
+ }
+ drawCaptionText = false;
+ r = rback;
+ }
+ else
+ {
+ Rectangle rback = new Rectangle(3, 3, this.Width - 6, GetGrabHandleCaptionHeight());
+ re.Bounds = rback;
+ OnPreRender(re);
+
+ if (!re.Cancel)
+ {
+ Pen p1 = new Pen(pa.Colors.BarFloatingBorder, 1);
+ NativeFunctions.DrawRectangle(g, p, r);
+ r.Inflate(-1, -1);
+ NativeFunctions.DrawRectangle(g, p, r);
+
+ p1.Dispose();
+ p1 = new Pen(pa.Colors.BarFloatingBorder, 1);
+ g.DrawLine(p1, 1, 2, 2, 2);
+ g.DrawLine(p1, this.Width - 3, 2, this.Width - 2, 2);
+ g.DrawLine(p1, 1, this.Height - 3, 2, this.Height - 3);
+ g.DrawLine(p1, this.Width - 3, this.Height - 3, this.Width - 2, this.Height - 3);
+ p1.Dispose();
+ p1 = null;
+
+ if (this.GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane)
+ {
+ sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.Default;
+
+ if (m_CaptionBackColor.IsEmpty)
+ {
+ if (this.LayoutType == eLayoutType.Toolbar || m_HasFocus)
+ DisplayHelp.FillRectangle(g, rback, pa.Colors.BarCaptionBackground, pa.Colors.BarCaptionBackground2, pa.Colors.BarCaptionBackgroundGradientAngle);
+ else
+ DisplayHelp.FillRectangle(g, rback, pa.Colors.BarCaptionInactiveBackground, pa.Colors.BarCaptionInactiveBackground2, pa.Colors.BarCaptionInactiveBackgroundGAngle);
+ }
+ else
+ DisplayHelp.FillRectangle(g, new Rectangle(3, 3, this.Width - 6, GetGrabHandleCaptionHeight()), m_CaptionBackColor, Color.Empty);
+
+ g.SmoothingMode = sm;
+ }
+ }
+ r = rback;
+ }
+
+ r.Inflate(-1, -1);
+
+ if (this.GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane)
+ {
+ if (this.CanHideResolved)
+ {
+ m_SystemButtons.CloseButtonRect = new Rectangle(r.Right - (m_SystemButtons.ButtonSize.Width + 3), r.Y + (r.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.CloseButton, m_SystemButtons.CloseButtonRect);
+ OnPreRender(re);
+ m_SystemButtons.CloseButtonRect = re.Bounds;
+ r.Width -= (m_SystemButtons.CloseButtonRect.Width + 3);
+ if (!re.Cancel)
+ PaintCloseButton(pa);
+ }
+ if (this.EffectiveCanMaximizeFloating)
+ {
+ m_SystemButtons.MaximizeButtonRect =
+ new Rectangle(r.Right - (m_SystemButtons.ButtonSize.Width + 3),
+ r.Y + (r.Height - m_SystemButtons.ButtonSize.Height)/2, m_SystemButtons.ButtonSize.Width,
+ m_SystemButtons.ButtonSize.Height);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.MaximizeButton,
+ m_SystemButtons.MaximizeButtonRect);
+ OnPreRender(re);
+ m_SystemButtons.MaximizeButtonRect = re.Bounds;
+ r.Width -= (m_SystemButtons.MaximizeButtonRect.Width + 3);
+ if (!re.Cancel)
+ PaintMaximizeButton(pa);
+ }
+ if (this.ShowCustomizeMenuButton)
+ {
+ m_SystemButtons.CustomizeButtonRect = new Rectangle(r.Right - (m_SystemButtons.ButtonSize.Width + 1), r.Y + (r.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.CustomizeButton, m_SystemButtons.CustomizeButtonRect);
+ OnPreRender(re);
+ m_SystemButtons.CustomizeButtonRect = re.Bounds;
+ r.Width -= (m_SystemButtons.CustomizeButtonRect.Width + 2);
+ if (!re.Cancel)
+ PaintCustomizeButton(pa);
+ }
+ r.X += 2;
+ r.Width -= 2;
+ if (r.Width > 0 && drawCaptionText)
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.CaptionText, r);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ System.Drawing.Font objFont = null;
+ try
+ {
+ objFont = new Font(this.Font, FontStyle.Bold);
+ }
+ catch
+ {
+ objFont = SystemFonts.MenuFont; // (Font)System.Windows.Forms.SystemInformation.MenuFont.Clone();
+ }
+ eTextFormat sf = eTextFormat.Default | eTextFormat.EndEllipsis | eTextFormat.SingleLine | eTextFormat.VerticalCenter;
+ if (m_CaptionForeColor.IsEmpty)
+ {
+ if (this.DrawThemedCaption)
+ {
+ if (m_HasFocus)
+ state = ThemeWindowStates.CaptionActive;
+ else
+ state = ThemeWindowStates.CaptionInactive;
+ r.Y += 1;
+ //theme.DrawText(g, this.Text, objFont, r, part, state, ThemeTextFormat.Left | ThemeTextFormat.VCenter);
+ }
+ //else
+ TextDrawing.DrawString(g, this.Text, objFont, ((m_HasFocus || this.LayoutType == eLayoutType.Toolbar) ? pa.Colors.BarCaptionText : pa.Colors.BarCaptionInactiveText), r, sf);
+ }
+ else
+ TextDrawing.DrawString(g, this.Text, objFont, m_CaptionForeColor, r, sf);
+ objFont.Dispose();
+ objFont = null;
+ }
+ }
+ }
+ else
+ {
+ this.PaintGrabHandle(pa);
+ }
+ }
+ else if (m_BarState == eBarState.Docked && BarFunctions.IsOffice2007Style(this.Style) && this.GetRenderer() != null && (!this.IsThemed || this.MenuBar))
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.DisplayRectangle);
+ OnPreRender(re);
+ if (!re.Cancel && this.BackColor != Color.Transparent)
+ {
+ ToolbarRendererEventArgs tre = new ToolbarRendererEventArgs(this, g, this.DisplayRectangle);
+ tre.ItemPaintArgs = pa;
+ this.GetRenderer().DrawToolbarBackground(tre);
+ }
+ else
+ PaintGrabHandle(pa);
+ }
+ else
+ {
+ p.Dispose();
+ p = null;
+ bool drawBorder = true;
+ // Docked state
+ if (m_ItemContainer.m_BackgroundColor.IsEmpty && this.BackColor != Color.Transparent)
+ {
+ if (this.IsThemed)
+ {
+ Rectangle r = new Rectangle(-this.Location.X, -this.Location.Y, this.Parent.Width, this.Parent.Height);
+ ThemeRebar theme = this.ThemeRebar;
+ theme.DrawBackground(g, ThemeRebarParts.Background, ThemeRebarStates.Normal, r);
+ }
+ else
+ {
+ sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.Default;
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.ClientRectangle);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ if (this.MenuBar)
+ {
+ if (!pa.Colors.MenuBarBackground2.IsEmpty && pa.Colors.MenuBarBackground2.A > 0)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(this.ClientRectangle, pa.Colors.MenuBarBackground, pa.Colors.MenuBarBackground2, pa.Colors.MenuBarBackgroundGradientAngle);
+ g.FillRectangle(gradient, this.ClientRectangle);
+ gradient.Dispose();
+ }
+ else if (IsGradientStyle && this.Parent != null && !pa.Colors.DockSiteBackColor2.IsEmpty && !pa.Colors.DockSiteBackColor.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(-this.Left, -this.Top, this.Parent.Width, this.Parent.Height), pa.Colors.DockSiteBackColor, pa.Colors.DockSiteBackColor2, 0f);
+ g.FillRectangle(gradient, -this.Left, -this.Top, this.Parent.Width, this.Parent.Height);
+ gradient.Dispose();
+ }
+ else
+ {
+ using (SolidBrush brush = new SolidBrush(pa.Colors.MenuBarBackground))
+ g.FillRectangle(brush, this.DisplayRectangle);
+ }
+ }
+ else
+ {
+ if (this.Style == eDotNetBarStyle.VS2005 && this.LayoutType == eLayoutType.DockContainer && !this.BackColor.IsEmpty)
+ {
+ DisplayHelp.FillRectangle(g, this.ClientRectangle, this.BackColor, Color.Empty);
+ }
+ else if (this.GradientBackground)
+ DisplayHelp.FillRectangle(g, this.ClientRectangle, pa.Colors.BarBackground, pa.Colors.BarBackground2, pa.Colors.BarBackgroundGradientAngle);
+ else
+ {
+ using (SolidBrush brush = new SolidBrush(pa.Colors.BarBackground))
+ g.FillRectangle(brush, this.ClientRectangle);
+ }
+ }
+ }
+ else
+ drawBorder = false;
+ g.SmoothingMode = sm;
+ }
+ }
+ else if (!m_ItemContainer.BackColor.IsEmpty)
+ {
+ sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.Default;
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.DisplayRectangle);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ using (SolidBrush brush = new SolidBrush(m_ItemContainer.BackColor))
+ g.FillRectangle(brush, this.DisplayRectangle);
+ }
+ else
+ drawBorder = false;
+ g.SmoothingMode = sm;
+ }
+
+ if (this.Parent != null && this.Parent.BackgroundImage != null && this.Parent is DockSite)
+ {
+ Rectangle r = new Rectangle(-this.Location.X, -this.Location.Y, this.Parent.Width, this.Parent.Height);
+ DockSite site = this.Parent as DockSite;
+ BarFunctions.PaintBackgroundImage(g, r, site.BackgroundImage, site.BackgroundImagePosition, site.BackgroundImageAlpha);
+ }
+ else
+ PaintBackgroundImage(pa.Graphics);
+
+ if (drawBorder)
+ {
+ if (IsGradientStyle && !this.IsThemed && this.LayoutType == eLayoutType.Toolbar && !this.MenuBar && this.BarType == eBarType.Toolbar && this.BackColor != Color.Transparent)
+ {
+ if (p != null) p.Dispose();
+ p = new Pen(pa.Colors.BarDockedBorder, 1);
+ g.DrawLine(p, 0, this.Height - 1, this.Width, this.Height - 1);
+ p.Dispose();
+ p = null;
+ }
+ else
+ {
+ Rectangle border = this.ClientRectangle;
+ border.Inflate(-2, -2);
+ BarFunctions.DrawBorder(g, m_DockedBorder, border, m_SingleLineColor);
+ }
+ }
+ PaintGrabHandle(pa);
+ }
+ m_ItemContainer.Paint(pa);
+ if (m_BarType == eBarType.StatusBar && this.GrabHandleStyle == eGrabHandleStyle.ResizeHandle)
+ {
+ PaintGrabHandle(pa);
+ }
+ if (p != null) p.Dispose();
+ g.SmoothingMode = sm;
+ g.TextRenderingHint = th;
+
+ if (HasPostRender)
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.All, this.ClientRectangle);
+ OnPostRender(re);
+ }
+ }
+
+ ///
+ /// Raises the PreRender event.
+ ///
+ /// Provides the event arguments
+ protected virtual void OnPreRender(RenderBarEventArgs e)
+ {
+ if (PreRender != null)
+ PreRender(this, e);
+ }
+
+ ///
+ /// Raises the PostRender event.
+ ///
+ /// Provides the event arguments
+ protected virtual void OnPostRender(RenderBarEventArgs e)
+ {
+ if (PostRender != null)
+ PostRender(this, e);
+ }
+
+ private bool HasPostRender
+ {
+ get
+ {
+ return PostRender != null;
+ }
+ }
+
+ private bool GradientBackground
+ {
+ get
+ {
+ if (this.Style == eDotNetBarStyle.VS2005 && this.LayoutType == eLayoutType.DockContainer)
+ return false;
+ return true;
+ }
+ }
+
+ internal bool ThemedBackground
+ {
+ get
+ {
+ if (this.IsThemed && m_ItemContainer.m_BackgroundColor.IsEmpty)
+ return true;
+ return false;
+ }
+ }
+
+ ///
+ /// Drawns bar grab handle if one specified.
+ ///
+ /// Context information.
+ internal void PaintGrabHandle(ItemPaintArgs pa)
+ {
+ RenderBarEventArgs re = null;
+ Graphics g = pa.Graphics;
+ // Draw grab handles
+ if (m_GrabHandleStyle != eGrabHandleStyle.None)
+ {
+ Rectangle r = Rectangle.Empty;
+
+ if (m_GrabHandleStyle != eGrabHandleStyle.Caption && m_GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane && m_GrabHandleStyle != eGrabHandleStyle.CaptionDotted && this.IsThemed && m_GrabHandleStyle != eGrabHandleStyle.ResizeHandle)
+ {
+ ThemeRebar theme = this.ThemeRebar;
+ ThemeRebarParts part = ThemeRebarParts.Gripper;
+
+ if (m_ItemContainer.Orientation == eOrientation.Vertical)
+ {
+ part = ThemeRebarParts.GripperVert;
+ r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, m_GrabHandleRect.Width - 4, 5);
+ }
+ else
+ r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, 5, m_GrabHandleRect.Height - 4);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
+ OnPreRender(re);
+ r = re.Bounds;
+ if (!re.Cancel)
+ theme.DrawBackground(g, part, ThemeRebarStates.Normal, r);
+ return;
+ }
+
+ Color clr = pa.Colors.BarBackground;
+ if (!m_ItemContainer.m_BackgroundColor.IsEmpty)
+ clr = m_ItemContainer.m_BackgroundColor;
+
+ switch (m_GrabHandleStyle)
+ {
+ case eGrabHandleStyle.Single:
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ {
+ r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, 3, m_GrabHandleRect.Height - 4);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
+ OnPreRender(re);
+ if (!re.Cancel)
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
+ }
+ else
+ {
+ r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, m_GrabHandleRect.Width - 4, 3);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
+ OnPreRender(re);
+ if (!re.Cancel)
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
+ }
+ break;
+ }
+ case eGrabHandleStyle.Double:
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ {
+ r = new Rectangle(m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 1, 3, m_GrabHandleRect.Height - 2);
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
+ r.Offset(3, 0);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
+ OnPreRender(re);
+ if (!re.Cancel)
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
+ }
+ else
+ {
+ r = new Rectangle(m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 1, m_GrabHandleRect.Width - 2, 3);
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
+ r.Offset(0, 3);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
+ OnPreRender(re);
+ if (!re.Cancel)
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
+ }
+ break;
+ }
+ case eGrabHandleStyle.DoubleThin:
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ {
+ r = new Rectangle(m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 2, 3, m_GrabHandleRect.Height - 4);
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Left | System.Windows.Forms.Border3DSide.Right, clr);
+ r.Offset(3, 0);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
+ OnPreRender(re);
+ if (!re.Cancel)
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Left | System.Windows.Forms.Border3DSide.Right, clr);
+ }
+ else
+ {
+ r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 1, m_GrabHandleRect.Width - 4, 2);
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Top | System.Windows.Forms.Border3DSide.Bottom, clr);
+ r.Offset(0, 3);
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
+ OnPreRender(re);
+ if (!re.Cancel)
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Top | System.Windows.Forms.Border3DSide.Bottom, clr);
+ }
+ break;
+ }
+ case eGrabHandleStyle.DoubleFlat:
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ Pen pen = new Pen(ControlPaint.Dark(clr), 1);
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ {
+ g.DrawLine(/*SystemPens.ControlDark*/pen, m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, m_GrabHandleRect.X + 2, m_GrabHandleRect.Height - 4);
+ g.DrawLine(/*SystemPens.ControlDark*/pen, m_GrabHandleRect.X + 5, m_GrabHandleRect.Top + 2, m_GrabHandleRect.X + 5, m_GrabHandleRect.Height - 4);
+ }
+ else
+ {
+ g.DrawLine(pen, m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, m_GrabHandleRect.Width - 4, m_GrabHandleRect.Y + 2);
+ g.DrawLine(pen, m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 5, m_GrabHandleRect.Width - 4, m_GrabHandleRect.Y + 5);
+ }
+ pen.Dispose();
+ pen = null;
+ }
+ break;
+ }
+ case eGrabHandleStyle.Dotted:
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ Brush brushDark = new SolidBrush(ControlPaint.Dark(clr));
+ Brush brushLight = new SolidBrush(ControlPaint.Light(clr));
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ {
+ for (int i = 0; i < (m_GrabHandleRect.Height - 4); i += 4)
+ {
+ g.FillRectangle(/*SystemBrushes.ControlDark*/brushDark, m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 2 + i, 2, 2);
+ g.FillRectangle(/*SystemBrushes.ControlLight*/brushLight, m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 2 + i, 1, 1);
+
+ g.FillRectangle(brushDark, m_GrabHandleRect.X + 5, m_GrabHandleRect.Top + 2 + i, 2, 2);
+ g.FillRectangle(brushLight, m_GrabHandleRect.X + 5, m_GrabHandleRect.Top + 2 + i, 1, 1);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < (m_GrabHandleRect.Width - 4); i += 4)
+ {
+ g.FillRectangle(SystemBrushes.ControlDark, m_GrabHandleRect.Left + 2 + i, m_GrabHandleRect.Y + 1, 2, 2);
+ g.FillRectangle(SystemBrushes.ControlLight, m_GrabHandleRect.Left + 2 + i, m_GrabHandleRect.Y + 1, 1, 1);
+
+ g.FillRectangle(SystemBrushes.ControlDark, m_GrabHandleRect.Left + 2 + i, m_GrabHandleRect.Y + 5, 2, 2);
+ g.FillRectangle(SystemBrushes.ControlLight, m_GrabHandleRect.Left + 2 + i, m_GrabHandleRect.Y + 5, 1, 1);
+ }
+ }
+ brushDark.Dispose();
+ brushLight.Dispose();
+ }
+ break;
+ }
+ case eGrabHandleStyle.Stripe:
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ {
+ for (int i = 0; i < (m_GrabHandleRect.Height - 4); i += 3)
+ BarFunctions.DrawBorder3D(g, m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + i + 2, 5, 2, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Top | System.Windows.Forms.Border3DSide.Bottom, clr);
+ //System.Windows.Forms.ControlPaint.DrawBorder3D(g,m_GrabHandleRect.X+2,m_GrabHandleRect.Top+i+2,5,2,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.Top | System.Windows.Forms.Border3DSide.Bottom);
+ }
+ else
+ {
+ for (int i = 0; i < (m_GrabHandleRect.Width - 4); i += 3)
+ BarFunctions.DrawBorder3D(g, m_GrabHandleRect.Left + i + 2, m_GrabHandleRect.Y + 2, 2, 5, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Right | System.Windows.Forms.Border3DSide.Left, clr);
+ //System.Windows.Forms.ControlPaint.DrawBorder3D(g,m_GrabHandleRect.Left+i+2,m_GrabHandleRect.Y+2,2,5,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.Right | System.Windows.Forms.Border3DSide.Left);
+ }
+ }
+ break;
+ }
+ case eGrabHandleStyle.StripeFlat:
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ Pen pen = new Pen(pa.Colors.BarStripeColor/*ControlPaint.Dark(clr)*/, 1);
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ {
+ for (int i = 2; i < (m_GrabHandleRect.Height - 6); i += 2)
+ g.DrawLine(/*SystemPens.ControlDark*/pen, m_GrabHandleRect.X + 3, m_GrabHandleRect.Top + i + 3, m_GrabHandleRect.X + 5, m_GrabHandleRect.Top + i + 3);
+ }
+ else
+ {
+ for (int i = 1; i < (m_GrabHandleRect.Width - 6); i += 2)
+ g.DrawLine(/*SystemPens.ControlDark*/pen, m_GrabHandleRect.Left + i + 3, m_GrabHandleRect.Y + 2, m_GrabHandleRect.Left + i + 3, m_GrabHandleRect.Y + 5);
+ }
+ pen.Dispose();
+ }
+ break;
+ }
+ case eGrabHandleStyle.CaptionTaskPane:
+ case eGrabHandleStyle.CaptionDotted:
+ {
+ Rectangle targetRect = m_GrabHandleRect;
+ Brush brush = null;
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.Caption, m_GrabHandleRect);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ if (m_BarState == eBarState.Floating)
+ {
+ DisplayHelp.FillRectangle(g, targetRect, pa.Colors.BarCaptionBackground, pa.Colors.BarCaptionBackground2, pa.Colors.BarCaptionBackgroundGradientAngle);
+ }
+ else
+ {
+ if (!this.CaptionBackColor.IsEmpty)
+ brush = new SolidBrush(this.CaptionBackColor);
+ if (pa.Colors.BarBackground2.IsEmpty)
+ {
+ if (m_HasFocus && m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ brush = new SolidBrush(pa.Colors.BarCaptionBackground);
+ else
+ brush = new SolidBrush(pa.Colors.BarBackground);
+ }
+ else
+ {
+ brush = BarFunctions.CreateLinearGradientBrush(targetRect, pa.Colors.BarBackground, pa.Colors.BarBackground2, pa.Colors.BarBackgroundGradientAngle);
+ }
+
+ g.FillRectangle(brush, targetRect);
+
+ brush.Dispose();
+ brush = null;
+ }
+
+ Brush brushDark = null;
+ Brush brushLight = new SolidBrush(ControlPaint.Light(clr));
+
+ if (!pa.Colors.BarStripeColor.IsEmpty)
+ {
+ clr = pa.Colors.BarStripeColor;
+ brushDark = new SolidBrush(clr);
+ }
+ else
+ brushDark = new SolidBrush(ControlPaint.Dark(clr));
+ int y = m_GrabHandleRect.Top + 4;
+ int x = m_GrabHandleRect.Left + 4;
+ for (int i = y; i <= m_GrabHandleRect.Bottom - 4; i += 5)
+ {
+ g.FillRectangle(brushLight, x + 1, i + 1, 2, 2);
+ g.FillRectangle(brushDark, x, i, 2, 2);
+ }
+ if (brushLight != null) brushLight.Dispose();
+ if (brushDark != null) brushDark.Dispose();
+ }
+
+ targetRect.X += 8;
+ targetRect.Width -= 8;
+
+ targetRect.Inflate(-1, -1);
+ PaintGrabHandleButtons(pa, ref targetRect);
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ PaintCaptionText(pa, targetRect);
+ break;
+ }
+ case eGrabHandleStyle.Caption:
+ {
+ Rectangle targetRect = m_GrabHandleRect;
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.Caption, m_GrabHandleRect);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ ThemeWindow theme = null;
+ ThemeWindowParts part = ThemeWindowParts.SmallCaption;
+ ThemeWindowStates state = ThemeWindowStates.CaptionInactive;
+ if (this.DrawThemedCaption)
+ theme = this.ThemeWindow;
+
+ if (m_DockedBorder == eBorderType.None)
+ targetRect.Inflate(-1, 0);
+ if (m_CaptionBackColor.IsEmpty)
+ {
+ if (this.Style == eDotNetBarStyle.Office2000)
+ {
+ if (m_HasFocus)
+ g.FillRectangle(SystemBrushes.ActiveCaption, targetRect);
+ else
+ g.FillRectangle(SystemBrushes.InactiveCaption, targetRect);
+ }
+ else
+ {
+ if (this.DrawThemedCaption)
+ {
+ if (m_HasFocus)
+ state = ThemeWindowStates.CaptionActive;
+ theme.DrawBackground(g, part, state, targetRect);
+ }
+ else
+ {
+ Color hatchForeColor, hatchBackColor;
+ if (m_HasFocus)
+ {
+ hatchForeColor = Color.FromArgb(128, pa.Colors.BarCaptionText);
+ hatchBackColor = pa.Colors.BarCaptionBackground;
+ if (pa.Colors.BarCaptionBackground2.IsEmpty)
+ DisplayHelp.FillRectangle(g, targetRect, pa.Colors.BarCaptionBackground);
+ else
+ {
+ using (System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(targetRect, pa.Colors.BarCaptionBackground, pa.Colors.BarCaptionBackground2, pa.Colors.BarCaptionBackgroundGradientAngle))
+ g.FillRectangle(gradient, targetRect);
+ }
+ }
+ else
+ {
+ hatchForeColor = Color.FromArgb(192, pa.Colors.BarCaptionInactiveText);
+ hatchBackColor = pa.Colors.BarCaptionInactiveBackground;
+ if (pa.Colors.BarCaptionInactiveBackground2.IsEmpty)
+ DisplayHelp.FillRectangle(g, targetRect, pa.Colors.BarCaptionInactiveBackground);
+ else
+ {
+ using (System.Drawing.Drawing2D.LinearGradientBrush brush = BarFunctions.CreateLinearGradientBrush(targetRect, pa.Colors.BarCaptionInactiveBackground, pa.Colors.BarCaptionInactiveBackground2, pa.Colors.BarCaptionInactiveBackgroundGAngle))
+ {
+ g.FillRectangle(brush, targetRect);
+ }
+ }
+
+ eDotNetBarStyle effectiveStyle = m_ItemContainer.EffectiveStyle;
+ if (effectiveStyle != eDotNetBarStyle.VS2005 && effectiveStyle != eDotNetBarStyle.Office2010 && !StyleManager.IsMetro(effectiveStyle))
+ {
+ Pen penCap = new Pen(pa.Colors.BarCaptionBackground, 1);
+ g.DrawLine(penCap, targetRect.X + 1, targetRect.Y, targetRect.Right - 2, targetRect.Y);
+ g.DrawLine(penCap, targetRect.X + 1, targetRect.Bottom - 1, targetRect.Right - 2, targetRect.Bottom - 1);
+ g.DrawLine(penCap, targetRect.X, targetRect.Y + 1, targetRect.X, targetRect.Bottom - 2);
+ g.DrawLine(penCap, targetRect.Right - 1, targetRect.Y + 1, targetRect.Right - 1, targetRect.Bottom - 2);
+ penCap.Dispose();
+ }
+ }
+ if (StyleManager.IsVisualStudio2012(StyleManager.Style))
+ {
+ Rectangle hatchRect = new Rectangle(targetRect.X, targetRect.Y + (targetRect.Height - 6) / 2, targetRect.Width, 6);
+ if (!string.IsNullOrEmpty(this.Text))
+ {
+ Size textSize = TextDrawing.MeasureString(g, this.Text, this.Font);
+ textSize.Width += 8;
+ if (textSize.Width < hatchRect.Width)
+ {
+ hatchRect.Width -= textSize.Width;
+ hatchRect.X += textSize.Width;
+ if (CanHideResolved)
+ hatchRect.Width -= 16;
+ if (GetPaintAutoHidePin())
+ hatchRect.Width -= 16;
+ if (ShowCustomizeMenuButton)
+ hatchRect.Width -= 16;
+ if (hatchRect.Width <= 0)
+ hatchRect = Rectangle.Empty;
+ }
+ else
+ hatchRect = Rectangle.Empty;
+ }
+ if (!hatchRect.IsEmpty)
+ {
+ Region oldClip = g.Clip;
+ g.SetClip(new Rectangle(hatchRect.X + 2, hatchRect.Y, hatchRect.Width - 2, hatchRect.Height), CombineMode.Intersect);
+ using (HatchBrush hatch = new HatchBrush(HatchStyle.Percent20, hatchForeColor, hatchBackColor))
+ g.FillRectangle(hatch, hatchRect);
+ g.Clip = oldClip;
+ if (oldClip != null) oldClip.Dispose();
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ DisplayHelp.FillRectangle(g, targetRect, m_CaptionBackColor);
+ }
+ }
+
+ targetRect.Inflate(-1, -1);
+
+ PaintGrabHandleButtons(pa, ref targetRect);
+
+ PaintCaptionText(pa, targetRect);
+ break;
+ }
+ case eGrabHandleStyle.ResizeHandle:
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.ResizeHandle, m_GrabHandleRect);
+ OnPreRender(re);
+ if (!re.Cancel && !StyleManager.IsMetro(m_ItemContainer.EffectiveStyle))
+ {
+ // Paint Internet Explorer-style dotted sizer in lower right
+ // draw light 'shadows'
+ Form form = this.FindForm();
+ if (form != null && form.WindowState == FormWindowState.Maximized)
+ break;
+ int direction = 1;
+ Point startLoc = new Point(this.ClientRectangle.Right, this.ClientRectangle.Bottom);
+ if (this.RightToLeft == RightToLeft.Yes)
+ {
+ direction = -1;
+ startLoc = new Point(0, this.ClientRectangle.Bottom - 2);
+ }
+ ColorFunctions.HLSColor hls = ColorFunctions.RGBToHSL(clr);
+ Color lightColor = ColorFunctions.HLSToRGB(hls.Hue, hls.Lightness + .3d, hls.Saturation);
+ Pen pen = new Pen(lightColor, 1);
+ g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 2,
+ startLoc.X - 3 * direction, startLoc.Y - 2);
+ g.DrawLine(pen, startLoc.X - 6 * direction, startLoc.Y - 2,
+ startLoc.X - 7 * direction, startLoc.Y - 2);
+ g.DrawLine(pen, startLoc.X - 10 * direction, startLoc.Y - 2,
+ startLoc.X - 11 * direction, startLoc.Y - 2);
+ g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 2,
+ startLoc.X - 2 * direction, startLoc.Y - 3);
+ g.DrawLine(pen, startLoc.X - 6 * direction, startLoc.Y - 2,
+ startLoc.X - 6 * direction, startLoc.Y - 3);
+ g.DrawLine(pen, startLoc.X - 10 * direction, startLoc.Y - 2,
+ startLoc.X - 10 * direction, startLoc.Y - 3);
+ g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 6,
+ startLoc.X - 3 * direction, startLoc.Y - 6);
+ g.DrawLine(pen, startLoc.X - 6 * direction, startLoc.Y - 6,
+ startLoc.X - 7 * direction, startLoc.Y - 6);
+ g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 6,
+ startLoc.X - 2 * direction, startLoc.Y - 7);
+ g.DrawLine(pen, startLoc.X - 6 * direction, startLoc.Y - 6,
+ startLoc.X - 6 * direction, startLoc.Y - 7);
+ g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 10,
+ startLoc.X - 3 * direction, startLoc.Y - 10);
+ g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 10,
+ startLoc.X - 2 * direction, startLoc.Y - 11);
+ pen.Dispose();
+
+ // draw dark squares
+ if (!StyleManager.IsMetro(m_ItemContainer.EffectiveStyle))
+ {
+ pen = new Pen(pa.Colors.BarStripeColor/*ControlPaint.Dark(clr)*/, 1);
+ g.DrawRectangle(pen, startLoc.X - 4 * direction, startLoc.Y - 4, 1, 1);
+ g.DrawRectangle(pen, startLoc.X - 8 * direction, startLoc.Y - 4, 1, 1);
+ g.DrawRectangle(pen, startLoc.X - 12 * direction, startLoc.Y - 4, 1, 1);
+ g.DrawRectangle(pen, startLoc.X - 4 * direction, startLoc.Y - 8, 1, 1);
+ g.DrawRectangle(pen, startLoc.X - 8 * direction, startLoc.Y - 8, 1, 1);
+ g.DrawRectangle(pen, startLoc.X - 4 * direction, startLoc.Y - 12, 1, 1);
+ pen.Dispose();
+ pen = null;
+ }
+ }
+ break;
+ }
+ case eGrabHandleStyle.Office2003:
+ case eGrabHandleStyle.Office2003SingleDot:
+ {
+ re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
+ OnPreRender(re);
+ if (!re.Cancel)
+ {
+ int x = m_GrabHandleRect.Left + (m_GrabHandleRect.Width - 3) / 2;
+ int y = m_GrabHandleRect.Top + 4;
+
+ if (m_GrabHandleStyle == eGrabHandleStyle.Office2003SingleDot)
+ {
+ x = m_GrabHandleRect.Left + (m_GrabHandleRect.Width - 3) / 2;
+ y = m_GrabHandleRect.Top + (m_GrabHandleRect.Height - 3) / 2;
+ }
+ else
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Vertical)
+ {
+ x = m_GrabHandleRect.Left + 4;
+ y = m_GrabHandleRect.Top + (m_GrabHandleRect.Height - 3) / 2;
+ }
+ }
+
+ Brush brushDark = null;
+ Brush brushLight = new SolidBrush(ControlPaint.Light(clr));
+
+ if (!pa.Colors.BarStripeColor.IsEmpty)
+ {
+ clr = pa.Colors.BarStripeColor;
+ brushDark = new SolidBrush(clr);
+ }
+ else
+ brushDark = new SolidBrush(ControlPaint.Dark(clr));
+
+ if (m_GrabHandleStyle == eGrabHandleStyle.Office2003SingleDot)
+ {
+ g.FillRectangle(brushLight, x + 1, y + 1, 2, 2);
+ g.FillRectangle(brushDark, x, y, 2, 2);
+ }
+ else
+ {
+ if (StyleManager.IsVisualStudio2012(StyleManager.Style))
+ {
+ Rectangle tr = new Rectangle(m_GrabHandleRect.X, m_GrabHandleRect.Y+2, 6, m_GrabHandleRect.Height-4);
+ Region oldClip = g.Clip;
+ g.SetClip(new Rectangle(tr.X, tr.Y + 1, tr.Width, tr.Height - 2), CombineMode.Intersect);
+ using (HatchBrush hatch = new HatchBrush(HatchStyle.Percent20, clr, pa.Colors.BarBackground))
+ g.FillRectangle(hatch, tr);
+ g.Clip = oldClip;
+ if (oldClip != null) oldClip.Dispose();
+ }
+ else
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Vertical)
+ {
+ for (int i = x; i <= m_GrabHandleRect.Right - 4; i += 5)
+ {
+ g.FillRectangle(brushLight, i + 1, y + 1, 2, 2);
+ g.FillRectangle(brushDark, i, y, 2, 2);
+ }
+ }
+ else
+ {
+ for (int i = y; i <= m_GrabHandleRect.Bottom - 4; i += 5)
+ {
+ g.FillRectangle(brushLight, x + 1, i + 1, 2, 2);
+ g.FillRectangle(brushDark, x, i, 2, 2);
+ }
+ }
+ }
+ }
+ brushDark.Dispose();
+ brushLight.Dispose();
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ private void PaintCaptionText(ItemPaintArgs pa, Rectangle targetRect)
+ {
+ Graphics g = pa.Graphics;
+ RenderBarEventArgs re = new RenderBarEventArgs(this, g, eBarRenderPart.CaptionText, targetRect);
+ OnPreRender(re);
+ if (re.Cancel) return;
+ System.Drawing.Font objFont = null;
+ bool bDisposeFont = false;
+ try
+ {
+ objFont = this.Font.Clone() as Font; //new Font(this.Font.Name, 8);
+ bDisposeFont = true;
+ }
+ catch
+ {
+ objFont = SystemFonts.MenuFont; // System.Windows.Forms.SystemInformation.MenuFont;
+ bDisposeFont = true;
+ }
+ eTextFormat sf = eTextFormat.Default | eTextFormat.SingleLine | eTextFormat.EndEllipsis | eTextFormat.VerticalCenter;
+ if (m_CaptionForeColor.IsEmpty)
+ {
+ if (this.IsThemed)
+ {
+ if (targetRect.Height < objFont.Height)
+ targetRect.Height = objFont.Height;
+ if (targetRect.Width > 0)
+ {
+ if (!m_HasFocus)
+ TextDrawing.DrawString(g, this.Text, objFont, SystemColors.WindowText, targetRect, sf);
+ else
+ TextDrawing.DrawString(g, this.Text, objFont, SystemColors.ActiveCaptionText, targetRect, sf);
+ }
+ }
+ else
+ {
+ if (targetRect.Height < objFont.Height)
+ targetRect.Height = objFont.Height;
+ if (targetRect.Width > 0)
+ {
+ Color textColor = pa.Colors.BarCaptionText;
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ textColor = pa.Colors.ItemText;
+ else if ((this.Style == eDotNetBarStyle.OfficeXP || this.Style == eDotNetBarStyle.Office2003 || this.Style == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(this.Style)) && !m_HasFocus)
+ textColor = pa.Colors.BarCaptionInactiveText;
+ TextDrawing.DrawString(g, this.Text, objFont, textColor, targetRect, sf);
+ }
+ }
+ }
+ else if (targetRect.Width > 0)
+ TextDrawing.DrawString(g, this.Text, objFont, m_CaptionForeColor, targetRect, sf);
+ if (bDisposeFont)
+ objFont.Dispose();
+ }
+
+ ///
+ /// Gets whether caption of floating bar will be drawn using themes.
+ ///
+ internal bool DrawThemedCaption
+ {
+ get
+ {
+ if (BarFunctions.IsOffice2007Style(this.Style) || !this.ThemeAware)
+ return false;
+ if (this.IsThemed || m_BarState == eBarState.Floating && BarFunctions.ThemedOS && Themes.ThemesActive && this.LayoutType == eLayoutType.DockContainer)
+ return true;
+ return false;
+ }
+ }
+
+ private bool GetPaintAutoHidePin()
+ {
+ bool ret = false;
+ if (m_CanAutoHide && m_ItemContainer.LayoutType == eLayoutType.DockContainer && m_BarState != eBarState.Floating)
+ {
+ if (this.Parent is DockSite && this.Parent.Dock == DockStyle.Fill)
+ ret = false;
+ else
+ ret = true;
+ }
+ return ret;
+ }
+
+ private void PaintGrabHandleButtons(ItemPaintArgs pa, ref Rectangle targetRect)
+ {
+ RenderBarEventArgs re = null;
+ if (this.CanHideResolved)
+ {
+ if (this.Style == eDotNetBarStyle.Office2000)
+ m_SystemButtons.CloseButtonRect = new Rectangle(targetRect.Right - 11, targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Width) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
+ else
+ m_SystemButtons.CloseButtonRect = new Rectangle(targetRect.Right - (m_SystemButtons.ButtonSize.Width + 1), targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
+ re = new RenderBarEventArgs(this, pa.Graphics, eBarRenderPart.CloseButton, m_SystemButtons.CloseButtonRect);
+ OnPreRender(re);
+ m_SystemButtons.CloseButtonRect = re.Bounds;
+ targetRect.Width -= (m_SystemButtons.CloseButtonRect.Width + 3);
+ if (!re.Cancel)
+ PaintCloseButton(pa);
+ }
+ if (GetPaintAutoHidePin())
+ {
+ if (this.Style == eDotNetBarStyle.Office2000)
+ m_SystemButtons.AutoHideButtonRect = new Rectangle(targetRect.Right - (m_SystemButtons.ButtonSize.Width - 1), targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
+ else
+ m_SystemButtons.AutoHideButtonRect = new Rectangle(targetRect.Right - (m_SystemButtons.ButtonSize.Width + 1), targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
+ re = new RenderBarEventArgs(this, pa.Graphics, eBarRenderPart.AutoHideButton, m_SystemButtons.AutoHideButtonRect);
+ OnPreRender(re);
+ m_SystemButtons.AutoHideButtonRect = re.Bounds;
+ targetRect.Width -= (m_SystemButtons.AutoHideButtonRect.Width + 3);
+ if (!re.Cancel)
+ PaintAutoHideButton(pa);
+ }
+ if (this.ShowCustomizeMenuButton)
+ {
+ re = new RenderBarEventArgs(this, pa.Graphics, eBarRenderPart.CustomizeButton, Rectangle.Empty);
+
+ if (this.Style == eDotNetBarStyle.Office2000)
+ {
+ m_SystemButtons.CustomizeButtonRect = new Rectangle(targetRect.X, targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
+ re.Bounds = m_SystemButtons.CustomizeButtonRect;
+ OnPreRender(re);
+ m_SystemButtons.CustomizeButtonRect = re.Bounds;
+ targetRect.Width -= (m_SystemButtons.CustomizeButtonRect.Width + 2);
+ targetRect.X += (m_SystemButtons.CustomizeButtonRect.Width + 2);
+ }
+ else
+ {
+ m_SystemButtons.CustomizeButtonRect = new Rectangle(targetRect.Right - (m_SystemButtons.ButtonSize.Width + 1), targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
+ re.Bounds = m_SystemButtons.CustomizeButtonRect;
+ OnPreRender(re);
+ m_SystemButtons.CustomizeButtonRect = re.Bounds;
+ targetRect.Width -= (m_SystemButtons.CustomizeButtonRect.Width + 2);
+ }
+
+ if (!re.Cancel)
+ PaintCustomizeButton(pa);
+ }
+
+ if (this.GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
+ {
+ targetRect.X += 2;
+ targetRect.Width -= 2;
+ targetRect.Inflate(0, -2);
+ m_SystemButtons.CaptionButtonRect = targetRect;
+ re = new RenderBarEventArgs(this, pa.Graphics, eBarRenderPart.CaptionTaskPane, m_SystemButtons.CaptionButtonRect);
+ OnPreRender(re);
+ m_SystemButtons.CaptionButtonRect = re.Bounds;
+ if (!re.Cancel)
+ PaintCaptionButton(pa);
+ }
+
+ targetRect.X += 2;
+ targetRect.Width -= 2;
+ }
+
+ protected void PaintOffice(Graphics g)
+ {
+ m_SystemButtons.CustomizeButtonRect = Rectangle.Empty;
+ m_SystemButtons.CloseButtonRect = Rectangle.Empty;
+
+ if (m_ItemContainer.BackColor.IsEmpty)
+ {
+ using (SolidBrush brush = new SolidBrush(SystemColors.Control))
+ g.FillRectangle(brush, this.DisplayRectangle);
+ }
+ else
+ {
+ using (SolidBrush brush = new SolidBrush(m_ItemContainer.BackColor))
+ g.FillRectangle(brush, this.DisplayRectangle);
+ }
+ ColorScheme cs = this.GetColorScheme();
+ PaintSideBar(g);
+ ItemPaintArgs pa = GetItemPaintArgs(g); // new ItemPaintArgs(m_Owner as IOwner, this, g, cs); // TODO: ADD SUPPORT FOR SCHEMES
+ //pa.DesignerSelection = m_DesignerSelection;
+ if (m_ItemContainer.SubItems.Count > 0)
+ {
+ if (m_BarState == eBarState.Popup)
+ {
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g, 0, 0, this.ClientSize.Width, this.ClientSize.Height, System.Windows.Forms.Border3DStyle.Raised);
+ PaintSideBar(g);
+ }
+ else if (m_BarState == eBarState.Floating)
+ {
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g, 0, 0, this.ClientSize.Width, this.ClientSize.Height, System.Windows.Forms.Border3DStyle.Raised | System.Windows.Forms.Border3DStyle.RaisedOuter);
+ if (m_CaptionBackColor.IsEmpty)
+ g.FillRectangle(SystemBrushes.ActiveCaption, 4, 4, this.ClientSize.Width - 8, 15);
+ else
+ {
+ using (SolidBrush b1 = new SolidBrush(m_CaptionBackColor))
+ g.FillRectangle(b1, 4, 4, this.ClientSize.Width - 8, 15);
+ }
+
+ System.Drawing.Font objFont = null;
+ bool bDisposeFont = false;
+ try
+ {
+ objFont = new Font(this.Font, FontStyle.Bold);
+ bDisposeFont = true;
+ }
+ catch
+ {
+ objFont = SystemFonts.MenuFont; // System.Windows.Forms.SystemInformation.MenuFont;
+ bDisposeFont = true;
+ }
+
+ Rectangle r = Rectangle.Empty;
+ if (this.ShowCustomizeMenuButton)
+ {
+ r = new Rectangle(18, 4, this.ClientSize.Width - 22, 15);
+ m_SystemButtons.CustomizeButtonRect = new Rectangle(5, 6, 15, 14);
+ PaintCustomizeButton(pa);
+ }
+ else
+ {
+ r = new Rectangle(4, 4, this.ClientSize.Width - 8, 15);
+ }
+ if (this.CanHideResolved)
+ {
+ m_SystemButtons.CloseButtonRect = new Rectangle(r.Right - m_SystemButtons.ButtonSize.Width, 6, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
+ PaintCloseButton(pa);
+ r.Width -= (m_SystemButtons.ButtonSize.Width + 1);
+ }
+
+ if (m_CaptionForeColor.IsEmpty)
+ TextDrawing.DrawString(g, this.Text, objFont, SystemColors.ActiveCaptionText, r, eTextFormat.Default);
+ else
+ TextDrawing.DrawString(g, this.Text, objFont, m_CaptionForeColor, r, eTextFormat.Default);
+
+ if (bDisposeFont)
+ objFont.Dispose();
+ }
+ else
+ {
+ // Docked state
+ BarFunctions.DrawBorder(g, m_DockedBorder, this.ClientRectangle, m_SingleLineColor);
+ PaintGrabHandle(pa);
+ }
+
+ m_ItemContainer.Paint(pa);
+ }
+ }
+ private void PaintMaximizeButton()
+ {
+ this.Invalidate(m_SystemButtons.MaximizeButtonRect);
+ this.Update();
+ }
+ private void PaintCloseButton()
+ {
+ this.Invalidate(m_SystemButtons.CloseButtonRect);
+ this.Update();
+ }
+ private void PaintCloseButton(ItemPaintArgs pa)
+ {
+ if (m_SystemButtons.CloseButtonRect.IsEmpty)
+ return;
+
+ Graphics g = pa.Graphics;
+
+ if (this.DrawThemedCaption)
+ {
+ ThemeWindow theme = this.ThemeWindow;
+ ThemeWindowParts part = ThemeWindowParts.SmallCloseButton;
+ ThemeWindowStates state = ThemeWindowStates.ButtonNormal;
+ if (m_SystemButtons.MouseDownClose)
+ state = ThemeWindowStates.ButtonPushed;
+ else if (m_SystemButtons.MouseOverClose)
+ state = ThemeWindowStates.ButtonHot;
+ theme.DrawBackground(g, part, state, m_SystemButtons.CloseButtonRect);
+ return;
+ }
+
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ {
+ ButtonState state = ButtonState.Normal;
+ if (m_SystemButtons.MouseDownClose)
+ state = ButtonState.Pushed;
+ ControlPaint.DrawCaptionButton(g, m_SystemButtons.CloseButtonRect, CaptionButton.Close, state);
+ }
+ else
+ {
+ Pen pen = null;
+
+ if (m_SystemButtons.MouseDownClose)
+ {
+ if (pa.Colors.ItemPressedBackground2.IsEmpty)
+ DisplayHelp.FillRectangle(g, m_SystemButtons.CloseButtonRect, pa.Colors.ItemPressedBackground);
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(m_SystemButtons.CloseButtonRect, pa.Colors.ItemPressedBackground, pa.Colors.ItemPressedBackground2, pa.Colors.ItemPressedBackgroundGradientAngle);
+ g.FillRectangle(gradient, m_SystemButtons.CloseButtonRect);
+ gradient.Dispose();
+ }
+ using (Pen p1 = new Pen(pa.Colors.ItemPressedBorder))
+ NativeFunctions.DrawRectangle(g, p1, m_SystemButtons.CloseButtonRect);
+ }
+ else if (m_SystemButtons.MouseOverClose)
+ {
+ pen = new Pen(pa.Colors.ItemHotText); //SystemPens.ControlText;
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(m_SystemButtons.CloseButtonRect, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, m_SystemButtons.CloseButtonRect);
+ gradient.Dispose();
+ }
+ else
+ DisplayHelp.FillRectangle(g, m_SystemButtons.CloseButtonRect, pa.Colors.ItemHotBackground);
+ pen.Dispose();
+ pen = null;
+ using (Pen p1 = new Pen(pa.Colors.ItemHotBorder))
+ NativeFunctions.DrawRectangle(g, p1, m_SystemButtons.CloseButtonRect);
+ }
+
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ pen = new Pen(pa.Colors.ItemText, Dpi.Width1);
+ else
+ pen = new Pen(((m_HasFocus || this.LayoutType == eLayoutType.Toolbar) ? pa.Colors.BarCaptionText : pa.Colors.BarCaptionInactiveText));
+ if (m_SystemButtons.MouseOverClose)
+ pen = new Pen(pa.Colors.ItemHotText, Dpi.Width1);
+ else if (m_SystemButtons.MouseDownClose)
+ pen = new Pen(pa.Colors.ItemPressedText, Dpi.Width1);
+ else if (!m_CaptionForeColor.IsEmpty)
+ pen = new Pen(m_CaptionForeColor, Dpi.Width1);
+ else if (!m_HasFocus && m_BarState != eBarState.Floating && m_GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane && m_GrabHandleStyle != eGrabHandleStyle.CaptionDotted)
+ pen = new Pen(pa.Colors.BarCaptionInactiveText, Dpi.Width1);
+
+ Point[] p = new Point[2];
+ Rectangle rect = m_SystemButtons.CloseButtonRect;
+ rect.Inflate(-1, -1);
+ p[0].X = rect.Left + Dpi.Width2;
+ p[0].Y = rect.Top + Dpi.Height3;
+ p[1].X = rect.Right - Dpi.Width4;
+ p[1].Y = rect.Bottom - Dpi.Height4;
+ g.DrawLine(pen, p[0], p[1]);
+ p[0].X++;
+ p[1].X++;
+ g.DrawLine(pen, p[0], p[1]);
+
+ p[0].X = rect.Right - Dpi.Width3;
+ p[0].Y = rect.Top + Dpi.Height3;
+ p[1].X = rect.Left + Dpi.Width3;
+ p[1].Y = rect.Bottom - Dpi.Height4;
+ g.DrawLine(pen, p[0], p[1]);
+ p[0].X--;
+ p[1].X--;
+ g.DrawLine(pen, p[0], p[1]);
+ pen.Dispose();
+ }
+ }
+ private void PaintMaximizeButton(ItemPaintArgs pa)
+ {
+ if (m_SystemButtons.MaximizeButtonRect.IsEmpty)
+ return;
+
+ Graphics g = pa.Graphics;
+
+ if (this.DrawThemedCaption)
+ {
+ ThemeWindow theme = this.ThemeWindow;
+ ThemeWindowParts part = ThemeWindowParts.SmallMaxCaption;
+ ThemeWindowStates state = ThemeWindowStates.ButtonNormal;
+ if (m_SystemButtons.MouseDownMaximize)
+ state = ThemeWindowStates.ButtonPushed;
+ else if (m_SystemButtons.MouseOverMaximize)
+ state = ThemeWindowStates.ButtonHot;
+ theme.DrawBackground(g, part, state, m_SystemButtons.MaximizeButtonRect);
+ return;
+ }
+
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ {
+ ButtonState state = ButtonState.Normal;
+ if (m_SystemButtons.MouseDownMaximize)
+ state = ButtonState.Pushed;
+ ControlPaint.DrawCaptionButton(g, m_SystemButtons.MaximizeButtonRect, CaptionButton.Maximize, state);
+ }
+ else
+ {
+ Pen pen = null;
+
+ if (m_SystemButtons.MouseDownMaximize)
+ {
+ if (pa.Colors.ItemPressedBackground2.IsEmpty)
+ DisplayHelp.FillRectangle(g, m_SystemButtons.MaximizeButtonRect, pa.Colors.ItemPressedBackground);
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(m_SystemButtons.MaximizeButtonRect, pa.Colors.ItemPressedBackground, pa.Colors.ItemPressedBackground2, pa.Colors.ItemPressedBackgroundGradientAngle);
+ g.FillRectangle(gradient, m_SystemButtons.CloseButtonRect);
+ gradient.Dispose();
+ }
+ using (Pen p1 = new Pen(pa.Colors.ItemPressedBorder))
+ NativeFunctions.DrawRectangle(g, p1, m_SystemButtons.MaximizeButtonRect);
+ }
+ else if (m_SystemButtons.MouseOverMaximize)
+ {
+ pen = new Pen(pa.Colors.ItemHotText); //SystemPens.ControlText;
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(m_SystemButtons.MaximizeButtonRect, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, m_SystemButtons.MaximizeButtonRect);
+ gradient.Dispose();
+ }
+ else
+ DisplayHelp.FillRectangle(g, m_SystemButtons.MaximizeButtonRect, pa.Colors.ItemHotBackground);
+ pen.Dispose();
+ pen = null;
+ using (Pen p1 = new Pen(pa.Colors.ItemHotBorder))
+ NativeFunctions.DrawRectangle(g, p1, m_SystemButtons.MaximizeButtonRect);
+ }
+
+ SolidBrush brush=null;
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ brush = new SolidBrush(pa.Colors.ItemText);
+ else
+ brush = new SolidBrush(((m_HasFocus || this.LayoutType == eLayoutType.Toolbar) ? pa.Colors.BarCaptionText : pa.Colors.BarCaptionInactiveText));
+ if (m_SystemButtons.MouseOverMaximize)
+ brush = new SolidBrush(pa.Colors.ItemHotText);
+ else if (m_SystemButtons.MouseDownMaximize)
+ brush = new SolidBrush(pa.Colors.ItemPressedText);
+ else if (!m_CaptionForeColor.IsEmpty)
+ brush = new SolidBrush(m_CaptionForeColor);
+ else if (!m_HasFocus && m_BarState != eBarState.Floating && m_GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane && m_GrabHandleStyle != eGrabHandleStyle.CaptionDotted)
+ brush = new SolidBrush(pa.Colors.BarCaptionInactiveText);
+
+
+ Rectangle rect = m_SystemButtons.MaximizeButtonRect;
+ rect.Inflate(-1, -1);
+ Region oldClip = g.Clip;
+ if (_IsMaximized)
+ {
+ Rectangle rMax = new Rectangle(rect.X + (rect.Width - Dpi.Width10) / 2 + Dpi.Width3, rect.Y + (rect.Height - Dpi.Height10) / 2, Dpi.Width7, Dpi.Height7);
+ g.SetClip(new Rectangle(rMax.X + Dpi.Width1, rMax.Y + Dpi.Height2, rMax.Width - Dpi.Width2, rMax.Height - Dpi.Height3), CombineMode.Exclude);
+ rMax.Offset(-Dpi.Width3, Dpi.Height3);
+ g.SetClip(new Rectangle(rMax.X + Dpi.Width1, rMax.Y + Dpi.Height2, rMax.Width - Dpi.Width2, rMax.Height - Dpi.Height3), CombineMode.Exclude);
+ rMax.Offset(Dpi.Width3, -Dpi.Height3);
+ g.FillRectangle(brush, rMax);
+ g.Clip = oldClip;
+ rMax.Offset(-Dpi.Width3, Dpi.Height3);
+ g.SetClip(new Rectangle(rMax.X + Dpi.Width1, rMax.Y + Dpi.Height2, rMax.Width - Dpi.Width2, rMax.Height - Dpi.Height3), CombineMode.Exclude);
+ g.FillRectangle(brush, rMax);
+ }
+ else
+ {
+ Rectangle rMax = new Rectangle(rect.X + (rect.Width - Dpi.Width9) / 2, rect.Y + (rect.Height - Dpi.Height9) / 2, Dpi.Width9, Dpi.Height9);
+ g.SetClip(new Rectangle(rMax.X + Dpi.Width1, rMax.Y + Dpi.Height3, rMax.Width - Dpi.Width2, rMax.Height - Dpi.Height4), CombineMode.Exclude);
+ g.FillRectangle(brush, rMax);
+ }
+ g.Clip = oldClip;
+ if (oldClip != null) oldClip.Dispose();
+ brush.Dispose();
+ }
+ }
+ private void PaintCaptionButton()
+ {
+ this.Invalidate(m_SystemButtons.CaptionButtonRect);
+ this.Update();
+ }
+ private void PaintCaptionButton(ItemPaintArgs pa)
+ {
+ if (m_SystemButtons.CaptionButtonRect.IsEmpty)
+ return;
+
+ Rectangle rect = m_SystemButtons.CaptionButtonRect;
+ Graphics g = pa.Graphics;
+
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ {
+ ButtonState state = ButtonState.Normal;
+ if (m_SystemButtons.MouseDownCaption)
+ state = ButtonState.Pushed;
+ ControlPaint.DrawButton(g, rect, state);
+ }
+ else
+ {
+ if (m_CaptionMenu != null && m_CaptionMenu.Expanded)
+ {
+ if (pa.Colors.ItemExpandedBackground2.IsEmpty)
+ DisplayHelp.FillRectangle(g, rect, pa.Colors.ItemExpandedBackground);
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(rect, pa.Colors.ItemExpandedBackground, pa.Colors.ItemExpandedBackground2, pa.Colors.ItemExpandedBackgroundGradientAngle);
+ g.FillRectangle(gradient, rect);
+ gradient.Dispose();
+ }
+ using (Pen p1 = new Pen(pa.Colors.ItemExpandedBorder))
+ NativeFunctions.DrawRectangle(g, p1, rect);
+ }
+ else if (m_SystemButtons.MouseDownCaption)
+ {
+ if (pa.Colors.ItemPressedBackground2.IsEmpty)
+ DisplayHelp.FillRectangle(g, rect, pa.Colors.ItemPressedBackground);
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(rect, pa.Colors.ItemPressedBackground, pa.Colors.ItemPressedBackground2, pa.Colors.ItemPressedBackgroundGradientAngle);
+ g.FillRectangle(gradient, rect);
+ gradient.Dispose();
+ }
+ using (Pen p1 = new Pen(pa.Colors.ItemPressedBorder))
+ NativeFunctions.DrawRectangle(g, p1, rect);
+ }
+ else if (m_SystemButtons.MouseOverCaption)
+ {
+ Pen pen = new Pen(pa.Colors.ItemHotText);
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(rect, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, rect);
+ gradient.Dispose();
+ }
+ else
+ DisplayHelp.FillRectangle(g, rect, pa.Colors.ItemHotBackground);
+ using (Pen p1 = new Pen(pa.Colors.ItemHotBorder))
+ NativeFunctions.DrawRectangle(g, p1, rect);
+ }
+ }
+ SolidBrush brush = null;
+ Color textColor = pa.Colors.ItemText;
+
+ if (m_SystemButtons.MouseOverCaption)
+ textColor = pa.Colors.ItemHotText;
+ else if (m_SystemButtons.MouseDownCaption)
+ textColor = pa.Colors.ItemPressedText;
+ else if (!m_CaptionForeColor.IsEmpty)
+ textColor = m_CaptionForeColor;
+ else
+ textColor = pa.Colors.ItemText;
+ brush = new SolidBrush(textColor);
+ eTextFormat format = eTextFormat.Default | eTextFormat.VerticalCenter | eTextFormat.EndEllipsis | eTextFormat.SingleLine;
+ Rectangle rText = rect;
+ rText.Width -= Dpi.Width12;
+ rText.X += Dpi.Width3;
+ if (rText.Width > Dpi.Width8)
+ TextDrawing.DrawString(g, this.Text, this.Font, textColor, rText, format);
+
+ Point[] p = new Point[3];
+ p[0].X = rect.Right - Dpi.Width9;
+ p[0].Y = rect.Top + (rect.Height + Dpi.Height6) / 2;
+ p[1].X = p[0].X - Dpi.Width4;
+ p[1].Y = p[0].Y - Dpi.Height5;
+ p[2].X = p[1].X + Dpi.Width9;
+ p[2].Y = p[1].Y;
+ g.FillPolygon(brush, p);
+
+ brush.Dispose();
+ }
+ private void PaintCustomizeButton()
+ {
+ this.Invalidate(m_SystemButtons.CustomizeButtonRect);
+ this.Update();
+ }
+ private void PaintCustomizeButton(ItemPaintArgs pa)
+ {
+ if (m_SystemButtons.CustomizeButtonRect.IsEmpty)
+ return;
+ Graphics g = pa.Graphics;
+ Brush brush = new SolidBrush(((m_HasFocus || this.LayoutType == eLayoutType.Toolbar) ? pa.Colors.BarCaptionText : pa.Colors.BarCaptionInactiveText));
+
+ if (!this.DrawThemedCaption)
+ {
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ {
+ Point[] p1 = new Point[3];
+ p1[0].X = m_SystemButtons.CustomizeButtonRect.X + Dpi.Width4;
+ p1[0].Y = m_SystemButtons.CustomizeButtonRect.Y + Dpi.Height8;
+ p1[1].X = p1[0].X - Dpi.Width3;
+ p1[1].Y = p1[0].Y - Dpi.Height4;
+ p1[2].X = p1[1].X + Dpi.Width7;
+ p1[2].Y = p1[1].Y;
+ g.FillPolygon(SystemBrushes.ActiveCaptionText, p1);
+ brush.Dispose();
+ return;
+ }
+ else
+ {
+ if (!m_CaptionForeColor.IsEmpty)
+ {
+ brush.Dispose();
+ brush = new SolidBrush(m_CaptionForeColor);
+ }
+ if (!m_HasFocus && m_BarState != eBarState.Floating)
+ {
+ brush.Dispose();
+ brush = new SolidBrush(pa.Colors.BarCaptionInactiveText);
+ }
+
+ if (m_SystemButtons.MouseDownCustomize)
+ {
+ if (pa.Colors.ItemPressedBackground2.IsEmpty)
+ {
+ using (SolidBrush b = new SolidBrush(pa.Colors.ItemPressedBackground))
+ g.FillRectangle(b, m_SystemButtons.CustomizeButtonRect);
+ }
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(m_SystemButtons.CustomizeButtonRect, pa.Colors.ItemPressedBackground, pa.Colors.ItemPressedBackground2, pa.Colors.ItemPressedBackgroundGradientAngle);
+ g.FillRectangle(gradient, m_SystemButtons.CustomizeButtonRect);
+ gradient.Dispose();
+ }
+ using (Pen p1 = new Pen(pa.Colors.ItemPressedBorder))
+ NativeFunctions.DrawRectangle(g, p1, m_SystemButtons.CustomizeButtonRect);
+ }
+ else if (m_SystemButtons.MouseOverCustomize)
+ {
+ brush.Dispose();
+ brush = new SolidBrush(pa.Colors.BarCaptionText); // SystemBrushes.ControlText;
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(m_SystemButtons.CustomizeButtonRect, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, m_SystemButtons.CustomizeButtonRect);
+ gradient.Dispose();
+ }
+ else
+ {
+ using (SolidBrush b = new SolidBrush(pa.Colors.ItemHotBackground))
+ g.FillRectangle(b, m_SystemButtons.CustomizeButtonRect);
+ }
+ using (Pen p1 = new Pen(pa.Colors.ItemHotBorder, Dpi.Width1))
+ NativeFunctions.DrawRectangle(g, p1, m_SystemButtons.CustomizeButtonRect);
+ }
+ }
+ }
+
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ {
+ brush.Dispose();
+ brush = new SolidBrush(pa.Colors.ItemText);
+ }
+ else
+ {
+ brush.Dispose();
+ brush = new SolidBrush(((m_HasFocus || this.LayoutType == eLayoutType.Toolbar) ? pa.Colors.BarCaptionText : pa.Colors.BarCaptionInactiveText));
+ }
+ if (m_SystemButtons.MouseOverCustomize)
+ {
+ brush.Dispose();
+ brush = new SolidBrush(pa.Colors.ItemHotText);
+ }
+ else if (m_SystemButtons.MouseDownCustomize)
+ {
+ brush.Dispose();
+ brush = new SolidBrush(pa.Colors.ItemPressedText);
+ }
+ else if (!m_CaptionForeColor.IsEmpty)
+ {
+ brush.Dispose();
+ brush = new SolidBrush(m_CaptionForeColor);
+ }
+ else if (!m_HasFocus && m_BarState != eBarState.Floating && m_GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane && m_GrabHandleStyle != eGrabHandleStyle.CaptionDotted)
+ {
+ brush.Dispose();
+ brush = new SolidBrush(pa.Colors.BarCaptionInactiveText);
+ }
+
+ Point[] p = new Point[3];
+ p[0].X = m_SystemButtons.CustomizeButtonRect.Right - Dpi.Width7;
+ p[0].Y = m_SystemButtons.CustomizeButtonRect.Top + Dpi.Height8;
+ p[1].X = p[0].X - Dpi.Width3;
+ p[1].Y = p[0].Y - Dpi.Height4;
+ p[2].X = p[1].X + Dpi.Width7;
+ p[2].Y = p[1].Y;
+ g.FillPolygon(brush, p);
+ brush.Dispose();
+ }
+ private void PaintAutoHideButton()
+ {
+ if (!m_SystemButtons.AutoHideButtonRect.IsEmpty)
+ {
+ Rectangle r = m_SystemButtons.AutoHideButtonRect;
+ r.Inflate(1, 1);
+ this.Invalidate(r);
+ this.Update();
+ }
+ }
+ private void PaintAutoHideButton(ItemPaintArgs pa)
+ {
+ if (m_SystemButtons.AutoHideButtonRect.IsEmpty)
+ return;
+
+ Graphics g = pa.Graphics;
+
+ if (this.DrawThemedCaption)
+ {
+ Image img = null;
+ if (m_SystemButtons.MouseDownAutoHide && !this.AutoHide || this.AutoHide && !m_SystemButtons.MouseDownAutoHide)
+ {
+ if (m_SystemButtons.MouseOverAutoHide)
+ img = BarFunctions.LoadBitmap("SystemImages.Pin.png");
+ else
+ img = BarFunctions.LoadBitmap("SystemImages.PinInactive.png");
+ g.DrawImage(img, m_SystemButtons.AutoHideButtonRect.X + (m_SystemButtons.AutoHideButtonRect.Width - img.Width) / 2, m_SystemButtons.AutoHideButtonRect.Y + (m_SystemButtons.AutoHideButtonRect.Height - img.Height) / 2, img.Width, img.Height);
+ }
+ else
+ {
+ if (m_SystemButtons.MouseOverAutoHide)
+ img = BarFunctions.LoadBitmap("SystemImages.PinPushed.png");
+ else
+ img = BarFunctions.LoadBitmap("SystemImages.PinPushedInactive.png");
+ g.DrawImage(img, m_SystemButtons.AutoHideButtonRect.X + (m_SystemButtons.AutoHideButtonRect.Width - img.Width) / 2, m_SystemButtons.AutoHideButtonRect.Y + (m_SystemButtons.AutoHideButtonRect.Height - img.Height) / 2, img.Width, img.Height);
+ }
+ return;
+ }
+
+
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ {
+ Rectangle r = m_SystemButtons.AutoHideButtonRect;
+ r.Inflate(1, 0);
+ if (m_SystemButtons.MouseDownAutoHide)
+ {
+ ControlPaint.DrawBorder3D(g, r, Border3DStyle.SunkenInner, Border3DSide.All);
+ }
+ else
+ {
+ ControlPaint.DrawBorder3D(g, r, Border3DStyle.Raised, Border3DSide.All);
+ }
+ }
+ else
+ {
+ if (m_SystemButtons.MouseDownAutoHide)
+ {
+ if (pa.Colors.ItemPressedBackground2.IsEmpty)
+ DisplayHelp.FillRectangle(g, m_SystemButtons.AutoHideButtonRect, pa.Colors.ItemPressedBackground);
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(m_SystemButtons.AutoHideButtonRect, pa.Colors.ItemPressedBackground, pa.Colors.ItemPressedBackground2, pa.Colors.ItemPressedBackgroundGradientAngle);
+ g.FillRectangle(gradient, m_SystemButtons.AutoHideButtonRect);
+ gradient.Dispose();
+ }
+ using (Pen p1 = new Pen(pa.Colors.ItemPressedBorder))
+ NativeFunctions.DrawRectangle(g, p1, m_SystemButtons.AutoHideButtonRect);
+ }
+ else if (m_SystemButtons.MouseOverAutoHide)
+ {
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(m_SystemButtons.AutoHideButtonRect, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, m_SystemButtons.AutoHideButtonRect);
+ gradient.Dispose();
+ }
+ else
+ DisplayHelp.FillRectangle(g, m_SystemButtons.AutoHideButtonRect, pa.Colors.ItemHotBackground);
+ using (Pen p1 = new Pen(pa.Colors.ItemHotBorder))
+ NativeFunctions.DrawRectangle(g, p1, m_SystemButtons.AutoHideButtonRect);
+ }
+ }
+ if (m_SystemButtons.MouseDownAutoHide && !this.AutoHide || this.AutoHide && !m_SystemButtons.MouseDownAutoHide)
+ {
+ Rectangle r = new Rectangle(m_SystemButtons.AutoHideButtonRect.X + (m_SystemButtons.AutoHideButtonRect.Width - Dpi.Width10) / 2, m_SystemButtons.AutoHideButtonRect.Y + (m_SystemButtons.AutoHideButtonRect.Height - Dpi.Height7) / 2, Dpi.Width10, Dpi.Height7);
+
+ Pen pen = null;
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ pen = new Pen(pa.Colors.ItemText, Dpi.Width1);
+ else
+ pen = new Pen(((m_HasFocus || this.LayoutType == eLayoutType.Toolbar) ? pa.Colors.BarCaptionText : pa.Colors.BarCaptionInactiveText));
+ if (m_SystemButtons.MouseOverAutoHide)
+ pen = new Pen(pa.Colors.ItemHotText, Dpi.Width1);
+ else if (m_SystemButtons.MouseDownAutoHide)
+ pen = new Pen(pa.Colors.ItemPressedText, Dpi.Width1);
+ else if (!m_CaptionForeColor.IsEmpty)
+ pen = new Pen(m_CaptionForeColor, Dpi.Width1);
+ else if (!m_HasFocus && m_BarState != eBarState.Floating && m_GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane && m_GrabHandleStyle != eGrabHandleStyle.CaptionDotted)
+ pen = new Pen(pa.Colors.BarCaptionInactiveText, Dpi.Width1);
+
+ g.DrawRectangle(pen, r.X + Dpi.Width4, r.Y + Dpi.Height1, Dpi.Width5, Dpi.Height4);
+ g.DrawLine(pen, r.X + Dpi.Width4, r.Y + Dpi.Height4, r.X + Dpi.Width9, r.Y + Dpi.Height4);
+ g.DrawLine(pen, r.X + Dpi.Width4, r.Y, r.X + Dpi.Width4, r.Y + Dpi.Height6);
+ g.DrawLine(pen, r.X, r.Y + Dpi.Height3, r.X + Dpi.Width3, r.Y + Dpi.Height3);
+ }
+ else
+ {
+ Rectangle r = new Rectangle(m_SystemButtons.AutoHideButtonRect.X + (m_SystemButtons.AutoHideButtonRect.Width - Dpi.Width7) / 2, m_SystemButtons.AutoHideButtonRect.Y + (m_SystemButtons.AutoHideButtonRect.Height - Dpi.Height9) / 2, Dpi.Width7, Dpi.Height9);
+
+ Pen pen = null;
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ pen = new Pen(pa.Colors.ItemText, Dpi.Width1);
+ else
+ pen = new Pen(((m_HasFocus || this.LayoutType == eLayoutType.Toolbar) ? pa.Colors.BarCaptionText : pa.Colors.BarCaptionInactiveText), Dpi.Width1);
+ if (m_SystemButtons.MouseOverAutoHide)
+ pen = new Pen(pa.Colors.ItemHotText, Dpi.Width1);
+ else if (m_SystemButtons.MouseDownAutoHide)
+ pen = new Pen(pa.Colors.ItemPressedText, Dpi.Width1);
+ else if (!m_CaptionForeColor.IsEmpty)
+ pen = new Pen(m_CaptionForeColor, Dpi.Width1);
+ else if (!m_HasFocus && m_BarState != eBarState.Floating && m_GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane && m_GrabHandleStyle != eGrabHandleStyle.CaptionDotted)
+ pen = new Pen(pa.Colors.BarCaptionInactiveText, Dpi.Width1);
+
+ g.DrawRectangle(pen, r.X + Dpi.Width1, r.Y, Dpi.Width4, Dpi.Height5);
+ g.DrawLine(pen, r.X + Dpi.Width4, r.Y, r.X + Dpi.Width4, r.Y + Dpi.Height5);
+ g.DrawLine(pen, r.X, r.Y + Dpi.Height5, r.X + Dpi.Width6, r.Y + Dpi.Height5);
+ g.DrawLine(pen, r.X + Dpi.Width3, r.Y + Dpi.Height5, r.X + Dpi.Width3, r.Y + Dpi.Height8);
+ }
+ }
+
+ ///
+ /// Paints bar side bar.
+ ///
+ /// Reference to graphics object.
+ internal void PaintSideBar(Graphics g)
+ {
+ if (m_SideBarImage.Picture == null || m_BarState != eBarState.Popup)
+ return;
+
+ if (!m_SideBarImage.GradientColor1.IsEmpty && !m_SideBarImage.GradientColor2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush lgb = BarFunctions.CreateLinearGradientBrush(m_SideBarRect, m_SideBarImage.GradientColor1, m_SideBarImage.GradientColor2, m_SideBarImage.GradientAngle);
+ g.FillRectangle(lgb, m_SideBarRect);
+ }
+ else if (!m_SideBarImage.BackColor.Equals(Color.Empty))
+ DisplayHelp.FillRectangle(g, m_SideBarRect, m_SideBarImage.BackColor);
+
+ if (m_SideBarImage.StretchPicture)
+ {
+ g.DrawImage(m_SideBarImage.Picture, m_SideBarRect);
+ }
+ else
+ {
+ if (m_SideBarImage.Alignment == eAlignment.Top)
+ g.DrawImage(m_SideBarImage.Picture, m_SideBarRect.X, m_SideBarRect.Top, m_SideBarRect.Width, m_SideBarImage.Picture.Height);
+ else if (m_SideBarImage.Alignment == eAlignment.Bottom)
+ g.DrawImage(m_SideBarImage.Picture, m_SideBarRect.Left, m_SideBarRect.Bottom - m_SideBarImage.Picture.Height, m_SideBarImage.Picture.Width, m_SideBarImage.Picture.Height);
+ else
+ g.DrawImage(m_SideBarImage.Picture, m_SideBarRect.Left, m_SideBarRect.Top + (m_SideBarRect.Height - m_SideBarImage.Picture.Height) / 2, m_SideBarImage.Picture.Width, m_SideBarImage.Picture.Height);
+ }
+ }
+
+ internal BaseItem ParentInternal
+ {
+ get
+ {
+ return m_ParentItem;
+ }
+ }
+
+ ///
+ /// Gets/Sets the parent item of the Bar. The parents item sub-items are displayed on the bar.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public BaseItem ParentItem
+ {
+ get
+ {
+ if (m_ParentItem != null)
+ return m_ParentItem;
+ return m_ItemContainer;
+ }
+ set
+ {
+ RestoreContainer();
+
+ if (m_ItemContainer.SubItems.Count > 0)
+ m_ItemContainer.SubItems.Clear();
+
+ m_ParentItem = value;
+
+ if (m_ParentItem == null || m_ParentItem.SubItems.Count == 0)
+ return;
+
+ m_ItemContainer.Style = m_ParentItem.Style;
+
+ BaseItem objTmp = m_ParentItem.SubItems[0];
+ if (objTmp != null)
+ m_OldContainer = objTmp.ContainerControl;
+ else
+ m_OldContainer = null;
+
+ m_ItemContainer.SubItems.AllowParentRemove = false;
+ foreach (BaseItem objItem in m_ParentItem.SubItems)
+ {
+ objItem.ContainerControl = this;
+ m_ItemContainer.SubItems.Add(objItem);
+ }
+ m_ItemContainer.SubItems.AllowParentRemove = true;
+
+ // Get the parent's screen position
+ if (m_ParentItem.Displayed)
+ {
+ System.Windows.Forms.Control objCtrl = m_ParentItem.ContainerControl as System.Windows.Forms.Control;
+ if (BaseItem.IsHandleValid(objCtrl))
+ {
+ m_ParentItemScreenPos = objCtrl.PointToScreen(new Point(m_ParentItem.LeftInternal, m_ParentItem.TopInternal));
+ objCtrl = null;
+ }
+ }
+ }
+ }
+
+ private void SetupRegion()
+ {
+ if (m_BarState != eBarState.Popup)
+ return;
+
+ Rectangle r = new Rectangle(0, 0, this.Width, this.Height);
+ System.Drawing.Region rgn = new System.Drawing.Region(r);
+ r.X = this.Width - 2;
+ r.Y = 0;
+ r.Width = 2;
+ r.Height = 2;
+ rgn.Xor(r);
+ r.X = 0;
+ r.Y = this.Height - 2;
+ r.Width = 2;
+ r.Height = 2;
+ rgn.Xor(r);
+ this.Region = rgn;
+ }
+
+ private void SetRoundRegion(Control c)
+ {
+ Rectangle rectPath = c.ClientRectangle;
+ rectPath.Width--;
+ rectPath.Height--;
+ GraphicsPath path = DisplayHelp.GetRoundedRectanglePath(rectPath, m_CornerSize);
+ Region r = new Region();
+ r.MakeEmpty();
+ r.Union(path);
+ // Widen path for the border...
+ path.Widen(SystemPens.ControlText);
+ r.Union(path);
+ c.Region = r;
+ }
+
+ ///
+ /// Recalculates the layout of the Bar, resizes the Bar if necessary and repaints it.
+ ///
+ public void RecalcLayout()
+ {
+ if (m_LayoutSuspended || IsDisposing) return;
+
+ if (m_BarState == eBarState.Docked)
+ {
+ if (this.Parent != null && !PassiveBar)
+ {
+ if (m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ this.Invalidate(this.Region, true);
+
+ if (this.Parent is DockSite)
+ ((DockSite)this.Parent).RecalcLayout();
+ else
+ {
+ RecalcSize();
+ this.Refresh();
+ }
+ ResizeDockTab();
+ }
+ }
+ else
+ {
+ RecalcSize();
+ ResizeDockTab();
+ this.Refresh();
+ }
+ }
+
+ internal void OnDockContainerWidthChanged(DockContainerItem item, int width)
+ {
+ if (m_LayoutSuspended)
+ return;
+
+ if (this.DockSide == eDockSide.Document || this.Parent is DockSite && ((DockSite)this.Parent).DocumentDockContainer != null)
+ {
+ ((DockSite)this.DockedSite).GetDocumentUIManager().SetBarWidth(this, width + 2);
+ }
+ else if (m_BarState == eBarState.AutoHide)
+ {
+ m_ItemContainer.MinWidth = width;
+ m_LastDockSiteInfo.DockedWidth = width + 2;
+ }
+ //else
+ //{
+ // m_ItemContainer.MinWidth=width+2;
+ // if(this.AutoHide)
+ // m_LastDockSiteInfo.DockedWidth=width+2;
+
+ // ChangeSplitSize(new Size(width+2,0));
+
+ // this.RecalcLayout();
+ //}
+ }
+
+ internal void OnDockContainerHeightChanged(DockContainerItem item, int height)
+ {
+ if (m_LayoutSuspended)
+ return;
+
+ if (this.DockSide == eDockSide.Document || this.Parent is DockSite && ((DockSite)this.Parent).DocumentDockContainer != null)
+ {
+ ((DockSite)this.DockedSite).GetDocumentUIManager().SetBarHeight(this, height + this.GetNonClientHeight());
+ }
+ else if (m_BarState == eBarState.AutoHide)
+ {
+ m_ItemContainer.MinHeight = height;
+ m_LastDockSiteInfo.DockedHeight = height + 2;
+ }
+ //else
+ //{
+ // m_ItemContainer.MinHeight=height+2;
+ // if(this.AutoHide)
+ // m_LastDockSiteInfo.DockedHeight=height+2;
+
+ // ChangeSplitSize(new Size(0,height+this.GetNonClientHeight())); // Accounts for caption size and border
+
+ // this.RecalcLayout();
+ //}
+ }
+
+ internal void OnDockContainerMinimumSizeChanged(DockContainerItem item)
+ {
+ if (this.AutoHide)
+ {
+ m_LastDockSiteInfo.DockedHeight = 0;
+ m_LastDockSiteInfo.DockedWidth = 0;
+ }
+ }
+
+ private void ChangeSplitSize(System.Drawing.Size size)
+ {
+ // Support for resizing of the side-by-side docked bars i.e. on the same line
+ if (this.Parent != null && this.Parent.Controls.Count > 1)
+ {
+ Bar barLeft = null, barRight = null;
+
+ Bar previous = this.GetPreviousVisibleBar(this);
+ Bar next = this.GetNextVisibleBar(this);
+ if (next != null && next.LayoutType == eLayoutType.DockContainer && next.DockLine == this.DockLine)
+ {
+ barLeft = this;
+ barRight = next;
+ }
+ else if (previous != null && previous.LayoutType == eLayoutType.DockContainer && previous.DockLine == this.DockLine)
+ {
+ barLeft = previous;
+ barRight = this;
+ if (size.Width > 0)
+ size.Width = barLeft.Width + (barRight.Width - size.Width);
+ if (size.Height > 0)
+ size.Height = barLeft.Height + (barRight.Height - size.Height);
+ }
+
+ if (this.DockSide == eDockSide.Left || this.DockSide == eDockSide.Right)
+ {
+ if (barLeft != null && barRight != null && barLeft.DockLine == barRight.DockLine)
+ {
+ System.Drawing.Size minLeftSize = barLeft.MinimumDockSize(eOrientation.Horizontal);
+ System.Drawing.Size minThisSize = barRight.MinimumDockSize(eOrientation.Horizontal);
+ int heightOffset = size.Height - barLeft.Height;
+ if (size.Height >= minLeftSize.Height && barRight.Height - heightOffset >= minThisSize.Height)
+ {
+ Size oldLeftBarSize = barLeft.Size;
+ Size oldSize = barRight.Size;
+ Size newBarLeftSize = barLeft.RecalcSizeOnly(new Size(barLeft.Width, size.Height));
+ Size newSize = barRight.RecalcSizeOnly(new Size(barRight.Width, barRight.Height - heightOffset));
+ if (!oldLeftBarSize.Equals(newBarLeftSize) && !oldSize.Equals(newSize))
+ {
+ barRight.SplitDockHeight = 0;
+ barLeft.SplitDockHeight = size.Height;
+ }
+ }
+ }
+ else
+ {
+ this.SplitDockHeight = 0;
+ this.SplitDockWidth = 0;
+ }
+ }
+ else if (this.DockSide == eDockSide.Top || this.DockSide == eDockSide.Bottom)
+ {
+ if (barLeft != null && barRight != null && barLeft.DockLine == barRight.DockLine)
+ {
+ System.Drawing.Size minLeftSize = barLeft.MinimumDockSize(eOrientation.Horizontal);
+ System.Drawing.Size minThisSize = barRight.MinimumDockSize(eOrientation.Horizontal);
+ int widthOffset = size.Width - barLeft.Width;
+ if (size.Width >= minLeftSize.Width && barRight.Width - widthOffset >= minThisSize.Width)
+ {
+ Size oldLeftBarSize = barLeft.Size;
+ Size oldSize = barRight.Size;
+ Size newBarLeftSize = barLeft.RecalcSizeOnly(new Size(size.Width, barLeft.Height));
+ Size newSize = barRight.RecalcSizeOnly(new Size(barRight.Width - widthOffset, barRight.Height));
+ if (!oldLeftBarSize.Equals(newBarLeftSize) && !oldSize.Equals(newSize))
+ {
+ barRight.SplitDockWidth = 0;
+ barLeft.SplitDockWidth = size.Width;
+ }
+ }
+ }
+ else
+ {
+ this.SplitDockHeight = 0;
+ this.SplitDockWidth = 0;
+ }
+ }
+ }
+ }
+
+ internal int SplitDockHeight
+ {
+ get
+ {
+ if (this.Parent != null && m_SplitDockHeightPercent > 0)
+ {
+ int height = ((this.Parent.Height * m_SplitDockHeightPercent) / 1000);
+ Size sz = GetAdjustedFullSize(this.MinimumDockSize(eOrientation.Horizontal));
+ if (height < sz.Height)
+ height = sz.Height;
+ return height;
+ }
+ return 0;
+ }
+ set
+ {
+ if (this.Parent != null && value > 0)
+ {
+ if (value > this.Parent.Height)
+ value = this.Parent.Height;
+ m_SplitDockHeightPercent = (int)(((float)value / (float)this.Parent.Height) * 1000);
+ }
+ else
+ m_SplitDockHeightPercent = 0;
+ }
+ }
+ internal int SplitDockWidth
+ {
+ get
+ {
+ if (this.Parent != null && m_SplitDockWidthPercent > 0)
+ {
+ return ((this.Parent.Width * m_SplitDockWidthPercent) / 1000);
+ }
+ return 0;
+ }
+ set
+ {
+ if (this.Parent != null && value > 0)
+ {
+ if (value > this.Parent.Width)
+ value = this.Parent.Width;
+ m_SplitDockWidthPercent = (int)(((float)value / (float)this.Parent.Width) * 1000);
+ }
+ else
+ m_SplitDockWidthPercent = 0;
+ }
+ }
+
+ internal int MinHeight
+ {
+ get
+ {
+ if (m_ItemContainer.MinHeight > 0)
+ return m_ItemContainer.MinHeight + GetNonClientHeight();
+ return 0;
+ }
+ set
+ {
+ if (m_ItemContainer == null) return;
+ if (value > 0)
+ m_ItemContainer.MinHeight = value - GetNonClientHeight();
+ else
+ m_ItemContainer.MinHeight = 0;
+ }
+ }
+ internal int GetNonClientHeight()
+ {
+ return GetGrabHandleCaptionHeight() + 2; // Caption + border
+ }
+
+ private bool m_RecalculatingSize = false; // Used to preven re-entrancy
+ ///
+ /// Recalculates the layout of the Bar and repaints it. This will not change the size of the Bar it will only force the recalculation of the size for each contained item and it will repaint the bar. To ensure that Bar is resized if necessary as well call RecalcLayout method.
+ ///
+ public void RecalcSize()
+ {
+ if (!BarFunctions.IsHandleValid(this))
+ return;
+
+ m_GrabHandleRect = Rectangle.Empty;
+ if (m_RecalculatingSize || m_ItemContainer == null)
+ return;
+ Form form = this.FindForm();
+ if (form != null && form.WindowState == FormWindowState.Minimized)
+ return;
+
+ m_RecalculatingSize = true;
+
+ if (this.LayoutType == eLayoutType.DockContainer && m_TabDockItems == null)
+ RefreshDockTab(false);
+
+ try
+ {
+ //m_ItemContainer.IsRightToLeft = (this.RightToLeft == RightToLeft.Yes);
+ if (m_BarState == eBarState.Docked)
+ {
+ m_ItemContainer.WrapItems = m_WrapItemsDock;
+ m_ItemContainer.Stretch = m_DockStretch;
+ }
+ else if (m_BarState == eBarState.Floating || m_BarState == eBarState.AutoHide)
+ {
+ m_ItemContainer.WrapItems = m_WrapItemsFloat;
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer)
+ m_ItemContainer.Stretch = m_DockStretch;
+ else
+ m_ItemContainer.Stretch = false;
+ }
+ else
+ {
+ m_ItemContainer.WrapItems = true;
+ m_ItemContainer.Stretch = false;
+ }
+
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ {
+ if (m_BarState == eBarState.Docked && !(this.Parent is DockSite))
+ {
+ System.Drawing.Size size = RecalcSizeOffice();
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal)
+ this.Height = size.Height;
+ else
+ this.Width = size.Width;
+ }
+ else
+ this.ClientSize = RecalcSizeOffice();
+ }
+ else
+ {
+ if (m_BarState == eBarState.Docked && !(this.Parent is DockSite))
+ {
+ System.Drawing.Size size = RecalcSizeDotNet();
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal)
+ this.Height = size.Height;
+ else
+ this.Width = size.Width;
+ }
+ else
+ this.ClientSize = RecalcSizeDotNet();
+ }
+
+ if (m_DropShadow != null)
+ NativeFunctions.SetWindowPos(m_DropShadow.Handle, new IntPtr(NativeFunctions.HWND_NOTOPMOST), this.Left + 5, this.Top + 5, this.Width - 2, this.Height - 2, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
+
+ if (m_BarState == eBarState.Docked)
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal)
+ m_DockedSizeH = this.Size;
+ else
+ m_DockedSizeV = this.Size;
+ RefreshOffice2003Region();
+ }
+ else if (this.Region != null)
+ this.Region = null;
+ if (m_BarState == eBarState.Floating && !PassiveBar)
+ {
+ m_Float.RefreshRegion(this.ClientSize);
+ m_Float.ClientSize = this.ClientSize;
+ }
+ }
+ finally
+ {
+ m_RecalculatingSize = false;
+ }
+
+ if (this.LayoutType == eLayoutType.DockContainer && m_TabDockItems != null && this.DesignMode && this.Site != null)
+ RefreshDockTab(false);
+
+ OnItemLayoutUpdated(EventArgs.Empty);
+ }
+
+ ///
+ /// Occurs after internal item layout has been updated and items have valid bounds assigned.
+ ///
+ public event EventHandler ItemLayoutUpdated;
+ ///
+ /// Raises ItemLayoutUpdated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnItemLayoutUpdated(EventArgs e)
+ {
+ EventHandler handler = ItemLayoutUpdated;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ private void RefreshOffice2003Region()
+ {
+ if (m_RoundCorners && IsGradientStyle && !this.MenuBar && this.LayoutType == eLayoutType.Toolbar && this.BarType == eBarType.Toolbar && !this.IsThemed && this.GrabHandleStyle != eGrabHandleStyle.ResizeHandle && this.BackColor != Color.Transparent)
+ {
+ System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
+ path.AddLine(0, 2, 2, 0);
+ path.AddLine(2, 0, this.Width - 2, 0);
+ path.AddLine(this.Width, 2, this.Width, this.Height - 3);
+ path.AddLine(this.Width - 3, this.Height, 3, this.Height);
+ path.AddLine(2, this.Height, 0, this.Height - 3);
+ this.Region = new Region(path);
+ }
+ else if (this.Region != null)
+ this.Region = null;
+ }
+
+ internal void RecalcSize(System.Drawing.Size frameSize)
+ {
+ m_GrabHandleRect = Rectangle.Empty;
+ if (m_RecalculatingSize || m_ItemContainer == null)
+ return;
+ m_RecalculatingSize = true;
+
+ try
+ //if(m_ItemContainer.SubItemsCount>0)
+ {
+ if (m_BarState == eBarState.Docked)
+ {
+ m_ItemContainer.WrapItems = m_WrapItemsDock;
+ m_ItemContainer.Stretch = m_DockStretch;
+ }
+ else if (m_BarState == eBarState.Floating || m_BarState == eBarState.AutoHide)
+ {
+ m_ItemContainer.WrapItems = m_WrapItemsFloat;
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer)
+ m_ItemContainer.Stretch = m_DockStretch;
+ else
+ m_ItemContainer.Stretch = false;
+ }
+ else
+ {
+ m_ItemContainer.WrapItems = true;
+ m_ItemContainer.Stretch = false;
+ }
+
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ this.ClientSize = RecalcSizeOffice(false, frameSize, m_ItemContainer.Orientation, m_BarState, m_ItemContainer.WrapItems);
+ else
+ {
+ this.ClientSize = RecalcSizeDotNet(false, frameSize, m_ItemContainer.Orientation, m_BarState, m_ItemContainer.WrapItems);
+ }
+
+ if (m_DropShadow != null)
+ NativeFunctions.SetWindowPos(m_DropShadow.Handle, new IntPtr(NativeFunctions.HWND_NOTOPMOST), this.Left + 5, this.Top + 5, this.Width - 2, this.Height - 2, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
+
+ if (m_BarState == eBarState.Docked)
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal)
+ m_DockedSizeH = this.Size;
+ else
+ m_DockedSizeV = this.Size;
+ RefreshOffice2003Region();
+ }
+ if (m_BarState == eBarState.Floating && !PassiveBar)
+ {
+ m_Float.RefreshRegion(this.ClientSize);
+ m_Float.ClientSize = this.ClientSize;
+ }
+ }
+ finally
+ {
+ m_RecalculatingSize = false;
+ }
+ }
+
+ private System.Drawing.Size RecalcSizeOnly(System.Drawing.Size objFrameSize)
+ {
+ return RecalcSizeOnly(objFrameSize, m_ItemContainer.Orientation, m_BarState, m_ItemContainer.WrapItems);
+ }
+ private System.Drawing.Size RecalcSizeOnly(System.Drawing.Size objFrameSize, eOrientation barOrientation, eBarState barState, bool bWrapItems)
+ {
+ if (m_ItemContainer.SubItems.Count > 0)
+ {
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ return RecalcSizeOffice(true, objFrameSize, barOrientation, barState, bWrapItems);
+ else
+ return RecalcSizeDotNet(true, objFrameSize, barOrientation, barState, bWrapItems);
+ }
+ return System.Drawing.Size.Empty;
+ }
+
+ private System.Drawing.Size RecalcSizeDotNet()
+ {
+ return RecalcSizeDotNet(false, this.Size, m_ItemContainer.Orientation, this.m_BarState, m_ItemContainer.WrapItems);
+ }
+ private System.Drawing.Size RecalcSizeDotNet(bool bCalculateOnly, System.Drawing.Size objFrameSize, eOrientation barOrientation, eBarState barState, bool bWrapItems)
+ {
+ System.Drawing.Size thisSize = System.Drawing.Size.Empty;
+ int iTopMargin = 0, iBottomMargin = 0, iLeftMargin = 0, iRightMargin = 0, iRightTabMargin = 0;
+ int iOrgWidth = 0, iOrgHeight = 0;
+ eOrientation oldOrientation = m_ItemContainer.Orientation;
+ eBarState thisBarState = m_BarState;
+ bool bOldStretch = m_ItemContainer.Stretch;
+ bool bOldWrapItems = m_ItemContainer.WrapItems;
+ m_ItemContainer.IsRightToLeft = (this.RightToLeft == RightToLeft.Yes);
+ if (bCalculateOnly)
+ {
+ m_ItemContainer.Orientation = barOrientation;
+ thisBarState = barState;
+ m_ItemContainer.WrapItems = bWrapItems;
+ if (barState == eBarState.Docked)
+ m_ItemContainer.Stretch = m_DockStretch;
+ else
+ {
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer)
+ m_ItemContainer.Stretch = m_DockStretch;
+ else
+ m_ItemContainer.Stretch = false;
+ }
+ }
+
+ if (thisBarState == eBarState.Docked)
+ {
+ if (m_DockedBorder != eBorderType.None)
+ {
+ iTopMargin = Dpi.Height3;
+ iBottomMargin = Dpi.Height3;
+ iLeftMargin = Dpi.Width3;
+ iRightMargin = Dpi.Width3;
+ }
+ }
+ else if (thisBarState == eBarState.Floating)
+ {
+ if (this.IsThemed || this.DrawThemedCaption)
+ {
+ if (m_ThemeWindowMargins.IsEmpty)
+ this.RefreshThemeMargins();
+ iTopMargin = m_ThemeWindowMargins.Top;
+ iLeftMargin = m_ThemeWindowMargins.Left;
+ iRightMargin = m_ThemeWindowMargins.Right;
+ iBottomMargin = m_ThemeWindowMargins.Bottom;
+ if (this.GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
+ iTopMargin = GetGrabHandleTaskPaneHeight() + m_ThemeWindowMargins.Bottom;
+ }
+ else
+ {
+ if (this.GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
+ iTopMargin = GetGrabHandleTaskPaneHeight() + Dpi.Height4;
+ else
+ iTopMargin = GetNonClientHeight();
+ iLeftMargin = Dpi.Width2;
+ iRightMargin = Dpi.Width2;
+ iBottomMargin = Dpi.Height3;
+ }
+ }
+ else
+ {
+ iTopMargin = this.ClientMarginTop;
+ iLeftMargin = this.ClientMarginLeft;
+ iRightMargin = this.ClientMarginRight;
+ iBottomMargin = this.ClientMarginBottom;
+ }
+
+ int iTop = iTopMargin, iLeft = iLeftMargin;
+
+ if (BarType == eBarType.StatusBar && BarFunctions.IsOffice2007Style(m_ItemContainer.EffectiveStyle))
+ iTop += Dpi.Height2;
+
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && !m_AutoHideState && GetDockTabVisible())
+ {
+ if (m_ItemContainer.VisibleSubItems > 1 || m_AlwaysDisplayDockTab && m_ItemContainer.VisibleSubItems == 1 && m_BarState != eBarState.Floating)
+ {
+ int dockTabStripHeight = Dpi.Height(DockTabStripHeight);
+ switch (m_DockTabAlignment)
+ {
+ case eTabStripAlignment.Top:
+ {
+ iTop += dockTabStripHeight;
+ break;
+ }
+ case eTabStripAlignment.Left:
+ {
+ iLeft += dockTabStripHeight;
+ break;
+ }
+ case eTabStripAlignment.Right:
+ {
+ iRightTabMargin = dockTabStripHeight;
+ break;
+ }
+ default:
+ {
+ iBottomMargin += dockTabStripHeight;
+ break;
+ }
+ }
+ }
+ }
+
+ // Take in account the side bar picture
+ if (thisBarState == eBarState.Popup && m_SideBarImage.Picture != null)
+ iLeft += m_SideBarImage.Picture.Width;
+ else if (thisBarState == eBarState.Docked || this.BarState == eBarState.AutoHide)
+ {
+ // Show grab handles if any selected
+ if (m_GrabHandleStyle != eGrabHandleStyle.None)
+ {
+ if (m_GrabHandleStyle == eGrabHandleStyle.ResizeHandle)
+ {
+ // Leave space for the window sizer at the right
+ if (this.RightToLeft == RightToLeft.Yes)
+ iLeft += GrabHandleResizeWidth;
+ else
+ iRightMargin += GrabHandleResizeWidth;
+ }
+ else
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType == eLayoutType.Toolbar)
+ {
+
+ if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
+ iLeft += GetGrabHandleCaptionHeight();
+ else
+ {
+ if (this.RightToLeft == RightToLeft.Yes)
+ iRightMargin += GrabHandleDotNetWidth;
+ else
+ iLeft += GrabHandleDotNetWidth;
+ }
+ }
+ else
+ {
+ if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
+ iTop += GetGrabHandleCaptionHeight();
+ else if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ iTop += GetGrabHandleTaskPaneHeight();
+ else
+ iTop += GrabHandleDotNetWidth;
+ }
+ }
+ }
+ }
+
+ if (!bCalculateOnly)
+ {
+ m_ItemContainer.TopInternal = iTop;
+ m_ItemContainer.LeftInternal = iLeft;
+ }
+ else
+ {
+ iOrgHeight = m_ItemContainer.HeightInternal;
+ iOrgWidth = m_ItemContainer.WidthInternal;
+ }
+
+ // Suspend Layout while setting suggested size
+ m_ItemContainer.SuspendLayout = true;
+ if (!bCalculateOnly)
+ {
+ if (thisBarState == eBarState.Popup)
+ m_ItemContainer.WidthInternal = m_InitialContainerWidth;
+ else
+ {
+ m_ItemContainer.WidthInternal = objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin; //m_ItemContainer.WidthInternal=this.Width-iLeft-iRightMargin;
+ m_ItemContainer.HeightInternal = objFrameSize.Height - iTop - iBottomMargin; //m_ItemContainer.HeightInternal=this.Height-iTop-iBottomMargin;
+ }
+ }
+ else
+ {
+ m_ItemContainer.WidthInternal = objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin;
+ m_ItemContainer.HeightInternal = objFrameSize.Height - iTop - iBottomMargin;
+ }
+ m_ItemContainer.SuspendLayout = false;
+
+ if (m_ItemContainer.VisibleSubItems == 0 || (m_ItemContainer.SubItems.Count == 1 && m_ItemContainer.SubItems[0] is CustomizeItem && !m_ItemContainer.SubItems[0].Visible))
+ {
+ m_ItemContainer.RecalcSize();
+ if (this.LayoutType != eLayoutType.DockContainer && this.DockSide != eDockSide.Document)
+ {
+ m_ItemContainer.WidthInternal = 36;
+ m_ItemContainer.HeightInternal = 24;
+ }
+ }
+ else
+ m_ItemContainer.RecalcSize();
+
+ iTop += m_ItemContainer.HeightInternal;
+ if (IsGradientStyle && this.LayoutType == eLayoutType.Toolbar && !this.MenuBar && !this.IsThemed && BarType != eBarType.StatusBar)
+ iTop++;
+
+ if (!bCalculateOnly)
+ {
+ if (this.RightToLeft == RightToLeft.Yes)
+ {
+ if (this.LayoutType == eLayoutType.Toolbar && m_ItemContainer.WidthInternal < objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin && this.Stretch)
+ {
+ m_ItemContainer.LeftInternal = objFrameSize.Width - iRightMargin - m_ItemContainer.WidthInternal;
+ m_ItemContainer.RecalcSize();
+ }
+ m_ClientRect = new Rectangle(m_ItemContainer.LeftInternal, iTopMargin, m_ItemContainer.WidthInternal, iTop);
+ }
+ else
+ m_ClientRect = new Rectangle(iLeft, iTopMargin, m_ItemContainer.WidthInternal, iTop);
+ }
+
+ if (!bCalculateOnly)
+ {
+ if ((thisBarState == eBarState.Docked || thisBarState == eBarState.AutoHide) && m_GrabHandleStyle != eGrabHandleStyle.None && m_GrabHandleStyle != eGrabHandleStyle.ResizeHandle)
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType == eLayoutType.Toolbar)
+ {
+ if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
+ m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, GetGrabHandleCaptionHeight(), iTop);
+ else
+ {
+ if (this.RightToLeft == RightToLeft.Yes)
+ m_GrabHandleRect = new Rectangle(m_ItemContainer.WidthInternal + iLeft + iLeftMargin, iTopMargin, 10, iTop);
+ else
+ m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, 10, iTop);
+ }
+ }
+ else
+ {
+ if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
+ m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleCaptionHeight());
+ else if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleTaskPaneHeight());
+ else
+ {
+ //if (this.RightToLeft == RightToLeft.Yes)
+ // m_GrabHandleRect = new Rectangle(objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, 10);
+ //else
+ m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, 10);
+ }
+ }
+ }
+ else if (thisBarState == eBarState.Floating)
+ {
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
+ {
+ m_GrabHandleRect = new Rectangle(iLeftMargin, ((this.IsThemed || this.DrawThemedCaption) ? m_ThemeWindowMargins.Bottom : 2), m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleTaskPaneHeight());
+ }
+ else
+ {
+ m_GrabHandleRect = new Rectangle(2, 2, m_ItemContainer.WidthInternal + iRightTabMargin, GetGrabHandleCaptionHeight());
+ if (this.CanHideResolved)
+ m_GrabHandleRect.Width -= 14;
+ }
+ }
+
+ if (thisBarState == eBarState.Popup && m_SideBarImage.Picture != null)
+ m_SideBarRect = new Rectangle(iLeft - m_SideBarImage.Picture.Width, iTopMargin, m_SideBarImage.Picture.Width, iTop - iTopMargin);
+
+ //if(iLeft+m_ItemContainer.Width+iRightMargin!=this.ClientSize.Width || this.ClientSize.Height!=iTop+iBottomMargin)
+ // this.ClientSize=new Size(iLeft+m_ItemContainer.Width+iRightMargin,iTop+iBottomMargin);
+ thisSize = new Size(iLeft + m_ItemContainer.WidthInternal + iRightMargin + iRightTabMargin, iTop + iBottomMargin);
+ }
+ else
+ {
+ //if(m_BarState==eBarState.Floating)
+ thisSize = new Size(iLeft + m_ItemContainer.WidthInternal + iRightMargin + iRightTabMargin, iTop + iBottomMargin);
+ //else
+ // thisSize=new Size(iLeft+m_ItemContainer.WidthInternal+iRightMargin+iRightTabMargin+14,iTop+iBottomMargin);
+ m_ItemContainer.WidthInternal = iOrgWidth;
+ m_ItemContainer.HeightInternal = iOrgHeight;
+ m_ItemContainer.Orientation = oldOrientation;
+ m_ItemContainer.WrapItems = bOldWrapItems;
+ m_ItemContainer.Stretch = bOldStretch;
+ m_ItemContainer.RecalcSize();
+ }
+ return thisSize;
+ }
+
+ private System.Drawing.Size RecalcSizeOffice()
+ {
+ return RecalcSizeOffice(false, this.Size, m_ItemContainer.Orientation, this.m_BarState, m_ItemContainer.WrapItems);
+ }
+ private System.Drawing.Size RecalcSizeOffice(bool bCalculateOnly, System.Drawing.Size objFrameSize, eOrientation barOrientation, eBarState barState, bool bWrapItems)
+ {
+ System.Drawing.Size thisSize = System.Drawing.Size.Empty;
+
+ int iTopMargin = 0, iBottomMargin = 0, iLeftMargin = 0, iRightMargin = 0, iRightTabMargin = 0;
+ int iOrgWidth = 0, iOrgHeight = 0;
+ eOrientation oldOrientation = m_ItemContainer.Orientation;
+ eBarState thisBarState = m_BarState;
+ bool bOldStretch = m_ItemContainer.Stretch;
+ bool bOldWrapItems = m_ItemContainer.WrapItems;
+ m_ItemContainer.IsRightToLeft = (this.RightToLeft == RightToLeft.Yes);
+ if (bCalculateOnly)
+ {
+ m_ItemContainer.Orientation = barOrientation;
+ thisBarState = barState;
+ m_ItemContainer.WrapItems = bWrapItems;
+ if (barState == eBarState.Docked)
+ m_ItemContainer.Stretch = m_DockStretch;
+ else
+ {
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer)
+ m_ItemContainer.Stretch = m_DockStretch;
+ else
+ m_ItemContainer.Stretch = false;
+ }
+ }
+
+ if (thisBarState == eBarState.Docked)
+ {
+ if (m_DockedBorder != eBorderType.None)
+ {
+ iTopMargin = 2;
+ iBottomMargin = 2;
+ iLeftMargin = 2;
+ iRightMargin = 2;
+ }
+ }
+ else if (thisBarState == eBarState.Floating)
+ {
+ iTopMargin = 22;
+ iLeftMargin = 4;
+ iRightMargin = 4;
+ iBottomMargin = 4;
+ }
+ else
+ {
+ iTopMargin = this.ClientMarginTop;
+ iLeftMargin = this.ClientMarginLeft;
+ iRightMargin = this.ClientMarginRight;
+ iBottomMargin = this.ClientMarginBottom;
+ }
+
+ int iTop = iTopMargin, iLeft = iLeftMargin;
+
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && !m_AutoHideState && GetDockTabVisible())
+ {
+ if (m_ItemContainer.VisibleSubItems > 1 || m_AlwaysDisplayDockTab && m_ItemContainer.VisibleSubItems == 1 && m_BarState != eBarState.Floating)
+ {
+ int dockTabStripHeight = Dpi.Height(DockTabStripHeight);
+ switch (m_DockTabAlignment)
+ {
+ case eTabStripAlignment.Top:
+ {
+ iTop += dockTabStripHeight;
+ break;
+ }
+ case eTabStripAlignment.Left:
+ {
+ iLeft += dockTabStripHeight;
+ break;
+ }
+ case eTabStripAlignment.Right:
+ {
+ iRightTabMargin = dockTabStripHeight;
+ break;
+ }
+ default:
+ {
+ iBottomMargin += dockTabStripHeight;
+ break;
+ }
+ }
+ }
+ }
+
+ // Take in account the side bar picture
+ if (thisBarState == eBarState.Popup && m_SideBarImage.Picture != null)
+ iLeft += m_SideBarImage.Picture.Width;
+ else if (thisBarState == eBarState.Docked || this.BarState == eBarState.AutoHide)
+ {
+ // Show grab handles if any selected
+ if (m_GrabHandleStyle != eGrabHandleStyle.None)
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ iLeft += GrabHandleOfficeWidth;
+ else
+ {
+ if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
+ iTop += GetGrabHandleCaptionHeight();
+ else if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ iTop += GetGrabHandleTaskPaneHeight();
+ else
+ iTop += GrabHandleOfficeWidth;
+ }
+ }
+ }
+
+ if (!bCalculateOnly)
+ {
+ m_ItemContainer.TopInternal = iTop;
+ m_ItemContainer.LeftInternal = iLeft;
+ }
+ else
+ {
+ iOrgHeight = m_ItemContainer.HeightInternal;
+ iOrgWidth = m_ItemContainer.WidthInternal;
+ }
+
+ if (!bCalculateOnly)
+ {
+ if (thisBarState == eBarState.Popup)
+ m_ItemContainer.WidthInternal = m_InitialContainerWidth;
+ else
+ {
+ m_ItemContainer.WidthInternal = objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin; //m_ItemContainer.WidthInternal=this.Width-iLeft-iRightMargin;
+ m_ItemContainer.HeightInternal = objFrameSize.Height - iTop - iBottomMargin; //m_ItemContainer.HeightInternal=this.Height-iTop-iBottomMargin;
+ }
+ }
+ else
+ {
+ m_ItemContainer.WidthInternal = objFrameSize.Width - iLeft - iRightMargin - iRightTabMargin;
+ m_ItemContainer.HeightInternal = objFrameSize.Height - iTop - iBottomMargin;
+ }
+
+ if (m_ItemContainer.VisibleSubItems == 0)
+ {
+ m_ItemContainer.WidthInternal = 36;
+ m_ItemContainer.HeightInternal = 24;
+ }
+ else
+ m_ItemContainer.RecalcSize();
+
+ iTop += m_ItemContainer.HeightInternal;
+
+ if (!bCalculateOnly)
+ m_ClientRect = new Rectangle(iLeft, iTopMargin, m_ItemContainer.WidthInternal, iTop);
+
+ if (!bCalculateOnly)
+ {
+ if ((thisBarState == eBarState.Docked || this.BarState == eBarState.AutoHide) && m_GrabHandleStyle != eGrabHandleStyle.None)
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ {
+ m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, 12, iTop);
+ }
+ else
+ {
+ if (m_GrabHandleStyle == eGrabHandleStyle.Caption)
+ m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleCaptionHeight());
+ else if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
+ m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, GetGrabHandleTaskPaneHeight());
+ else
+ m_GrabHandleRect = new Rectangle(iLeftMargin, iTopMargin, m_ItemContainer.WidthInternal + iLeft - iLeftMargin + iRightTabMargin, 12);
+ }
+ }
+ else if (thisBarState == eBarState.Floating)
+ {
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
+ m_GrabHandleRect = new Rectangle(4, 4, m_ItemContainer.WidthInternal + iRightTabMargin, GetGrabHandleTaskPaneHeight());
+ else
+ m_GrabHandleRect = new Rectangle(4, 4, m_ItemContainer.WidthInternal + iRightTabMargin, 15);
+ if (this.CanHideResolved)
+ m_GrabHandleRect.Width -= 14;
+ }
+
+ if (thisBarState == eBarState.Popup && m_SideBarImage.Picture != null)
+ m_SideBarRect = new Rectangle(iLeft - m_SideBarImage.Picture.Width, iTopMargin, m_SideBarImage.Picture.Width, iTop - iTopMargin);
+ //this.ClientSize=new Size(iLeft+m_ItemContainer.Width+iRightMargin,iTop+iBottomMargin);
+ thisSize = new Size(iLeft + m_ItemContainer.WidthInternal + iRightMargin + iRightTabMargin, iTop + iBottomMargin);
+ }
+ else
+ {
+ thisSize = new Size(iLeft + m_ItemContainer.WidthInternal + iRightMargin + iRightTabMargin, iTop + iBottomMargin);
+ m_ItemContainer.WidthInternal = iOrgWidth;
+ m_ItemContainer.HeightInternal = iOrgHeight;
+ m_ItemContainer.Orientation = oldOrientation;
+ m_ItemContainer.WrapItems = bOldWrapItems;
+ m_ItemContainer.Stretch = bOldStretch;
+ m_ItemContainer.RecalcSize();
+ }
+ return thisSize;
+ }
+
+ private void RestoreContainer()
+ {
+ if (m_ParentItem != null)// && m_ParentItem.SubItems.Count!=0)
+ {
+ foreach (BaseItem objItem in m_ParentItem.SubItems)
+ {
+ objItem.Expanded = false;
+ objItem.SetParent(m_ParentItem);
+ objItem.ContainerControl = m_OldContainer;
+ objItem.Displayed = false;
+ objItem.Orientation = m_ParentItem.Orientation;
+ }
+ m_ItemContainer.SubItems._Clear();
+ }
+ }
+
+ internal void OnAddedToBars()
+ {
+ if (m_Owner != null && m_Owner is IOwner)
+ {
+ if (((IOwner)m_Owner).Images != null)
+ m_ItemContainer.RefreshImageSize();
+ }
+ }
+
+ internal void ProcessDelayedCommands()
+ {
+ if (m_DockSideDelayed >= 0)
+ {
+ if (!((eDockSide)m_DockSideDelayed == eDockSide.Document && this.DockSide == eDockSide.Document))
+ this.DockSide = (eDockSide)m_DockSideDelayed;
+ m_DockSideDelayed = -1;
+ foreach (BaseItem item in m_ItemContainer.SubItems)
+ item.OnProcessDelayedCommands();
+ }
+ }
+
+ private bool IsAnyControl(Control ctrlParent, Control ctrlReference)
+ {
+ if (ctrlParent == ctrlReference)
+ return true;
+ foreach (Control ctrl in ctrlParent.Controls)
+ {
+ if (ctrl == ctrlReference)
+ return true;
+ bool bRet = IsAnyControl(ctrl, ctrlReference);
+ if (bRet)
+ return true;
+ }
+ return false;
+ }
+
+ private int GetGrabHandleTaskPaneHeight()
+ {
+ if (this.Font != null)
+ return Math.Max(Dpi.Height(GrabHandleTaskPaneHeight), this.Font.Height + Dpi.Height2);
+ return Dpi.Height(GrabHandleTaskPaneHeight);
+ }
+
+ private int _CaptionHeight = 0;
+ ///
+ /// Gets or sets docked bar caption height. Default value is 0 which means system predefined height is used.
+ ///
+ [DefaultValue(0), Category("Appearance"), Description("Indicates docked bar caption height. Default value is 0 which means system predefined height is used.")]
+ public int CaptionHeight
+ {
+ get { return _CaptionHeight; }
+ set { _CaptionHeight = value; this.RecalcLayout(); }
+ }
+
+ private int GetGrabHandleCaptionHeight()
+ {
+ if (_CaptionHeight > 0) return Dpi.Height(_CaptionHeight);
+ if (this.Font != null)
+ return Math.Max(Dpi.Height(GrabHandleCaptionHeight), this.Font.Height + 2);
+ return Dpi.Height(GrabHandleCaptionHeight);
+ }
+
+ ///
+ /// Gets or sets whether bar when changed over to floating state is hidden instead of shown. This property is used
+ /// internally to optimize loading of hidden floating bars. You should not use this property in your code. It is for internal DotNetBar
+ /// infrastructure use only.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool LoadingHideFloating
+ {
+ get { return m_LoadingHideFloating; }
+ set { m_LoadingHideFloating = value; }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DockDocumentManager(DockSiteInfo pDockInfo)
+ {
+ DocumentDockUIManager dm = pDockInfo.objDockSite.GetDocumentUIManager();
+ if (pDockInfo.objDockSite.Dock == DockStyle.Fill)
+ dm.Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide);
+ else if ((pDockInfo.DockLine == -1 || pDockInfo.DockLine == 999) && (pDockInfo.objDockSite.Dock == DockStyle.Left || pDockInfo.objDockSite.Dock == DockStyle.Right)) // Ajdust for edge case docking
+ {
+ dm.Dock(null, this, pDockInfo.DockLine == -1 ? eDockSide.Left : eDockSide.None);
+ }
+ else if ((pDockInfo.DockLine == -1 || pDockInfo.DockLine == 999) && (pDockInfo.objDockSite.Dock == DockStyle.Top || pDockInfo.objDockSite.Dock == DockStyle.Bottom)) // Ajdust for edge case docking
+ {
+ dm.Dock(null, this, pDockInfo.DockLine == -1 ? eDockSide.Top : eDockSide.None);
+ }
+ else
+ dm.Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide);
+ }
+
+ internal void RemoveFromFloatingContainer()
+ {
+ if (m_Float == null) return;
+ // Remember undocked size
+ m_FloatingRect = new Rectangle(m_Float.Location, this.Size);
+ m_Float.Controls.Remove(this);
+ m_Float.Hide();
+ m_Float.Dispose();
+ m_Float = null;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DockingHandler(DockSiteInfo pDockInfo, Point p)
+ {
+ IOwner owner = m_Owner as IOwner;
+
+ if (m_TempTabBar != null && pDockInfo.TabDockContainer == m_TempTabBar)
+ return;
+
+ if (pDockInfo.objDockSite == null && (m_BarState != eBarState.Floating || m_Float == null))
+ {
+ m_DockingInProgress = true;
+
+ if (m_TempTabBar != null)
+ {
+ RemoveTempTabBarItems();
+ m_TempTabBar.RecalcLayout();
+ m_TempTabBar = null;
+ }
+
+ // Remember last docking info
+ DockSiteInfo tempInfo = m_LastDockSiteInfo;
+ m_LastDockSiteInfo = new DockSiteInfo();
+ // Preserve the relative last docked to bar in case the return to same docking position is needed
+ m_LastDockSiteInfo.LastRelativeDocumentId = tempInfo.LastRelativeDocumentId;
+ m_LastDockSiteInfo.LastRelativeDockToBar = tempInfo.LastRelativeDockToBar;
+
+ m_LastDockSiteInfo.DockedHeight = this.Height;
+ m_LastDockSiteInfo.DockedWidth = this.Width;
+ m_LastDockSiteInfo.DockLine = this.DockLine;
+ m_LastDockSiteInfo.DockOffset = this.DockOffset;
+ if (this.Parent != null)
+ m_LastDockSiteInfo.DockSide = this.Parent.Dock;
+ else
+ m_LastDockSiteInfo.DockSide = DockStyle.Left;
+
+ if (this.Parent != null && this.Parent is DockSite)
+ {
+ m_LastDockSiteInfo.InsertPosition = ((DockSite)this.Parent).Controls.GetChildIndex(this);
+ m_LastDockSiteInfo.objDockSite = (DockSite)this.DockedSite;
+ }
+ if (m_LastDockSiteInfo.objDockSite == null)
+ {
+ IOwnerBarSupport barSupp = m_Owner as IOwnerBarSupport;
+ if (barSupp != null)
+ {
+ switch (m_LastDockSiteInfo.DockSide)
+ {
+ case DockStyle.Left:
+ m_LastDockSiteInfo.objDockSite = barSupp.LeftDockSite;
+ break;
+ case DockStyle.Right:
+ m_LastDockSiteInfo.objDockSite = barSupp.RightDockSite;
+ break;
+ case DockStyle.Top:
+ m_LastDockSiteInfo.objDockSite = barSupp.TopDockSite;
+ break;
+ case DockStyle.Bottom:
+ m_LastDockSiteInfo.objDockSite = barSupp.BottomDockSite;
+ break;
+ case DockStyle.Fill:
+ m_LastDockSiteInfo.objDockSite = barSupp.FillDockSite;
+ break;
+ }
+ }
+ }
+
+ // Undock the window
+ m_BarState = eBarState.Floating;
+ if (m_Float == null)
+ {
+ m_Float = new FloatingContainer(this);
+ m_Float.CreateControl();
+ }
+
+ // Must reset the ActiveControl to null because on MDI Forms if this was not done
+ // MDI form could not be closed if bar that had ActiveControl is floating.
+ if (owner.ParentForm != null && owner.ParentForm.ActiveControl == this)
+ {
+ owner.ParentForm.ActiveControl = null;
+ this.Focus(); // Fixes the problem on SDI forms
+ }
+ else if (owner.ParentForm != null && IsAnyControl(this, owner.ParentForm.ActiveControl))
+ {
+ owner.ParentForm.ActiveControl = null;
+ this.Focus();
+ }
+
+ // Check for parent since if bar is deserialized there is no parent and state is Docked by default
+
+ if (this.Parent != null && this.Parent is DockSite)
+ {
+ if (((DockSite)this.Parent).IsDocumentDock || ((DockSite)this.Parent).DocumentDockContainer != null)
+ {
+ ((DockSite)this.Parent).GetDocumentUIManager().UnDock(this);
+ }
+ else
+ ((DockSite)this.Parent).RemoveBar(this);
+ }
+
+ this.Parent = null;
+ m_Float.Controls.Add(this);
+ if (!this.Visible/* && !m_BarDefinitionLoading*/)
+ base.Visible = true;
+ // IMPORTANT SINCE WE OVERRIDE BASE LOCATION WE HAVE TO USE BASE HERE TO ACTUALLY MOVE IT
+ base.Location = new Point(0, 0);
+
+ m_FloatingRect = new Rectangle(m_FloatingRect.Location, GetFloatingSize());
+ this.Size = m_FloatingRect.Size;
+
+ this.DockOrientation = eOrientation.Horizontal;
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && m_AlwaysDisplayDockTab)
+ RefreshDockTab(true);
+ this.RecalcSize();
+ m_FloatingRect.Size = this.Size;
+
+ m_Float.Location = p;
+ if (m_ItemContainer.LayoutType != eLayoutType.Toolbar)
+ m_MouseDownPt = new Point(this.Width / 2, 8);
+ else
+ m_MouseDownPt = new Point(8, 8);
+
+ if (m_LoadingHideFloating)
+ m_Float.Visible = false;
+ else
+ m_Float.Show();
+
+ m_FloatingRect.Location = m_Float.Location;
+
+ // TODO: Bug Width was sometimes not reflected properly
+ if (m_Float.Width != m_FloatingRect.Width)
+ m_Float.Width = m_FloatingRect.Width;
+
+ if (owner.ParentForm != null)
+ {
+ bool activate = true;
+ if (m_BarDefinitionLoading && owner is DotNetBarManager && !((DotNetBarManager)owner).ActivateOnLayoutLoad)
+ activate = false;
+ if (activate)
+ owner.ParentForm.Activate();
+ }
+ m_DockingInProgress = false;
+
+ // Raise events
+ if (BarUndock != null)
+ BarUndock(this, new EventArgs());
+ IOwnerBarSupport ownerDockEvents = m_Owner as IOwnerBarSupport;
+ if (ownerDockEvents != null)
+ ownerDockEvents.InvokeBarUndock(this, new EventArgs());
+ OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.BarUndocked));
+
+ // Resize Docking Tab if it exists
+ ResizeDockTab();
+ }
+ else
+ {
+ // Change the Z-Order of the dock-site if needed
+ if ((pDockInfo.FullSizeDock || pDockInfo.PartialSizeDock) && pDockInfo.DockSiteZOrderIndex >= 0 && pDockInfo.objDockSite != null && pDockInfo.objDockSite.Parent != null)
+ pDockInfo.objDockSite.Parent.Controls.SetChildIndex(pDockInfo.objDockSite, pDockInfo.DockSiteZOrderIndex);
+
+ if (m_Owner != null)
+ {
+ if (pDockInfo.TabDockContainer != null)
+ {
+ if (m_TempTabBar != null && pDockInfo.TabDockContainer != m_TempTabBar)
+ {
+ RemoveTempTabBarItems();
+ m_TempTabBar.RecalcLayout();
+ m_TempTabBar = null;
+ }
+ if (m_TempTabBar != pDockInfo.TabDockContainer)
+ {
+ m_DockingInProgress = true;
+
+ if (m_DockTabTearOffIndex == -1)
+ {
+ if (m_Float != null && m_Float.Visible)
+ {
+ if (owner.ParentForm != null)
+ owner.ParentForm.Activate();
+ // Remember undocked size
+ m_FloatingRect = new Rectangle(m_Float.Location, this.Size);
+ m_DockOffset = pDockInfo.DockOffset;
+ m_DockLine = pDockInfo.DockLine;
+ m_Float.Controls.Remove(this);
+ m_Float.Hide();
+ m_Float.Dispose();
+ m_Float = null;
+ }
+ else if (this.Parent != null && this.Parent is DockSite)
+ ((DockSite)this.Parent).RemoveBar(this);
+ m_BarState = eBarState.Docked;
+ if (!m_BarDefinitionLoading)
+ base.Visible = false;
+
+ foreach (BaseItem item in m_ItemContainer.SubItems)
+ {
+ DockContainerItem dockitem = item as DockContainerItem;
+ if (dockitem != null)
+ {
+ DockContainerItem temp = new DockContainerItem();
+ temp.Displayed = false;
+ temp.Text = item.Text;
+ temp.Image = dockitem.Image;
+ temp.ImageIndex = dockitem.ImageIndex;
+ temp.Icon = dockitem.Icon;
+ temp.Tag = "systempdockitem";
+ pDockInfo.TabDockContainer.Items.Add(temp);
+ }
+ m_TempTabBar = pDockInfo.TabDockContainer;
+ m_TempTabBar.RecalcLayout();
+ m_TempTabBar.Refresh();
+ }
+ }
+ else
+ {
+ DockContainerItem dockitem = m_ItemContainer.SubItems[m_DockTabTearOffIndex] as DockContainerItem;
+ if (dockitem != null)
+ {
+ DockContainerItem temp = new DockContainerItem();
+ temp.Displayed = false;
+ temp.Text = dockitem.Text;
+ temp.Image = dockitem.Image;
+ temp.ImageIndex = dockitem.ImageIndex;
+ temp.Icon = dockitem.Icon;
+ temp.Tag = "systempdockitem";
+ pDockInfo.TabDockContainer.Items.Add(temp);
+ }
+ m_TempTabBar = pDockInfo.TabDockContainer;
+ m_TempTabBar.RecalcLayout();
+ m_TempTabBar.Refresh();
+ }
+ m_DockingInProgress = false;
+ }
+
+ }
+ else
+ {
+ if (m_TempTabBar != null)
+ {
+ // Allow tabbed bar to change position only if it is going to different bar
+ if (pDockInfo.objDockSite == m_TempTabBar.Parent)
+ return;
+ RemoveTempTabBarItems();
+ m_TempTabBar.RecalcLayout();
+ m_TempTabBar = null;
+ }
+ // If coming from the tabs
+ if (!this.Visible && !m_BarDefinitionLoading)
+ this.Visible = true;
+ if (pDockInfo.LastRelativeDockToBar != null && pDockInfo.LastRelativeDockToBar.DockedSite != null && owner is DotNetBarManager)
+ {
+ DotNetBarManager manager = (DotNetBarManager)owner;
+ if (pDockInfo.LastRelativeDockToBar.AutoHide)
+ {
+ if (pDockInfo.objDockSite != null)
+ pDockInfo.objDockSite.GetDocumentUIManager().Dock(this);
+ else
+ manager.Dock(this, eDockSide.Right);
+ }
+ else if (!pDockInfo.LastRelativeDockToBar.Visible ||
+ pDockInfo.LastRelativeDockToBar.DockSide == eDockSide.None) // Closed or floating
+ {
+ manager.Dock(this, m_LastDockSiteInfo.LastDockSiteSide);
+ }
+ else if (pDockInfo.LastRelativeDockToBar.DockSide != eDockSide.None &&
+ m_LastDockSiteInfo.LastDockSiteSide != pDockInfo.LastRelativeDockToBar.DockSide) // Reference bar docked somewhere else
+ {
+ manager.Dock(this, m_LastDockSiteInfo.LastDockSiteSide);
+ }
+ else
+ manager.Dock(this, pDockInfo.LastRelativeDockToBar, LastDockSide);
+ if (this.IsDisposed) return;
+ m_BarState = eBarState.Docked;
+ pDockInfo.LastRelativeDockToBar = null;
+ }
+ else if (pDockInfo.objDockSite != null && m_BarState != eBarState.Docked)
+ {
+ m_DockingInProgress = true;
+ if (m_Float != null && m_BarState == eBarState.Floating)
+ {
+ if (owner.ParentForm != null)
+ owner.ParentForm.Activate();
+ // Remember undocked size
+ m_FloatingRect = new Rectangle(m_Float.Location, this.Size);
+ m_DockOffset = pDockInfo.DockOffset;
+ m_DockLine = pDockInfo.DockLine;
+ m_Float.Controls.Remove(this);
+ m_Float.Hide();
+ m_Float.Dispose();
+ m_Float = null;
+ }
+ m_BarState = eBarState.Docked;
+
+ if (pDockInfo.objDockSite.IsDocumentDock || pDockInfo.objDockSite.DocumentDockContainer != null)
+ {
+ DockDocumentManager(pDockInfo);
+ }
+ else
+ {
+ if (pDockInfo.InsertPosition == -10)
+ pDockInfo.objDockSite.AddBar(this);
+ else
+ pDockInfo.objDockSite.AddBar(this, pDockInfo.InsertPosition);
+ }
+ m_DockingInProgress = false;
+
+ // // Raise events
+ // if(BarDock!=null)
+ // BarDock(this,new EventArgs());
+ // IOwnerBarSupport ownerDockEvents=m_Owner as IOwnerBarSupport;
+ // if(ownerDockEvents!=null)
+ // ownerDockEvents.InvokeBarDock(this,new EventArgs());
+ }
+ else if (pDockInfo.objDockSite != null && pDockInfo.objDockSite != this.Parent)
+ {
+ m_DockingInProgress = true;
+ // Must reset the ActiveControl to null becouse on MDI Forms if this was not done
+ // MDI form could not be closed if bar that had ActiveControl is floating.
+ if (owner.ParentForm != null && owner.ParentForm.ActiveControl == this)
+ {
+ owner.ParentForm.ActiveControl = null;
+ this.Focus(); // Fixes the problem on SDI forms
+ }
+ else if (owner.ParentForm != null && IsAnyControl(this, owner.ParentForm.ActiveControl))
+ {
+ owner.ParentForm.ActiveControl = null;
+ this.Focus();
+ }
+
+ // It is docked somewhere else, we need to undockit and dockit on another site
+ // If Bar is deserialized there is no parent
+ if (this.Parent != null && this.Parent is DockSite)
+ {
+ if (((DockSite)this.Parent).IsDocumentDock || ((DockSite)this.Parent).DocumentDockContainer != null)
+ ((DockSite)this.Parent).GetDocumentUIManager().UnDock(this);
+ else
+ ((DockSite)this.Parent).RemoveBar(this);
+ }
+
+ // If coming from the tabs
+ if (!this.Visible && !m_BarDefinitionLoading)
+ this.Visible = true;
+
+ m_DockOffset = pDockInfo.DockOffset;
+ m_DockLine = pDockInfo.DockLine;
+
+ if (pDockInfo.objDockSite.IsDocumentDock || pDockInfo.objDockSite.DocumentDockContainer != null)
+ {
+ pDockInfo.objDockSite.GetDocumentUIManager().Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide);
+ }
+ else
+ {
+ if (pDockInfo.InsertPosition == -10)
+ pDockInfo.objDockSite.AddBar(this);
+ else
+ pDockInfo.objDockSite.AddBar(this, pDockInfo.InsertPosition);
+ }
+ // Raise events
+ // if(BarDock!=null)
+ // BarDock(this,new EventArgs());
+ // IOwnerBarSupport ownerDockEvents=m_Owner as IOwnerBarSupport;
+ // if(ownerDockEvents!=null)
+ // ownerDockEvents.InvokeBarDock(this,new EventArgs());
+ m_DockingInProgress = false;
+ }
+ else if (this.Parent != null && pDockInfo.objDockSite == this.Parent)
+ {
+ if (pDockInfo.objDockSite.IsDocumentDock || pDockInfo.objDockSite.DocumentDockContainer != null)
+ {
+ pDockInfo.objDockSite.GetDocumentUIManager().Dock(pDockInfo.MouseOverBar, this, pDockInfo.MouseOverDockSide);
+ }
+ else
+ {
+ if (m_DockLine != pDockInfo.DockLine || m_DockOffset != pDockInfo.DockOffset && !this.Stretch || pDockInfo.objDockSite.Controls.GetChildIndex(this) != pDockInfo.InsertPosition || pDockInfo.NewLine)
+ {
+ m_DockLine = pDockInfo.DockLine;
+ m_DockOffset = pDockInfo.DockOffset;
+ // If coming from the tabs
+ if (!this.Visible && !m_BarDefinitionLoading)
+ this.Visible = true;
+ if (pDockInfo.NewLine)
+ pDockInfo.objDockSite.SetBarPosition(this, pDockInfo.InsertPosition, true);
+ else if (pDockInfo.InsertPosition == -10)
+ {
+ pDockInfo.objDockSite.AdjustBarPosition(this);
+ pDockInfo.objDockSite.RecalcLayout();
+ }
+ else
+ pDockInfo.objDockSite.SetBarPosition(this, pDockInfo.InsertPosition);
+ }
+ }
+ }
+ else
+ {
+ Point newLocation = new Point(p.X - m_MouseDownPt.X, p.Y - m_MouseDownPt.Y);
+ ScreenInformation screen = BarFunctions.ScreenFromControl(m_Float);
+ if (screen != null)
+ {
+ if (newLocation.Y + 8 >= screen.WorkingArea.Bottom)
+ newLocation.Y = screen.WorkingArea.Bottom - 8;
+ else if (newLocation.Y <= screen.WorkingArea.Y - 1 && this.EffectiveCanMaximizeFloating && !this.IsMaximized &&
+ BarFunctions.ScreenFromPoint(new Point(newLocation.X, screen.Bounds.Y - 32)) == null) // Make sure there is no screen above
+ {
+ this.IsMaximized = true;
+ }
+ else if (this.IsMaximized && (Math.Abs(p.X - m_MouseDownPt.X) > 0 || Math.Abs(p.Y - m_MouseDownPt.Y) > 0) && newLocation.Y > screen.WorkingArea.Y + 8)
+ {
+ this.IsMaximized = false;
+ m_MouseDownPt.X = this.ClientSize.Width / 2;
+ newLocation = new Point(p.X - m_MouseDownPt.X, p.Y - m_MouseDownPt.Y);
+ }
+ }
+ if (!this.IsMaximized)
+ m_Float.Location = newLocation;
+ if (((IOwner)m_Owner).ParentForm != null)
+ ((IOwner)m_Owner).ParentForm.Update();
+ }
+ }
+ }
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && (m_TabDockItems == null || !m_TabDockItems.Visible))
+ {
+ int iVisible = m_ItemContainer.VisibleSubItems;
+ if (!(m_BarState == eBarState.Floating && iVisible <= 1) && (m_AlwaysDisplayDockTab || iVisible > 0))
+ {
+ eBarState oldBarState = m_BarState;
+ m_BarState = eBarState.Docked;
+ RefreshDockTab(false);
+ m_BarState = oldBarState;
+ }
+ }
+ if (m_BarState != eBarState.Floating)
+ InvokeBarDockEvents();
+ }
+ }
+
+ internal void InvokeBarDockEvents()
+ {
+ // Raise events
+ if (BarDock != null)
+ BarDock(this, new EventArgs());
+ IOwnerBarSupport ownerDockEvents = m_Owner as IOwnerBarSupport;
+ if (ownerDockEvents != null)
+ ownerDockEvents.InvokeBarDock(this, new EventArgs());
+ OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.BarDocked));
+ }
+
+ private Size GetFloatingSize()
+ {
+ Size size = m_FloatingRect.Size;
+ if (size.IsEmpty)
+ {
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer)
+ {
+ int tab = this.SelectedDockTab;
+ if (tab >= 0 && m_ItemContainer.SubItems[tab] is DockContainerItem)
+ {
+ DockContainerItem item = m_ItemContainer.SubItems[tab] as DockContainerItem;
+ size = Dpi.Size(item.DefaultFloatingSize);
+ }
+ else if (m_ItemContainer.SubItems.Count > 0 && m_ItemContainer.SubItems[0] is DockContainerItem)
+ {
+ DockContainerItem item = m_ItemContainer.SubItems[0] as DockContainerItem;
+ size = Dpi.Size(item.DefaultFloatingSize);
+ }
+ else
+ {
+ if (m_ItemContainer.Orientation == eOrientation.Vertical)
+ size = new Size(m_ItemContainer.WidthInternal + 16, m_ItemContainer.WidthInternal + 16);
+ else
+ size = new Size(m_ItemContainer.HeightInternal + 24, m_ItemContainer.HeightInternal + 24);
+ }
+ }
+ else
+ size = System.Windows.Forms.Screen.FromControl(this).WorkingArea.Size;
+ }
+
+ return size;
+ }
+
+ private void RemoveTempTabBarItems()
+ {
+ if (m_TempTabBar != null)
+ {
+ System.Collections.ArrayList list = new System.Collections.ArrayList(m_TempTabBar.Items.Count);
+ m_TempTabBar.Items.CopyTo(list);
+ foreach (BaseItem item in list)
+ {
+ if (item.Tag != null && item.Tag.ToString() == "systempdockitem")
+ m_TempTabBar.Items.Remove(item);
+ }
+ }
+ }
+
+ internal Bar TempTabBar
+ {
+ get { return m_TempTabBar; }
+ }
+
+ internal void DragMouseMove()
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ this.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, p.X, p.Y, 0));
+ }
+ internal void DragMouseUp()
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ this.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, p.X, p.Y, 0));
+ }
+
+ internal void InternalMouseMove(MouseEventArgs e)
+ {
+ this.OnMouseMove(e);
+ }
+
+ ///
+ /// Returns true if bar is being moved/dragged by user.
+ ///
+ internal bool IsBarMoving
+ {
+ get { return m_MoveWindow; }
+ }
+
+ ///
+ /// Method is called by DotNetBarManager when bar is being moved and Escape key is pressed.
+ ///
+ internal void OnEscapeKey()
+ {
+ EndDocking(true, Point.Empty);
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ this.InvalidateFontChange();
+ base.OnFontChanged(e);
+ }
+
+ private void InvalidateFontChange()
+ {
+ if (m_ItemContainer != null)
+ BarUtilities.InvalidateFontChange(m_ItemContainer.SubItems);
+ }
+
+ private bool m_InMouseMove = false;
+ private Rectangle m_OldOutlineRectangle = Rectangle.Empty;
+ private Form m_OutlineForm = null;
+ //private bool m_OutlineDrag=true;
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ if (m_InMouseMove)
+ return;
+ m_InMouseMove = true;
+ // Start window dragging
+ if (m_MoveWindow && m_BarState != eBarState.Popup && e.Button == System.Windows.Forms.MouseButtons.Left && DotNetBarManager.MouseDockingEnabled)
+ {
+ if (this.Cursor != System.Windows.Forms.Cursors.SizeAll)
+ this.Cursor = System.Windows.Forms.Cursors.SizeAll;
+
+ Point p = Control.MousePosition;
+ Point p2 = this.PointToClient(p);
+ IOwnerBarSupport ownerDock = m_Owner as IOwnerBarSupport;
+
+ // Graceful exit
+ if (ownerDock == null || Math.Abs(p2.X - m_MouseDownPt.X) <= 4 && Math.Abs(p2.Y - m_MouseDownPt.Y) <= 4)
+ {
+ base.OnMouseMove(e);
+ m_InMouseMove = false;
+ return;
+ }
+ DockSiteInfo pDockInfo = ownerDock.GetDockInfo(this, p.X, p.Y);
+ if (pDockInfo.objDockSite == null && !m_CanUndock)
+ {
+ base.OnMouseMove(e);
+ m_InMouseMove = false;
+ return;
+ }
+ bool bPreview = true;
+
+ if (!m_OldOutlineRectangle.IsEmpty)
+ {
+ NativeFunctions.DrawReversibleDesktopRect(m_OldOutlineRectangle, 3);
+ m_OldOutlineRectangle = Rectangle.Empty;
+ }
+
+ if (pDockInfo.UseOutline && pDockInfo.objDockSite != null)
+ {
+ Rectangle r = pDockInfo.objDockSite.GetBarDockRectangle(this, ref pDockInfo);
+ if (!r.IsEmpty)
+ {
+ bPreview = false;
+ if (m_OutlineForm == null)
+ m_OutlineForm = CreateOutlineForm();
+ NativeFunctions.SetWindowPos(m_OutlineForm.Handle, new IntPtr(NativeFunctions.HWND_TOP), r.X, r.Y, r.Width, r.Height, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
+ }
+ }
+ if (bPreview && m_OutlineForm != null)
+ {
+ m_OutlineForm.Visible = false;
+ }
+
+ m_DragDockInfo = pDockInfo;
+
+ if (bPreview)
+ {
+ //if(m_BarState==eBarState.Floating || this.LayoutType!=eLayoutType.DockContainer || pDockInfo.TabDockContainer!=null)
+ DockingHandler(pDockInfo, p);
+ }
+ }
+ else if (e.Button == System.Windows.Forms.MouseButtons.None)
+ {
+ if (m_BarState == eBarState.Floating)
+ {
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && ((e.X <= 2 && e.Y <= 2) || (e.X >= this.Width - 4 && e.Y >= this.Height - 4)))
+ this.Cursor = System.Windows.Forms.Cursors.SizeNWSE;
+ else if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && ((e.X >= this.Width - 2 && e.Y <= 2) || (e.X <= 4 && e.Y >= this.Height - 4)))
+ this.Cursor = System.Windows.Forms.Cursors.SizeNESW;
+ else if (e.X >= 0 && e.X <= 2 || e.X >= this.Width - 3 && e.X <= this.Width)
+ this.Cursor = System.Windows.Forms.Cursors.SizeWE;
+ else if (e.Y >= 0 && e.Y <= 2 || e.Y >= this.Height - 3 && e.Y <= this.Height)
+ this.Cursor = System.Windows.Forms.Cursors.SizeNS;
+ else if (this.Cursor == System.Windows.Forms.Cursors.SizeWE || this.Cursor == System.Windows.Forms.Cursors.SizeNS || this.Cursor == System.Windows.Forms.Cursors.SizeNWSE || this.Cursor == System.Windows.Forms.Cursors.SizeNESW)
+ this.Cursor = System.Windows.Forms.Cursors.Default;
+ }
+ //else if(m_BarState==eBarState.Docked && m_ItemContainer.LayoutType==eLayoutType.DockContainer && m_ItemContainer.Stretch)
+ //{
+ // if((e.X<=2 && this.DockedSite.Dock==DockStyle.Right) || (e.X>=this.Width-2 && this.DockedSite.Dock==DockStyle.Left))
+ // this.Cursor=Cursors.VSplit;
+ // else if((e.Y<=2 && this.DockedSite.Dock==DockStyle.Bottom) || (e.Y>=this.Height-2 && this.DockedSite.Dock==DockStyle.Top))
+ // this.Cursor=Cursors.HSplit;
+ // else if(e.X<=2 && (this.DockedSite.Dock==DockStyle.Bottom || this.DockedSite.Dock==DockStyle.Top) && this.Left>0)
+ // this.Cursor=Cursors.VSplit;
+ // else if(e.Y<=2 && (this.DockedSite.Dock==DockStyle.Left || this.DockedSite.Dock==DockStyle.Right) && this.Top>0)
+ // this.Cursor=Cursors.HSplit;
+ // else if(this.Cursor==Cursors.HSplit || this.Cursor==Cursors.VSplit)
+ // this.Cursor=Cursors.Default;
+ //}
+ else if (m_BarState == eBarState.AutoHide && m_ItemContainer.LayoutType == eLayoutType.DockContainer && m_ItemContainer.Stretch)
+ {
+ if ((e.X <= 2 && m_LastDockSiteInfo.DockSide == DockStyle.Right) || (e.X >= this.Width - 2 && m_LastDockSiteInfo.DockSide == DockStyle.Left))
+ this.Cursor = Cursors.VSplit;
+ else if ((e.Y <= 2 && m_LastDockSiteInfo.DockSide == DockStyle.Bottom) || (e.Y >= this.Height - 2 && m_LastDockSiteInfo.DockSide == DockStyle.Top))
+ this.Cursor = Cursors.HSplit;
+ else if (e.X <= 2 && (m_LastDockSiteInfo.DockSide == DockStyle.Bottom || m_LastDockSiteInfo.DockSide == DockStyle.Top) && this.Left > 0)
+ this.Cursor = Cursors.VSplit;
+ else if (e.Y <= 2 && (m_LastDockSiteInfo.DockSide == DockStyle.Left || m_LastDockSiteInfo.DockSide == DockStyle.Right) && this.Top > 0)
+ this.Cursor = Cursors.HSplit;
+ else if (this.Cursor == Cursors.HSplit || this.Cursor == Cursors.VSplit)
+ this.Cursor = Cursors.Default;
+ }
+ else if (m_BarState == eBarState.Docked && m_GrabHandleStyle == eGrabHandleStyle.ResizeHandle)
+ {
+ if ((e.X > this.Location.X + this.Width - GrabHandleResizeWidth && this.RightToLeft == RightToLeft.No) ||
+ (e.X < this.Location.X + +GrabHandleResizeWidth && this.RightToLeft == RightToLeft.Yes))
+ {
+ Form form = this.FindForm();
+ if (form != null && form.WindowState == FormWindowState.Maximized)
+ {
+ if (this.Cursor == Cursors.SizeNESW || this.Cursor == Cursors.SizeNWSE)
+ this.Cursor = Cursors.Default;
+ }
+ else
+ {
+ if (this.RightToLeft == RightToLeft.Yes)
+ this.Cursor = Cursors.SizeNESW;
+ else
+ this.Cursor = Cursors.SizeNWSE;
+ }
+ }
+ else if (this.Cursor == Cursors.SizeNESW || this.Cursor == Cursors.SizeNWSE)
+ this.Cursor = Cursors.Default;
+ }
+
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.OfficeXP || m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2003 || m_ItemContainer.EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(m_ItemContainer.EffectiveStyle))
+ {
+ if (!m_SystemButtons.CloseButtonRect.IsEmpty && m_SystemButtons.CloseButtonRect.Contains(e.X, e.Y))
+ {
+ if (!m_SystemButtons.MouseOverClose)
+ {
+ m_SystemButtons.MouseOverClose = true;
+ PaintCloseButton();
+ }
+ }
+ else if (m_SystemButtons.MouseOverClose)
+ {
+ m_SystemButtons.MouseOverClose = false;
+ PaintCloseButton();
+ }
+ if (!m_SystemButtons.MaximizeButtonRect.IsEmpty && m_SystemButtons.MaximizeButtonRect.Contains(e.X, e.Y))
+ {
+ if (!m_SystemButtons.MouseOverMaximize)
+ {
+ m_SystemButtons.MouseOverMaximize = true;
+ PaintMaximizeButton();
+ }
+ }
+ else if (m_SystemButtons.MouseOverMaximize)
+ {
+ m_SystemButtons.MouseOverMaximize = false;
+ PaintMaximizeButton();
+ }
+ if (!m_SystemButtons.CaptionButtonRect.IsEmpty && m_SystemButtons.CaptionButtonRect.Contains(e.X, e.Y))
+ {
+ if (!m_SystemButtons.MouseOverCaption)
+ {
+ m_SystemButtons.MouseOverCaption = true;
+ PaintCaptionButton();
+ }
+ }
+ else if (m_SystemButtons.MouseOverCaption)
+ {
+ m_SystemButtons.MouseOverCaption = false;
+ PaintCaptionButton();
+ }
+ if (!m_SystemButtons.CustomizeButtonRect.IsEmpty && m_SystemButtons.CustomizeButtonRect.Contains(e.X, e.Y))
+ {
+ if (!m_SystemButtons.MouseOverCustomize)
+ {
+ m_SystemButtons.MouseOverCustomize = true;
+ PaintCustomizeButton();
+ }
+ }
+ else if (m_SystemButtons.MouseOverCustomize)
+ {
+ m_SystemButtons.MouseOverCustomize = false;
+ PaintCustomizeButton();
+ }
+ if (!m_SystemButtons.AutoHideButtonRect.IsEmpty && m_SystemButtons.AutoHideButtonRect.Contains(e.X, e.Y))
+ {
+ if (!m_SystemButtons.MouseOverAutoHide)
+ {
+ m_SystemButtons.MouseOverAutoHide = true;
+ PaintAutoHideButton();
+ }
+ }
+ else if (m_SystemButtons.MouseOverAutoHide)
+ {
+ m_SystemButtons.MouseOverAutoHide = false;
+ PaintAutoHideButton();
+ }
+ }
+ }
+ else if (e.Button == System.Windows.Forms.MouseButtons.Left && m_SizeWindow != 0 && m_BarState == eBarState.Floating)
+ {
+ System.Drawing.Size oldSize = this.ClientSize;
+ System.Drawing.Size newSize = System.Drawing.Size.Empty;
+ System.Drawing.Size minSize = MinimumDockSize(m_ItemContainer.Orientation);
+ if (m_SizeWindow == SIZE_NWN || m_SizeWindow == SIZE_NWS)
+ {
+ if (m_SizeWindow == SIZE_NWS)
+ newSize = RecalcSizeOnly(new System.Drawing.Size(e.X, e.Y));
+ else
+ newSize = RecalcSizeOnly(new System.Drawing.Size(this.Width - e.X, this.Height - e.Y));
+ if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height)
+ {
+ if (m_SizeWindow == SIZE_NWS)
+ this.ClientSize = newSize;
+ else
+ {
+ m_Float.Location = new Point(m_Float.Left + (this.Width - newSize.Width), m_Float.Top + (this.Height - newSize.Height));
+ this.ClientSize = newSize;
+ }
+ RecalcSize();
+ this.Update();
+ // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it.
+ IOwner owner = m_Owner as IOwner;
+ if (owner != null && owner.ParentForm != null)
+ owner.ParentForm.Update();
+ }
+ }
+ else if (m_SizeWindow == SIZE_NEN || m_SizeWindow == SIZE_NES)
+ {
+ if (m_SizeWindow == SIZE_NES)
+ newSize = RecalcSizeOnly(new System.Drawing.Size(this.Width - e.X, e.Y));
+ else
+ newSize = RecalcSizeOnly(new System.Drawing.Size(e.X, this.Height - e.Y));
+ if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height)
+ {
+ if (m_SizeWindow == SIZE_NES)
+ {
+ m_Float.Location = new Point(m_Float.Left + (this.Width - newSize.Width), m_Float.Top);
+ this.ClientSize = newSize;
+ }
+ else
+ {
+ m_Float.Location = new Point(m_Float.Left, m_Float.Top + (this.Height - newSize.Height));
+ this.ClientSize = newSize;
+ }
+ RecalcSize();
+ this.Update();
+ // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it.
+ IOwner owner = m_Owner as IOwner;
+ if (owner != null && owner.ParentForm != null)
+ owner.ParentForm.Update();
+ }
+ }
+ else if (m_SizeWindow == SIZE_E)
+ {
+ newSize = RecalcSizeOnly(new System.Drawing.Size(e.X, this.Height));
+ if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height)
+ {
+ this.ClientSize = newSize;
+ RecalcSize();
+ this.Update();
+ // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it.
+ IOwner owner = m_Owner as IOwner;
+ if (owner != null && owner.ParentForm != null)
+ owner.ParentForm.Update();
+ }
+ }
+ else if (m_SizeWindow == SIZE_W)
+ {
+ newSize = RecalcSizeOnly(new System.Drawing.Size(this.Width - e.X, this.Height));
+ if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height)
+ {
+ int iRight = m_Float.Right;
+ this.ClientSize = newSize;
+ RecalcSize();
+ m_Float.Left = m_Float.Left + iRight - m_Float.Right;
+ this.Update();
+ // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it.
+ IOwner owner = m_Owner as IOwner;
+ if (owner != null && owner.ParentForm != null)
+ owner.ParentForm.Update();
+ }
+ }
+ else if (m_SizeWindow == SIZE_S)
+ {
+ if (e.Y > 0)
+ {
+ if (m_ItemContainer.LayoutType == eLayoutType.TaskList || m_ItemContainer.LayoutType == eLayoutType.DockContainer)
+ newSize = RecalcSizeOnly(new System.Drawing.Size(this.Width, e.Y));
+ else
+ newSize = RecalcSizeOnly(new System.Drawing.Size((int)(m_MouseDownSize.Width * ((float)m_MouseDownSize.Height / (float)e.Y)), this.Height));
+ if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height)
+ {
+ this.ClientSize = newSize;
+ RecalcSize();
+ this.Update();
+ // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it.
+ IOwner owner = m_Owner as IOwner;
+ if (owner != null && owner.ParentForm != null)
+ owner.ParentForm.Update();
+ }
+ }
+ }
+ else if (m_SizeWindow == SIZE_N)
+ {
+ if (e.Y != 0)
+ {
+ if (m_ItemContainer.LayoutType == eLayoutType.TaskList || m_ItemContainer.LayoutType == eLayoutType.DockContainer)
+ newSize = RecalcSizeOnly(new Size(this.Width, this.Height - e.Y));
+ else
+ newSize = RecalcSizeOnly(new System.Drawing.Size((int)(m_MouseDownSize.Width * ((float)m_MouseDownSize.Height / (float)(this.Height - e.Y))), this.Height));
+ if (!oldSize.Equals(newSize) && newSize.Width >= minSize.Width && newSize.Height >= minSize.Height)
+ {
+ int iBottom = m_Float.Bottom;
+ this.ClientSize = newSize;
+ RecalcSize();
+ m_Float.Top = m_Float.Top + iBottom - m_Float.Bottom;
+ this.Update();
+ // Updates the parent form, there was a very bad lagging painting effect when dockable window is resized and the DotNetBar controls where behind it.
+ IOwner owner = m_Owner as IOwner;
+ if (owner != null && owner.ParentForm != null)
+ owner.ParentForm.Update();
+ }
+ }
+ }
+ m_FloatingRect = new Rectangle(this.Location, this.Size);
+ }
+ else if (e.Button == System.Windows.Forms.MouseButtons.Left && m_SizeWindow != 0 && m_BarState == eBarState.AutoHide || m_SizeWindow == SIZE_PARENTRESIZE && m_BarState == eBarState.Docked) //(m_BarState == eBarState.Docked || m_BarState == eBarState.AutoHide))
+ {
+ System.Drawing.Size oldSize = this.ClientSize;
+ System.Drawing.Size newSize = System.Drawing.Size.Empty;
+ if (m_SizeWindow == SIZE_PARENTRESIZE)
+ {
+ if (this.RightToLeft == RightToLeft.No)
+ {
+ if (this.Parent != null && this.Parent.Parent != null)
+ {
+ Point pScreen = this.PointToScreen(new Point(e.X, e.Y));
+ if (this.Parent.Parent.Parent != null)
+ {
+ Point pl = this.Parent.Parent.Parent.PointToScreen(this.Parent.Parent.Location);
+ this.Parent.Parent.Size = new Size(pScreen.X - pl.X + m_ResizeOffset.X, pScreen.Y - pl.Y + m_ResizeOffset.Y);
+ }
+ else
+ this.Parent.Parent.Size = new Size(pScreen.X - this.Parent.Parent.Location.X + m_ResizeOffset.X, pScreen.Y - this.Parent.Parent.Location.Y + m_ResizeOffset.Y);
+ IOwner owner = m_Owner as IOwner;
+ if (owner != null && owner.ParentForm != null)
+ owner.ParentForm.Update();
+ }
+ else if (m_Owner == null && !(this.Parent is DockSite) && !(this.Parent is FloatingContainer))
+ {
+ Form form = this.FindForm();
+ if (form != null)
+ {
+ Point pScreen = this.PointToScreen(new Point(e.X, e.Y));
+ form.Size = new Size(pScreen.X - form.Location.X + m_ResizeOffset.X, pScreen.Y - form.Location.Y + m_ResizeOffset.Y);
+ form.Update();
+ }
+ }
+ }
+ else
+ {
+ if (this.Parent != null && this.Parent.Parent != null)
+ {
+ Point pScreen = this.PointToScreen(new Point(e.X, e.Y));
+ if (this.Parent.Parent.Parent != null)
+ {
+ Point pl = this.Parent.Parent.Parent.PointToScreen(this.Parent.Parent.Location);
+ Rectangle b = this.Parent.Parent.Bounds;
+ b.X = pScreen.X - m_ResizeOffset.X;
+ b.Width += this.Parent.Parent.Left - b.X;
+ b.Height = pScreen.Y - pl.Y + m_ResizeOffset.Y;
+ this.Parent.Parent.Bounds = b;
+ }
+ else
+ {
+ Rectangle b = this.Parent.Parent.Bounds;
+ b.X = pScreen.X - m_ResizeOffset.X;
+ b.Width += this.Parent.Parent.Left - b.X;
+ b.Height = pScreen.Y - this.Parent.Parent.Location.Y + m_ResizeOffset.Y;
+ this.Parent.Parent.Bounds = b;
+ }
+ IOwner owner = m_Owner as IOwner;
+ if (owner != null && owner.ParentForm != null)
+ owner.ParentForm.Update();
+ }
+ else if (m_Owner == null && !(this.Parent is DockSite) && !(this.Parent is FloatingContainer))
+ {
+ Form form = this.FindForm();
+ if (form != null)
+ {
+ Point pScreen = this.PointToScreen(new Point(e.X, e.Y));
+ Rectangle b = form.Bounds;
+
+ b.X = pScreen.X - m_ResizeOffset.X;
+ b.Width += form.Left - b.X;
+ b.Height = pScreen.Y - form.Location.Y + m_ResizeOffset.Y;
+ form.Bounds = b;
+ //Size = new Size(pScreen.X - form.Location.X + m_ResizeOffset.X, pScreen.Y - form.Location.Y + m_ResizeOffset.Y);
+ form.Update();
+ }
+ }
+ }
+ }
+ else if (m_SizeWindow == SIZE_HSPLITRIGHT)
+ {
+ int formClientWidth = GetFormClientWidth();
+ int mouseX = e.X;
+ int minClientSize = 32;
+ if (m_Owner is DotNetBarManager) minClientSize = ((DotNetBarManager)m_Owner).MinimumClientSize.Width;
+
+ if (minClientSize > 0 && formClientWidth + mouseX < minClientSize)
+ mouseX = minClientSize - formClientWidth;
+
+ if (formClientWidth + mouseX >= minClientSize || minClientSize == 0)
+ {
+ int oldMinWidth = m_ItemContainer.MinWidth;
+ m_ItemContainer.MinWidth = 0;
+ newSize = RecalcSizeOnly(new Size(this.Width - mouseX, this.Height));
+ m_ItemContainer.MinWidth = oldMinWidth;
+ if (!oldSize.Equals(newSize))
+ {
+ if (m_BarState == eBarState.AutoHide)
+ {
+ Rectangle oldRect = this.Bounds;
+ this.EnableRedraw = false;
+ try
+ {
+ m_ItemContainer.MinWidth = m_ItemContainer.WidthInternal - mouseX;
+ this.Width = this.Width - mouseX;
+ RecalcSize();
+ this.Left = this.Left + (oldSize.Width - this.Size.Width);
+ }
+ finally
+ {
+ this.EnableRedraw = true;
+ }
+ if (this.Parent != null)
+ {
+ this.Parent.Invalidate(oldRect, true);
+ this.Parent.Invalidate(this.Bounds, true);
+ this.Parent.Update();
+ }
+ else
+ this.Refresh();
+ }
+ else
+ {
+ int iOldMinWidth = m_ItemContainer.MinWidth;
+ m_ItemContainer.MinWidth = m_ItemContainer.WidthInternal - mouseX;
+
+ if (m_ItemContainer.MinWidth < iOldMinWidth)
+ SyncLineMinWidth();
+ RecalcLayout();
+ }
+ if (m_BarState == eBarState.AutoHide)
+ m_LastDockSiteInfo.DockedWidth = this.Width;
+ }
+ }
+ }
+ else if (m_SizeWindow == SIZE_HSPLITLEFT)
+ {
+ int formClientWidth = GetFormClientWidth();
+ int mouseX = e.X;
+ int minClientSize = 32;
+ if (m_Owner is DotNetBarManager) minClientSize = ((DotNetBarManager)m_Owner).MinimumClientSize.Width;
+
+ if (minClientSize > 0 && formClientWidth - (mouseX - this.Width) < minClientSize)
+ {
+ mouseX = formClientWidth + this.Width - minClientSize;
+ }
+
+ if (formClientWidth - (mouseX - this.Width) >= minClientSize || minClientSize == 0)
+ {
+ int oldMinWidth = m_ItemContainer.MinWidth;
+ m_ItemContainer.MinWidth = 0;
+ newSize = RecalcSizeOnly(new Size(mouseX, this.Height));
+ m_ItemContainer.MinWidth = oldMinWidth;
+ if (!oldSize.Equals(newSize))
+ {
+ if (m_BarState == eBarState.AutoHide)
+ {
+ Rectangle oldRect = this.Bounds;
+ this.EnableRedraw = false;
+ try
+ {
+ m_ItemContainer.MinWidth = m_ItemContainer.WidthInternal + (mouseX - this.Width);
+ this.Width = this.Width + (mouseX - this.Width);
+ RecalcSize();
+ }
+ finally
+ {
+ this.EnableRedraw = true;
+ }
+ if (this.Parent != null)
+ {
+ this.Parent.Invalidate(oldRect, true);
+ this.Parent.Invalidate(this.Bounds, true);
+ this.Parent.Update();
+ }
+ else
+ this.Refresh();
+ }
+ else
+ {
+ int iOldMinWidth = m_ItemContainer.MinWidth;
+ m_ItemContainer.MinWidth = m_ItemContainer.WidthInternal + (mouseX - this.Width);
+ if (m_ItemContainer.MinWidth < iOldMinWidth)
+ SyncLineMinWidth();
+ RecalcLayout();
+ }
+ if (m_BarState == eBarState.AutoHide)
+ m_LastDockSiteInfo.DockedWidth = this.Width;
+ }
+ }
+ }
+ else if (m_SizeWindow == SIZE_VSPLITBOTTOM)
+ {
+ int formClientHeight = GetFormClientHeight();
+ int mouseY = e.Y;
+ int minClientSize = 32;
+ if (m_Owner is DotNetBarManager) minClientSize = ((DotNetBarManager)m_Owner).MinimumClientSize.Height;
+
+ if (minClientSize > 0 && formClientHeight + mouseY < minClientSize)
+ mouseY = minClientSize - formClientHeight;
+
+ if (formClientHeight + mouseY >= minClientSize || minClientSize == 0)
+ {
+ int oldMinHeight = m_ItemContainer.MinHeight;
+ m_ItemContainer.MinHeight = 0;
+ newSize = RecalcSizeOnly(new Size(this.Width, this.Height - mouseY));
+ m_ItemContainer.MinHeight = oldMinHeight;
+ if (!oldSize.Equals(newSize))
+ {
+ if (m_BarState == eBarState.AutoHide)
+ {
+ Rectangle oldRect = this.Bounds;
+ this.EnableRedraw = false;
+ try
+ {
+ m_ItemContainer.MinHeight = m_ItemContainer.HeightInternal - mouseY;
+ this.Height = this.Height - mouseY;
+ RecalcSize();
+ this.Top = this.Top + (oldSize.Height - this.Height);
+ }
+ finally
+ {
+ this.EnableRedraw = true;
+ }
+ if (this.Parent != null)
+ {
+ this.Parent.Invalidate(oldRect, true);
+ this.Parent.Invalidate(this.Bounds, true);
+ this.Parent.Update();
+ }
+ else
+ this.Refresh();
+ }
+ else
+ {
+ int iOldMinHeight = m_ItemContainer.MinHeight;
+ Size minSize = this.MinimumDockSize(m_ItemContainer.Orientation);
+ if (m_ItemContainer.HeightInternal - mouseY >= minSize.Height)
+ m_ItemContainer.MinHeight = m_ItemContainer.HeightInternal - mouseY;
+ if (m_ItemContainer.MinHeight < iOldMinHeight)
+ SyncLineMinHeight();
+ RecalcLayout();
+ }
+
+ if (m_BarState == eBarState.AutoHide)
+ m_LastDockSiteInfo.DockedHeight = this.Height;
+ }
+ }
+ }
+ else if (m_SizeWindow == SIZE_VSPLITTOP)
+ {
+ int formClientHeight = GetFormClientHeight();
+ int mouseY = e.Y;
+ int minClientSize = 32;
+ if (m_Owner is DotNetBarManager) minClientSize = ((DotNetBarManager)m_Owner).MinimumClientSize.Height;
+
+ if (minClientSize > 0 && formClientHeight - (mouseY - this.Height) < minClientSize)
+ mouseY = formClientHeight + this.Height - minClientSize;
+
+ if (formClientHeight - (mouseY - this.Height) >= minClientSize || minClientSize == 0)
+ {
+ int oldMinHeight = m_ItemContainer.MinHeight;
+ m_ItemContainer.MinHeight = 0;
+ newSize = RecalcSizeOnly(new Size(this.Width, mouseY));
+ m_ItemContainer.MinHeight = oldMinHeight;
+ if (!oldSize.Equals(newSize))
+ {
+ if (m_BarState == eBarState.AutoHide)
+ {
+ Rectangle oldRect = this.Bounds;
+ this.EnableRedraw = false;
+ try
+ {
+ m_ItemContainer.MinHeight = m_ItemContainer.HeightInternal + (mouseY - this.Height);
+ this.Height = mouseY;
+ this.RecalcSize();
+ }
+ finally
+ {
+ this.EnableRedraw = true;
+ }
+ if (this.Parent != null)
+ {
+ this.Parent.Invalidate(oldRect, true);
+ this.Parent.Invalidate(this.Bounds, true);
+ this.Parent.Update();
+ }
+ else
+ this.Refresh();
+ }
+ else
+ {
+ int iOldMinHeight = m_ItemContainer.MinHeight;
+ m_ItemContainer.MinHeight = m_ItemContainer.HeightInternal + (mouseY - this.Height);
+ if (m_ItemContainer.MinHeight < iOldMinHeight)
+ SyncLineMinHeight();
+ RecalcLayout();
+ }
+
+ if (m_BarState == eBarState.AutoHide)
+ m_LastDockSiteInfo.DockedHeight = this.Height;
+ }
+ }
+ }
+ else if (m_SizeWindow == SIZE_HSPLIT && this.Parent.Controls.IndexOf(this) > 0)
+ {
+ Bar barLeft = GetPreviousVisibleBar(this); //this.Parent.Controls[iIndex] as Bar;
+ if (barLeft != null && barLeft.DockLine == this.DockLine)
+ {
+ System.Drawing.Size minLeftSize = GetAdjustedFullSize(barLeft.MinimumDockSize(eOrientation.Horizontal));
+ System.Drawing.Size minThisSize = GetAdjustedFullSize(this.MinimumDockSize(eOrientation.Horizontal));
+ int x = e.X;
+ if (barLeft.Width + x < minLeftSize.Width)
+ x += (minLeftSize.Width - (barLeft.Width + x)) - 1;
+ if (this.Width - x < minThisSize.Width)
+ x -= (minThisSize.Width - (this.Width - x)) + 1;
+
+ if (barLeft.Width + x >= minLeftSize.Width && this.Width - x >= minThisSize.Width)
+ {
+ Size oldLeftBarSize = barLeft.Size;
+ Size newBarLeftSize = barLeft.RecalcSizeOnly(new Size(barLeft.Width + x, this.Height));
+ newSize = this.RecalcSizeOnly(new Size(this.Width - x, this.Height));
+ if (!oldLeftBarSize.Equals(newBarLeftSize) && !oldSize.Equals(newSize))
+ {
+ this.SplitDockWidth = 0;
+ barLeft.SplitDockWidth = barLeft.Width + x;
+ foreach (Control c in this.Parent.Controls)
+ {
+ if (c != this && c != barLeft && c.Visible && c is Bar)
+ {
+ Bar b = c as Bar;
+ if (b.DockLine == this.DockLine && b.SplitDockHeight == 0)
+ b.SplitDockWidth = b.Width;
+ }
+ }
+ RecalcLayout();
+ }
+ }
+ }
+ }
+ else if (m_SizeWindow == SIZE_VSPLIT && this.Parent.Controls.IndexOf(this) > 0)
+ {
+ // Resize two bars that are docked on the same line, this bar is always on the right side
+ //int iIndex=this.Parent.Controls.IndexOf(this)-1; // Index of the control to the left
+ Bar barLeft = GetPreviousVisibleBar(this); //this.Parent.Controls[iIndex] as Bar;
+ if (barLeft != null && barLeft.DockLine == this.DockLine)
+ {
+ System.Drawing.Size minLeftSize = GetAdjustedFullSize(barLeft.MinimumDockSize(eOrientation.Horizontal));
+ System.Drawing.Size minThisSize = GetAdjustedFullSize(this.MinimumDockSize(eOrientation.Horizontal));
+ int y = e.Y;
+ if (barLeft.Height + y < minLeftSize.Height)
+ y += (minLeftSize.Height - (barLeft.Height + y)) - 1;
+ if (this.Height - y < minThisSize.Height)
+ y -= minThisSize.Height - (this.Height - y) + 1;
+ if (barLeft.Height + y >= minLeftSize.Height && this.Height - y >= minThisSize.Height)
+ {
+ Size oldLeftBarSize = barLeft.Size;
+ Size newBarLeftSize = barLeft.RecalcSizeOnly(new Size(barLeft.Width, this.Height + y));
+ newSize = this.RecalcSizeOnly(new Size(this.Width, this.Height - y));
+ if (!oldLeftBarSize.Equals(newBarLeftSize) && !oldSize.Equals(newSize))
+ {
+ this.SplitDockHeight = 0;
+ barLeft.SplitDockHeight = barLeft.Height + y;
+ foreach (Control c in this.Parent.Controls)
+ {
+ if (c != this && c != barLeft && c.Visible && c is Bar)
+ {
+ Bar b = c as Bar;
+ if (b.DockLine == this.DockLine && b.SplitDockHeight == 0)
+ b.SplitDockHeight = b.Height;
+ }
+ }
+ RecalcLayout();
+ }
+ }
+ }
+ }
+ }
+
+ if (m_BarState == eBarState.Popup && m_ParentItem != null && m_ParentItem.DesignMode && e.Button == System.Windows.Forms.MouseButtons.Left && (Math.Abs(e.X - m_MouseDownPt.X) >= 2 || Math.Abs(e.Y - m_MouseDownPt.Y) >= 2 || m_DragDropInProgress))
+ {
+ BaseItem focus = m_FocusItem;
+ if (m_Owner is IOwner)
+ focus = ((IOwner)m_Owner).GetFocusItem();
+ ISite site = this.GetSite();
+ if (site != null && focus != null)
+ {
+ DesignTimeMouseMove(e);
+ }
+ }
+
+ base.OnMouseMove(e);
+ if (m_ItemContainer.SubItems.Count == 0)
+ {
+ m_InMouseMove = false;
+ return;
+ }
+ if (!m_MoveWindow && m_SizeWindow == 0)
+ m_ItemContainer.InternalMouseMove(e);
+ m_InMouseMove = false;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Form CreateOutlineForm()
+ {
+ return BarFunctions.CreateOutlineForm();
+ }
+ private Bar GetPreviousVisibleBar(Bar startBar)
+ {
+ if (this.Parent == null)
+ return null;
+ int iIndex = this.Parent.Controls.IndexOf(this) - 1;
+ if (iIndex >= 0)
+ {
+ for (int i = iIndex; i >= 0; i--)
+ {
+ if (this.Parent.Controls[i].Visible)
+ return this.Parent.Controls[i] as Bar;
+ }
+ }
+ return null;
+ }
+
+ private Bar GetNextVisibleBar(Bar startBar)
+ {
+ if (this.Parent == null)
+ return null;
+ int iIndex = this.Parent.Controls.IndexOf(this) + 1;
+ if (iIndex >= 0)
+ {
+ for (int i = iIndex; i < this.Parent.Controls.Count; i++)
+ {
+ if (this.Parent.Controls[i].Visible)
+ return this.Parent.Controls[i] as Bar;
+ }
+ }
+ return null;
+ }
+
+ private int GetFormClientWidth()
+ {
+ IOwner owner = m_Owner as IOwner;
+ if (owner == null || this.Parent == null || (this.Parent.Parent == null && m_BarState != eBarState.AutoHide))
+ return 0;
+
+ Control parentControl = this.Parent.Parent;
+ if (m_BarState == eBarState.AutoHide)
+ parentControl = owner.ParentForm;
+ if (parentControl == null && owner.ParentForm == null && m_Owner is DotNetBarManager)
+ parentControl = ((DotNetBarManager)m_Owner).ParentUserControl;
+
+ if (parentControl == null)
+ return 0;
+ int width = parentControl.ClientSize.Width;
+
+ foreach (Control ctrl in parentControl.Controls)
+ {
+ if (ctrl.Visible && (ctrl.Dock == DockStyle.Left || ctrl.Dock == DockStyle.Right))
+ width -= ctrl.Width;
+ }
+ if (m_BarState == eBarState.AutoHide && this.Visible)
+ width -= this.Width;
+ return width;
+ }
+
+ private int GetFormClientHeight()
+ {
+ IOwner owner = m_Owner as IOwner;
+ if (owner == null || this.Parent == null || (this.Parent.Parent == null && m_BarState != eBarState.AutoHide))
+ return 0;
+ Control parentControl = null;
+ if (m_BarState == eBarState.AutoHide)
+ parentControl = owner.ParentForm;
+ else
+ parentControl = this.Parent.Parent;
+
+ if (parentControl == null && owner.ParentForm == null && m_Owner is DotNetBarManager)
+ parentControl = ((DotNetBarManager)m_Owner).ParentUserControl;
+
+ if (parentControl == null)
+ return 0;
+ int height = parentControl.ClientSize.Height;
+
+ foreach (Control ctrl in parentControl.Controls)
+ {
+ if (ctrl.Visible && (ctrl.Dock == DockStyle.Top || ctrl.Dock == DockStyle.Bottom))
+ height -= ctrl.Height;
+ }
+ if (m_BarState == eBarState.AutoHide && this.Visible)
+ height -= this.Height;
+ return height;
+ }
+
+ internal void SyncLineMinWidth()
+ {
+ if (this.Parent == null)
+ return;
+ foreach (Control ctrl in this.Parent.Controls)
+ {
+ Bar bar = ctrl as Bar;
+ if (bar == null || bar == this || bar.DockLine != m_DockLine)
+ continue;
+ bar.ItemsContainer.MinWidth = m_ItemContainer.MinWidth;
+ }
+ }
+ internal void SyncLineMinHeight()
+ {
+ if (this.Parent == null)
+ return;
+ foreach (Control ctrl in this.Parent.Controls)
+ {
+ Bar bar = ctrl as Bar;
+ if (bar == null || bar == this || bar.DockLine != m_DockLine)
+ continue;
+ bar.ItemsContainer.MinHeight = m_ItemContainer.MinHeight;
+ }
+ }
+
+ protected override void OnMouseHover(EventArgs e)
+ {
+ base.OnMouseHover(e);
+ InternalMouseHover();
+ }
+
+ internal void InternalMouseHover()
+ {
+ if (!m_MoveWindow)
+ {
+ if (Control.MouseButtons == MouseButtons.Left)
+ {
+ Point pClient = this.PointToClient(Control.MousePosition);
+ if (!this.ClientRectangle.Contains(pClient))
+ {
+ IOwnerMenuSupport menu = this.Owner as IOwnerMenuSupport;
+ if (menu != null)
+ {
+ if (menu.RelayMouseHover())
+ return;
+ }
+ }
+ }
+ m_ItemContainer.InternalMouseHover();
+
+ if (m_SystemButtons.MouseOverAutoHide)
+ {
+ using (LocalizationManager lm = new LocalizationManager(m_Owner as IOwnerLocalize))
+ {
+ string tip = lm.GetLocalizedString(LocalizationKeys.BarAutoHideButtonTooltip);
+ if (tip != "")
+ ShowToolTip(tip);
+ }
+ }
+ else if (m_SystemButtons.MouseOverCustomize)
+ {
+ using (LocalizationManager lm = new LocalizationManager(m_Owner as IOwnerLocalize))
+ {
+ string tip = lm.GetLocalizedString(LocalizationKeys.BarCustomizeButtonTooltip);
+ if (tip != "")
+ ShowToolTip(tip);
+ }
+ }
+ else if (m_SystemButtons.MouseOverClose)
+ {
+ using (LocalizationManager lm = new LocalizationManager(m_Owner as IOwnerLocalize))
+ {
+ string tip = lm.GetLocalizedString(LocalizationKeys.BarCloseButtonTooltip);
+ if (tip != "")
+ ShowToolTip(tip);
+ }
+ }
+ else if (m_SystemButtons.MouseOverMaximize)
+ {
+ using (LocalizationManager lm = new LocalizationManager(m_Owner as IOwnerLocalize))
+ {
+ string tip = lm.GetLocalizedString(LocalizationKeys.BarMaximizeButtonTooltip);
+ if (!string.IsNullOrEmpty(tip))
+ ShowToolTip(tip);
+ }
+ }
+ }
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ // If we had hot sub item pass the mouse leave message to it...
+ if (this.Cursor != System.Windows.Forms.Cursors.Arrow)
+ this.Cursor = System.Windows.Forms.Cursors.Arrow;
+
+ if (m_SystemButtons.MouseOverClose)
+ {
+ m_SystemButtons.MouseOverClose = false;
+ PaintCloseButton();
+ }
+ if (m_SystemButtons.MouseOverMaximize)
+ {
+ m_SystemButtons.MouseOverMaximize = false;
+ PaintMaximizeButton();
+ }
+ if (m_SystemButtons.MouseOverCaption)
+ {
+ m_SystemButtons.MouseOverCaption = false;
+ PaintCaptionButton();
+ }
+ if (m_SystemButtons.MouseOverCustomize)
+ {
+ m_SystemButtons.MouseOverCustomize = false;
+ PaintCustomizeButton();
+ }
+ if (m_SystemButtons.MouseOverAutoHide)
+ {
+ m_SystemButtons.MouseOverAutoHide = false;
+ PaintAutoHideButton();
+ }
+
+ if (!m_MoveWindow)
+ m_ItemContainer.InternalMouseLeave();
+
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ m_MouseDownPt = new Point(e.X, e.Y);
+ m_MouseDownSize = this.Size;
+ HideToolTip();
+ if (e.Button == MouseButtons.Left && !m_SystemButtons.CustomizeButtonRect.IsEmpty && m_SystemButtons.CustomizeButtonRect.Contains(m_MouseDownPt) && !this.DesignMode && !m_ItemContainer.DesignMode)
+ {
+ if (m_CustomizeMenu != null)
+ {
+ if (m_CustomizeMenu.GetOwner() == null)
+ m_CustomizeMenu.SetOwner(m_Owner);
+ Point popupLocation;
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ popupLocation = new Point(0, 16);
+ else
+ popupLocation = new Point(m_SystemButtons.CustomizeButtonRect.Left, m_SystemButtons.CustomizeButtonRect.Bottom);
+ if (popupLocation.X < 0)
+ popupLocation.X = 0;
+ popupLocation = this.PointToScreen(popupLocation);
+ m_CustomizeMenu.SetSourceControl(this);
+ m_CustomizeMenu.Popup(popupLocation);
+ base.OnMouseDown(e);
+ return;
+ }
+ else
+ {
+ foreach (BaseItem objItem in m_ItemContainer.SubItems)
+ {
+ if (objItem is CustomizeItem && !objItem.Expanded)
+ {
+ if (m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2000)
+ ((CustomizeItem)objItem).PopupLocation = new Point(this.Left - 128, this.Top + 16);
+ else
+ ((CustomizeItem)objItem).PopupLocation = new Point(m_SystemButtons.CustomizeButtonRect.Left, m_SystemButtons.CustomizeButtonRect.Bottom);
+
+ objItem.Expanded = true;
+ base.OnMouseDown(e);
+ return;
+ }
+ }
+ }
+ }
+ else if (e.Button == MouseButtons.Left && !m_SystemButtons.CloseButtonRect.IsEmpty && m_SystemButtons.CloseButtonRect.Contains(e.X, e.Y))
+ {
+ m_SystemButtons.MouseDownClose = true;
+ PaintCloseButton();
+ base.OnMouseDown(e);
+ return;
+ }
+ else if (e.Button == MouseButtons.Left && !m_SystemButtons.MaximizeButtonRect.IsEmpty && m_SystemButtons.MaximizeButtonRect.Contains(e.X, e.Y))
+ {
+ m_SystemButtons.MouseDownMaximize = true;
+ PaintMaximizeButton();
+ base.OnMouseDown(e);
+ return;
+ }
+ else if (e.Button == MouseButtons.Left && !m_SystemButtons.CaptionButtonRect.IsEmpty && m_SystemButtons.CaptionButtonRect.Contains(e.X, e.Y))
+ {
+ m_SystemButtons.MouseDownCaption = true;
+ PaintCaptionButton();
+ base.OnMouseDown(e);
+ return;
+ }
+ else if (e.Button == MouseButtons.Left && !m_SystemButtons.AutoHideButtonRect.IsEmpty && m_SystemButtons.AutoHideButtonRect.Contains(e.X, e.Y))
+ {
+ m_SystemButtons.MouseDownAutoHide = true;
+ PaintAutoHideButton();
+ base.OnMouseDown(e);
+ return;
+ }
+ else if (e.Button == System.Windows.Forms.MouseButtons.Left && m_BarState == eBarState.Floating)
+ {
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && e.X <= 4 && e.Y <= 4)
+ m_SizeWindow = SIZE_NWN;
+ else if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && e.X >= this.Width - 4 && e.Y >= this.Height - 4)
+ m_SizeWindow = SIZE_NWS;
+ else if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && e.X >= this.Width - 4 && e.Y <= 4)
+ m_SizeWindow = SIZE_NEN;
+ else if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && e.X <= 4 && e.Y >= this.Height - 4)
+ m_SizeWindow = SIZE_NES;
+ else if (e.X >= 0 && e.X <= 2)
+ m_SizeWindow = SIZE_W;
+ else if (e.X >= this.Width - 3 && e.X <= this.Width)
+ m_SizeWindow = SIZE_E;
+ else if (e.Y >= 0 && e.Y <= 2)
+ m_SizeWindow = SIZE_N;
+ else if (e.Y >= this.Height - 3 && e.Y <= this.Height)
+ m_SizeWindow = SIZE_S;
+ }
+ //else if(e.Button==System.Windows.Forms.MouseButtons.Left && m_BarState==eBarState.Docked && m_ItemContainer.LayoutType==eLayoutType.DockContainer && m_ItemContainer.Stretch)
+ //{
+ // if(this.DockedSite.Dock==DockStyle.Right && e.X<=2)
+ // m_SizeWindow=SIZE_HSPLITRIGHT;
+ // else if(this.DockedSite.Dock==DockStyle.Left && e.X>=this.Width-2)
+ // m_SizeWindow=SIZE_HSPLITLEFT;
+ // else if(this.DockedSite.Dock==DockStyle.Bottom && e.Y<=2)
+ // m_SizeWindow=SIZE_VSPLITBOTTOM;
+ // else if(this.DockedSite.Dock==DockStyle.Top && e.Y>=this.Height-2)
+ // m_SizeWindow=SIZE_VSPLITTOP;
+ // else if((this.DockedSite.Dock==DockStyle.Bottom || this.DockedSite.Dock==DockStyle.Top) && e.X<=2 && this.Left>0)
+ // m_SizeWindow=SIZE_HSPLIT;
+ // else if((this.DockedSite.Dock==DockStyle.Left || this.DockedSite.Dock==DockStyle.Right) && e.Y<=2 && this.Top>0)
+ // m_SizeWindow=SIZE_VSPLIT;
+ //}
+ else if (e.Button == System.Windows.Forms.MouseButtons.Left && m_BarState == eBarState.AutoHide && m_ItemContainer.LayoutType == eLayoutType.DockContainer && m_ItemContainer.Stretch)
+ {
+ if (m_LastDockSiteInfo.DockSide == DockStyle.Right && e.X <= 2)
+ m_SizeWindow = SIZE_HSPLITRIGHT;
+ else if (m_LastDockSiteInfo.DockSide == DockStyle.Left && e.X >= this.Width - 2)
+ m_SizeWindow = SIZE_HSPLITLEFT;
+ else if (m_LastDockSiteInfo.DockSide == DockStyle.Bottom && e.Y <= 2)
+ m_SizeWindow = SIZE_VSPLITBOTTOM;
+ else if (m_LastDockSiteInfo.DockSide == DockStyle.Top && e.Y >= this.Height - 2)
+ m_SizeWindow = SIZE_VSPLITTOP;
+ else if ((m_LastDockSiteInfo.DockSide == DockStyle.Bottom || m_LastDockSiteInfo.DockSide == DockStyle.Top) && e.X <= 2 && this.Left > 0)
+ m_SizeWindow = SIZE_HSPLIT;
+ else if ((m_LastDockSiteInfo.DockSide == DockStyle.Left || m_LastDockSiteInfo.DockSide == DockStyle.Right) && e.Y <= 2 && this.Top > 0)
+ m_SizeWindow = SIZE_VSPLIT;
+ }
+ else if (e.Button == MouseButtons.Right && this.CanCustomize && !m_ItemContainer.DesignMode && m_BarState != eBarState.Popup && !m_MoveWindow)
+ {
+ DotNetBarManager owner = m_Owner as DotNetBarManager;
+ if (owner != null)
+ {
+ IOwnerBarSupport ownersupport = m_Owner as IOwnerBarSupport;
+ if (ownersupport != null)
+ ownersupport.BarContextMenu(this, e);
+ }
+ }
+
+ if (e.Button == MouseButtons.Left && m_BarState == eBarState.Docked && this.m_GrabHandleStyle == eGrabHandleStyle.ResizeHandle
+ && (m_MouseDownPt.X > this.Location.X + this.Width - GrabHandleResizeWidth) && this.RightToLeft == RightToLeft.No)
+ {
+ Form formParent = this.FindForm();
+ if (formParent != null && formParent.WindowState != FormWindowState.Maximized || formParent == null)
+ {
+ // Start resizing parent window...
+ this.Capture = true;
+ this.Cursor = System.Windows.Forms.Cursors.SizeNWSE;
+ m_SizeWindow = SIZE_PARENTRESIZE;
+ Point p = this.PointToScreen(m_MouseDownPt);
+ if (this.Parent != null && this.Parent.Parent != null)
+ {
+ p = this.Parent.Parent.PointToClient(p);
+ m_ResizeOffset = new Point(this.Parent.Parent.Width - p.X, this.Parent.Parent.ClientRectangle.Height - p.Y);
+ }
+ else if (m_Owner == null && !(this.Parent is DockSite) && !(this.Parent is FloatingContainer))
+ {
+ if (formParent != null)
+ {
+ p = formParent.PointToClient(p);
+ m_ResizeOffset = new Point(formParent.Width - p.X, formParent.ClientRectangle.Height - p.Y);
+ }
+ }
+ }
+ }
+ else if (e.Button == MouseButtons.Left && m_BarState == eBarState.Docked && this.m_GrabHandleStyle == eGrabHandleStyle.ResizeHandle
+ && (m_MouseDownPt.X < this.Location.X + GrabHandleResizeWidth) && this.RightToLeft == RightToLeft.Yes)
+ {
+ Form formParent = this.FindForm();
+ if (formParent != null && formParent.WindowState != FormWindowState.Maximized || formParent == null)
+ {
+ // Start resizing parent window...
+ this.Capture = true;
+ this.Cursor = System.Windows.Forms.Cursors.SizeNESW;
+ m_SizeWindow = SIZE_PARENTRESIZE;
+ Point pointMouseDown = m_MouseDownPt;
+ if (formParent.GetType().GetProperty("RightToLeftLayout") != null)
+ {
+ if ((bool)TypeDescriptor.GetProperties(formParent)["RightToLeftLayout"].GetValue(formParent))
+ {
+ // Reverse it
+ pointMouseDown.X = this.Width - pointMouseDown.X;
+ }
+ }
+
+ Point p = this.PointToScreen(pointMouseDown);
+ if (this.Parent != null && this.Parent.Parent != null)
+ {
+ p = this.Parent.Parent.PointToClient(p);
+ m_ResizeOffset = new Point(p.X, this.Parent.Parent.ClientRectangle.Height - p.Y);
+ }
+ else if (m_Owner == null && !(this.Parent is DockSite) && !(this.Parent is FloatingContainer))
+ {
+ if (formParent != null)
+ {
+ p = formParent.PointToClient(p);
+ m_ResizeOffset = new Point(p.X, formParent.ClientRectangle.Height - p.Y);
+ }
+ }
+ }
+ }
+
+ if (e.Button == MouseButtons.Left && _CanMove && !m_GrabHandleRect.IsEmpty && m_GrabHandleRect.Contains(m_MouseDownPt) && m_SizeWindow == 0 && !m_AutoHideState && !(m_CustomizeMenu != null && m_CustomizeMenu.Expanded))
+ {
+ this.Cursor = System.Windows.Forms.Cursors.SizeAll;
+ this.Capture = true;
+ m_MoveWindow = true;
+ }
+
+ if (m_BarState == eBarState.Popup && m_ParentItem != null && m_ParentItem.DesignMode)
+ {
+ DesignTimeMouseDown(e);
+ }
+ else
+ m_ItemContainer.InternalMouseDown(e);
+
+ base.OnMouseDown(e);
+ }
+
+ internal bool IsSizingWindow
+ {
+ get { return m_SizeWindow != 0; }
+ }
+ internal void InternalMouseUp(MouseEventArgs e)
+ {
+ this.OnMouseUp(e);
+ }
+
+ internal void CloseBar()
+ {
+ BarClosingEventArgs closingArgs = new BarClosingEventArgs();
+ InvokeBarClosing(closingArgs);
+ if (!closingArgs.Cancel)
+ {
+ if (this.AutoHide)
+ this.AutoHide = false;
+ this.HideBar();
+ IOwner owner = this.Owner as IOwner;
+ if (owner.ParentForm != null && !owner.ParentForm.ContainsFocus)
+ owner.ParentForm.Focus();
+ InvokeUserVisibleChanged();
+ }
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ if (m_MoveWindow || m_SizeWindow != 0)
+ this.Cursor = System.Windows.Forms.Cursors.Default;
+
+ if (m_DragDropInProgress)
+ {
+ DesignTimeMouseUp(e);
+ }
+
+ if (m_MoveWindow)
+ {
+ EndDocking(false, new Point(e.X, e.Y));
+ }
+ else if (e.Button == MouseButtons.Left && !m_SystemButtons.CloseButtonRect.IsEmpty && m_SystemButtons.CloseButtonRect.Contains(m_MouseDownPt))
+ {
+ m_SystemButtons.MouseDownClose = false;
+ PaintCloseButton();
+ if (m_SystemButtons.CloseButtonRect.Contains(e.X, e.Y))
+ {
+ if (m_CloseSingleTab && this.SelectedDockContainerItem != null)
+ CloseDockTab(this.SelectedDockContainerItem);
+ else
+ CloseBar();
+ }
+ }
+ else if (e.Button == MouseButtons.Left && !m_SystemButtons.MaximizeButtonRect.IsEmpty && m_SystemButtons.MaximizeButtonRect.Contains(m_MouseDownPt))
+ {
+ m_SystemButtons.MouseDownMaximize = false;
+ if (m_SystemButtons.MaximizeButtonRect.Contains(e.X, e.Y))
+ {
+ if (this.Parent is FloatingContainer)
+ {
+ this.IsMaximized = !this.IsMaximized;
+ }
+ }
+ PaintMaximizeButton();
+ }
+ else if (e.Button == MouseButtons.Left && !m_SystemButtons.CaptionButtonRect.IsEmpty && m_SystemButtons.CaptionButtonRect.Contains(m_MouseDownPt))
+ {
+ m_SystemButtons.MouseDownCaption = false;
+ PaintCaptionButton();
+ if (m_SystemButtons.CaptionButtonRect.Contains(e.X, e.Y))
+ {
+ InvokeCaptionButtonClick();
+ if (m_AutoCreateCaptionMenu)
+ {
+ ToggleCaptionMenu();
+ PaintCaptionButton();
+ }
+ }
+ }
+ else if (e.Button == MouseButtons.Left && !m_SystemButtons.AutoHideButtonRect.IsEmpty && m_SystemButtons.AutoHideButtonRect.Contains(m_MouseDownPt))
+ {
+ m_SystemButtons.MouseDownAutoHide = false;
+ PaintAutoHideButton();
+ if (m_SystemButtons.AutoHideButtonRect.Contains(e.X, e.Y))
+ {
+ m_IgnoreAnimation = false;
+ this.AutoHide = !this.AutoHide;
+ }
+ }
+ m_MoveWindow = false;
+ m_SizeWindow = 0;
+
+ if (m_ItemContainer != null)
+ m_ItemContainer.InternalMouseUp(e);
+
+ base.OnMouseUp(e);
+ }
+
+ private bool _IsMaximized = false;
+ ///
+ /// Gets or sets whether floating dockable window is maximized.
+ ///
+ [Browsable(false)]
+ public bool IsMaximized
+ {
+ get { return _IsMaximized; }
+ set
+ {
+ if (value != _IsMaximized)
+ {
+ if (!(this.Parent is FloatingContainer) || this.LayoutType != eLayoutType.DockContainer)
+ throw new InvalidOperationException("Bar is not dockable window or its not floating");
+ bool oldValue = _IsMaximized;
+ _IsMaximized = value;
+ OnIsMaximizedChanged(oldValue, value);
+ }
+ }
+ }
+
+ private Rectangle _RestoredBounds = Rectangle.Empty;
+ ///
+ /// Called when IsMaximized property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnIsMaximizedChanged(bool oldValue, bool newValue)
+ {
+ FloatingContainer form = (FloatingContainer)this.Parent;
+ if (!newValue)
+ {
+ this.ClientSize = _RestoredBounds.Size;
+ this.Location = _RestoredBounds.Location;
+ //form.WindowState = FormWindowState.Normal;
+ }
+ else
+ {
+ _RestoredBounds = new Rectangle(m_Float.Location, this.ClientSize);
+ ScreenInformation screen = BarFunctions.ScreenFromControl(m_Float);
+ if (screen != null)
+ {
+ this.ClientSize = screen.WorkingArea.Size;
+ this.Location = screen.WorkingArea.Location;
+ }
+ //form.WindowState = FormWindowState.Maximized;
+ }
+ //this.ClientSize = form.ClientSize;
+ this.RecalcSize();
+ this.Update();
+ //OnPropertyChanged(new PropertyChangedEventArgs("IsMaximized"));
+
+ }
+
+ private void EndDocking(bool revertLast, Point mousePos)
+ {
+ if (this.Capture)
+ this.Capture = false;
+
+ this.Cursor = System.Windows.Forms.Cursors.Default;
+
+ IOwnerBarSupport barsupport = this.Owner as IOwnerBarSupport;
+ if (barsupport != null)
+ barsupport.DockComplete();
+
+ if (m_DragDockInfo.IsEmpty())
+ {
+ m_MoveWindow = false;
+ return;
+ }
+
+ if (m_TempTabBar != null || m_DragDockInfo.TabDockContainer != null)
+ {
+ DisposeDockingPreview();
+
+ Bar targetBar = m_TempTabBar;
+ if (targetBar == null)
+ targetBar = m_DragDockInfo.TabDockContainer;
+
+ RemoveTempTabBarItems();
+ if (m_DragDockInfo.TabDockContainer != this)
+ {
+ if (m_DockTabTearOffIndex == -1)
+ {
+ System.Collections.ArrayList list = new System.Collections.ArrayList(m_ItemContainer.SubItems.Count);
+ m_ItemContainer.SubItems.CopyTo(list);
+ DockContainerItem firstItem = null;
+ Form f = targetBar.FindForm();
+ if (f != null) f.ActiveControl = targetBar;
+ foreach (BaseItem item in list)
+ {
+ DockContainerItem dockitem = item as DockContainerItem;
+ if (dockitem != null)
+ {
+ if (firstItem == null) firstItem = dockitem;
+ dockitem.Displayed = false;
+ if (dockitem.OriginalBarName == "")
+ {
+ dockitem.OriginalBarName = this.Name;
+ dockitem.OriginalPosition = m_ItemContainer.SubItems.IndexOf(dockitem);
+ }
+ m_ItemContainer.SubItems.Remove(dockitem);
+ targetBar.Items.Add(dockitem);
+ }
+ }
+ targetBar.RecalcLayout();
+
+ if (firstItem != null)
+ {
+ targetBar.SelectedDockContainerItem = firstItem;
+ //if (f != null && firstItem.Control!=null) f.ActiveControl = firstItem.Control;
+ }
+ targetBar.InvokeBarDockEvents();
+
+ DotNetBarManager manager = m_Owner as DotNetBarManager;
+ if (manager != null)
+ {
+ m_MoveWindow = false;
+ targetBar = null;
+
+ if (this.CustomBar)
+ {
+ manager.Bars.Remove(this);
+ this.Dispose();
+ }
+ else
+ {
+ this.Visible = false;
+ }
+
+ if (manager.ParentForm != null)
+ manager.ParentForm.Activate();
+ return;
+ }
+ }
+ else
+ {
+ Form f = targetBar.FindForm();
+ if (f != null) f.ActiveControl = targetBar;
+ DockContainerItem dockitem = m_ItemContainer.SubItems[m_DockTabTearOffIndex] as DockContainerItem;
+ dockitem.Displayed = false;
+ m_ItemContainer.SubItems.Remove(dockitem);
+ targetBar.Items.Add(dockitem);
+
+ targetBar.SelectedDockContainerItem = dockitem;
+ targetBar.RecalcLayout();
+ //if (f != null && dockitem.Control != null) f.ActiveControl = dockitem.Control;
+ targetBar.InvokeBarDockEvents();
+ }
+ }
+ m_TempTabBar = null;
+ m_DockTabTearOffIndex = -1;
+ m_MoveWindow = false;
+ m_DragDockInfo = new DockSiteInfo();
+ return;
+ }
+
+ if (m_DockTabTearOffIndex != -1)
+ {
+ DisposeDockingPreview();
+ if (revertLast)
+ DockingHandler(m_LastDockSiteInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y)));
+ else
+ {
+ DockContainerItem dc = (DockContainerItem)this.Items[m_DockTabTearOffIndex];
+ Bar bar = TearOffDockContainerItem(dc, false);
+ bar.DockingHandler(m_DragDockInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y)));
+ Form f = this.FindForm();
+ if (f != null && dc != null && dc.Control != null)
+ {
+ f.ActiveControl = dc.Control;
+ }
+ }
+ m_DragDockInfo = new DockSiteInfo();
+ m_DockTabTearOffIndex = -1;
+ }
+ else
+ {
+ if (!m_OldOutlineRectangle.IsEmpty || m_OutlineForm != null)
+ {
+ DisposeDockingPreview();
+ if (revertLast)
+ {
+ if (this.LayoutType == eLayoutType.Toolbar)
+ DockingHandler(m_LastDockSiteInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y)));
+ }
+ else
+ DockingHandler(m_DragDockInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y)));
+ m_DragDockInfo = new DockSiteInfo();
+ }
+ else if (revertLast)
+ {
+ DockingHandler(m_LastDockSiteInfo, this.PointToScreen(new Point(mousePos.X, mousePos.Y)));
+ m_DragDockInfo = new DockSiteInfo();
+ }
+ }
+
+ m_MoveWindow = false;
+ }
+
+ private void DisposeDockingPreview()
+ {
+ if (!m_OldOutlineRectangle.IsEmpty || m_OutlineForm != null)
+ {
+ if (!m_OldOutlineRectangle.IsEmpty)
+ {
+ NativeFunctions.DrawReversibleDesktopRect(m_OldOutlineRectangle, DRAGRECTANGLE_WIDTH);
+ m_OldOutlineRectangle = Rectangle.Empty;
+ }
+ if (m_OutlineForm != null)
+ {
+ m_OutlineForm.Visible = false;
+ m_OutlineForm.Dispose();
+ m_OutlineForm = null;
+ }
+ }
+ }
+
+ internal Bar StartTabDrag()
+ {
+ if (m_TabDockItems.SelectedTab == null)
+ return null;
+ DockContainerItem item = m_TabDockItems.SelectedTab.AttachedItem as DockContainerItem;
+ if (item == null)
+ return null;
+ DotNetBarManager manager = m_Owner as DotNetBarManager;
+ if (manager == null)
+ return null;
+
+ if (this.VisibleItemCount == 1 && this.GrabHandleStyle == eGrabHandleStyle.None)
+ {
+ this.StartBarMove();
+ return this;
+ }
+ else if (!this.CanUndock)
+ {
+ m_DockTabTearOffIndex = this.Items.IndexOf(item);
+ this.StartBarMove();
+ return this;
+ }
+
+ Bar bar = TearOffDockContainerItem(item, true);
+ bar.InitalFloatLocation = Point.Empty;
+ bar.StartBarMove();
+ return bar;
+ }
+
+ internal Bar TearOffDockContainerItem(DockContainerItem item, bool floatBar)
+ {
+ return TearOffDockContainerItem(item, floatBar, new Point(Control.MousePosition.X - 32, Control.MousePosition.Y - 8));
+ }
+ internal Bar TearOffDockContainerItem(DockContainerItem item, bool floatBar, Point initialFloatLocation)
+ {
+ Form f = this.FindForm();
+ if (f != null)
+ {
+ f.ActiveControl = this;
+ }
+ DotNetBarManager manager = m_Owner as DotNetBarManager;
+ m_ItemContainer.SubItems.Remove(item);
+ this.RecalcLayout();
+ Bar bar = BarFunctions.CreateDuplicateDockBar(this);
+ bar.Text = item.Text;
+
+ bar.InitalFloatLocation = initialFloatLocation;
+
+ if (manager.Bars.Contains(item.Name))
+ {
+ string name = item.Name;
+ int i = 0;
+ while (manager.Bars.Contains(name + i.ToString()))
+ i++;
+ bar.Name = name + i.ToString();
+ }
+ else
+ bar.Name = item.Name;
+
+ bar.Items.Add(item);
+ manager.Bars.Add(bar);
+
+ if (floatBar)
+ {
+ bar.DockSide = eDockSide.None;
+ bar.Location = initialFloatLocation;
+ }
+
+ bar.LastDockSide = this.DockSide;
+ bar.m_LastDockSiteInfo.objDockSite = this.Parent as DockSite;
+ bar.m_LastDockSiteInfo.LastRelativeDockToBar = this;
+ bar.m_LastDockSiteInfo.LastDockSiteSide = this.DockSide;
+
+ bar.CustomBar = true;
+
+ IOwnerBarSupport ownerBar = m_Owner as IOwnerBarSupport;
+ if (ownerBar != null)
+ {
+ if (ownerBar.ApplyDocumentBarStyle && this.DockSide == eDockSide.Document)
+ BarFunctions.RestoreAutoDocumentBarStyle(bar); //BarFunctions.ApplyAutoDocumentBarStyle(bar);
+ ownerBar.InvokeBarTearOff(bar, new EventArgs());
+ }
+
+ return bar;
+ }
+
+ internal void StartBarMove()
+ {
+ m_MouseDownPt = this.PointToClient(Control.MousePosition);
+ m_MouseDownSize = this.Size;
+ this.Cursor = System.Windows.Forms.Cursors.SizeAll;
+ m_MoveWindow = true;
+ }
+
+ internal void InvokeUserVisibleChanged()
+ {
+ if (UserVisibleChanged != null)
+ UserVisibleChanged(this, new EventArgs());
+ }
+
+ private void InvokeAutoHideChanged()
+ {
+ EventArgs e = new EventArgs();
+ if (AutoHideChanged != null)
+ AutoHideChanged(this, e);
+ IOwnerBarSupport barSupp = m_Owner as IOwnerBarSupport;
+ if (barSupp != null)
+ barSupp.InvokeAutoHideChanged(this, e);
+ OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.AutoHideChanged));
+ }
+
+ ///
+ /// Closes the DockContainerItem with event source set to Code.
+ ///
+ /// DockContainerItem to close.
+ public void CloseDockTab(DockContainerItem dockTab)
+ {
+ CloseDockTab(dockTab, eEventSource.Code);
+ }
+
+ ///
+ /// Closes the DockContainerItem.
+ ///
+ /// DockContainerItem to close.
+ /// Source of the event.
+ public void CloseDockTab(DockContainerItem dockTab, eEventSource source)
+ {
+ DockTabClosingEventArgs e = new DockTabClosingEventArgs(dockTab, source);
+ InvokeDockTabClosing(e);
+ if (e.Cancel)
+ return;
+
+ if (this.VisibleItemCount > 1)
+ {
+ if (e.RemoveDockTab)
+ this.Items.Remove(dockTab);
+ else
+ BarUtilities.SetDockContainerVisible(dockTab, false);
+ }
+ else
+ {
+ if (e.RemoveDockTab)
+ this.Items.Remove(dockTab);
+ CloseBar();
+ if (!this.Visible)
+ dockTab.Visible = false;
+ }
+
+ InvokeDockTabClosed(e);
+ }
+
+ private void InvokeDockTabClosed(DockTabClosingEventArgs e)
+ {
+ if (DockTabClosed != null)
+ DockTabClosed(this, e);
+ if (this.Owner is DotNetBarManager)
+ {
+ ((DotNetBarManager)this.Owner).InvokeDockTabClosed(this, e);
+ }
+ OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.DockTabClosed, e.DockContainerItem));
+ }
+
+ internal void InvokeDockTabClosing(DockTabClosingEventArgs e)
+ {
+ if (DockTabClosing != null)
+ DockTabClosing(this, e);
+ if (this.Owner is DotNetBarManager)
+ {
+ ((DotNetBarManager)this.Owner).InvokeDockTabClosing(this, e);
+ }
+ }
+
+ private void InvokeBarClosing(BarClosingEventArgs e)
+ {
+ if (Closing != null)
+ Closing(this, e);
+ IOwnerBarSupport barSupp = m_Owner as IOwnerBarSupport;
+ if (barSupp != null)
+ barSupp.InvokeBarClosing(this, e);
+ }
+
+ ///
+ /// Raises the ItemClick event.
+ ///
+ /// Item that was clicked.
+ /// Event arguments.
+ protected virtual void OnItemClick(BaseItem item, EventArgs e)
+ {
+ if (ItemClick != null)
+ ItemClick(item, e);
+ }
+
+ internal void InvokeItemClick(BaseItem item, EventArgs e)
+ {
+ OnItemClick(item, e);
+ }
+
+ protected override void OnClick(EventArgs e)
+ {
+ m_ItemContainer.InternalClick(Control.MouseButtons, this.PointToClient(Control.MousePosition));
+ base.OnClick(e);
+ }
+
+ private eDoubleClickBarBehavior _DoubleClickBehavior = eDoubleClickBarBehavior.FloatAndReDock;
+ ///
+ /// Specifies the bar behavior when its title is double-clicked
+ ///
+ [DefaultValue(eDoubleClickBarBehavior.FloatAndReDock), Category("Behavior"), Description("Specifies the bar behavior when its title is double-clicked")]
+ public eDoubleClickBarBehavior DoubleClickBehavior
+ {
+ get { return _DoubleClickBehavior; }
+ set { _DoubleClickBehavior = value; }
+ }
+
+ protected override void OnDoubleClick(EventArgs e)
+ {
+ if (m_BarState == eBarState.Popup)
+ {
+ ISite site = this.GetSite();
+ if (site != null && site.DesignMode)
+ {
+ ISelectionService selection = (ISelectionService)site.GetService(typeof(ISelectionService));
+ if (selection != null)
+ {
+ IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost));
+ if (host != null)
+ {
+ IDesigner designer = host.GetDesigner(selection.PrimarySelection as IComponent);
+ if (designer != null)
+ {
+ designer.DoDefaultAction();
+ }
+ }
+ }
+ }
+ }
+
+
+ Point mouseDownPoint = this.PointToClient(Control.MousePosition);
+ if (m_GrabHandleRect.Contains(mouseDownPoint) &&
+ !m_SystemButtons.CloseButtonRect.Contains(mouseDownPoint) &&
+ !m_SystemButtons.AutoHideButtonRect.Contains(mouseDownPoint))
+ {
+ if (m_BarState == eBarState.Floating)
+ {
+ if (_DoubleClickBehavior == eDoubleClickBarBehavior.ReDock || _DoubleClickBehavior == eDoubleClickBarBehavior.FloatAndReDock)
+ ReDock();
+ }
+ else if (m_BarState == eBarState.Docked && this.CanUndock && this.Parent is DockSite)
+ {
+ Point p = Point.Empty;
+ if (m_FloatingRect.IsEmpty)
+ p = Control.MousePosition;
+ else
+ p = m_FloatingRect.Location;
+ if (_DoubleClickBehavior == eDoubleClickBarBehavior.Float || _DoubleClickBehavior == eDoubleClickBarBehavior.FloatAndReDock)
+ DockingHandler(new DockSiteInfo(), p);
+ }
+ }
+ if (!this.IsDisposed)
+ m_ItemContainer.InternalDoubleClick(Control.MouseButtons, Control.MousePosition);
+ base.OnDoubleClick(e);
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ ExKeyDown(e);
+ base.OnKeyDown(e);
+ }
+
+ internal void ExKeyDown(KeyEventArgs e)
+ {
+ m_ItemContainer.InternalKeyDown(e);
+ }
+
+ private void ResetHover()
+ {
+ // We need to reset hover thing since it is fired only first time mouse hovers inside the window and we need it for each of our items
+ NativeFunctions.TRACKMOUSEEVENT tme = new NativeFunctions.TRACKMOUSEEVENT();
+ tme.dwFlags = NativeFunctions.TME_QUERY;
+ tme.hwndTrack = this.Handle;
+ tme.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(tme);
+ NativeFunctions.TrackMouseEvent(ref tme);
+ tme.dwFlags = tme.dwFlags | NativeFunctions.TME_HOVER;
+ NativeFunctions.TrackMouseEvent(ref tme);
+ }
+
+ public override string ToString()
+ {
+ return this.Text;
+ }
+
+ private bool m_IsVisible = true;
+ internal bool IsVisible
+ {
+ get
+ {
+ return m_IsVisible;
+ }
+ }
+
+ protected override void OnVisibleChanged(EventArgs e)
+ {
+ if (this.IsHandleCreated)
+ m_IsVisible = base.Visible;
+ // Restore bar order when docked to the side. WinForms can change it's order which
+ // creates problem for docking...
+ if (m_BarShowIndex >= 0)
+ {
+ if (this.Parent is DockSite && this.Parent.Controls.IndexOf(this) != m_BarShowIndex)
+ {
+ this.Parent.Controls.SetChildIndex(this, m_BarShowIndex);
+ }
+ m_BarShowIndex = -1;
+ }
+
+ // Must reset the ActiveControl to null becouse on MDI Forms if this was not done
+ // MDI form could not be closed if bar that had ActiveControl is floating.
+ IOwner owner = m_Owner as IOwner;
+ if (owner != null)
+ {
+ if (owner.ParentForm != null && owner.ParentForm.ActiveControl == this)
+ {
+ owner.ParentForm.ActiveControl = null;
+ this.Focus(); // Fixes the problem on SDI forms
+ }
+ else if (owner.ParentForm != null && IsAnyControl(this, owner.ParentForm.ActiveControl))
+ {
+ owner.ParentForm.ActiveControl = null;
+ this.Focus();
+ }
+ }
+
+ base.OnVisibleChanged(e);
+
+ // m_DockingInProgress check is needed becouse we don't want RecalcLayout to be called from
+ // DockSite.AddBar. The visible change event will fire when from that procedure Bar is added
+ // to the Dock Site.
+ if (m_BarState == eBarState.Docked && !m_DockingInProgress && this.Visible)
+ {
+ if (this.LayoutType == eLayoutType.DockContainer && m_AlwaysDisplayDockTab) RefreshDockTab(false);
+ this.RecalcLayout();
+ }
+
+ if (!this.Visible && m_DropShadow != null)
+ {
+ m_DropShadow.Hide();
+ m_DropShadow.Dispose();
+ m_DropShadow = null;
+ }
+ if (!this.Visible && m_CustomizeMenu != null && m_CustomizeMenu.Expanded)
+ m_CustomizeMenu.Expanded = false;
+
+ }
+
+ private bool m_LayoutSuspended = false;
+ ///
+ /// Suspends normal layout logic.
+ ///
+ public new void SuspendLayout()
+ {
+ m_LayoutSuspended = true;
+ base.SuspendLayout();
+ }
+
+ ///
+ /// Resumes normal layout logic.
+ ///
+ public new void ResumeLayout()
+ {
+ this.ResumeLayout(true);
+ }
+
+ ///
+ /// Resumes normal layout logic. Optionally forces an immediate layout of pending layout requests.
+ ///
+ public new void ResumeLayout(bool performLayout)
+ {
+ m_LayoutSuspended = false;
+ base.ResumeLayout(true);
+ }
+
+ protected override void OnParentChanged(EventArgs e)
+ {
+ base.OnParentChanged(e);
+ if (this.Parent != null && !(this.Parent is FloatingContainer) && !(this.Parent is DockSite))
+ {
+ m_ItemContainer.SetOwner(this);
+ if (!m_ParentMsgHandlerRegistered && this.DesignMode && this.FindForm() != null)
+ {
+ DotNetBarManager.RegisterOwnerParentMsgHandler(this, this.FindForm());
+ m_ParentMsgHandlerRegistered = true;
+ }
+
+ // Cycle shortcuts
+ if (m_ShortcutTable.Count == 0)
+ {
+ foreach (BaseItem item in m_ItemContainer.SubItems)
+ ((IOwner)this).AddShortcutsFromItem(item);
+ }
+
+ if (this.Parent != null && !(this.Parent is FloatingContainer) && !(this.Parent is DockSite) && !this.AutoHide)
+ {
+ if (!m_FilterInstalled)
+ {
+ MessageHandler.RegisterMessageClient(this);
+ m_FilterInstalled = true;
+ }
+ }
+
+ if (!m_DockStretch) Stretch = true;
+ }
+ else if (m_FilterInstalled)
+ {
+ MessageHandler.UnregisterMessageClient(this);
+ m_FilterInstalled = false;
+ }
+
+ if (this.DesignMode)
+ m_ItemContainer.SetDesignMode(this.DesignMode);
+ }
+
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ base.OnHandleCreated(e);
+ if (m_ThemeWindowMargins.IsEmpty)
+ {
+ RefreshThemeMargins();
+ }
+
+ if (this.Parent != null && !(this.Parent is FloatingContainer) && !(this.Parent is DockSite) && !this.AutoHide)
+ {
+ if (!m_FilterInstalled)
+ {
+ MessageHandler.RegisterMessageClient(this);
+ m_FilterInstalled = true;
+ }
+ }
+
+ this.RecalcSize();
+ }
+
+ protected override void OnHandleDestroyed(EventArgs e)
+ {
+ DisposeThemes();
+ MenuEventSupportUnhook();
+ if (m_FilterInstalled)
+ {
+ MessageHandler.UnregisterMessageClient(this);
+ m_FilterInstalled = false;
+ }
+ base.OnHandleDestroyed(e);
+ }
+
+ private void RefreshThemeMargins()
+ {
+ if (!BarFunctions.ThemedOS)
+ return;
+
+ ThemeWindow theme = this.ThemeWindow;
+ Graphics g = this.CreateGraphics();
+ try
+ {
+ System.Drawing.Size sz = theme.ThemeMinSize(g, ThemeWindowParts.SmallFrameLeft, ThemeWindowStates.FrameActive);
+ m_ThemeWindowMargins.Left = sz.Width;
+ sz = theme.ThemeMinSize(g, ThemeWindowParts.SmallFrameRight, ThemeWindowStates.FrameActive);
+ m_ThemeWindowMargins.Right = sz.Width;
+ sz = theme.ThemeMinSize(g, ThemeWindowParts.SmallFrameBottom, ThemeWindowStates.FrameActive);
+ m_ThemeWindowMargins.Bottom = sz.Height;
+ sz = theme.ThemeTrueSize(g, ThemeWindowParts.SmallCaption, ThemeWindowStates.FrameActive);
+ m_ThemeWindowMargins.Top = sz.Height;
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ }
+
+ private void DisposeThemes()
+ {
+ if (m_ThemeWindow != null)
+ {
+ m_ThemeWindow.Dispose();
+ m_ThemeWindow = null;
+ }
+ if (m_ThemeRebar != null)
+ {
+ m_ThemeRebar.Dispose();
+ m_ThemeRebar = null;
+ }
+ if (m_ThemeToolbar != null)
+ {
+ m_ThemeToolbar.Dispose();
+ m_ThemeToolbar = null;
+ }
+ if (m_ThemeHeader != null)
+ {
+ m_ThemeHeader.Dispose();
+ m_ThemeHeader = null;
+ }
+ if (m_ThemeScrollBar != null)
+ {
+ m_ThemeScrollBar.Dispose();
+ m_ThemeScrollBar = null;
+ }
+ if (m_ThemeProgress != null)
+ {
+ m_ThemeProgress.Dispose();
+ m_ThemeProgress = null;
+ }
+ }
+ private void RefreshThemes()
+ {
+ if (m_ThemeWindow != null)
+ {
+ m_ThemeWindow.Dispose();
+ m_ThemeWindow = new ThemeWindow(this);
+ }
+ if (m_ThemeRebar != null)
+ {
+ m_ThemeRebar.Dispose();
+ m_ThemeRebar = new ThemeRebar(this);
+ }
+ if (m_ThemeToolbar != null)
+ {
+ m_ThemeToolbar.Dispose();
+ m_ThemeToolbar = new ThemeToolbar(this);
+ }
+ if (m_ThemeHeader != null)
+ {
+ m_ThemeHeader.Dispose();
+ m_ThemeHeader = new ThemeHeader(this);
+ }
+ if (m_ThemeScrollBar != null)
+ {
+ m_ThemeScrollBar.Dispose();
+ m_ThemeScrollBar = new ThemeScrollBar(this);
+ }
+ if (m_ThemeProgress != null)
+ {
+ m_ThemeProgress.Dispose();
+ m_ThemeProgress = new ThemeProgress(this);
+ }
+ }
+ internal DevComponents.DotNetBar.ThemeWindow ThemeWindow
+ {
+ get
+ {
+ if (m_ThemeWindow == null)
+ m_ThemeWindow = new ThemeWindow(this);
+ return m_ThemeWindow;
+ }
+ }
+ internal DevComponents.DotNetBar.ThemeRebar ThemeRebar
+ {
+ get
+ {
+ if (m_ThemeRebar == null)
+ m_ThemeRebar = new ThemeRebar(this);
+ return m_ThemeRebar;
+ }
+ }
+ internal DevComponents.DotNetBar.ThemeToolbar ThemeToolbar
+ {
+ get
+ {
+ if (m_ThemeToolbar == null)
+ m_ThemeToolbar = new ThemeToolbar(this);
+ return m_ThemeToolbar;
+ }
+ }
+ internal DevComponents.DotNetBar.ThemeHeader ThemeHeader
+ {
+ get
+ {
+ if (m_ThemeHeader == null)
+ m_ThemeHeader = new ThemeHeader(this);
+ return m_ThemeHeader;
+ }
+ }
+ internal DevComponents.DotNetBar.ThemeScrollBar ThemeScrollBar
+ {
+ get
+ {
+ if (m_ThemeScrollBar == null)
+ m_ThemeScrollBar = new ThemeScrollBar(this);
+ return m_ThemeScrollBar;
+ }
+ }
+ internal DevComponents.DotNetBar.ThemeProgress ThemeProgress
+ {
+ get
+ {
+ if (m_ThemeProgress == null)
+ m_ThemeProgress = new ThemeProgress(this);
+ return m_ThemeProgress;
+ }
+ }
+
+ private int ClientMarginLeft
+ {
+ get
+ {
+ int iMargin = 0;
+
+ if (m_ParentItem != null && m_ParentItem.EffectiveStyle != eDotNetBarStyle.Office2000)
+ iMargin = 1;
+ else
+ iMargin = 3;
+
+ return iMargin;
+ }
+ }
+
+ private int ClientMarginTop
+ {
+ get
+ {
+ int iMargin = 0;
+ if (m_ParentItem != null && m_ParentItem.EffectiveStyle != eDotNetBarStyle.Office2000)
+ iMargin = 2;
+ else
+ iMargin = 3;
+
+ return iMargin;
+ }
+ }
+
+ private int ClientMarginRight
+ {
+ get
+ {
+ bool bShowShadow = true;
+ int iMargin = 0;
+ IOwnerMenuSupport ownersupport = m_Owner as IOwnerMenuSupport;
+ if (ownersupport != null && !ownersupport.ShowPopupShadow)
+ bShowShadow = false;
+ if (m_ParentItem != null && m_ParentItem.EffectiveStyle != eDotNetBarStyle.Office2000)
+ {
+ if (this.AlphaShadow || !bShowShadow)
+ iMargin = 1;
+ else
+ iMargin = 3;
+ }
+ else
+ iMargin = 3;
+
+ return iMargin;
+ }
+ }
+
+ private int ClientMarginBottom
+ {
+ get
+ {
+ bool bShowShadow = true;
+ int iMargin = 0;
+ IOwnerMenuSupport ownersupport = m_Owner as IOwnerMenuSupport;
+ if (ownersupport != null && !ownersupport.ShowPopupShadow)
+ bShowShadow = false;
+ if (m_ParentItem != null && m_ParentItem.EffectiveStyle != eDotNetBarStyle.Office2000)
+ {
+ if (this.AlphaShadow || !bShowShadow)
+ iMargin = 2;
+ else
+ iMargin = 4;
+ }
+ else
+ iMargin = 3;
+
+ return iMargin;
+ }
+ }
+
+ ///
+ /// Returns whether popup bar should display shadow.
+ ///
+ internal bool DisplayShadow
+ {
+ get
+ {
+ if (PassiveBar)
+ return false;
+ IOwnerMenuSupport ownersupport = m_Owner as IOwnerMenuSupport;
+ if (ownersupport != null)
+ {
+ if (m_ParentItem != null && m_ParentItem.EffectiveStyle == eDotNetBarStyle.Office2000)
+ {
+ if (ownersupport.MenuDropShadow == eMenuDropShadow.Show)
+ return true;
+ else
+ return false;
+ }
+ return ownersupport.ShowPopupShadow;
+ }
+ else
+ {
+ if (m_ParentItem != null && m_ParentItem.EffectiveStyle == eDotNetBarStyle.Office2000)
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ ///
+ /// Returns whether popup bar shadow should be alpha-blended.
+ ///
+ internal bool AlphaShadow
+ {
+ get
+ {
+ if (Environment.OSVersion.Version.Major < 5)
+ return false;
+ IOwnerMenuSupport ownersupport = m_Owner as IOwnerMenuSupport;
+ if (ownersupport != null && !ownersupport.AlphaBlendShadow)
+ return false;
+ return NativeFunctions.CursorShadow;
+ }
+ }
+
+ protected override void OnGotFocus(EventArgs e)
+ {
+ base.OnGotFocus(e);
+ if (this.MenuBar)
+ this.Refresh();
+ }
+
+ protected override void OnLostFocus(EventArgs e)
+ {
+ base.OnLostFocus(e);
+ if (this.MenuBar)
+ this.Refresh();
+ }
+
+ internal bool MenuFocus
+ {
+ get
+ {
+ return m_MenuFocus;
+ }
+ set
+ {
+ if (m_MenuFocus != value)
+ {
+ m_MenuFocus = value;
+ if (m_MenuFocus)
+ {
+ m_ItemContainer.SetSystemFocus();
+ DotNetBarManager manager = m_Owner as DotNetBarManager;
+ if (manager != null)
+ manager.FocusedBar = this;
+ }
+ else
+ {
+ if (m_ItemContainer != null)
+ {
+ m_ItemContainer.AutoExpand = false;
+ m_ItemContainer.ReleaseSystemFocus();
+ m_ItemContainer.ContainerLostFocus(false);
+ }
+
+ DotNetBarManager manager = m_Owner as DotNetBarManager;
+ if (manager != null)
+ manager.FocusedBar = null;
+ }
+ if (this.MenuBar)
+ {
+ this.Refresh();
+ }
+ }
+ }
+ }
+
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public void SetDesignMode(bool b)
+ {
+ m_ItemContainer.SetDesignMode(b);
+ }
+
+ internal bool GetDesignMode()
+ {
+ return this.DesignMode;
+ }
+
+ internal int PopupWidth
+ {
+ get
+ {
+ return m_InitialContainerWidth;
+ }
+ set
+ {
+ m_InitialContainerWidth = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets the popup animation that will be applied when popup is shown.
+ ///
+ [System.ComponentModel.Browsable(false), DefaultValue(ePopupAnimation.ManagerControlled)]
+ public ePopupAnimation PopupAnimation
+ {
+ get
+ {
+ return m_PopupAnimation;
+ }
+ set
+ {
+ m_PopupAnimation = value;
+ }
+ }
+
+ #region ICustomSerialization Implementation
+ ///
+ /// Invokes SerializeItem event.
+ ///
+ /// Provides data for the event.
+ void ICustomSerialization.InvokeSerializeItem(SerializeItemEventArgs e)
+ {
+ if (SerializeItem != null)
+ SerializeItem(this, e);
+ if (this.Owner != this && this.Owner is ICustomSerialization)
+ ((ICustomSerialization)this.Owner).InvokeSerializeItem(e);
+ }
+
+ ///
+ /// Invokes DeserializeItem event.
+ ///
+ /// Provides data for the event.
+ void ICustomSerialization.InvokeDeserializeItem(SerializeItemEventArgs e)
+ {
+ if (DeserializeItem != null)
+ DeserializeItem(this, e);
+ if (this.Owner != this && this.Owner is ICustomSerialization)
+ ((ICustomSerialization)this.Owner).InvokeDeserializeItem(e);
+ }
+
+ ///
+ /// Gets whether any handlers have been defined for SerializeItem event. If no handles have been defined to optimize performance SerializeItem event will not be attempted to fire.
+ ///
+ bool ICustomSerialization.HasSerializeItemHandlers
+ {
+ get
+ {
+ bool b = SerializeItem != null;
+ if (this.Owner != this && this.Owner is ICustomSerialization)
+ b |= ((ICustomSerialization)this.Owner).HasSerializeItemHandlers;
+ return b;
+ }
+ }
+
+ ///
+ /// Gets whether any handlers have been defined for DeserializeItem event. If no handles have been defined to optimize performance DeserializeItem event will not be attempted to fire.
+ ///
+ bool ICustomSerialization.HasDeserializeItemHandlers
+ {
+ get
+ {
+ bool b = DeserializeItem != null;
+ if (this.Owner != this && this.Owner is ICustomSerialization)
+ b |= ((ICustomSerialization)this.Owner).HasDeserializeItemHandlers;
+ return b;
+ }
+ }
+ #endregion
+
+ ///
+ /// Saves the Bar definition to file.
+ ///
+ /// Definition file name.
+ public void SaveDefinition(string FileName)
+ {
+ System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
+
+ this.SaveDefinition(xmlDoc);
+
+ xmlDoc.Save(FileName);
+ }
+
+ internal void SaveDefinition(System.Xml.XmlDocument xmlDoc)
+ {
+ System.Xml.XmlElement xmlBar = xmlDoc.CreateElement("bar");
+ xmlDoc.AppendChild(xmlBar);
+ this.Serialize(xmlBar);
+ }
+
+ ///
+ /// Loads the Bar definition from file.
+ ///
+ /// Definition file name.
+ public void LoadDefinition(string FileName)
+ {
+ System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
+ xmlDoc.Load(FileName);
+ this.LoadDefinition(xmlDoc);
+ }
+
+ internal void LoadDefinition(System.Xml.XmlDocument xmlDoc)
+ {
+ if (xmlDoc.FirstChild.Name != "bar")
+ throw (new System.InvalidOperationException("XML Format not recognized"));
+
+ m_ItemContainer.SubItems.Clear();
+ this.Deserialize(xmlDoc.FirstChild as System.Xml.XmlElement);
+
+ IOwnerBarSupport ownersupport = m_Owner as IOwnerBarSupport;
+ if (ownersupport != null)
+ ownersupport.AddShortcutsFromBar(this);
+
+ ((IOwner)this).InvokeDefinitionLoaded(this, new EventArgs());
+ }
+
+ ///
+ /// Gets/Sets Bar definition as XML string.
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public string Definition
+ {
+ get
+ {
+ System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
+ SaveDefinition(xmlDoc);
+ return xmlDoc.OuterXml;
+ }
+ set
+ {
+ System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
+ xmlDoc.LoadXml(value);
+ LoadDefinition(xmlDoc);
+ }
+ }
+
+ void IOwner.InvokeDefinitionLoaded(object sender, EventArgs e)
+ {
+ if (DefinitionLoaded != null)
+ DefinitionLoaded(sender, e);
+ }
+
+ internal void Serialize(System.Xml.XmlElement xmlThisBar)
+ {
+ Serialize(xmlThisBar, false);
+ }
+
+ internal void Serialize(System.Xml.XmlElement xmlThisBar, bool bPropertiesOnly)
+ {
+ // Creates serialization context
+ ItemSerializationContext context = new ItemSerializationContext();
+ context.Serializer = this;
+ context.HasDeserializeItemHandlers = ((ICustomSerialization)this).HasDeserializeItemHandlers;
+ context.HasSerializeItemHandlers = ((ICustomSerialization)this).HasSerializeItemHandlers;
+
+ xmlThisBar.SetAttribute("name", this.Name);
+ xmlThisBar.SetAttribute("candockleft", System.Xml.XmlConvert.ToString(m_CanDockLeft));
+ xmlThisBar.SetAttribute("candockright", System.Xml.XmlConvert.ToString(m_CanDockRight));
+ xmlThisBar.SetAttribute("candocktop", System.Xml.XmlConvert.ToString(m_CanDockTop));
+ xmlThisBar.SetAttribute("candockbottom", System.Xml.XmlConvert.ToString(m_CanDockBottom));
+ xmlThisBar.SetAttribute("candockdoc", System.Xml.XmlConvert.ToString(m_CanDockDocument));
+ xmlThisBar.SetAttribute("candocktab", System.Xml.XmlConvert.ToString(m_CanDockTab));
+ xmlThisBar.SetAttribute("canmaximizefloating", System.Xml.XmlConvert.ToString(_CanMaximizeFloating));
+ xmlThisBar.SetAttribute("text", this.Text);
+ xmlThisBar.SetAttribute("dockline", System.Xml.XmlConvert.ToString(m_DockLine));
+ if (/*m_DockOffset==0 && this.Left>0 && */ (this.DockSide == eDockSide.Top || this.DockSide == eDockSide.Bottom))
+ xmlThisBar.SetAttribute("dockoffset", System.Xml.XmlConvert.ToString(this.Left));
+ else if (/*m_DockOffset==0 && this.Top>0 &&*/ (this.DockSide == eDockSide.Left || this.DockSide == eDockSide.Right))
+ xmlThisBar.SetAttribute("dockoffset", System.Xml.XmlConvert.ToString(this.Top));
+ //else
+ // xmlThisBar.SetAttribute("dockoffset",System.Xml.XmlConvert.ToString(m_DockOffset));
+ xmlThisBar.SetAttribute("grabhandle", System.Xml.XmlConvert.ToString((int)m_GrabHandleStyle));
+ xmlThisBar.SetAttribute("menubar", System.Xml.XmlConvert.ToString(m_MenuBar));
+ xmlThisBar.SetAttribute("stretch", System.Xml.XmlConvert.ToString(m_DockStretch));
+ xmlThisBar.SetAttribute("style", System.Xml.XmlConvert.ToString((int)m_ItemContainer.Style));
+ xmlThisBar.SetAttribute("wrapdock", System.Xml.XmlConvert.ToString(m_WrapItemsDock));
+ xmlThisBar.SetAttribute("wrapfloat", System.Xml.XmlConvert.ToString(m_WrapItemsFloat));
+ if (m_LockDockPosition)
+ xmlThisBar.SetAttribute("lockdockpos", System.Xml.XmlConvert.ToString(m_LockDockPosition));
+ if (!m_CanUndock)
+ xmlThisBar.SetAttribute("canundock", System.Xml.XmlConvert.ToString(m_CanUndock));
+ if (m_TabNavigation)
+ xmlThisBar.SetAttribute("tabnav", System.Xml.XmlConvert.ToString(m_TabNavigation));
+
+ if (!m_ShowToolTips)
+ xmlThisBar.SetAttribute("tooltips", System.Xml.XmlConvert.ToString(m_ShowToolTips));
+
+ if (m_ItemContainer.MoreItemsOnMenu)
+ xmlThisBar.SetAttribute("overflowmenu", System.Xml.XmlConvert.ToString(m_ItemContainer.MoreItemsOnMenu));
+
+ if (m_AutoHideState)
+ {
+ xmlThisBar.SetAttribute("state", System.Xml.XmlConvert.ToString((int)eBarState.Docked));
+ eDockSide dockside = eDockSide.None;
+ switch (m_LastDockSiteInfo.DockSide)
+ {
+ case DockStyle.Left:
+ dockside = eDockSide.Left;
+ break;
+ case DockStyle.Right:
+ dockside = eDockSide.Right;
+ break;
+ case DockStyle.Top:
+ dockside = eDockSide.Top;
+ break;
+ case DockStyle.Bottom:
+ dockside = eDockSide.Bottom;
+ break;
+ }
+ xmlThisBar.SetAttribute("dockside", System.Xml.XmlConvert.ToString((int)dockside));
+ }
+ else
+ {
+ xmlThisBar.SetAttribute("state", System.Xml.XmlConvert.ToString((int)m_BarState));
+ xmlThisBar.SetAttribute("dockside", System.Xml.XmlConvert.ToString((int)this.DockSide));
+ if (this.DockSide == eDockSide.None && m_Float != null)
+ xmlThisBar.SetAttribute("fpos", m_Float.Location.X + "," + m_Float.Location.Y + "," + this.DisplayRectangle.Width + "," + this.DisplayRectangle.Height);
+ }
+
+ IOwnerBarSupport ownersupport = m_Owner as IOwnerBarSupport;
+ if (m_BarState == eBarState.Floating && !this.Visible && ownersupport != null && ownersupport.WereVisible.Count > 0 && ownersupport.WereVisible.Contains(this))
+ xmlThisBar.SetAttribute("visible", System.Xml.XmlConvert.ToString(true));
+ else
+ {
+ if (m_AutoHideState)
+ {
+ xmlThisBar.SetAttribute("visible", System.Xml.XmlConvert.ToString(true));
+ xmlThisBar.SetAttribute("autohide", System.Xml.XmlConvert.ToString(true));
+ }
+ else
+ xmlThisBar.SetAttribute("visible", System.Xml.XmlConvert.ToString(this.Visible));
+ }
+ xmlThisBar.SetAttribute("custom", System.Xml.XmlConvert.ToString(m_CustomBar));
+ xmlThisBar.SetAttribute("canhide", System.Xml.XmlConvert.ToString(m_CanHide));
+ xmlThisBar.SetAttribute("imagesize", System.Xml.XmlConvert.ToString((int)m_ImageSize));
+ xmlThisBar.SetAttribute("itemsp", System.Xml.XmlConvert.ToString(m_ItemContainer.ItemSpacing));
+
+ xmlThisBar.SetAttribute("themes", System.Xml.XmlConvert.ToString(m_ThemeAware));
+
+ if (!m_ItemContainer.CanCustomize)
+ xmlThisBar.SetAttribute("cancust", System.Xml.XmlConvert.ToString(m_ItemContainer.CanCustomize));
+
+ // Save Font information if needed
+ if (this.Font != null)
+ {
+ if (m_CustomFont)
+ {
+ xmlThisBar.SetAttribute("fontname", this.Font.Name);
+ xmlThisBar.SetAttribute("fontemsize", System.Xml.XmlConvert.ToString(this.Font.Size));
+ xmlThisBar.SetAttribute("fontstyle", System.Xml.XmlConvert.ToString((int)this.Font.Style));
+ }
+ }
+
+ if (!m_ItemContainer.m_BackgroundColor.IsEmpty)
+ xmlThisBar.SetAttribute("backcolor", BarFunctions.ColorToString(m_ItemContainer.BackColor));
+ xmlThisBar.SetAttribute("layout", System.Xml.XmlConvert.ToString((int)m_ItemContainer.LayoutType));
+ xmlThisBar.SetAttribute("eqbutton", System.Xml.XmlConvert.ToString(m_ItemContainer.EqualButtonSize));
+ if (m_DockedBorder != eBorderType.None)
+ xmlThisBar.SetAttribute("dborder", System.Xml.XmlConvert.ToString((int)m_DockedBorder));
+
+ if (!m_AcceptDropItems)
+ xmlThisBar.SetAttribute("acceptdrop", System.Xml.XmlConvert.ToString(m_AcceptDropItems));
+
+ if (m_SingleLineColor != SystemColors.ControlDark)
+ xmlThisBar.SetAttribute("slcolor", BarFunctions.ColorToString(m_SingleLineColor));
+
+ if (!m_CaptionBackColor.IsEmpty)
+ xmlThisBar.SetAttribute("captionbc", BarFunctions.ColorToString(m_CaptionBackColor));
+ if (!m_CaptionForeColor.IsEmpty)
+ xmlThisBar.SetAttribute("captionfc", BarFunctions.ColorToString(m_CaptionForeColor));
+
+ if (m_AlwaysDisplayDockTab)
+ xmlThisBar.SetAttribute("showtab", System.Xml.XmlConvert.ToString(m_AlwaysDisplayDockTab));
+
+ if (this.AutoHide)
+ {
+ if (m_ItemContainer.MinWidth != 0)
+ xmlThisBar.SetAttribute("dockwidth", System.Xml.XmlConvert.ToString(m_ItemContainer.MinWidth));
+ else if (m_LastDockSiteInfo.DockedWidth != 0)
+ xmlThisBar.SetAttribute("dockwidth", System.Xml.XmlConvert.ToString(m_LastDockSiteInfo.DockedWidth));
+ if (m_ItemContainer.MinHeight != 0)
+ xmlThisBar.SetAttribute("dockheight", System.Xml.XmlConvert.ToString(m_ItemContainer.MinHeight));
+ else if (m_LastDockSiteInfo.DockedHeight != 0)
+ xmlThisBar.SetAttribute("dockheight", System.Xml.XmlConvert.ToString(m_LastDockSiteInfo.DockedHeight));
+ }
+ else
+ {
+ if (m_ItemContainer.MinWidth != 0 && this.CanSaveMinWidth)
+ xmlThisBar.SetAttribute("dockwidth", System.Xml.XmlConvert.ToString(m_ItemContainer.MinWidth));
+ if (m_ItemContainer.MinHeight != 0 && this.CanSaveMinHeight)
+ xmlThisBar.SetAttribute("dockheight", System.Xml.XmlConvert.ToString(m_ItemContainer.MinHeight));
+ }
+
+ if (m_SplitDockWidthPercent > 0)
+ xmlThisBar.SetAttribute("splitwidthpercent", System.Xml.XmlConvert.ToString(m_SplitDockWidthPercent));
+ if (m_SplitDockHeightPercent > 0)
+ xmlThisBar.SetAttribute("splitheightpercent", System.Xml.XmlConvert.ToString(m_SplitDockHeightPercent));
+
+
+ if (m_ItemContainer.PaddingBottom != 1)
+ xmlThisBar.SetAttribute("padbottom", System.Xml.XmlConvert.ToString(m_ItemContainer.PaddingBottom));
+ if (m_ItemContainer.PaddingLeft != 1)
+ xmlThisBar.SetAttribute("padleft", System.Xml.XmlConvert.ToString(m_ItemContainer.PaddingLeft));
+ if (m_ItemContainer.PaddingRight != 1)
+ xmlThisBar.SetAttribute("padright", System.Xml.XmlConvert.ToString(m_ItemContainer.PaddingRight));
+ if (m_ItemContainer.PaddingTop != 1)
+ xmlThisBar.SetAttribute("padtop", System.Xml.XmlConvert.ToString(m_ItemContainer.PaddingTop));
+
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && this.SelectedDockTab >= 0)
+ xmlThisBar.SetAttribute("seldocktab", System.Xml.XmlConvert.ToString(this.SelectedDockTab));
+
+ if (!m_CanAutoHide)
+ xmlThisBar.SetAttribute("canautohide", System.Xml.XmlConvert.ToString(m_CanAutoHide));
+ if (!m_CanReorderTabs)
+ xmlThisBar.SetAttribute("canreordertabs", System.Xml.XmlConvert.ToString(m_CanReorderTabs));
+ if (!m_CanTearOffTabs)
+ xmlThisBar.SetAttribute("cantearoff", System.Xml.XmlConvert.ToString(m_CanTearOffTabs));
+
+ // TODO: Menu Merge Implementation
+ //if(m_MergeEnabled)
+ // xmlThisBar.SetAttribute("merge",System.Xml.XmlConvert.ToString(m_MergeEnabled));
+
+ if (!m_HideFloatingInactive)
+ xmlThisBar.SetAttribute("hidein", System.Xml.XmlConvert.ToString(m_HideFloatingInactive));
+
+ if (m_DockTabAlignment != eTabStripAlignment.Bottom)
+ xmlThisBar.SetAttribute("tabalign", System.Xml.XmlConvert.ToString((int)m_DockTabAlignment));
+
+ if (m_AutoHideAnimationTime != 100)
+ xmlThisBar.SetAttribute("ahanim", System.Xml.XmlConvert.ToString(m_AutoHideAnimationTime));
+
+ if (!m_AutoCreateCaptionMenu)
+ xmlThisBar.SetAttribute("autocaptionmenu", System.Xml.XmlConvert.ToString(m_AutoCreateCaptionMenu));
+
+ if (m_AutoSyncBarCaption)
+ xmlThisBar.SetAttribute("autocaptionsync", System.Xml.XmlConvert.ToString(m_AutoSyncBarCaption));
+
+ if (!m_SaveLayoutChanges)
+ xmlThisBar.SetAttribute("savelayout", System.Xml.XmlConvert.ToString(m_SaveLayoutChanges));
+
+ if (m_ColorScheme.SchemeChanged)
+ {
+ System.Xml.XmlElement xmlScheme = xmlThisBar.OwnerDocument.CreateElement("colorscheme");
+ m_ColorScheme.Serialize(xmlScheme);
+ xmlThisBar.AppendChild(xmlScheme);
+ }
+
+ if (this.BackgroundImage != null)
+ {
+ System.Xml.XmlElement elementImage = xmlThisBar.OwnerDocument.CreateElement("backimage");
+ xmlThisBar.AppendChild(elementImage);
+ BarFunctions.SerializeImage(this.BackgroundImage, elementImage);
+ elementImage.SetAttribute("pos", ((int)m_BackgroundImagePosition).ToString());
+ elementImage.SetAttribute("alpha", m_BackgroundImageAlpha.ToString());
+ }
+
+ if (!bPropertiesOnly)
+ {
+ System.Xml.XmlElement xmlItems = xmlThisBar.OwnerDocument.CreateElement("items");
+ xmlThisBar.AppendChild(xmlItems);
+ foreach (BaseItem objItem in m_ItemContainer.SubItems)
+ {
+ if (objItem.ShouldSerialize)
+ {
+ System.Xml.XmlElement xmlItem = xmlThisBar.OwnerDocument.CreateElement("item");
+ xmlItems.AppendChild(xmlItem);
+ context.ItemXmlElement = xmlItem;
+ objItem.Serialize(context);
+ }
+ }
+ }
+ }
+
+ private bool CanSaveMinWidth
+ {
+ get
+ {
+ eDockSide dockSide = this.DockSide;
+ if (dockSide == eDockSide.None || dockSide == eDockSide.Left || dockSide == eDockSide.Right)
+ return true;
+ return false;
+ }
+ }
+
+ private bool CanSaveMinHeight
+ {
+ get
+ {
+ eDockSide dockSide = this.DockSide;
+ if (dockSide == eDockSide.None || dockSide == eDockSide.Top || dockSide == eDockSide.Bottom)
+ return true;
+ return false;
+ }
+ }
+
+ internal void Deserialize(System.Xml.XmlElement xmlThisBar)
+ {
+ // Creates serialization context
+ ItemSerializationContext context = new ItemSerializationContext();
+ context.Serializer = this;
+ context.HasDeserializeItemHandlers = ((ICustomSerialization)this).HasDeserializeItemHandlers;
+ context.HasSerializeItemHandlers = ((ICustomSerialization)this).HasSerializeItemHandlers;
+
+ Deserialize(xmlThisBar, context);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Deserialize(System.Xml.XmlElement xmlThisBar, ItemSerializationContext context)
+ {
+ m_BarDefinitionLoading = true;
+ m_IgnoreAnimation = true;
+ try
+ {
+ LoadCommonProperties(xmlThisBar);
+
+ this.BackgroundImage = null;
+
+ foreach (System.Xml.XmlElement xmlElem in xmlThisBar.ChildNodes)
+ {
+ switch (xmlElem.Name)
+ {
+ case "items":
+ {
+ foreach (System.Xml.XmlElement xmlItem in xmlElem.ChildNodes)
+ {
+ BaseItem objItem = context.CreateItemFromXml(xmlItem);
+ m_ItemContainer.SubItems.Add(objItem);
+ context.ItemXmlElement = xmlItem;
+ objItem.Deserialize(context);
+ }
+ break;
+ }
+ case "colorscheme":
+ {
+ m_ColorScheme.Deserialize(xmlElem);
+ break;
+ }
+ case "backimage":
+ {
+ this.BackgroundImage = BarFunctions.DeserializeImage(xmlElem);
+ m_BackgroundImagePosition = (eBackgroundImagePosition)System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("pos"));
+ m_BackgroundImageAlpha = System.Xml.XmlConvert.ToByte(xmlElem.GetAttribute("alpha"));
+ break;
+ }
+ }
+ }
+
+ if ((eDockSide)System.Xml.XmlConvert.ToInt32(xmlThisBar.GetAttribute("dockside")) == eDockSide.None)
+ {
+ // Try to load position
+ if (xmlThisBar.HasAttribute("fpos"))
+ {
+ string s = xmlThisBar.GetAttribute("fpos");
+ string[] arr = s.Split(',');
+ if (arr.Length == 4)
+ {
+ Rectangle r = new Rectangle(System.Xml.XmlConvert.ToInt32(arr[0]), System.Xml.XmlConvert.ToInt32(arr[1]), System.Xml.XmlConvert.ToInt32(arr[2]), System.Xml.XmlConvert.ToInt32(arr[3]));
+ m_FloatingRect = r;
+ }
+ }
+ if (!System.Xml.XmlConvert.ToBoolean(xmlThisBar.GetAttribute("visible")) || xmlThisBar.HasAttribute("autohide") && System.Xml.XmlConvert.ToBoolean(xmlThisBar.GetAttribute("autohide")))
+ m_LoadingHideFloating = true;
+ }
+
+ if (xmlThisBar.HasAttribute("seldocktab"))
+ {
+ int iTab = System.Xml.XmlConvert.ToInt32(xmlThisBar.GetAttribute("seldocktab"));
+ if (iTab >= 0 && iTab < m_ItemContainer.SubItems.Count)
+ {
+ foreach (BaseItem dockItem in m_ItemContainer.SubItems)
+ dockItem.Displayed = false;
+ m_ItemContainer.SubItems[iTab].Displayed = true;
+ }
+ }
+
+ // Last Thing to do so it is docked properly
+ m_DockLine = System.Xml.XmlConvert.ToInt32(xmlThisBar.GetAttribute("dockline"));
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer)
+ RefreshDockTab(true);
+ this.DockSide = (eDockSide)System.Xml.XmlConvert.ToInt32(xmlThisBar.GetAttribute("dockside"));
+ if (m_LoadingHideFloating) m_LoadingHideFloating = false;
+ if (xmlThisBar.HasAttribute("autohide") && context._DesignerHost == null)
+ {
+ base.Visible = false;
+ if (m_ItemContainer.MinWidth > 0)
+ this.Width = m_ItemContainer.MinWidth;
+ if (m_ItemContainer.MinHeight > 0)
+ this.Height = m_ItemContainer.MinHeight;
+ this.AutoHide = true;
+ m_LastDockSiteInfo.DockedWidth = m_ItemContainer.MinWidth;
+ m_LastDockSiteInfo.DockedHeight = m_ItemContainer.MinHeight;
+ }
+ else
+ {
+ if (context._DesignerHost == null)
+ this.Visible = System.Xml.XmlConvert.ToBoolean(xmlThisBar.GetAttribute("visible"));
+ else
+ this.Visible = true;
+ }
+ }
+ finally
+ {
+ m_BarDefinitionLoading = false;
+ }
+ m_TabsRearranged = false;
+ SetupAccessibility();
+ }
+
+ private void LoadCommonProperties(System.Xml.XmlElement xmlBar)
+ {
+ m_BarState = eBarState.Docked;
+ this.Name = xmlBar.GetAttribute("name");
+ if (xmlBar.HasAttribute("candockleft"))
+ m_CanDockLeft = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candockleft"));
+ if (xmlBar.HasAttribute("candockright"))
+ m_CanDockRight = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candockright"));
+ if (xmlBar.HasAttribute("candocktop"))
+ m_CanDockTop = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candocktop"));
+ if (xmlBar.HasAttribute("candockbottom"))
+ m_CanDockBottom = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candockbottom"));
+ if (xmlBar.HasAttribute("candockdoc"))
+ m_CanDockDocument = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candockdoc"));
+ if (xmlBar.HasAttribute("candocktab"))
+ m_CanDockTab = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("candocktab"));
+ if (xmlBar.HasAttribute("canmaximizefloating"))
+ _CanMaximizeFloating = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("canmaximizefloating"));
+ if (xmlBar.HasAttribute("text"))
+ this.Text = xmlBar.GetAttribute("text");
+ if (xmlBar.HasAttribute("dockline"))
+ m_DockLine = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockline"));
+ if (xmlBar.HasAttribute("dockoffset"))
+ m_DockOffset = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockoffset"));
+ if (xmlBar.HasAttribute("grabhandle"))
+ m_GrabHandleStyle = (eGrabHandleStyle)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("grabhandle"));
+ if (xmlBar.HasAttribute("menubar"))
+ m_MenuBar = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("menubar"));
+ if (xmlBar.HasAttribute("stretch"))
+ m_DockStretch = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("stretch"));
+ if (xmlBar.HasAttribute("wrapdock"))
+ m_WrapItemsDock = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("wrapdock"));
+ if (xmlBar.HasAttribute("wrapfloat"))
+ m_WrapItemsFloat = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("wrapfloat"));
+ if (xmlBar.HasAttribute("custom"))
+ m_CustomBar = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("custom"));
+ if (xmlBar.HasAttribute("canhide"))
+ m_CanHide = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("canhide"));
+ if (xmlBar.HasAttribute("imagesize"))
+ m_ImageSize = (eBarImageSize)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("imagesize"));
+
+ if (xmlBar.HasAttribute("itemsp"))
+ m_ItemContainer.ItemSpacing = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("itemsp"));
+ // else
+ // m_ItemContainer.ItemSpacing=0;
+
+ if (xmlBar.HasAttribute("backcolor"))
+ m_ItemContainer.BackColor = BarFunctions.ColorFromString(xmlBar.GetAttribute("backcolor"));
+
+ if (xmlBar.HasAttribute("layout"))
+ m_ItemContainer.LayoutType = (eLayoutType)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("layout"));
+
+ if (xmlBar.HasAttribute("eqbutton"))
+ m_ItemContainer.EqualButtonSize = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("eqbutton"));
+
+ if (xmlBar.HasAttribute("dborder"))
+ m_DockedBorder = (eBorderType)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dborder"));
+ //else
+ // m_DockedBorder=eBorderType.None;
+
+ if (xmlBar.HasAttribute("acceptdrop"))
+ m_AcceptDropItems = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("acceptdrop"));
+
+ if (xmlBar.HasAttribute("slcolor"))
+ m_SingleLineColor = BarFunctions.ColorFromString(xmlBar.GetAttribute("slcolor"));
+
+ if (xmlBar.HasAttribute("captionbc"))
+ m_CaptionBackColor = BarFunctions.ColorFromString(xmlBar.GetAttribute("captionbc"));
+ if (xmlBar.HasAttribute("captionfc"))
+ m_CaptionForeColor = BarFunctions.ColorFromString(xmlBar.GetAttribute("captionfc"));
+
+ if (xmlBar.HasAttribute("dockwidth"))
+ m_ItemContainer.MinWidth = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockwidth"));
+ if (xmlBar.HasAttribute("dockheight"))
+ m_ItemContainer.MinHeight = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockheight"));
+
+ if (xmlBar.HasAttribute("splitwidthpercent"))
+ m_SplitDockWidthPercent = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("splitwidthpercent"));
+ else
+ m_SplitDockWidthPercent = 0;
+ if (xmlBar.HasAttribute("splitheightpercent"))
+ m_SplitDockHeightPercent = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("splitheightpercent"));
+ // else
+ // m_SplitDockHeightPercent=0;
+
+ if (xmlBar.HasAttribute("padbottom"))
+ m_ItemContainer.PaddingBottom = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("padbottom"));
+ if (xmlBar.HasAttribute("padleft"))
+ m_ItemContainer.PaddingLeft = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("padleft"));
+ if (xmlBar.HasAttribute("padright"))
+ m_ItemContainer.PaddingRight = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("padright"));
+ if (xmlBar.HasAttribute("padtop"))
+ m_ItemContainer.PaddingTop = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("padtop"));
+
+ if (xmlBar.HasAttribute("lockdockpos"))
+ m_LockDockPosition = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("lockdockpos"));
+ if (xmlBar.HasAttribute("canundock"))
+ m_CanUndock = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("canundock"));
+ if (xmlBar.HasAttribute("canreordertabs"))
+ m_CanReorderTabs = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("canreordertabs"));
+ if (xmlBar.HasAttribute("cantearoff"))
+ m_CanTearOffTabs = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("cantearoff"));
+
+ if (xmlBar.HasAttribute("canautohide"))
+ m_CanAutoHide = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("canautohide"));
+
+ if (xmlBar.HasAttribute("cancust"))
+ m_ItemContainer.CanCustomize = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("cancust"));
+
+ if (xmlBar.HasAttribute("tabalign"))
+ m_DockTabAlignment = (eTabStripAlignment)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("tabalign"));
+
+ if (xmlBar.HasAttribute("showtab"))
+ m_AlwaysDisplayDockTab = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("showtab"));
+
+ // TODO: Menu Merge Implementation
+ //if(xmlBar.HasAttribute("merge"))
+ // m_MergeEnabled=System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("merge"));
+
+ if (xmlBar.HasAttribute("hidein"))
+ m_HideFloatingInactive = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("hidein"));
+
+ if (xmlBar.HasAttribute("themes"))
+ {
+ m_ThemeAware = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("themes"));
+ m_ItemContainer.ThemeAware = m_ThemeAware;
+ }
+
+ if (xmlBar.HasAttribute("tabnav"))
+ m_TabNavigation = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("tabnav"));
+
+ if (xmlBar.HasAttribute("tooltips"))
+ m_ShowToolTips = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("tooltips"));
+ // else
+ // m_ShowToolTips=true;
+
+ if (xmlBar.HasAttribute("overflowmenu"))
+ m_ItemContainer.MoreItemsOnMenu = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("overflowmenu"));
+ // else
+ // m_ItemContainer.MoreItemsOnMenu=false;
+
+ if (xmlBar.HasAttribute("autocaptionmenu"))
+ m_AutoCreateCaptionMenu = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("autocaptionmenu"));
+ // else
+ // m_AutoCreateCaptionMenu=true;
+
+ if (xmlBar.HasAttribute("autocaptionsync"))
+ this.AutoSyncBarCaption = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("autocaptionsync"));
+ // else
+ // this.AutoSyncBarCaption=false;
+
+ if (xmlBar.HasAttribute("style"))
+ {
+ string sty = xmlBar.GetAttribute("style");
+ //if (sty == "5")
+ // this.Style = eDotNetBarStyle.Office2007;
+ //else
+ this.Style = (eDotNetBarStyle)System.Xml.XmlConvert.ToInt32(sty);
+ }
+
+ // Load font information if it exists
+ if (xmlBar.HasAttribute("fontname"))
+ {
+ string FontName = xmlBar.GetAttribute("fontname");
+ float FontSize = System.Xml.XmlConvert.ToSingle(xmlBar.GetAttribute("fontemsize"));
+ System.Drawing.FontStyle FontStyle = (System.Drawing.FontStyle)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("fontstyle"));
+ try
+ {
+ this.Font = new Font(FontName, FontSize, FontStyle);
+ }
+ catch (Exception)
+ {
+ this.Font = SystemFonts.MenuFont; // System.Windows.Forms.SystemInformation.MenuFont.Clone() as Font;
+ }
+ m_CustomFont = true;
+ }
+
+ if (xmlBar.HasAttribute("ahanim"))
+ m_AutoHideAnimationTime = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("ahanim"));
+ // else
+ // m_AutoHideAnimationTime=100;
+
+ if (xmlBar.HasAttribute("savelayout"))
+ m_SaveLayoutChanges = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("savelayout"));
+ // else
+ // m_SaveLayoutChanges=true;
+ }
+
+ ///
+ /// Gets or sets whether layout changes are saved for this bar when DotNetBarManager.SaveLayout method is used to save layout for all bars. Default value is true which means that layout changes are saved.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(true),Category("Behavior"),Description("Indicates whether layout changes are saved for this bar")]
+ public bool SaveLayoutChanges
+ {
+ get { return m_SaveLayoutChanges; }
+ set { m_SaveLayoutChanges = value; }
+ }
+
+ ///
+ /// Saves the Bar layout to file.
+ ///
+ /// Definition file name.
+ public void SaveLayout(string FileName)
+ {
+ System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
+
+ this.SaveLayout(xmlDoc);
+
+ xmlDoc.Save(FileName);
+ }
+
+ internal void SaveLayout(System.Xml.XmlDocument xmlDoc)
+ {
+ System.Xml.XmlElement xmlBar = xmlDoc.CreateElement("bar");
+ xmlDoc.AppendChild(xmlBar);
+ this.SerializeLayout(xmlBar);
+ }
+
+ ///
+ /// Loads the Bar definition from file.
+ ///
+ /// Definition file name.
+ public void LoadLayout(string FileName)
+ {
+ System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
+ xmlDoc.Load(FileName);
+ this.LoadLayout(xmlDoc);
+ }
+
+ internal void LoadLayout(System.Xml.XmlDocument xmlDoc)
+ {
+ if (xmlDoc.FirstChild.Name != "bar")
+ throw (new System.InvalidOperationException("XML Format not recognized"));
+
+ this.DeserializeLayout(xmlDoc.FirstChild as System.Xml.XmlElement);
+ }
+
+ ///
+ /// Gets/Sets Bar layout as XML string.
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public string LayoutDefinition
+ {
+ get
+ {
+ System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
+ SaveLayout(xmlDoc);
+ return xmlDoc.OuterXml;
+ }
+ set
+ {
+ System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
+ xmlDoc.LoadXml(value);
+ LoadLayout(xmlDoc);
+ }
+ }
+
+ internal void SerializeLayout(System.Xml.XmlElement xmlThisBar)
+ {
+ if (this.CustomBar)
+ {
+ this.Serialize(xmlThisBar, true);
+ }
+ else
+ {
+ xmlThisBar.SetAttribute("name", this.Name);
+ xmlThisBar.SetAttribute("dockline", System.Xml.XmlConvert.ToString(m_DockLine));
+ xmlThisBar.SetAttribute("layout", System.Xml.XmlConvert.ToString((int)this.LayoutType));
+
+ if (m_DockOffset == 0 && this.Left > 0 && (this.DockSide == eDockSide.Top || this.DockSide == eDockSide.Bottom))
+ xmlThisBar.SetAttribute("dockoffset", System.Xml.XmlConvert.ToString(this.Left));
+ else if (m_DockOffset == 0 && this.Top > 0 && (this.DockSide == eDockSide.Left || this.DockSide == eDockSide.Right))
+ xmlThisBar.SetAttribute("dockoffset", System.Xml.XmlConvert.ToString(this.Top));
+ else
+ xmlThisBar.SetAttribute("dockoffset", System.Xml.XmlConvert.ToString(m_DockOffset));
+
+ if (m_AutoHideState)
+ {
+ xmlThisBar.SetAttribute("state", System.Xml.XmlConvert.ToString((int)eBarState.Docked));
+ eDockSide dockside = eDockSide.None;
+ switch (m_LastDockSiteInfo.DockSide)
+ {
+ case DockStyle.Left:
+ dockside = eDockSide.Left;
+ break;
+ case DockStyle.Right:
+ dockside = eDockSide.Right;
+ break;
+ case DockStyle.Top:
+ dockside = eDockSide.Top;
+ break;
+ case DockStyle.Bottom:
+ dockside = eDockSide.Bottom;
+ break;
+ }
+ xmlThisBar.SetAttribute("dockside", System.Xml.XmlConvert.ToString((int)dockside));
+ }
+ else
+ {
+ xmlThisBar.SetAttribute("state", System.Xml.XmlConvert.ToString((int)m_BarState));
+ xmlThisBar.SetAttribute("dockside", System.Xml.XmlConvert.ToString((int)this.DockSide));
+ if (this.DockSide == eDockSide.None && m_Float != null)
+ xmlThisBar.SetAttribute("fpos", m_Float.Location.X + "," + m_Float.Location.Y + "," + this.DisplayRectangle.Width + "," + this.DisplayRectangle.Height);
+ else if (!m_FloatingRect.IsEmpty)
+ xmlThisBar.SetAttribute("fpos", m_FloatingRect.X + "," + m_FloatingRect.Y + "," + m_FloatingRect.Width + "," + m_FloatingRect.Height);
+ }
+
+ IOwnerBarSupport ownersupport = m_Owner as IOwnerBarSupport;
+ if (m_BarState == eBarState.Floating && !this.Visible && ownersupport != null && ownersupport.WereVisible.Count > 0 && ownersupport.WereVisible.Contains(this))
+ xmlThisBar.SetAttribute("visible", System.Xml.XmlConvert.ToString(true));
+ else
+ {
+ if (m_AutoHideState)
+ {
+ xmlThisBar.SetAttribute("visible", System.Xml.XmlConvert.ToString(true));
+ xmlThisBar.SetAttribute("autohide", System.Xml.XmlConvert.ToString(true));
+ }
+ else
+ xmlThisBar.SetAttribute("visible", System.Xml.XmlConvert.ToString(this.Visible));
+ }
+
+ if (m_ItemContainer.MinWidth != 0)
+ xmlThisBar.SetAttribute("dockwidth", System.Xml.XmlConvert.ToString(m_ItemContainer.MinWidth));
+ if (m_ItemContainer.MinHeight != 0)
+ xmlThisBar.SetAttribute("dockheight", System.Xml.XmlConvert.ToString(m_ItemContainer.MinHeight));
+ if (m_SplitDockWidthPercent > 0)
+ xmlThisBar.SetAttribute("splitwidthpercent", System.Xml.XmlConvert.ToString(m_SplitDockWidthPercent));
+ if (m_SplitDockHeightPercent > 0)
+ xmlThisBar.SetAttribute("splitheightpercent", System.Xml.XmlConvert.ToString(m_SplitDockHeightPercent));
+
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && this.SelectedDockTab >= 0)
+ xmlThisBar.SetAttribute("seldocktab", System.Xml.XmlConvert.ToString(this.SelectedDockTab));
+ }
+
+ System.Xml.XmlElement xmlItems = xmlThisBar.OwnerDocument.CreateElement("items");
+
+ foreach (BaseItem item in m_ItemContainer.SubItems)
+ {
+ if (item.OriginalBarName != "" || item.OriginalPosition >= 0 || item.UserCustomized || this.CustomBar || m_TabsRearranged || this.LayoutType == eLayoutType.DockContainer)
+ {
+ System.Xml.XmlElement xmlItem = xmlThisBar.OwnerDocument.CreateElement("item");
+ xmlItem.SetAttribute("name", item.Name);
+ xmlItem.SetAttribute("origBar", item.OriginalBarName);
+ xmlItem.SetAttribute("origPos", System.Xml.XmlConvert.ToString(item.OriginalPosition));
+ xmlItem.SetAttribute("pos", System.Xml.XmlConvert.ToString(m_ItemContainer.SubItems.IndexOf(item)));
+ if (!item.Visible)
+ xmlItem.SetAttribute("visible", System.Xml.XmlConvert.ToString(item.Visible));
+ xmlItems.AppendChild(xmlItem);
+ }
+ }
+
+ if (xmlItems.ChildNodes.Count > 0)
+ xmlThisBar.AppendChild(xmlItems);
+ }
+
+ internal void DeserializeLayout(System.Xml.XmlElement xmlBar)
+ {
+ m_BarDefinitionLoading = true;
+ try
+ {
+ m_IgnoreAnimation = true;
+
+ LoadCommonProperties(xmlBar);
+
+ if (xmlBar.ChildNodes.Count > 0)
+ {
+ foreach (System.Xml.XmlElement xmlChild in xmlBar.ChildNodes)
+ {
+ if (xmlChild.Name == "items")
+ {
+ // Load items stored on bar first...
+ LoadLayoutItems(xmlBar);
+ break;
+ }
+ }
+ }
+
+ // Try to load floating position
+ if (xmlBar.HasAttribute("fpos"))
+ {
+ string s = xmlBar.GetAttribute("fpos");
+ string[] arr = s.Split(',');
+ if (arr.Length == 4)
+ {
+ Rectangle r = new Rectangle(System.Xml.XmlConvert.ToInt32(arr[0]), System.Xml.XmlConvert.ToInt32(arr[1]), System.Xml.XmlConvert.ToInt32(arr[2]), System.Xml.XmlConvert.ToInt32(arr[3]));
+ m_FloatingRect = r;
+ }
+ }
+
+ if ((eDockSide)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockside")) == eDockSide.None)
+ {
+ if (!System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("visible")))
+ m_LoadingHideFloating = true;
+ }
+
+ if (xmlBar.HasAttribute("seldocktab"))
+ {
+ int iTab = System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("seldocktab"));
+ if (iTab >= 0 && iTab < m_ItemContainer.SubItems.Count)
+ {
+ foreach (BaseItem dockItem in m_ItemContainer.SubItems)
+ dockItem.Displayed = false;
+ m_ItemContainer.SubItems[iTab].Displayed = true;
+ if (m_AutoSyncBarCaption)
+ this.Text = m_ItemContainer.SubItems[iTab].Text;
+ }
+ }
+
+ // Last Thing to do so it is docked properly
+ //m_DockLine=System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockline"));
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer)
+ RefreshDockTab(true);
+ if (this.AutoHide)
+ {
+ if (xmlBar.HasAttribute("autohide"))
+ {
+ // If it is going back to auto-hide mode make sure it does not affect any bars on same line when we
+ // bring it out of auto-hide state
+ int minWidth = m_ItemContainer.MinWidth;
+ int minHeight = m_ItemContainer.MinHeight;
+ m_ItemContainer.MinWidth = 0;
+ m_ItemContainer.MinHeight = 0;
+ this.AutoHide = false;
+ m_ItemContainer.MinWidth = minWidth;
+ m_ItemContainer.MinHeight = minHeight;
+ }
+ else
+ this.AutoHide = false;
+ }
+
+ this.DockSide = (eDockSide)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("dockside"));
+ if (m_LoadingHideFloating) m_LoadingHideFloating = false;
+ if (xmlBar.HasAttribute("autohide"))
+ {
+ if (!this.AutoHide)
+ {
+ base.Visible = false;
+ if (m_ItemContainer.MinWidth > 0)
+ this.Width = m_ItemContainer.MinWidth;
+ if (m_ItemContainer.MinHeight > 0)
+ this.Height = m_ItemContainer.MinHeight;
+ this.AutoHide = true;
+ m_LastDockSiteInfo.DockedWidth = m_ItemContainer.MinWidth;
+ m_LastDockSiteInfo.DockedHeight = m_ItemContainer.MinHeight;
+ }
+ }
+ else
+ this.Visible = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("visible"));
+ }
+ finally
+ {
+ m_BarDefinitionLoading = false;
+ }
+ }
+
+ private void LoadLayoutItems(System.Xml.XmlElement xmlBar)
+ {
+ bool customBar = false;
+ eLayoutType layoutType = eLayoutType.Toolbar;
+ DotNetBarManager manager = null;
+ if (m_Owner != null && m_Owner is DotNetBarManager)
+ manager = m_Owner as DotNetBarManager;
+
+ if (xmlBar.HasAttribute("layout"))
+ layoutType = (eLayoutType)System.Xml.XmlConvert.ToInt32(xmlBar.GetAttribute("layout"));
+
+ if (layoutType == eLayoutType.DockContainer)
+ m_TabsRearranged = true;
+
+ if (xmlBar.HasAttribute("custom"))
+ customBar = System.Xml.XmlConvert.ToBoolean(xmlBar.GetAttribute("custom"));
+
+ foreach (System.Xml.XmlElement xmlElem in xmlBar.ChildNodes)
+ {
+ switch (xmlElem.Name)
+ {
+ case "items":
+ {
+ for (int i = 0; i < xmlElem.ChildNodes.Count; i++)
+ {
+ System.Xml.XmlElement xmlItem = xmlElem.ChildNodes[i] as System.Xml.XmlElement;
+ string itemName = xmlItem.GetAttribute("name");
+ string originalBar = xmlItem.GetAttribute("origBar");
+ int originalPos = System.Xml.XmlConvert.ToInt32(xmlItem.GetAttribute("origPos"));
+ int actualPos = System.Xml.XmlConvert.ToInt32(xmlItem.GetAttribute("pos"));
+ bool visible = true;
+ if (xmlItem.HasAttribute("visible"))
+ visible = System.Xml.XmlConvert.ToBoolean(xmlItem.GetAttribute("visible"));
+
+ if (layoutType == eLayoutType.DockContainer)
+ {
+ // Just adjust item position
+ if (this.Items.Contains(itemName))
+ {
+ BaseItem item = this.Items[itemName];
+
+ if (item.Visible != visible)
+ item.Visible = visible;
+
+ if (this.Items.IndexOf(this.Items[itemName]) != actualPos)
+ {
+ this.Items.Remove(item);
+ if (this.Items.Count > actualPos)
+ this.Items.Insert(actualPos, item);
+ else
+ this.Items.Add(item);
+ }
+ }
+ else if (manager != null)
+ {
+ // Move item from other bar onto this bar...
+ BaseItem item = manager.GetItem(itemName);
+ if (item != null && item is DockContainerItem)
+ {
+ Bar parentBar = item.ContainerControl as Bar;
+ item.Parent.SubItems.Remove(item);
+ if (item.Visible != visible)
+ item.Visible = visible;
+ if (this.Items.Count > actualPos)
+ this.Items.Insert(actualPos, item);
+ else
+ this.Items.Add(item);
+ if (parentBar != null && parentBar.Items.Count == 0)
+ {
+ if (parentBar.AutoHide) parentBar.AutoHide = false;
+ parentBar.Visible = false;
+ //manager.Bars.Remove(parentBar);
+ }
+ else if (parentBar != null && parentBar.VisibleItemCount == 0)
+ {
+ parentBar.Visible = false;
+ }
+ }
+ }
+ }
+ else
+ {
+ BaseItem item = null;
+ if (this.Items.Contains(itemName))
+ {
+ item = this.Items[itemName];
+ if (this.Items.IndexOf(itemName) != actualPos)
+ {
+ this.Items.Remove(item);
+ if (this.Items.Count > actualPos)
+ this.Items.Insert(actualPos, item);
+ else
+ this.Items.Add(item);
+ }
+ }
+ else
+ {
+ if (originalBar != "" && manager != null && manager.Bars.Contains(originalBar))
+ {
+ if (manager.Bars[originalBar].Items.Contains(itemName))
+ item = manager.Bars[originalBar].Items[itemName];
+ }
+ if (item == null)
+ item = manager.GetItem(itemName, true);
+ if (item != null)
+ {
+ if (item.ContainerControl == null || originalBar == "" && !(item.ContainerControl is Bar))
+ item = item.Copy();
+ else
+ item.Parent.SubItems.Remove(item);
+ if (this.Items.Count > actualPos)
+ this.Items.Insert(actualPos, item);
+ else
+ this.Items.Add(item);
+ }
+ }
+ if (item != null)
+ {
+ if (item.Visible != visible)
+ item.Visible = visible;
+ item.OriginalBarName = originalBar;
+ item.OriginalPosition = originalPos;
+ item.UserCustomized = true;
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // TODO: Menu Merge Implementation
+ // private bool IsParentMdiChild
+ // {
+ // get
+ // {
+ // IOwner owner=m_Owner as IOwner;
+ // if(owner!=null && owner.ParentForm!=null)
+ // {
+ // return ((IOwner)m_Owner).ParentForm.IsMdiChild;
+ // }
+ // return false;
+ // }
+ // }
+
+ ///
+ /// Sets the client size of the bar excluding caption. This method is useful when setting the size of the bars with layout type DockContainer.
+ ///
+ /// Width of bar in pixels.
+ /// Height of bar in pixels.
+ [Obsolete("Method is obsolete. Use DocumentDockUIManager.SetBarWidth or DocumentDockUIManager.SetBarHeight instead. You can obtain DocumentDockUIManager using DockSite.GetDocumentUIManager method.")]
+ public void SetSize(int width, int height)
+ {
+ if (m_BarState == eBarState.Docked)
+ {
+ m_ItemContainer.MinHeight = height;
+ m_ItemContainer.MinWidth = width;
+ SyncLineMinWidth();
+ SyncLineMinHeight();
+ }
+ else
+ {
+ this.Size = new Size(width, height);
+ }
+ if (this.IsHandleCreated)
+ this.RecalcLayout();
+ }
+
+ ///
+ /// Sets the client size of the bar excluding caption. This method is useful when setting the size of the bars with layout type DockContainer.
+ ///
+ /// New bar size
+ [Obsolete("Method is obsolete. Use DocumentDockUIManager.SetBarWidth or DocumentDockUIManager.SetBarHeight instead. You can obtain DocumentDockUIManager using DockSite.GetDocumentUIManager method.")]
+ public void SetSize(System.Drawing.Size size)
+ {
+ SetSize(size.Width, size.Height);
+ }
+
+ ///
+ /// Specifies background image position when container is larger than image.
+ ///
+ [Browsable(true), DevCoBrowsable(true),Category("Appearance"),DefaultValue(eBackgroundImagePosition.Stretch),Description("Specifies background image position when container is larger than image.")]
+ public eBackgroundImagePosition BackgroundImagePosition
+ {
+ get { return m_BackgroundImagePosition; }
+ set
+ {
+ if (m_BackgroundImagePosition != value)
+ {
+ m_BackgroundImagePosition = value;
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Specifies the transparency of background image.
+ ///
+ [Browsable(true), DefaultValue((byte)255),DevCoBrowsable(true),Category("Appearance"),Description("Specifies the transparency of background image.")]
+ public byte BackgroundImageAlpha
+ {
+ get { return m_BackgroundImageAlpha; }
+ set
+ {
+ if (m_BackgroundImageAlpha != value)
+ {
+ m_BackgroundImageAlpha = value;
+ this.Refresh();
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBackgroundImageAlpha()
+ {
+ return m_BackgroundImageAlpha != 255;
+ }
+
+ ///
+ /// Sets/Gets the side bar image structure.
+ ///
+ [System.ComponentModel.Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public SideBarImage SideBar
+ {
+ get
+ {
+ return m_SideBarImage;
+ }
+ set
+ {
+ m_SideBarImage = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets the caption of the Bar. This text is displayed in title of the Bar when Bar is floating.
+ ///
+ [DevCoBrowsable(true)]
+ public override string Text
+ {
+ get
+ {
+ return base.Text;
+ }
+ set
+ {
+ if (base.Text != value)
+ {
+ base.Text = value;
+ if (this.Visible && (m_BarState == eBarState.Floating ||
+ (m_BarState == eBarState.Docked || m_BarState == eBarState.AutoHide) &&
+ (m_GrabHandleStyle == eGrabHandleStyle.Caption || m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane ||
+ m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)))
+ {
+ this.Refresh();
+ }
+ }
+ }
+ }
+
+ [DevCoBrowsable(true)]
+ public override System.Drawing.Font Font
+ {
+ get
+ {
+ return base.Font;
+ }
+ set
+ {
+ base.Font = value;
+ if (this.Font != null)
+ m_CustomFont = ShouldSerializeFont();
+ }
+ }
+
+ ///
+ /// Returns true if Font property should be serialized by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeFont()
+ {
+ if (this.Font != null)
+ {
+ if (this.Font.Name != System.Windows.Forms.SystemInformation.MenuFont.Name || this.Font.Size != System.Windows.Forms.SystemInformation.MenuFont.Size || this.Font.Style != System.Windows.Forms.SystemInformation.MenuFont.Style)
+ return true;
+ else
+ return false;
+ }
+ return false;
+ }
+ ///
+ /// Designer method to reset the property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public new void ResetFont()
+ {
+ if (this.LayoutType == eLayoutType.DockContainer)
+ base.ResetFont();
+ else
+ this.Font = System.Windows.Forms.SystemInformation.MenuFont.Clone() as Font;
+ }
+
+ protected internal bool IsThemed
+ {
+ get
+ {
+ if (m_ThemeAware && this.Style != eDotNetBarStyle.Office2000 && BarFunctions.ThemedOS && Themes.ThemesActive)
+ return true;
+ return false;
+ }
+ }
+
+ ///
+ /// Specifies whether Bar is drawn using Themes when running on OS that supports themes like Windows XP.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.DefaultValue(false),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Specifies whether SideBar is drawn using Themes when running on OS that supports themes like Windows XP.")]
+ public virtual bool ThemeAware
+ {
+ get
+ {
+ return m_ThemeAware;
+ }
+ set
+ {
+ m_ThemeAware = value;
+ m_ItemContainer.ThemeAware = value;
+ }
+ }
+
+ ///
+ /// Returns current Bar state.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public eBarState BarState
+ {
+ get
+ {
+ return m_BarState;
+ }
+ }
+
+ internal void SetBarState(eBarState state)
+ {
+ m_BarState = state;
+ if (m_BarState != eBarState.Popup && m_DropShadow != null)
+ {
+ m_DropShadow.Hide();
+ m_DropShadow.Dispose();
+ m_DropShadow = null;
+ }
+ }
+
+ ///
+ /// Returns the collection of sub-items hosted on the Bar.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public SubItemsCollection Items
+ {
+ get
+ {
+ if (m_ItemContainer == null)
+ return null;
+ return m_ItemContainer.SubItems;
+ }
+ }
+
+ ///
+ /// Returns the reference to the container that containing the sub-items.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public GenericItemContainer ItemsContainer
+ {
+ get
+ {
+ return m_ItemContainer;
+ }
+ }
+
+ ///
+ /// Gets/Sets whether the items that could not be displayed on the non-wrap Bar are displayed on popup menu or popup Bar.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates whether the items that could not be displayed on the non-wrap Bar are displayed on popup menu or popup Bar."),DefaultValue(false)]
+ public bool DisplayMoreItemsOnMenu
+ {
+ get
+ {
+ return m_ItemContainer.MoreItemsOnMenu;
+ }
+ set
+ {
+ m_ItemContainer.MoreItemsOnMenu = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets the spacing in pixels between the sub-items.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Indicates the spacing in pixels between the sub-items."),DefaultValue(0)]
+ public int ItemSpacing
+ {
+ get
+ {
+ return m_ItemContainer.ItemSpacing;
+ }
+ set
+ {
+ if (m_ItemContainer.ItemSpacing == value)
+ return;
+ m_ItemContainer.ItemSpacing = value;
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets/Sets the padding in pixels. This represents the spacing between the top edge of the bar and the top of the item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Gets/Sets the padding in pixels. This represents the spacing between the top of the bar and the top of the item."),DefaultValue(1)]
+ public int PaddingTop
+ {
+ get
+ {
+ return m_ItemContainer.PaddingTop;
+ }
+ set
+ {
+ if (m_ItemContainer.PaddingTop == value)
+ return;
+ m_ItemContainer.PaddingTop = value;
+ if (this.DesignMode)
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets/Sets the padding in pixels. This represents the spacing between the bottom edge of the bar and the bottom of the item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Gets/Sets the padding in pixels. This represents the spacing between the bottom edge of the bar and the bottom of the item."),DefaultValue(1)]
+ public int PaddingBottom
+ {
+ get
+ {
+ return m_ItemContainer.PaddingBottom;
+ }
+ set
+ {
+ if (m_ItemContainer.PaddingBottom == value)
+ return;
+ m_ItemContainer.PaddingBottom = value;
+ if (this.DesignMode)
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets/Sets the padding in pixels. This represents the spacing between the left edge of the bar and the left side of the first item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Gets/Sets the padding in pixels. This represents the spacing between the left edge of the bar and the left position of the first item."),DefaultValue(1)]
+ public int PaddingLeft
+ {
+ get
+ {
+ return m_ItemContainer.PaddingLeft;
+ }
+ set
+ {
+ if (m_ItemContainer.PaddingLeft == value)
+ return;
+ m_ItemContainer.PaddingLeft = value;
+ if (this.DesignMode)
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets/Sets the padding in pixels. This represents the spacing between the right edge of the bar and the right side of the last item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Gets/Sets the padding in pixels. This represents the spacing between the right edge of the bar and the right side of the last item."),DefaultValue(1)]
+ public int PaddingRight
+ {
+ get
+ {
+ return m_ItemContainer.PaddingRight;
+ }
+ set
+ {
+ if (m_ItemContainer.PaddingRight == value)
+ return;
+ m_ItemContainer.PaddingRight = value;
+ if (this.DesignMode)
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Sets/Gets whether bar is menu bar. Menu bar will show system icons
+ /// for Maximized forms in MDI Applications. Only one bar can be a Menu bar in an application.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates Bar layout type."),DefaultValue(false)]
+ public bool MenuBar
+ {
+ get
+ {
+ return m_MenuBar;
+ }
+ set
+ {
+ m_MenuBar = value;
+ SetupAccessibility();
+ }
+ }
+
+ ///
+ /// Gets or sets the visual type of the bar. The type specified here is used to determine the appearance of the bar.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(eBarType.Toolbar), Category("Appearance"), Description("Indicates visual type of the bar. The type specified here is used to determine the appearance of the bar.")]
+ public eBarType BarType
+ {
+ get { return m_BarType; }
+ set
+ {
+ m_BarType = value;
+ if (m_BarType == eBarType.StatusBar)
+ m_ItemContainer.ToolbarItemsAlign = eContainerVerticalAlignment.Middle;
+ else
+ m_ItemContainer.ToolbarItemsAlign = eContainerVerticalAlignment.Top;
+ if (BarType == eBarType.DockWindow)
+ this.ResetFont();
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets Bar Color Scheme.
+ ///
+ [System.ComponentModel.Editor(typeof(ColorSchemeVSEditor), typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Gets or sets Bar Color Scheme."),DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public DevComponents.DotNetBar.ColorScheme ColorScheme
+ {
+ get { return m_ColorScheme; }
+ set
+ {
+ if (value == null)
+ throw new ArgumentException("NULL is not a valid value for this property.");
+ m_ColorScheme = value;
+ if (this.Visible)
+ this.Refresh();
+ }
+ }
+
+ internal ColorScheme GetColorScheme()
+ {
+ if (BarFunctions.IsOffice2007Style(this.Style))
+ {
+ Office2007Renderer r = this.GetRenderer() as Office2007Renderer;
+ if (r != null && r.ColorTable.LegacyColors != null)
+ return r.ColorTable.LegacyColors;
+ }
+
+ if (m_Owner is DotNetBarManager && ((DotNetBarManager)m_Owner).UseGlobalColorScheme)
+ return ((DotNetBarManager)m_Owner).ColorScheme;
+ return m_ColorScheme;
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeColorScheme()
+ {
+ return m_ColorScheme.SchemeChanged;
+ }
+
+ ///
+ /// Resets the ColorScheme property to its default value.
+ ///
+ public void ResetColorScheme()
+ {
+ m_ColorScheme.Refresh();
+ this.Invalidate();
+ }
+
+ ///
+ /// Gets or sets Caption (Title bar) background color.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates the background color of the caption (Title bar)."),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Color CaptionBackColor
+ {
+ get
+ {
+ return m_CaptionBackColor;
+ }
+ set
+ {
+ if (m_CaptionBackColor != value)
+ {
+ m_CaptionBackColor = value;
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets Caption (Title bar) text color.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates the caption (Title bar) text color."),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Color CaptionForeColor
+ {
+ get
+ {
+ return m_CaptionForeColor;
+ }
+ set
+ {
+ if (m_CaptionForeColor != value)
+ {
+ m_CaptionForeColor = value;
+ this.Refresh();
+ }
+ }
+ }
+
+ internal void ClearMDIChildSystemItems(bool bRecalcLayout)
+ {
+ if (m_ItemContainer == null)
+ return;
+ try
+ {
+ if (m_ItemContainer.SubItems.Contains("dotnetbarsysiconitem"))
+ m_ItemContainer.SubItems.Remove("dotnetbarsysiconitem");
+ if (m_ItemContainer.SubItems.Contains("dotnetbarsysmenuitem"))
+ m_ItemContainer.SubItems.Remove("dotnetbarsysmenuitem");
+ if (bRecalcLayout)
+ this.RecalcLayout();
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ internal void ShowMDIChildSystemItems(System.Windows.Forms.Form objMdiChild, bool bRecalcLayout)
+ {
+ ClearMDIChildSystemItems(bRecalcLayout);
+
+ if (objMdiChild == null)
+ return;
+
+ MDISystemItem mdi = new MDISystemItem("dotnetbarsysiconitem");
+ mdi.Icon = objMdiChild.Icon;
+ if (!objMdiChild.ControlBox)
+ mdi.CloseEnabled = false;
+ if (!objMdiChild.MinimizeBox)
+ mdi.MinimizeEnabled = false;
+ mdi.Click += new System.EventHandler(this.MDISysItemClick);
+ mdi.IsSystemIcon = true;
+ m_ItemContainer.SubItems.Add(mdi, 0);
+
+ mdi = new MDISystemItem("dotnetbarsysmenuitem");
+ if (!objMdiChild.ControlBox)
+ mdi.CloseEnabled = false;
+ if (!objMdiChild.MinimizeBox)
+ mdi.MinimizeEnabled = false;
+ mdi.ItemAlignment = eItemAlignment.Far;
+ mdi.Click += new System.EventHandler(this.MDISysItemClick);
+
+ m_ItemContainer.SubItems.Add(mdi);
+
+ if (bRecalcLayout)
+ this.RecalcLayout();
+ }
+
+ private void MDISysItemClick(object sender, System.EventArgs e)
+ {
+ MDISystemItem mdi = sender as MDISystemItem;
+ IOwner owner = m_Owner as IOwner;
+ Form frm = null;
+ if (owner != null)
+ frm = owner.ActiveMdiChild;
+ if (frm == null)
+ {
+ ClearMDIChildSystemItems(true);
+ return;
+ }
+ if (mdi.LastButtonClick == SystemButton.Minimize)
+ {
+ NativeFunctions.PostMessage(frm.Handle, NativeFunctions.WM_SYSCOMMAND, new IntPtr(NativeFunctions.SC_MINIMIZE), IntPtr.Zero);
+ //frm.WindowState=FormWindowState.Minimized;
+ }
+ else if (mdi.LastButtonClick == SystemButton.Restore)
+ {
+ NativeFunctions.PostMessage(frm.Handle, NativeFunctions.WM_SYSCOMMAND, new IntPtr(NativeFunctions.SC_RESTORE), IntPtr.Zero);
+ //frm.WindowState=FormWindowState.Normal;
+ }
+ else if (mdi.LastButtonClick == SystemButton.Close)
+ {
+ NativeFunctions.PostMessage(frm.Handle, NativeFunctions.WM_SYSCOMMAND, new IntPtr(NativeFunctions.SC_CLOSE), IntPtr.Zero);
+ }
+ else if (mdi.LastButtonClick == SystemButton.NextWindow)
+ {
+ NativeFunctions.PostMessage(frm.Handle, NativeFunctions.WM_SYSCOMMAND, new IntPtr(NativeFunctions.SC_NEXTWINDOW), IntPtr.Zero);
+ }
+ }
+
+ ///
+ /// Gets or sets whether toolbars with appropriate style appear with rounded corners. Default value is true.
+ ///
+ [Browsable(true), DevCoBrowsable(false), Category("Appearance"), Description("Indicates whether toolbars with appropriate style appear with rounded corners."), DefaultValue(true)]
+ public bool RoundCorners
+ {
+ get { return m_RoundCorners; }
+ set
+ {
+ m_RoundCorners = value;
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets/Sets the visual style of the Bar.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Specifies the visual style of the Bar."),DefaultValue(eDotNetBarStyle.OfficeXP)]
+ public eDotNetBarStyle Style
+ {
+ get
+ {
+ return m_ItemContainer.Style;
+ }
+ set
+ {
+ //if(m_ItemContainer.Style==value)
+ // return;
+ m_ColorScheme.SwitchStyle(value);
+ m_ItemContainer.Style = value;
+ if ((m_ItemContainer.EffectiveStyle == eDotNetBarStyle.Office2003 || m_ItemContainer.EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(m_ItemContainer.EffectiveStyle)) && this.LayoutType == eLayoutType.Toolbar && this.GrabHandleStyle != eGrabHandleStyle.None && this.GrabHandleStyle != eGrabHandleStyle.ResizeHandle)
+ m_GrabHandleStyle = eGrabHandleStyle.Office2003;
+ SetDockTabStyle(m_ItemContainer.EffectiveStyle);
+ if (this.AutoHide)
+ {
+ AutoHidePanel panel = this.GetAutoHidePanel();
+ if (panel != null)
+ panel.Style = value;
+ }
+ else
+ {
+ this.Invalidate();
+ this.RecalcLayout();
+ }
+ }
+ }
+
+ //internal int MinClientSize
+ //{
+ // get
+ // {
+ // if(this.SelectedDockTab>=0)
+ // {
+ // return ((DockContainerItem)m_TabDockItems.SelectedTab.AttachedItem).MinFormClientSize;
+ // }
+ // else if(m_ItemContainer.LayoutType==eLayoutType.DockContainer && m_ItemContainer.SubItems.Count==1 && m_ItemContainer.SubItems[0] is DockContainerItem)
+ // return ((DockContainerItem)m_ItemContainer.SubItems[0]).MinFormClientSize;
+
+ // return m_MinClientSize;
+ // }
+ // set {m_MinClientSize=value;}
+ //}
+
+ internal bool IsPositionOnDockTab(int x, int y)
+ {
+ // Receives the screen coordinates
+ Point p = this.PointToClient(new Point(x, y));
+ if (m_GrabHandleRect.Contains(p) || m_TabDockItems != null && m_TabDockItems.Bounds.Contains(p))
+ return true;
+ return false;
+ }
+
+ internal void AppLostFocus()
+ {
+ if (m_ItemContainer != null)
+ m_ItemContainer.ContainerLostFocus(true);
+ if (!this.IsDisposed)
+ AccessibilityNotifyClients(AccessibleEvents.StateChange, 0);
+ }
+ internal void AppActivate()
+ {
+ if (!this.IsDisposed)
+ AccessibilityNotifyClients(AccessibleEvents.StateChange, 0);
+ }
+
+ internal void HideBar()
+ {
+ if (m_DesignerParent && this.Parent != null)
+ {
+ this.Parent.Controls.Remove(this);
+ m_DesignerParent = false;
+ }
+
+ if (m_BarState == eBarState.Floating)
+ {
+ if (m_Float != null)
+ {
+ m_Float.Hide();
+ base.OnVisibleChanged(new EventArgs());
+ }
+ }
+ else
+ {
+ base.Hide();
+
+ if (!m_DockingInProgress && !m_LayoutSuspended && this.Parent is DockSite && ((DockSite)this.Parent).DocumentDockContainer != null)
+ ((DockSite)this.Parent).GetDocumentUIManager().AdjustContainerSize(this, true);
+
+ if (m_Owner != null && m_Owner is DotNetBarManager && ((DotNetBarManager)m_Owner).IsDisposed)
+ return;
+ this.RecalcLayout();
+ }
+ }
+
+ private bool m_DesignerParent = false;
+ private bool AddtoDesignTimeContainer()
+ {
+ ISite site = GetSite();
+ if (site == null)
+ return false;
+
+ IDesignerHost dh = site.GetService(typeof(IDesignerHost)) as IDesignerHost;
+ if (dh == null) return false;
+
+ Control parent = dh.RootComponent as Control;
+ while (parent != null)
+ {
+ parent = parent.Parent;
+ if (parent != null && parent.GetType().Name.IndexOf("DesignerFrame") >= 0)
+ break;
+ }
+ if (parent == null || parent.Parent == null) return false;
+ //parent = parent.Parent;
+ Point p = parent.PointToClient(this.Location);
+ parent.Controls.Add(this);
+ this.Location = p;
+ base.Show();
+ this.Update();
+ this.BringToFront();
+ m_DesignerParent = true;
+ return true;
+ }
+
+ internal void ShowBar()
+ {
+ if (PassiveBar)
+ {
+ base.Show();
+ this.Update();
+ return;
+ }
+
+ if (m_BarState == eBarState.Floating)
+ {
+ if (m_Float == null)
+ {
+ m_Float = new FloatingContainer(this);
+ m_Float.CreateControl();
+ if (this.Parent != null)
+ {
+ if (this.Parent is DockSite)
+ ((DockSite)this.Parent).RemoveBar(this);
+ else
+ this.Parent.Controls.Remove(this);
+ }
+ this.Parent = null;
+ m_Float.Controls.Add(this);
+ // WE OVERRIDE BASE LOCATION WE MUST USE BASE.
+ base.Location = new Point(0, 0);
+ }
+ if (m_Float != null)
+ {
+ // TODO: Show method did not want to show the form, check has it been fixed in newer versions
+ //m_Float.Show();
+ //NativeFunctions.SetWindowPos(m_Float.Handle.ToInt32(),NativeFunctions.HWND_TOP,0,0,0,0,NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOSIZE | NativeFunctions.SWP_NOACTIVATE | NativeFunctions.SWP_NOMOVE);
+ //m_Float.TopMost=true;
+ m_Float.TopLevel = true;
+ m_Float.Visible = true;
+ if (!base.Visible)
+ base.Visible = true;
+ m_Float.Refresh();
+ }
+ }
+ else if (m_BarState == eBarState.Popup)
+ {
+ // Design mode add
+ if (m_ParentItem != null && (m_ParentItem.Site != null && m_ParentItem.Site.DesignMode ||
+ m_ParentItem.Parent != null && m_ParentItem.Parent.Site != null && m_ParentItem.Parent.Site.DesignMode))
+ {
+ if (AddtoDesignTimeContainer())
+ return;
+ }
+
+ //NativeFunctions.sndPlaySound("MenuPopup",NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT);
+ ePopupAnimation animation = m_PopupAnimation;
+ if (!BarFunctions.SupportsAnimation)
+ animation = ePopupAnimation.None;
+ else
+ {
+ IOwnerMenuSupport ownersupport = m_Owner as IOwnerMenuSupport;
+ if (animation == ePopupAnimation.ManagerControlled)
+ {
+ if (ownersupport != null)
+ animation = ownersupport.PopupAnimation;
+ if (animation == ePopupAnimation.ManagerControlled)
+ animation = ePopupAnimation.SystemDefault;
+ }
+
+ if (animation == ePopupAnimation.SystemDefault)
+ animation = NativeFunctions.SystemMenuAnimation;
+ else if (animation == ePopupAnimation.Random)
+ {
+ Random r = new System.Random();
+ int i = r.Next(2);
+ animation = ePopupAnimation.Fade;
+ if (i == 1)
+ animation = ePopupAnimation.Slide;
+ else if (i == 2)
+ animation = ePopupAnimation.Unfold;
+ }
+ }
+
+ if (BarFunctions.IsOffice2007Style(this.Style) && this.BarType == eBarType.Toolbar)
+ SetRoundRegion(this);
+
+ if (animation == ePopupAnimation.Fade && Environment.OSVersion.Version.Major >= 5)
+ {
+ // TODO: Blending was leaving the white dots in the region that was excluded, make sure that it is not happening for final release, test other AnimateWindows
+ NativeFunctions.AnimateWindow(this.Handle, BarFunctions.ANIMATION_INTERVAL, NativeFunctions.AW_BLEND);
+ }
+ else if (animation == ePopupAnimation.Slide)
+ NativeFunctions.AnimateWindow(this.Handle, BarFunctions.ANIMATION_INTERVAL, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_HOR_POSITIVE | NativeFunctions.AW_VER_POSITIVE));
+ else if (animation == ePopupAnimation.Unfold)
+ NativeFunctions.AnimateWindow(this.Handle, BarFunctions.ANIMATION_INTERVAL, (NativeFunctions.AW_HOR_POSITIVE | NativeFunctions.AW_VER_POSITIVE));
+ else
+ base.Show();
+
+ if (animation != ePopupAnimation.None && this.Controls.Count > 0)
+ this.Refresh();
+
+ if (this.DisplayShadow && this.AlphaShadow)
+ {
+ if (m_DropShadow != null)
+ {
+ m_DropShadow.Hide();
+ m_DropShadow.Dispose();
+ }
+ m_DropShadow = new PopupShadow(true);
+ m_DropShadow.CreateControl();
+ NativeFunctions.SetWindowPos(m_DropShadow.Handle, new IntPtr(NativeFunctions.HWND_NOTOPMOST), this.Left + 5, this.Top + 5, this.Width - 2, this.Height - 2, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
+ m_DropShadow.UpdateShadow();
+ }
+ }
+ else
+ {
+ // Retain bar's position in controls collection it can change when bar is shown
+ // OnVisibleChanged will be triggered and index of the bar will be checked against
+ // this value. If it has changed it will be restored.
+ if (this.Parent is DockSite)
+ m_BarShowIndex = this.Parent.Controls.IndexOf(this);
+ else
+ m_BarShowIndex = -1;
+
+ if (!m_DockingInProgress && !m_LayoutSuspended && this.Parent is DockSite && this.Parent.Dock != DockStyle.Fill && ((DockSite)this.Parent).DocumentDockContainer != null)
+ {
+ DockSite ds = this.Parent as DockSite;
+ m_LayoutSuspended = true;
+ base.Show();
+ m_LayoutSuspended = false;
+ ds.GetDocumentUIManager().AdjustContainerSize(this, true);
+ // Reset the side by side docking for the bars so they are uniform
+ if (!m_BarDefinitionLoading)
+ {
+ DocumentBaseContainer dc = ds.GetDocumentUIManager().GetDocumentFromBar(this);
+ if (dc != null && dc.Parent is DocumentDockContainer)
+ {
+ DocumentDockContainer p = dc.Parent as DocumentDockContainer;
+ int visibleCount = p.Documents.VisibleCount;
+ if (visibleCount > 1)
+ {
+ if (p.Orientation == eOrientation.Horizontal && (ds.Dock == DockStyle.Top || ds.Dock == DockStyle.Bottom))
+ {
+ //float f = 1 + dc.LayoutBounds.Width / (float)(p.DisplayBounds.Width - dc.LayoutBounds.Width);
+ //dc.SetLayoutBounds(new Rectangle(dc.LayoutBounds.X, dc.LayoutBounds.Y, (int)(dc.LayoutBounds.Width * f), dc.LayoutBounds.Height));
+ dc.SetLayoutBounds(new Rectangle(dc.LayoutBounds.X, dc.LayoutBounds.Y, (int)(p.LayoutBounds.Width / visibleCount), dc.LayoutBounds.Height));
+ }
+ else if (p.Orientation == eOrientation.Vertical && (ds.Dock == DockStyle.Left || ds.Dock == DockStyle.Right))
+ {
+ //float f = 1 + dc.LayoutBounds.Height / (float)(p.DisplayBounds.Height - dc.LayoutBounds.Height);
+ //dc.SetLayoutBounds(new Rectangle(dc.LayoutBounds.X, dc.LayoutBounds.Y, dc.LayoutBounds.Width, (int)(dc.LayoutBounds.Height * f)));
+ dc.SetLayoutBounds(new Rectangle(dc.LayoutBounds.X, dc.LayoutBounds.Y, dc.LayoutBounds.Width, (int)(p.LayoutBounds.Height / visibleCount)));
+ }
+ }
+ }
+ }
+ DotNetBarManager man = this.Owner as DotNetBarManager;
+ if (man != null && man.SuspendLayout)
+ ds.NeedsLayout = true;
+ }
+ else
+ base.Show();
+
+ m_BarShowIndex = -1;
+ }
+ // This makes the bar paint BEFORE it returns out of this function
+ this.Update();
+ }
+
+ internal bool DockingInProgress
+ {
+ get
+ {
+ return m_DockingInProgress;
+ }
+ }
+
+ ///
+ /// Gets/Sets whether the items will be wrapped into next line when Bar is full. Applies to both docked and floating Bar states.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public bool WrapItems
+ {
+ get
+ {
+ return m_ItemContainer.WrapItems;
+ }
+ }
+
+ ///
+ /// Gets/Sets whether the items will be wrapped into next line when Bar is full. Applies only to Bars that are docked.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Indicates whether the items will be wrapped into next line when Bar is full. Applies only to Bars that are docked."),DefaultValue(false)]
+ public bool WrapItemsDock
+ {
+ get
+ {
+ return m_WrapItemsDock;
+ }
+ set
+ {
+ m_WrapItemsDock = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets whether the items will be wrapped into next line when Bar is full. Applies only to Bars that are floating.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Indicates whether the items will be wrapped into next line when Bar is full. Applies only to Bars that are floating."),DefaultValue(true)]
+ public bool WrapItemsFloat
+ {
+ get
+ {
+ return m_WrapItemsFloat;
+ }
+ set
+ {
+ m_WrapItemsFloat = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets the grab handle style of the docked Bars.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates the grab handle style of the docked Bars."),DefaultValue(eGrabHandleStyle.None)]
+ public eGrabHandleStyle GrabHandleStyle
+ {
+ get
+ {
+ return m_GrabHandleStyle;
+ }
+ set
+ {
+ if (m_GrabHandleStyle == value)
+ return;
+ m_GrabHandleStyle = value;
+ SetupAccessibility();
+ if (this.Visible && !m_LayoutSuspended)
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets the grab handle client rectangle.
+ ///
+ [Browsable(false), DevCoBrowsable(false)]
+ public Rectangle GrabHandleRect
+ {
+ get
+ {
+ return m_GrabHandleRect;
+ }
+ }
+
+ internal void DockContainerItemCanCloseChanged(DockContainerItem item, eDockContainerClose oldValue, eDockContainerClose newValue)
+ {
+ if (SelectedDockContainerItem != item) return;
+ UpdateCloseButtonVisibility();
+ }
+
+ private void UpdateCloseButtonVisibility()
+ {
+ bool canHideResolved = this.CanHideResolved;
+
+ if (m_BarState == eBarState.Floating || m_BarState == eBarState.Docked && (m_GrabHandleStyle == eGrabHandleStyle.Caption || m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted))
+ this.Invalidate(m_GrabHandleRect);
+
+ if (m_TabDockItems != null && m_TabDockItems._TabSystemBox != null)
+ {
+ m_TabDockItems._TabSystemBox.CloseVisible = canHideResolved;
+ }
+ }
+
+ ///
+ /// Returns CanClose based on the selected dock-container item.
+ ///
+ private bool CanHideResolved
+ {
+ get
+ {
+ DockContainerItem item = this.SelectedDockContainerItem;
+ if (item == null || item.CanClose == eDockContainerClose.Inherit)
+ return CanHide;
+ return item.CanClose == eDockContainerClose.Yes;
+ }
+ }
+
+ ///
+ /// Gets/Sets whether the Bar can be hidden by end-user. Applies to Document docked bars only.
+ ///
+ [Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Determines whether bar can be hidden."),DefaultValue(false)]
+ public bool CanHide
+ {
+ get
+ {
+ return m_CanHide;
+ }
+ set
+ {
+ if (m_CanHide == value)
+ return;
+ m_CanHide = value;
+ if (m_BarState == eBarState.Floating || m_BarState == eBarState.Docked && (m_GrabHandleStyle == eGrabHandleStyle.Caption || m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted))
+ this.Invalidate(m_GrabHandleRect);
+ UpdateDockTabSettings();
+ if (m_TabDockItems != null && BarFunctions.IsHandleValid(this))
+ {
+ m_TabDockItems.RecalcSize();
+ if (this.DesignMode)
+ m_TabDockItems.Invalidate();
+ }
+ }
+ }
+
+ private bool EffectiveCanMaximizeFloating
+ {
+ get
+ {
+ return _CanMaximizeFloating && this.LayoutType == eLayoutType.DockContainer &&
+ this.Parent is FloatingContainer;
+ }
+ }
+
+ private bool _CanMaximizeFloating = true;
+ ///
+ /// Indicates whether Maximize button is visible on floating dock windows.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether Maximize button is visible on floating dock windows.")]
+ public bool CanMaximizeFloating
+ {
+ get { return _CanMaximizeFloating; }
+ set
+ {
+ if (value != _CanMaximizeFloating)
+ {
+ bool oldValue = _CanMaximizeFloating;
+ _CanMaximizeFloating = value;
+ OnCanMaximizeFloatingChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when CanMaximizeFloating property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnCanMaximizeFloatingChanged(bool oldValue, bool newValue)
+ {
+ if (m_BarState == eBarState.Floating && (m_GrabHandleStyle == eGrabHandleStyle.Caption || m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted))
+ this.Invalidate(m_GrabHandleRect);
+ //OnPropertyChanged(new PropertyChangedEventArgs("CanMaximizeFloating"));
+ }
+
+ ///
+ /// Gets/Sets border style when Bar is docked.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates border style when Bar is docked."),DefaultValue(eBorderType.None)]
+ public eBorderType DockedBorderStyle
+ {
+ get
+ {
+ return m_DockedBorder;
+ }
+ set
+ {
+ if (m_DockedBorder == value)
+ return;
+ m_DockedBorder = value;
+ if (m_BarState == eBarState.Docked && this.Visible)
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets/Sets whether floating bar is hidden when application loses focus.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(true),Category("Docking"),Description("Indicates whether floating bar is hidden when application loses focus.")]
+ public bool HideFloatingInactive
+ {
+ get
+ {
+ return m_HideFloatingInactive;
+ }
+ set
+ {
+ m_HideFloatingInactive = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets whether tab navigation buttons are shown for tabbed dockable bars.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(false),Category("Docking"),Description("Indicates whether tab navigation buttons are shown for tabbed dockable bars.")]
+ public bool TabNavigation
+ {
+ get
+ {
+ return m_TabNavigation;
+ }
+ set
+ {
+ if (m_TabNavigation != value)
+ {
+ m_TabNavigation = value;
+ UpdateDockTabSettings();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the border line color when docked border is a single line.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates the border line color when docked border is a single line.")]
+ public Color SingleLineColor
+ {
+ get
+ {
+ return m_SingleLineColor;
+ }
+ set
+ {
+ if (m_SingleLineColor != value)
+ {
+ m_SingleLineColor = value;
+ if (m_BarState == eBarState.Docked && this.Visible && m_DockedBorder == eBorderType.SingleLine)
+ this.Refresh();
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSingleLineColor()
+ {
+ return (m_SingleLineColor != SystemColors.ControlDark);
+ }
+
+ ///
+ /// Gets/Sets whether Bar is visible or not.
+ ///
+ [DevCoBrowsable(true), DefaultValue(true)]
+ public new bool Visible
+ {
+ get
+ {
+ if (m_BarState == eBarState.Floating && m_Float != null)
+ return m_Float.Visible;
+ return base.Visible;
+ }
+ set
+ {
+ m_IsVisible = value;
+ if (base.Visible == value)
+ {
+ // This allows the Bar to be hidden when Visible property is set from forms constructor...
+ if (/*!this.IsHandleCreated &&*/ value == false)
+ base.Visible = false;
+ return;
+ }
+ if (value)
+ this.ShowBar();
+ else
+ this.HideBar();
+ }
+ }
+
+ ///
+ /// Returns number of items that have Visible property set to true.
+ ///
+ [Browsable(false)]
+ public int VisibleItemCount
+ {
+ get
+ {
+ return m_ItemContainer.VisibleSubItems;
+ }
+ }
+
+ private BaseItem GetFirstVisibleItem()
+ {
+ foreach (BaseItem item in this.Items)
+ {
+ if (item.Visible)
+ return item;
+ }
+ return null;
+ }
+
+ ///
+ /// Gets or sets whether bar is valid drop target for end-user bar customization. Default value is true.
+ /// When bar is used as dock container then you can use this property to prevent docking of other bars as dock tabs.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Determines whether end-user can drag and drop items on the Bar."),DefaultValue(true)]
+ public bool AcceptDropItems
+ {
+ get
+ {
+ return m_AcceptDropItems;
+ }
+ set
+ {
+ m_AcceptDropItems = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether items on the Bar can be customized.
+ ///
+ [Browsable(true), Category("Behavior"),Description("Gets or sets whether items on the Bar can be customized."),DefaultValue(true)]
+ public bool CanCustomize
+ {
+ get
+ {
+ if (m_ItemContainer != null)
+ return m_ItemContainer.CanCustomize;
+ return false;
+ }
+ set
+ {
+ if (this.DesignMode) return;
+ if (m_ItemContainer != null)
+ m_ItemContainer.CanCustomize = value;
+ }
+ }
+
+
+ ///
+ /// Makes the Bar display by setting the visible property to true.
+ ///
+ public new void Show()
+ {
+ this.Visible = true;
+ }
+
+ ///
+ /// Hides the Bar.
+ ///
+ public new void Hide()
+ {
+ if (this.AutoHide)
+ this.AutoHide = false;
+ this.Visible = false;
+ this.RecalcLayout();
+ }
+
+ ///
+ /// Specifies whether Bar was created by user using Customize dialog.
+ ///
+ [System.ComponentModel.Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool CustomBar
+ {
+ get
+ {
+ return m_CustomBar;
+ }
+ set
+ {
+ m_CustomBar = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets the Bar name used to identify Bar from code.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Design"),System.ComponentModel.Description("Bar name that can be used to identify Bar from code.")]
+ public new string Name
+ {
+ get
+ {
+ return base.Name;
+ }
+ set
+ {
+ base.Name = value;
+ if (this.Site != null)
+ this.Site.Name = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets the Image size for all sub-items on the Bar.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Specifies the Image size that will be used by items on this bar."),DefaultValue(eBarImageSize.Default)]
+ public eBarImageSize ImageSize
+ {
+ get
+ {
+ return m_ImageSize;
+ }
+ set
+ {
+ if (m_ImageSize == value)
+ return;
+ m_ImageSize = value;
+ m_ItemContainer.RefreshImageSize();
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets the layout type.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Indicates Bar layout type."),DefaultValue(eLayoutType.Toolbar)]
+ public eLayoutType LayoutType
+ {
+ get
+ {
+ if (m_ItemContainer == null)
+ return eLayoutType.Toolbar;
+ return m_ItemContainer.LayoutType;
+ }
+ set
+ {
+ if (m_ItemContainer.LayoutType == value)
+ return;
+ m_ItemContainer.LayoutType = value;
+ if (value == eLayoutType.DockContainer)
+ this.ResetFont();
+ SetupAccessibility();
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets whether all buttons are automatically resized to the largest button in collection.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates that buttons will be automatically resized to match the size of the largest button on the bar."),DefaultValue(false)]
+ public bool EqualButtonSize
+ {
+ get
+ {
+ return m_ItemContainer.EqualButtonSize;
+ }
+ set
+ {
+ if (m_ItemContainer.EqualButtonSize == value)
+ return;
+ m_ItemContainer.EqualButtonSize = value;
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets rounded corner size for styles that use rounded corners.
+ ///
+ internal int CornerSize
+ {
+ get { return m_CornerSize; }
+ set { m_CornerSize = value; }
+ }
+
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting. Default value is false.
+ ///
+ [DefaultValue(false), Browsable(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting.")]
+ public bool AntiAlias
+ {
+ get { return m_AntiAlias; }
+ set
+ {
+ if (m_AntiAlias != value)
+ {
+ m_AntiAlias = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+
+ ///
+ /// Gets or sets whether mouse over fade effect is enabled for buttons. Default value is false. Note that Fade effect
+ /// will work only when Office2007 style is used. For other styles this property has no effect and fade animation is not used regardless
+ /// this property setting.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance"), Description("Indicates whether mouse over fade effect for buttons is enabled.")]
+ public bool FadeEffect
+ {
+ get { return m_FadeEffect; }
+ set
+ {
+ m_FadeEffect = value;
+ }
+ }
+
+ ///
+ /// Gets whether fade effect should be in use.
+ ///
+ internal bool IsFadeEnabled
+ {
+ get
+ {
+ if (this.DesignMode || (!BarFunctions.IsOffice2007Style(m_ItemContainer.EffectiveStyle)) || m_FadeEffect && NativeFunctions.IsTerminalSession() || this.IsThemed || TextDrawing.UseTextRenderer)
+ return false;
+ return m_FadeEffect;
+ }
+ }
+
+ ///
+ /// Gets or sets the Bar back color.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Specifies background color of the Bar."),DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public override Color BackColor
+ {
+ get
+ {
+ if (m_ItemContainer != null)
+ return m_ItemContainer.BackColor;
+ else
+ {
+ return base.BackColor;
+ }
+ }
+ set
+ {
+ if (m_ItemContainer != null)
+ m_ItemContainer.BackColor = value;
+ else
+ base.BackColor = value;
+ this.Invalidate();
+ }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void ResetBackColor()
+ {
+ if (m_ItemContainer != null)
+ m_ItemContainer.BackColor = Color.Empty;
+ else
+ base.BackColor = SystemColors.Control;
+ }
+ public bool ShouldSerializeBackColor()
+ {
+ if (m_ItemContainer != null)
+ {
+ if (!m_ItemContainer.m_BackgroundColor.IsEmpty)
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Returns whether Size property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSize()
+ {
+ if (this.LayoutType == eLayoutType.DockContainer && this.Parent is DockSite && this.Parent.Dock == DockStyle.Fill)
+ return false;
+ return true;
+ }
+
+ ///
+ /// Gets or sets the Bar customize menu (Applies to the bars with LayoutType set to DockWindow only).
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates the Customize popup menu."),DefaultValue(null)]
+ public PopupItem CustomizeMenu
+ {
+ get
+ {
+ return m_CustomizeMenu;
+ }
+ set
+ {
+ m_CustomizeMenu = value;
+ }
+ }
+
+ ///
+ /// Indicates the auto-hide side of the parent form where bar is positioned.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(false),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates the auto-hide side of the parent form where bar is positioned.")]
+ public eDockSide AutoHideSide
+ {
+ get
+ {
+ eDockSide side = eDockSide.None;
+ if (m_AutoHideState)
+ {
+ switch (m_LastDockSiteInfo.DockSide)
+ {
+ case DockStyle.Left:
+ {
+ side = eDockSide.Left;
+ break;
+ }
+ case DockStyle.Right:
+ {
+ side = eDockSide.Right;
+ break;
+ }
+ case DockStyle.Top:
+ {
+ side = eDockSide.Top;
+ break;
+ }
+ default:
+ {
+ side = eDockSide.Bottom;
+ break;
+ }
+ }
+ }
+ return side;
+ }
+ }
+
+ ///
+ /// Gets or sets whether tab text is always visible while bar is in auto-hide state. Default value is false which indicates that only text for the active dock tab is visible.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Auto-Hide"), Description("")]
+ public bool AutoHideTabTextAlwaysVisible
+ {
+ get { return m_AutoHideTextAlwaysVisible; }
+ set
+ {
+ m_AutoHideTextAlwaysVisible = value;
+ if (this.AutoHide && this.GetAutoHidePanel() != null)
+ this.GetAutoHidePanel().Invalidate();
+ }
+ }
+
+ private bool m_AutoHideStateDelayed = false;
+ ///
+ /// Indicates whether Bar is in auto-hide state. Applies to non-document dockable bars only.
+ ///
+ [Browsable(true), DefaultValue(false), DevCoBrowsable(true), System.ComponentModel.Category("Auto-Hide"), System.ComponentModel.Description("Indicates whether Bar is in auto-hide state. Applies to non-document dockable bars only."), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual bool AutoHide
+ {
+ get
+ {
+ return m_AutoHideState;
+ }
+ set
+ {
+ if (this.DesignMode)
+ return;
+ if (m_LayoutSuspended)
+ {
+ m_AutoHideStateDelayed = value;
+ return;
+ }
+ if (!m_CanAutoHide || this.LayoutType != eLayoutType.DockContainer || this.Parent != null && this.Parent.Dock == DockStyle.Fill && value)
+ return;
+ if (m_AutoHideState == value)
+ return;
+
+ m_AutoHideState = value;
+ AutoHideStateChanged();
+ InvokeAutoHideChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the visibility of the bar when bar is in auto-hide state.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(false),System.ComponentModel.Category("Auto-Hide"),System.ComponentModel.Description("Gets or sets the visibility of the bar when bar is in auto-hide state."), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public bool AutoHideVisible
+ {
+ get
+ {
+ return this.Visible;
+ }
+ set
+ {
+ if (!this.AutoHide || this.Visible == value)
+ return;
+
+ AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
+ if (value && panel != null && m_AutoHideState)
+ panel.ShowBar(this);
+ else if (!value && panel != null && m_AutoHideState)
+ panel.HideBar(this);
+ }
+ }
+
+ ///
+ /// Indicates whether Bar can be auto hidden.
+ ///
+ [Browsable(true), DefaultValue(true),Category("Auto-Hide"),Description("Indicates whether Bar can be auto hidden.")]
+ public bool CanAutoHide
+ {
+ get
+ {
+ return m_CanAutoHide;
+ }
+ set
+ {
+ m_CanAutoHide = value;
+ if (!m_CanAutoHide)
+ {
+ m_SystemButtons.AutoHideButtonRect = Rectangle.Empty;
+ m_SystemButtons.MouseOverAutoHide = false;
+ m_SystemButtons.MouseDownAutoHide = false;
+ }
+ if (this.IsHandleCreated)
+ this.Invalidate();
+ }
+ }
+
+ private Component m_GlobalParentComponent = null;
+ ///
+ /// Gets or sets the global parent control used as part of Global Items feature when bar is used as context menu bar. This property is used internally by
+ /// DotNetBar and should not be set directly.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Component GlobalParentComponent
+ {
+ get { return m_GlobalParentComponent; }
+ set { m_GlobalParentComponent = value; }
+ }
+
+ ///
+ /// Returns the first child item with specified name regardless of it's hierarchy.
+ ///
+ /// Item name.
+ ///
+ public BaseItem GetItem(string name)
+ {
+ BaseItem item = BarFunctions.GetSubItemByName(m_ItemContainer, name);
+ if (item != null)
+ return item;
+
+ if (m_GlobalParentComponent != null)
+ {
+ if (m_GlobalParentComponent is RibbonControl)
+ return ((RibbonControl)m_GlobalParentComponent).RibbonStrip.GetItem(name);
+ else if (m_GlobalParentComponent is DotNetBarManager)
+ return ((DotNetBarManager)m_GlobalParentComponent).GetItem(name);
+ }
+
+ return null;
+ }
+
+ ///
+ /// Returns the collection of items with the specified name.
+ ///
+ /// Item name to look for.
+ ///
+ public ArrayList GetItems(string ItemName)
+ {
+ ArrayList list = new ArrayList(15);
+ if (m_GlobalParentComponent != null)
+ {
+ if (m_GlobalParentComponent is RibbonControl)
+ list.AddRange(((RibbonControl)m_GlobalParentComponent).RibbonStrip.GetItems(ItemName));
+ else if (m_GlobalParentComponent is DotNetBarManager)
+ list.AddRange(((DotNetBarManager)m_GlobalParentComponent).GetItems(ItemName));
+ }
+ else
+ {
+ BarFunctions.GetSubItemsByName(m_ItemContainer, ItemName, list);
+ }
+
+ return list;
+ }
+
+ ///
+ /// Returns the collection of items with the specified name and type.
+ ///
+ /// Item name to look for.
+ /// Item type to look for.
+ ///
+ public ArrayList GetItems(string ItemName, Type itemType)
+ {
+ ArrayList list = new ArrayList(15);
+
+ if (m_GlobalParentComponent != null)
+ {
+ if (m_GlobalParentComponent is RibbonControl)
+ list.AddRange(((RibbonControl)m_GlobalParentComponent).RibbonStrip.GetItems(ItemName, itemType));
+ else if (m_GlobalParentComponent is DotNetBarManager)
+ list.AddRange(((DotNetBarManager)m_GlobalParentComponent).GetItems(ItemName, itemType));
+ }
+ else
+ {
+ BarFunctions.GetSubItemsByNameAndType(m_ItemContainer, ItemName, list, itemType);
+ }
+
+ return list;
+ }
+
+ ///
+ /// Returns the collection of items with the specified name and type. This member is not implemented and should not be used.
+ ///
+ /// Item name to look for.
+ /// Item type to look for.
+ /// Indicates whether GlobalName property is used for searching.
+ ///
+ public ArrayList GetItems(string ItemName, Type itemType, bool useGlobalName)
+ {
+ ArrayList list = new ArrayList(15);
+
+ if (m_GlobalParentComponent != null)
+ {
+ if (m_GlobalParentComponent is RibbonControl)
+ list.AddRange(((RibbonControl)m_GlobalParentComponent).RibbonStrip.GetItems(ItemName, itemType, useGlobalName));
+ else if (m_GlobalParentComponent is DotNetBarManager)
+ list.AddRange(((DotNetBarManager)m_GlobalParentComponent).GetItems(ItemName, itemType, false, useGlobalName));
+ }
+ else
+ {
+ BarFunctions.GetSubItemsByNameAndType(m_ItemContainer, ItemName, list, itemType, useGlobalName);
+ }
+
+ return list;
+ }
+
+ ///
+ /// Returns AutoHidePanel that bar is on if in auto-hide state otherwise returns null.
+ ///
+ /// AutoHidePanel object or null if bar is not in auto-hide state.
+ public AutoHidePanel GetAutoHidePanel()
+ {
+ if (!this.AutoHide)
+ return null;
+
+ return GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
+ }
+
+ private AutoHidePanel GetAutoHidePanel(DockStyle dock)
+ {
+ IOwnerAutoHideSupport ownerAutoHide = m_Owner as IOwnerAutoHideSupport;
+ if (ownerAutoHide == null)
+ return null;
+
+ AutoHidePanel panel = null;
+ switch (m_LastDockSiteInfo.DockSide)
+ {
+ case DockStyle.Left:
+ {
+ panel = ownerAutoHide.LeftAutoHidePanel;
+ break;
+ }
+ case DockStyle.Right:
+ {
+ panel = ownerAutoHide.RightAutoHidePanel;
+ break;
+ }
+ case DockStyle.Top:
+ {
+ panel = ownerAutoHide.TopAutoHidePanel;
+ break;
+ }
+ default:
+ {
+ panel = ownerAutoHide.BottomAutoHidePanel;
+ break;
+ }
+ }
+
+ if (this.AntiAlias) panel.AntiAlias = true;
+ panel.Style = this.Style;
+
+ return panel;
+ }
+ private Size GetLargestMinSize()
+ {
+ Size ret = Size.Empty;
+ foreach (BaseItem item in m_ItemContainer.SubItems)
+ {
+ if (item is DockContainerItem)
+ {
+ DockContainerItem dock = item as DockContainerItem;
+ if (dock.MinimumSize.Width > ret.Width)
+ ret.Width = dock.MinimumSize.Width;
+ if (dock.MinimumSize.Height > ret.Height)
+ ret.Height = dock.MinimumSize.Height;
+ }
+ }
+ return ret;
+ }
+ private Control GetOwnerControl()
+ {
+ Control parentControl = null;
+ IOwner owner = m_Owner as IOwner;
+ if (owner is DotNetBarManager && ((DotNetBarManager)owner).TopDockSite != null)
+ parentControl = ((DotNetBarManager)owner).TopDockSite.Parent;
+ else if (owner != null)
+ parentControl = owner.ParentForm;
+ return parentControl;
+ }
+
+ private void AutoHideStateChanged()
+ {
+ IOwner owner = m_Owner as IOwner;
+ IOwnerAutoHideSupport ownerAutoHide = m_Owner as IOwnerAutoHideSupport;
+ if (owner == null)
+ return;
+
+ Control parentControl = GetOwnerControl();
+
+ if (parentControl == null)
+ return;
+
+ if (m_AutoHideState)
+ {
+ if (m_BarState == eBarState.AutoHide)
+ return;
+ if (m_TabDockItems != null)
+ m_TabDockItems.Visible = false;
+ // Remember last docking info
+ DockSiteInfo tempInfo = m_LastDockSiteInfo;
+ m_LastDockSiteInfo = new DockSiteInfo();
+ // Preserve the relative last docked to bar in case the return to same docking position is needed
+ m_LastDockSiteInfo.LastRelativeDocumentId = tempInfo.LastRelativeDocumentId;
+ m_LastDockSiteInfo.LastRelativeDockToBar = tempInfo.LastRelativeDockToBar;
+
+ if (!m_BarDefinitionLoading)
+ {
+ if (this.Height > 0)
+ m_LastDockSiteInfo.DockedHeight = this.Height;
+ else if (m_ItemContainer != null && m_ItemContainer.MinHeight > 0)
+ m_LastDockSiteInfo.DockedHeight = m_ItemContainer.MinHeight + 22;
+ if (this.Width > 0)
+ m_LastDockSiteInfo.DockedWidth = this.Width;
+ else if (m_ItemContainer != null && m_ItemContainer.MinWidth > 0)
+ m_LastDockSiteInfo.DockedWidth = m_ItemContainer.MinWidth + 22;
+
+ // This will force proper recalculation in SetAutoHideSize procedure
+ System.Drawing.Size minSize = GetLargestMinSize();
+ if (minSize.Width > m_LastDockSiteInfo.DockedWidth)
+ m_LastDockSiteInfo.DockedWidth = 0;
+ if (minSize.Height > m_LastDockSiteInfo.DockedHeight)
+ m_LastDockSiteInfo.DockedHeight = 0;
+ }
+
+ m_LastDockSiteInfo.DockLine = this.DockLine;
+ m_LastDockSiteInfo.DockOffset = this.DockOffset;
+ if (this.Parent != null && m_BarState == eBarState.Docked)
+ m_LastDockSiteInfo.DockSide = this.Parent.Dock;
+ else
+ m_LastDockSiteInfo.DockSide = DockStyle.Left;
+ if (this.Parent != null && this.Parent is DockSite)
+ {
+ m_LastDockSiteInfo.InsertPosition = ((DockSite)this.Parent).Controls.GetChildIndex(this);
+ m_LastDockSiteInfo.objDockSite = (DockSite)this.DockedSite;
+ }
+
+ // Undock the window
+ m_BarState = eBarState.AutoHide;
+ ResetActiveControl();
+ parentControl.SuspendLayout();
+ try
+ {
+ // Check for parent since if bar is deserialized there is no parent and state is Docked by default
+ base.Visible = false;
+ if (this.Parent != null && this.Parent is DockSite)
+ {
+ DockSite ds = this.Parent as DockSite;
+ if (ds.DocumentDockContainer != null)
+ {
+ // Remember the split view docking if it was in effect
+ if (ds.Dock != DockStyle.Fill)
+ {
+ DocumentBarContainer dbr = ds.GetDocumentUIManager().GetDocumentFromBar(this) as DocumentBarContainer;
+ if (dbr != null && dbr.Parent is DocumentDockContainer)
+ {
+ DocumentDockContainer ddc = dbr.Parent as DocumentDockContainer;
+ if (ddc.Orientation == eOrientation.Horizontal && (ds.Dock == DockStyle.Top || ds.Dock == DockStyle.Bottom) ||
+ ddc.Orientation == eOrientation.Vertical && (ds.Dock == DockStyle.Left || ds.Dock == DockStyle.Right) && ddc.Documents.Count > 1)
+ {
+ for (int i = 0; i < ddc.Documents.Count; i++)
+ {
+ if (ddc.Documents[i] is DocumentBarContainer && ddc.Documents[i].Visible && ddc.Documents[i] != dbr)
+ {
+ m_LastDockSiteInfo.MouseOverBar = ((DocumentBarContainer)ddc.Documents[i]).Bar;
+ if (i < ddc.Documents.IndexOf(dbr))
+ m_LastDockSiteInfo.MouseOverDockSide = (ddc.Orientation == eOrientation.Horizontal ? eDockSide.Left : eDockSide.Bottom);
+ else
+ m_LastDockSiteInfo.MouseOverDockSide = (ddc.Orientation == eOrientation.Horizontal ? eDockSide.Right : eDockSide.Top);
+ break;
+ }
+ }
+ }
+ }
+ }
+ ds.GetDocumentUIManager().UnDock(this);
+ }
+ else
+ ((DockSite)this.Parent).RemoveBar(this);
+ }
+ this.Parent = null;
+
+ parentControl.Controls.Add(this);
+ parentControl.Controls.SetChildIndex(this, 0);
+ AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
+ panel.AddBar(this);
+
+ if (!m_BarDefinitionLoading)
+ SetAutoHideSize();
+ if (!m_IgnoreAnimation && m_AutoHideAnimationTime != 0)
+ this.Visible = true;
+ }
+ finally
+ {
+ parentControl.ResumeLayout();
+ }
+ //this.RecalcSize();
+ if (!m_BarDefinitionLoading)
+ {
+ this.Update();
+ AnimateHide();
+ }
+ }
+ else
+ {
+ AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
+ panel.RemoveBar(this);
+ if (m_LastDockSiteInfo.objDockSite != null)
+ {
+ if (m_LastDockSiteInfo.MouseOverBar != null)
+ {
+ if (m_LastDockSiteInfo.objDockSite.GetDocumentUIManager() == null ||
+ m_LastDockSiteInfo.objDockSite.GetDocumentUIManager().GetDocumentFromBar(m_LastDockSiteInfo.MouseOverBar) == null)
+ {
+ m_LastDockSiteInfo.MouseOverBar = null;
+ m_LastDockSiteInfo.MouseOverDockSide = eDockSide.None;
+ m_LastDockSiteInfo.NewLine = true;
+ }
+ }
+ }
+ else
+ {
+ m_LastDockSiteInfo.MouseOverBar = null;
+ m_LastDockSiteInfo.MouseOverDockSide = eDockSide.None;
+ m_LastDockSiteInfo.NewLine = true;
+ }
+
+ //m_LastDockSiteInfo.NewLine = true;
+ DockingHandler(m_LastDockSiteInfo, Point.Empty);
+ if (!this.IsVisible)
+ this.Visible = true;
+ this.RefreshDockTab(true);
+ this.ResizeDockTab();
+ m_ItemContainer.MinHeight = 0;
+ m_ItemContainer.MinWidth = 0;
+ }
+ }
+
+ internal void SetAutoHideSize()
+ {
+ IOwner owner = m_Owner as IOwner;
+ IOwnerBarSupport ownerBar = m_Owner as IOwnerBarSupport;
+ IOwnerAutoHideSupport ownerAutoHide = m_Owner as IOwnerAutoHideSupport;
+ Control parentControl = this.GetOwnerControl();
+
+ if (owner == null || parentControl == null || ownerBar == null || ownerAutoHide == null)
+ return;
+
+ int width = parentControl.ClientSize.Width;
+ int height = parentControl.ClientSize.Height;
+ int x = 0, y = 0;
+
+ //if(ownerBar.TopDockSite.Parent is UserControl)
+ {
+ switch (m_LastDockSiteInfo.DockSide)
+ {
+ case DockStyle.Left:
+ {
+ width = ownerBar.LeftDockSite.Parent.Width;
+ height = ownerBar.LeftDockSite.Parent.Height;
+ Point pLoc = ownerAutoHide.LeftAutoHidePanel.Location;
+ x = pLoc.X + ownerAutoHide.LeftAutoHidePanel.Width;
+ y = pLoc.Y;
+ break;
+ }
+ case DockStyle.Right:
+ {
+ width = ownerBar.RightDockSite.Parent.Width;
+ height = ownerBar.RightDockSite.Parent.Height;
+ Point pLoc = ownerAutoHide.RightAutoHidePanel.Location;
+ x = pLoc.X;
+ y = pLoc.Y;
+ break;
+ }
+ case DockStyle.Top:
+ {
+ width = ownerBar.TopDockSite.Parent.Width;
+ height = ownerBar.TopDockSite.Parent.Height;
+ Point pLoc = ownerAutoHide.TopAutoHidePanel.Location;
+ x = pLoc.X;
+ y = pLoc.Y + ownerAutoHide.TopAutoHidePanel.Height;
+ break;
+ }
+ default:
+ {
+ width = ownerBar.BottomDockSite.Parent.Width;
+ height = ownerBar.BottomDockSite.Parent.Height;
+ Point pLoc = ownerAutoHide.BottomAutoHidePanel.Location;
+ x = pLoc.X;
+ y = pLoc.Y;
+ break;
+ }
+ }
+ }
+
+ switch (m_LastDockSiteInfo.DockSide)
+ {
+ case DockStyle.Left:
+ {
+ // if(ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.TopDockSite)>ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.LeftDockSite))
+ // {
+ // height-=ownerBar.TopDockSite.Height;
+ // y=ownerBar.TopDockSite.Bottom;
+ // }
+ // if(ownerAutoHide.HasBottomAutoHidePanel)
+ // height-=ownerAutoHide.BottomAutoHidePanel.Height;
+ // if(ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.BottomDockSite)>ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.LeftDockSite))
+ // height-=ownerBar.BottomDockSite.Height;
+ height = ownerAutoHide.LeftAutoHidePanel.Height;
+ width = m_LastDockSiteInfo.DockedWidth;
+ if (width == 0)
+ {
+ int index = -1;
+ if (this.SelectedDockTab >= 0 && this.Items[this.SelectedDockTab] is DockContainerItem)
+ index = this.SelectedDockTab;
+ else if (this.Items.Count > 0 && this.Items[0] is DockContainerItem)
+ index = 0;
+ if (index >= 0)
+ width = Math.Max(((DockContainerItem)this.Items[index]).MinimumSize.Width, ((DockContainerItem)this.Items[index]).Width);
+ this.EnableRedraw = false;
+ try
+ {
+ this.Size = new Size(width, height);
+ this.RecalcSize();
+ }
+ finally
+ {
+ this.EnableRedraw = true;
+ }
+ width = this.Width;
+ m_LastDockSiteInfo.DockedWidth = width;
+ }
+ // if(!(ownerBar.TopDockSite.Parent is UserControl))
+ // {
+ // x=ownerAutoHide.LeftAutoHidePanel.Right;
+ // }
+ // else
+ // y+=ownerBar.TopDockSite.Top;
+ break;
+ }
+ case DockStyle.Right:
+ {
+ // if(ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.TopDockSite)>ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.RightDockSite))
+ // {
+ // height-=ownerBar.TopDockSite.Height;
+ // y=ownerBar.TopDockSite.Bottom;
+ // }
+ // if(ownerAutoHide.HasBottomAutoHidePanel)
+ // height-=ownerAutoHide.BottomAutoHidePanel.Height;
+ // if(ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.BottomDockSite)>ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.RightDockSite))
+ // height-=ownerBar.BottomDockSite.Height;
+ height = ownerAutoHide.RightAutoHidePanel.Height;
+ width = m_LastDockSiteInfo.DockedWidth;
+ if (width == 0)
+ {
+ int index = -1;
+ if (this.SelectedDockTab >= 0 && this.Items[this.SelectedDockTab] is DockContainerItem)
+ index = this.SelectedDockTab;
+ else if (this.Items.Count > 0 && this.Items[0] is DockContainerItem)
+ index = 0;
+ if (index >= 0)
+ width = Math.Max(((DockContainerItem)this.Items[index]).MinimumSize.Width, ((DockContainerItem)this.Items[index]).Width);
+ this.EnableRedraw = false;
+ try
+ {
+ this.Size = new Size(width, height);
+ this.RecalcSize();
+ }
+ finally
+ {
+ this.EnableRedraw = true;
+ }
+ width = this.Width;
+ m_LastDockSiteInfo.DockedWidth = width;
+ }
+ // if(!(ownerBar.TopDockSite.Parent is UserControl))
+ // x=ownerAutoHide.RightAutoHidePanel.Left-width;
+ // else
+ // {
+ x -= width;
+ //y+=ownerBar.TopDockSite.Top;
+ //}
+ break;
+ }
+ case DockStyle.Top:
+ {
+ // if(ownerAutoHide.HasLeftAutoHidePanel)
+ // {
+ // width-=ownerAutoHide.LeftAutoHidePanel.Width;
+ // x+=ownerAutoHide.LeftAutoHidePanel.Width;
+ // }
+ // if(ownerAutoHide.HasRightAutoHidePanel)
+ // {
+ // width-=ownerAutoHide.RightAutoHidePanel.Width;
+ // }
+ // if(ownerBar.TopDockSite.Parent.Controls.IndexOf(ownerBar.TopDockSite)= 0 && this.Items[this.SelectedDockTab] is DockContainerItem)
+ index = this.SelectedDockTab;
+ else if (this.Items.Count > 0 && this.Items[0] is DockContainerItem)
+ index = 0;
+ if (index >= 0)
+ height = Math.Max(((DockContainerItem)this.Items[index]).MinimumSize.Height, ((DockContainerItem)this.Items[index]).Height);
+
+ this.EnableRedraw = false;
+ try
+ {
+ this.Size = new Size(width, height);
+ this.RecalcSize();
+ }
+ finally
+ {
+ this.EnableRedraw = true;
+ }
+ height = this.Height;
+ m_LastDockSiteInfo.DockedHeight = height;
+ }
+
+ // if(!(ownerBar.TopDockSite.Parent is UserControl))
+ // y=ownerAutoHide.TopAutoHidePanel.Bottom;
+
+ break;
+ }
+ default:
+ {
+ // if(ownerAutoHide.HasLeftAutoHidePanel)
+ // {
+ // width-=ownerAutoHide.LeftAutoHidePanel.Width;
+ // x+=ownerAutoHide.LeftAutoHidePanel.Width;
+ // }
+ // if(ownerAutoHide.HasRightAutoHidePanel)
+ // width-=ownerAutoHide.RightAutoHidePanel.Width;
+ // if(ownerBar.BottomDockSite.Parent.Controls.IndexOf(ownerBar.BottomDockSite)= 0 && this.Items[this.SelectedDockTab] is DockContainerItem)
+ index = this.SelectedDockTab;
+ else if (this.Items.Count > 0 && this.Items[0] is DockContainerItem)
+ index = 0;
+ if (index >= 0)
+ height = Math.Max(((DockContainerItem)this.Items[index]).MinimumSize.Height, ((DockContainerItem)this.Items[index]).Height);
+
+ this.EnableRedraw = false;
+ try
+ {
+ this.Size = new Size(width, height);
+ this.RecalcSize();
+ }
+ finally
+ {
+ this.EnableRedraw = true;
+ }
+ height = this.Height;
+
+ m_LastDockSiteInfo.DockedHeight = height;
+ if (m_TabDockItems != null) m_LastDockSiteInfo.DockedHeight += m_TabDockItems.Height;
+ }
+ y -= height;
+ // if(!(ownerBar.TopDockSite.Parent is UserControl))
+ // y=ownerAutoHide.BottomAutoHidePanel.Top-height;
+ // else if(this.Parent!=null)
+ // {
+ // Point p=ownerAutoHide.BottomAutoHidePanel.PointToScreen(Point.Empty);
+ // p=this.Parent.PointToClient(p);
+ // y=p.Y-height;
+ // }
+ break;
+ }
+ }
+
+ Rectangle r = new Rectangle(x, y, width, height);
+ AutoHideDisplayEventArgs eventArgs = new AutoHideDisplayEventArgs(r);
+ if (AutoHideDisplay != null)
+ {
+ AutoHideDisplay(this, eventArgs);
+ r = eventArgs.DisplayRectangle;
+ }
+ if (ownerBar != null)
+ {
+ ownerBar.InvokeAutoHideDisplay(this, eventArgs);
+ r = eventArgs.DisplayRectangle;
+ }
+ this.Bounds = r;
+ //this.Size=r.Size; //new Size(width,height);
+ //this.Location=r.Location; //new Point(x,y);
+ this.RecalcSize();
+
+ if (m_LastDockSiteInfo.DockSide == DockStyle.Bottom)
+ {
+ if (this.Height != height)
+ this.Top += (height - this.Height);
+ }
+ else if (m_LastDockSiteInfo.DockSide == DockStyle.Right)
+ {
+ if (this.Width != width)
+ this.Left += (width - this.Width);
+ }
+
+ }
+
+ ///
+ /// Gets or sets how long it takes to play the auto-hide animation, in milliseconds. Maximum value is 2000, 0 disables animation.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(100),Category("Auto-Hide"),Description("Specifies how long it takes to play the auto-hide animation, in milliseconds. Maximum value is 2000, 0 disables animation.")]
+ public virtual int AutoHideAnimationTime
+ {
+ get { return m_AutoHideAnimationTime; }
+ set
+ {
+ if (value < 0)
+ value = 0;
+ if (value > 2000)
+ value = 2000;
+ m_AutoHideAnimationTime = value;
+ }
+ }
+
+ internal bool AnimateShow()
+ {
+ if (this.Visible)
+ return false;
+
+ CancelEventArgs e = new CancelEventArgs();
+ OnBeforeAutoHideDisplayed(e);
+ if (e.Cancel) return false;
+
+ SetAutoHideSize();
+ Rectangle rectEnd = new Rectangle(this.Location, this.Size);
+ Rectangle rectStart = rectEnd;
+ this.Parent.Controls.SetChildIndex(this, 0);
+ if (!m_IgnoreAnimation && m_AutoHideAnimationTime > 0 /*&& BarFunctions.SupportsAnimation*/)
+ {
+ switch (m_LastDockSiteInfo.DockSide)
+ {
+ case DockStyle.Left:
+ rectStart.Width = 1;
+ break;
+ case DockStyle.Right:
+ rectStart.X = rectStart.Right - 1;
+ rectStart.Width = 1;
+ break;
+ case DockStyle.Top:
+ rectStart.Height = 1;
+ break;
+ default:
+ rectStart.Y = rectStart.Bottom - 1;
+ rectStart.Height = 1;
+ break;
+ }
+ }
+ try
+ {
+ m_AnimationInProgress = true;
+ BarFunctions.AnimateControl(this, true, m_AutoHideAnimationTime, rectStart, rectEnd);
+ }
+ finally
+ {
+ m_AnimationInProgress = false;
+ }
+
+ m_IgnoreAnimation = false;
+
+ OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.AutoHideOpen));
+
+ return true;
+ }
+ internal bool AnimateHide()
+ {
+ if (!this.Visible)
+ return true;
+
+ CancelEventArgs e = new CancelEventArgs();
+ OnBeforeAutoHideHidden(e);
+ if (e.Cancel) return false;
+
+ this.Parent.Controls.SetChildIndex(this, 0);
+ Rectangle rectStart = new Rectangle(this.Location, this.Size);
+ Rectangle rectEnd = rectStart;
+
+ if (!m_IgnoreAnimation && m_AutoHideAnimationTime > 0 /*&& BarFunctions.SupportsAnimation*/)
+ {
+ switch (m_LastDockSiteInfo.DockSide)
+ {
+ case DockStyle.Left:
+ rectEnd.Width = 1;
+ break;
+ case DockStyle.Right:
+ rectEnd.X = rectEnd.Right - 1;
+ rectEnd.Width = 1;
+ break;
+ case DockStyle.Top:
+ rectEnd.Height = 1;
+ break;
+ default:
+ rectEnd.Y = rectEnd.Bottom - 1;
+ rectEnd.Height = 1;
+ break;
+ }
+
+ try
+ {
+ m_AnimationInProgress = true;
+ BarFunctions.AnimateControl(this, false, m_AutoHideAnimationTime, rectStart, rectEnd);
+ }
+ finally
+ {
+ m_AnimationInProgress = false;
+ }
+ }
+ else
+ this.Visible = false;
+
+ OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.AutoHideFolded));
+ return true;
+ }
+ ///
+ /// Occurs before the bar in auto-hide state is displayed on popup and allows you to cancel display by setting Cancel=true on event arguments.
+ ///
+ public event CancelEventHandler BeforeAutoHideDisplayed;
+ ///
+ /// Raises BeforeAutoHideDisplayed event.
+ ///
+ ///
+ protected virtual void OnBeforeAutoHideDisplayed(CancelEventArgs e)
+ {
+ CancelEventHandler eh = BeforeAutoHideDisplayed;
+ if (eh != null)
+ eh(this, e);
+ }
+
+ ///
+ /// Occurs before the bar in auto-hide state is hidden and allows you to cancel display by setting Cancel=true on event arguments.
+ ///
+ public event CancelEventHandler BeforeAutoHideHidden;
+ ///
+ /// Raises BeforeAutoHideHidden event.
+ ///
+ ///
+ protected virtual void OnBeforeAutoHideHidden(CancelEventArgs e)
+ {
+ CancelEventHandler eh = BeforeAutoHideHidden;
+ if (eh != null)
+ eh(this, e);
+ }
+
+ private void ResetActiveControl()
+ {
+ IOwner owner = m_Owner as IOwner;
+ // Must reset the ActiveControl to null becouse on MDI Forms if this was not done
+ // MDI form could not be closed if bar that had ActiveControl is floating.
+ if (owner.ParentForm != null && owner.ParentForm.ActiveControl == this)
+ {
+ owner.ParentForm.ActiveControl = null;
+ this.Focus(); // Fixes the problem on SDI forms
+ }
+ else if (owner.ParentForm != null && IsAnyControl(this, owner.ParentForm.ActiveControl))
+ {
+ owner.ParentForm.ActiveControl = null;
+ this.Focus();
+ }
+ }
+
+ private bool ShowCustomizeMenuButton
+ {
+ get
+ {
+ // We Show customize menu button if there is CustomizeItem in container or when
+ // LayoutType is DockingContainer and grab handle style is caption users have the docking container menu
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && (m_GrabHandleStyle == eGrabHandleStyle.Caption || m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane || m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted) && m_CustomizeMenu != null)
+ return true;
+ if (m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ {
+ if (m_ItemContainer.HaveCustomizeItem)
+ return true;
+ return (m_CustomizeMenu != null);
+ }
+ return false;
+ }
+ }
+
+ private void SysButtonMouseOverAutoHide(object sender, EventArgs e)
+ {
+ if (!m_SystemButtons.MouseOverAutoHide)
+ this.HideToolTip();
+ else
+ ResetHover();
+ }
+ private void SysButtonMouseOverCustomize(object sender, EventArgs e)
+ {
+ if (!m_SystemButtons.MouseOverCustomize)
+ this.HideToolTip();
+ else
+ ResetHover();
+ }
+ private void SysButtonMouseOverClose(object sender, EventArgs e)
+ {
+ if (!m_SystemButtons.MouseOverClose)
+ this.HideToolTip();
+ else
+ ResetHover();
+ }
+ private void SysButtonHideTooltip(object sender, EventArgs e)
+ {
+ HideToolTip();
+ }
+
+ ///
+ /// Destroys tooltip window.
+ ///
+ private void HideToolTip()
+ {
+ if (m_ToolTipWnd != null)
+ {
+ m_ToolTipWnd.Hide();
+ m_ToolTipWnd.Dispose();
+ m_ToolTipWnd = null;
+ ResetHover();
+ }
+ }
+
+ internal void HideAllToolTips()
+ {
+ HideToolTip();
+ if (m_ItemContainer != null)
+ {
+ foreach (BaseItem item in m_ItemContainer.SubItems)
+ this.HideItemToolTips(item);
+ }
+ }
+ private void HideItemToolTips(BaseItem item)
+ {
+ item.HideToolTip();
+ foreach (BaseItem i in item.SubItems)
+ this.HideItemToolTips(i);
+ }
+
+
+
+ ///
+ /// Shows tooltip for this item.
+ ///
+ private void ShowToolTip(string tipText)
+ {
+ if (this.DesignMode || !m_ShowToolTips || tipText == null || tipText == "")
+ return;
+
+ if (this.Visible)
+ {
+ if (m_ToolTipWnd == null)
+ m_ToolTipWnd = new ToolTip();
+ m_ToolTipWnd.Text = tipText;
+ IOwnerItemEvents ownerEvents = this.Owner as IOwnerItemEvents;
+ if (ownerEvents != null)
+ ownerEvents.InvokeToolTipShowing(m_ToolTipWnd, new EventArgs());
+ m_ToolTipWnd.ShowToolTip();
+ }
+ }
+
+ ///
+ /// Gets whether tooltip is visible or not.
+ ///
+ private bool ToolTipVisible
+ {
+ get
+ {
+ return (m_ToolTipWnd != null);
+ }
+ }
+
+ private void UpdateDockTabSettings()
+ {
+ if (m_TabDockItems == null || !BarFunctions.IsHandleValid(this))
+ return;
+
+ if (m_TabDockItems.CanReorderTabs != m_CanReorderTabs)
+ m_TabDockItems.CanReorderTabs = m_CanReorderTabs;
+ if (m_TabDockItems.TabAlignment != m_DockTabAlignment)
+ m_TabDockItems.TabAlignment = m_DockTabAlignment;
+
+ if (m_TabNavigation)
+ m_TabDockItems.TabLayoutType = eTabLayoutType.FixedWithNavigationBox;
+ else
+ m_TabDockItems.TabLayoutType = eTabLayoutType.FitContainer;
+
+ m_TabDockItems.ShowFocusRectangle = false;
+
+ if (m_TabDockItems._TabSystemBox != null)
+ m_TabDockItems._TabSystemBox.CloseVisible = this.CanHideResolved;
+
+ if (m_AutoHideState)
+ m_TabDockItems.Visible = false;
+ }
+
+ internal void CreateDockTab()
+ {
+ if (m_TabDockItems != null || !BarFunctions.IsHandleValid(this))
+ return;
+ m_TabDockItems = new TabStrip();
+ UpdateDockTabSettings();
+
+ this.SuspendLayout();
+ this.ResizeDockTab();
+ m_TabDockItems.SelectedTabChanging += new TabStrip.SelectedTabChangingEventHandler(this.TabStripTabChanging);
+ m_TabDockItems.SelectedTabChanged += new TabStrip.SelectedTabChangedEventHandler(TabDockItemsSelectedTabChanged);
+ m_TabDockItems.BeforeTabDisplay += new EventHandler(this.BeforeTabDisplay);
+ m_TabDockItems.TabMoved += new TabStrip.TabMovedEventHandler(this.TabStripTabMoved);
+ m_TabDockItems.TabItemClose += new TabStrip.UserActionEventHandler(TabStripTabItemClose);
+ m_TabDockItems.CloseButtonOnTabsVisible = m_DockTabCloseButtonVisible;
+ this.Controls.Add(m_TabDockItems);
+
+ SetDockTabStyle(m_ItemContainer.EffectiveStyle);
+
+ m_TabDockItems.Visible = GetDockTabVisible();
+ RefreshDockTabItems();
+ this.Invalidate();
+ this.ResumeLayout();
+ }
+
+ private void TabDockItemsSelectedTabChanged(object sender, TabStripTabChangedEventArgs e)
+ {
+ UpdateCloseButtonVisibility();
+ OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.SelectedDockTabChanged, this.SelectedDockContainerItem));
+ }
+
+ private void TabStripTabItemClose(object sender, TabStripActionEventArgs e)
+ {
+ TabItem ti = sender as TabItem;
+ if (ti != null)
+ {
+ DockContainerItem di = ti.AttachedItem as DockContainerItem;
+ if (di != null)
+ CloseDockTab(di, eEventSource.Mouse);
+ }
+ }
+
+ internal void SetDockTabStyle(eDotNetBarStyle style)
+ {
+ if (m_TabDockItems == null)
+ return;
+ if (style == eDotNetBarStyle.StyleManagerControlled)
+ style = StyleManager.GetEffectiveStyle();
+ if(StyleManager.IsMetro(style))
+ m_TabDockItems.Style = eTabStripStyle.Metro;
+ else if (style == eDotNetBarStyle.Office2003)
+ {
+ IOwnerBarSupport ob = m_Owner as IOwnerBarSupport;
+ if (this.DockSide == eDockSide.Document && ob != null && ob.ApplyDocumentBarStyle)
+ m_TabDockItems.Style = eTabStripStyle.OneNote;
+ else
+ m_TabDockItems.Style = eTabStripStyle.Office2003;
+ }
+ else if (style == eDotNetBarStyle.VS2005)
+ {
+ IOwnerBarSupport ob = m_Owner as IOwnerBarSupport;
+ if (this.DockSide == eDockSide.Document && ob != null && ob.ApplyDocumentBarStyle)
+ m_TabDockItems.Style = eTabStripStyle.VS2005Document;
+ else
+ m_TabDockItems.Style = eTabStripStyle.VS2005;
+ }
+ else if (BarFunctions.IsOffice2007Style(style))
+ {
+ IOwnerBarSupport ob = m_Owner as IOwnerBarSupport;
+ if (this.DockSide == eDockSide.Document && ob != null && ob.ApplyDocumentBarStyle)
+ m_TabDockItems.Style = eTabStripStyle.Office2007Document;
+ else
+ m_TabDockItems.Style = eTabStripStyle.Office2007Dock;
+ }
+ else
+ m_TabDockItems.Style = eTabStripStyle.Flat;
+ m_TabDockItems.ColorScheme.TabBorder = Color.Empty; // No border
+
+ if (TabStripStyleChanged != null)
+ TabStripStyleChanged(this, new EventArgs());
+ }
+
+ private void BeforeTabDisplay(object sender, EventArgs e)
+ {
+ if (sender is TabItem)
+ {
+ InvokeBeforeDockTabDisplayed(((TabItem)sender).AttachedItem);
+ }
+ }
+
+ private void DestroyDockTab()
+ {
+ if (m_TabDockItems == null)
+ return;
+ if (m_TabDockItems.IsDraggingBar)
+ {
+ //if(m_TabDockItems.Visible)
+ m_TabDockItems.Visible = false;
+ m_TabDockItems.Tabs.Clear();
+ return;
+ }
+ this.Controls.Remove(m_TabDockItems);
+ m_TabDockItems.Dispose();
+ m_TabDockItems = null;
+ }
+
+ internal void RefreshTabStrip()
+ {
+ if (m_TabDockItems != null)
+ m_TabDockItems.Refresh();
+ }
+
+ internal void RefreshDockTab(bool bFireEvents)
+ {
+ if (m_ItemContainer == null || !BarFunctions.IsHandleValid(this))
+ return;
+
+ SyncBarCaption();
+
+ int iVisibleItems = m_ItemContainer.VisibleSubItems;
+
+ if (iVisibleItems > 1 || m_AlwaysDisplayDockTab && m_BarState != eBarState.Floating)
+ {
+ if (m_TabDockItems == null)
+ {
+ CreateDockTab();
+ return;
+ }
+ else if (!m_TabDockItems.Visible && m_BarState != eBarState.AutoHide)
+ m_TabDockItems.Visible = GetDockTabVisible();
+ }
+ else
+ {
+ if (iVisibleItems == 1 && m_TabDockItems != null)
+ {
+ // Fire last DockTabChange Event
+ DockContainerItem item = null;
+ foreach (BaseItem baseItem in m_ItemContainer.SubItems)
+ {
+ if (baseItem.Visible && baseItem is DockContainerItem)
+ {
+ item = baseItem as DockContainerItem;
+ break;
+ }
+ }
+ if (item != null)
+ {
+ if (bFireEvents)
+ InvokeDockTabChange(null, item);
+ }
+ }
+ if (this.DesignMode)
+ {
+ if (m_TabDockItems != null)
+ m_TabDockItems.Visible = false;
+ }
+ else
+ DestroyDockTab();
+ return;
+ }
+
+ BaseItem oldItem = null;
+ if (bFireEvents && m_TabDockItems != null && m_TabDockItems.SelectedTab != null)
+ oldItem = m_TabDockItems.SelectedTab.AttachedItem;
+
+ RefreshDockTabItems();
+
+ if (bFireEvents && m_TabDockItems != null && m_TabDockItems.SelectedTab != null && oldItem != m_TabDockItems.SelectedTab.AttachedItem)
+ InvokeDockTabChange(oldItem, m_TabDockItems.SelectedTab.AttachedItem);
+ }
+
+ internal void RefreshAutoHidePanel()
+ {
+ if (this.AutoHide)
+ {
+ AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
+ if (panel != null)
+ {
+ panel.RefreshBar(this);
+ if (panel.SelectedDockContainerItem != null)
+ {
+ InvokeDockTabChange(null, panel.SelectedDockContainerItem);
+ }
+ }
+ }
+ }
+
+ internal void OnDockContainerVisibleChanged(DockContainerItem dockItem)
+ {
+ if (!this.AutoHide || dockItem.Visible)
+ return;
+ bool bDisplayed = true;
+ foreach (BaseItem item in this.Items)
+ {
+ if (item.Visible && bDisplayed)
+ {
+ item.Displayed = true;
+ bDisplayed = false;
+ }
+ else
+ item.Displayed = false;
+ }
+ }
+
+ ///
+ /// Re-docks the floating bar to its previous docking position.
+ ///
+ public void ReDock()
+ {
+
+ if (m_BarState == eBarState.Floating && (this.CanDockBottom || this.CanDockTop || this.CanDockLeft || this.CanDockRight || this.CanDockDocument))
+ {
+ DockingHandler(m_LastDockSiteInfo, Point.Empty);
+ }
+ }
+
+ internal void OnSubItemRemoved(BaseItem objItem)
+ {
+ if (objItem is DockContainerItem)
+ {
+ if (this.LayoutType == eLayoutType.DockContainer)
+ {
+ if (objItem.Displayed)
+ {
+ bool bOneDisp = false;
+ foreach (BaseItem item in this.Items)
+ {
+ if (item.Displayed)
+ bOneDisp = true;
+ }
+ if (!bOneDisp && this.Items.Count > 0)
+ this.Items[0].Displayed = true;
+ }
+ this.RefreshDockTab(true);
+ if (this.AutoHide)
+ {
+ AutoHidePanel panel = this.GetAutoHidePanel();
+ if (panel != null)
+ panel.RefreshBar(this);
+ }
+ }
+ }
+ SyncBarCaption();
+ }
+
+ ///
+ /// Invokes CaptionButtonClick event.
+ ///
+ protected void InvokeCaptionButtonClick()
+ {
+ if (CaptionButtonClick != null)
+ CaptionButtonClick(this, new EventArgs());
+ }
+
+ ///
+ /// Displays or hides the automatic caption button popup menu.
+ ///
+ private void ToggleCaptionMenu()
+ {
+ if (m_CaptionMenu != null)
+ {
+ bool bClose = m_CaptionMenu.Expanded;
+ if (bClose)
+ m_CaptionMenu.ClosePopup();
+ m_CaptionMenu.Dispose();
+ m_CaptionMenu = null;
+ if (bClose)
+ return;
+ }
+
+ if (this.Items.Count <= 0)
+ return;
+
+ m_CaptionMenu = new ButtonItem("sysCaptionButtonMenuParent");
+ m_CaptionMenu.Style = this.Style;
+ m_CaptionMenu.PopupShowing += new EventHandler(this.CaptionMenuShowing);
+ m_CaptionMenu.PopupFinalized += new EventHandler(this.CaptionMenuClose);
+ foreach (BaseItem item in this.Items)
+ {
+ ButtonItem menuItem = new ButtonItem("sysCaption_" + item.Name);
+ menuItem.Tag = item;
+ menuItem.OptionGroup = "sysCaptionMenu";
+ menuItem.Text = item.Text;
+ menuItem.BeginGroup = item.BeginGroup;
+ if (item is DockContainerItem)
+ {
+ DockContainerItem dock = item as DockContainerItem;
+ menuItem.Checked = item.Displayed;
+ if (dock.Image != null)
+ menuItem.Image = dock.Image.Clone() as System.Drawing.Image;
+ else if (dock.Icon != null)
+ menuItem.Icon = dock.Icon.Clone() as System.Drawing.Icon;
+ else if (dock.ImageIndex >= 0 && dock.ImageList != null)
+ menuItem.Image = dock.ImageList.Images[dock.ImageIndex].Clone() as System.Drawing.Image;
+ }
+ else
+ menuItem.Checked = item.Visible;
+ menuItem.Click += new EventHandler(this.CaptionMenuItemClick);
+ m_CaptionMenu.SubItems.Add(menuItem);
+ }
+
+ if (m_CaptionMenu.GetOwner() == null)
+ m_CaptionMenu.SetOwner(m_Owner);
+ System.Drawing.Size size = m_CaptionMenu.PopupSize;
+ Point popupLocation = new Point(m_SystemButtons.CaptionButtonRect.Right - size.Width, m_SystemButtons.CaptionButtonRect.Bottom);
+ if (popupLocation.X < 0)
+ popupLocation.X = 0;
+ popupLocation = this.PointToScreen(popupLocation);
+ m_CaptionMenu.Popup(popupLocation);
+ }
+ private void CaptionMenuItemClick(object sender, EventArgs e)
+ {
+ ButtonItem menuItem = sender as ButtonItem;
+ if (menuItem == null)
+ return;
+ if (this.LayoutType == eLayoutType.DockContainer)
+ this.SelectedDockTab = this.Items.IndexOf(menuItem.Tag as BaseItem);
+ else
+ {
+ foreach (BaseItem item in this.Items)
+ {
+ if (item == menuItem.Tag)
+ item.Visible = true;
+ else
+ item.Visible = false;
+ }
+ this.RecalcLayout();
+ m_CaptionMenu.Dispose();
+ m_CaptionMenu = null;
+ }
+ }
+ private void CaptionMenuShowing(object sender, EventArgs e)
+ {
+ if (m_CaptionMenu != null)
+ ((MenuPanel)m_CaptionMenu.PopupControl).ColorScheme = this.GetColorScheme();
+ }
+ private void CaptionMenuClose(object sender, EventArgs e)
+ {
+ PaintCaptionButton();
+ }
+
+ internal void RefreshDockContainerItem(DockContainerItem item)
+ {
+ if (m_ItemContainer == null || m_TabDockItems == null)
+ {
+ SyncBarCaption();
+ return;
+ }
+
+ foreach (TabItem tab in m_TabDockItems.Tabs)
+ {
+ if (tab.AttachedItem == item)
+ {
+ tab.Text = item.Text;
+ tab.AttachedItem = item;
+ tab.Tooltip = item.Tooltip;
+ tab.Name = item.Name;
+ if (item.Icon != null)
+ tab.Icon = item.Icon.Clone() as Icon;
+ else
+ {
+ tab.Image = item.TabImage;
+ tab.Icon = null;
+ }
+ break;
+ }
+ }
+ m_TabDockItems.Refresh();
+ if (this.AutoHide)
+ {
+ AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
+ if (panel != null)
+ panel.Refresh();
+ }
+ SyncBarCaption();
+ }
+
+ private bool GetDockTabVisible()
+ {
+ if (m_GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane && m_AutoCreateCaptionMenu || !_DockTabVisible)
+ return false;
+ return true;
+ }
+
+ private bool _DockTabVisible = true;
+ ///
+ /// Indicates whether dock tabs are visible when bar is acting as dock-container and it needs to display tabs to represents multiple DockContainerItem objects hosted by the bar. Default value is true.
+ ///
+ [DefaultValue(true), Browsable(false)]
+ public bool DockTabVisible
+ {
+ get { return _DockTabVisible; }
+ set
+ {
+ _DockTabVisible = value;
+ if (m_TabDockItems != null && !value)
+ m_TabDockItems.Visible = false;
+ }
+ }
+
+ private int _DockTabStripHeight = DOCKTABSTRIP_HEIGHT;
+ ///
+ /// Gets or sets height of the docked bar tab strip which displays docked tabs.
+ ///
+ [DefaultValue(DOCKTABSTRIP_HEIGHT), Category("Appearance"), Description("Indicates height of the docked bar tab strip which displays docked tabs.")]
+ public int DockTabStripHeight
+ {
+ get { return _DockTabStripHeight; }
+ set
+ {
+ if (value != _DockTabStripHeight)
+ {
+ int oldValue = _DockTabStripHeight;
+ _DockTabStripHeight = value;
+ OnDockTabStripHeightChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when DockTabStripHeight property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnDockTabStripHeightChanged(int oldValue, int newValue)
+ {
+ if (this.IsHandleCreated)
+ RecalcLayout();
+ //OnPropertyChanged(new PropertyChangedEventArgs("DockTabStripHeight"));
+ }
+
+ private bool m_RefreshingDockTab = false; // Used to preven re-entrancy
+ private void RefreshDockTabItems()
+ {
+ if (m_RefreshingDockTab)
+ return;
+ if (!m_TabDockItems.Visible && m_BarState != eBarState.AutoHide)
+ {
+ m_TabDockItems.Visible = GetDockTabVisible();
+ int dockTabStripHeight = Dpi.Height(DockTabStripHeight);
+ if (this.IsThemed && m_BarState == eBarState.Floating)
+ {
+ m_TabDockItems.Size = new Size(this.Width - (m_ThemeWindowMargins.Left + m_ThemeWindowMargins.Right), dockTabStripHeight);
+ m_TabDockItems.Location = new Point(m_ThemeWindowMargins.Left, this.Height - dockTabStripHeight - m_ThemeWindowMargins.Bottom);
+ }
+ else
+ {
+ m_TabDockItems.Size = new Size(this.Width - Dpi.Width4, dockTabStripHeight);
+ m_TabDockItems.Location = new Point(Dpi.Width2, this.Height - dockTabStripHeight - Dpi.Height2);
+ }
+ }
+ m_RefreshingDockTab = true;
+ try
+ {
+ m_TabDockItems.Tabs.Clear();
+ int iCount = 0;
+ foreach (BaseItem item in m_ItemContainer.SubItems)
+ {
+ if (item.Visible)
+ {
+ iCount++;
+ TabItem tab = new TabItem();
+ tab.Text = item.Text;
+ tab.Tooltip = item.Tooltip;
+ tab.Name = item.Name;
+ if (item is DockContainerItem)
+ {
+ DockContainerItem di = item as DockContainerItem;
+ if (di.Icon != null)
+ tab.Icon = di.Icon.Clone() as Icon;
+ else
+ tab.Image = di.TabImage;
+ tab.PredefinedColor = di.PredefinedTabColor;
+ }
+ m_TabDockItems.Tabs.Add(tab);
+ tab.AttachedItem = item;
+ if (item.Displayed)
+ {
+ m_TabDockItems._IgnoreBeforeTabDisplayEvent = true;
+ m_TabDockItems.SelectedTab = tab;
+ m_TabDockItems._IgnoreBeforeTabDisplayEvent = false;
+ }
+ }
+ }
+ if (iCount > 1 || iCount == 1 && m_AlwaysDisplayDockTab && m_BarState != eBarState.Floating)
+ {
+ if (!m_TabDockItems.Visible && m_BarState != eBarState.AutoHide)
+ m_TabDockItems.Visible = GetDockTabVisible();
+ if (m_TabDockItems.SelectedTab == null)
+ m_TabDockItems.SelectedTab = m_TabDockItems.Tabs[0];
+ else if (m_TabDockItems.SelectedTab.AttachedItem != null && !m_TabDockItems.SelectedTab.AttachedItem.Displayed)
+ m_TabDockItems.SelectedTab.AttachedItem.Displayed = true;
+ m_TabDockItems.Refresh();
+ }
+ else if (m_TabDockItems.Visible)
+ m_TabDockItems.Visible = false;
+ }
+ finally
+ {
+ m_RefreshingDockTab = false;
+ }
+
+ if (m_BarState == eBarState.AutoHide)
+ {
+ AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
+ if (panel != null)
+ panel.RefreshBar(this);
+ }
+ }
+
+ private void ResizeDockTab()
+ {
+ if (m_TabDockItems != null && m_TabDockItems.Visible)
+ {
+ Point p = Point.Empty;
+ Size sz = Size.Empty;
+
+ int dockTabStripHeight = Dpi.Height(DockTabStripHeight);
+ switch (m_DockTabAlignment)
+ {
+ case eTabStripAlignment.Top:
+ {
+ if (m_GrabHandleStyle != eGrabHandleStyle.None && !m_GrabHandleRect.IsEmpty)
+ {
+ p = new Point(m_GrabHandleRect.X, m_GrabHandleRect.Bottom);
+ sz = new Size(this.Width - m_GrabHandleRect.Left * 2, dockTabStripHeight);
+ }
+ else
+ {
+ if (m_BarState == eBarState.Docked)
+ {
+ p = new Point(Dpi.Width1, Dpi.Width1);
+ sz = new Size(this.Width - Dpi.Width2, dockTabStripHeight);
+ }
+ else if (m_BarState == eBarState.Floating)
+ {
+ if (this.IsThemed)
+ {
+ p = new Point(m_ThemeWindowMargins.Left, m_ThemeWindowMargins.Top);
+ sz = new Size(this.Width - (m_ThemeWindowMargins.Left + m_ThemeWindowMargins.Right), dockTabStripHeight);
+ }
+ else
+ {
+ p = new Point(Dpi.Width3, Dpi.Height3);
+ sz = new Size(this.Width - Dpi.Width6, dockTabStripHeight);
+ }
+ }
+ else
+ m_TabDockItems.Visible = false;
+ }
+ break;
+ }
+ case eTabStripAlignment.Left:
+ {
+ if (m_GrabHandleStyle != eGrabHandleStyle.None && !m_GrabHandleRect.IsEmpty)
+ {
+ p = new Point(m_GrabHandleRect.X + 1, m_GrabHandleRect.Bottom + Dpi.Height1);
+ sz = new Size(dockTabStripHeight, m_ItemContainer.HeightInternal - Dpi.Height1);
+ }
+ else
+ {
+ if (m_BarState == eBarState.Docked)
+ {
+ p = new Point(Dpi.Width2, Dpi.Height1);
+ sz = new Size(dockTabStripHeight, this.Height - Dpi.Height3);
+ }
+ else if (m_BarState == eBarState.Floating)
+ {
+ if (this.IsThemed)
+ {
+ p = new Point(m_ThemeWindowMargins.Left, m_ThemeWindowMargins.Top);
+ sz = new Size(this.Width - (m_ThemeWindowMargins.Left + m_ThemeWindowMargins.Right), dockTabStripHeight);
+ }
+ else
+ {
+ p = new Point(Dpi.Width3, Dpi.Height3);
+ sz = new Size(this.Width - Dpi.Width6, dockTabStripHeight);
+ }
+ }
+ else
+ m_TabDockItems.Visible = false;
+ }
+ break;
+ }
+ case eTabStripAlignment.Right:
+ {
+ if (m_GrabHandleStyle != eGrabHandleStyle.None && !m_GrabHandleRect.IsEmpty && m_BarState == eBarState.Docked)
+ {
+ p = new Point(this.ClientRectangle.Right - dockTabStripHeight, m_GrabHandleRect.Bottom + Dpi.Height1);
+ sz = new Size(dockTabStripHeight - Dpi.Width2, m_ItemContainer.HeightInternal);
+ }
+ else
+ {
+ if (m_BarState == eBarState.Docked)
+ {
+ p = new Point(this.Width - dockTabStripHeight, Dpi.Height1);
+ sz = new Size(dockTabStripHeight, this.Height - Dpi.Height2);
+ }
+ else if (m_BarState == eBarState.Floating)
+ {
+ if (this.IsThemed)
+ {
+ p = new Point(this.Width - m_ThemeWindowMargins.Right - dockTabStripHeight, m_ThemeWindowMargins.Top);
+ sz = new Size(dockTabStripHeight, this.Height - (m_ThemeWindowMargins.Top + m_ThemeWindowMargins.Bottom));
+ }
+ else
+ {
+ p = new Point(this.Width - Dpi.Width3 - dockTabStripHeight, m_ItemContainer.TopInternal);
+ sz = new Size(dockTabStripHeight, m_ItemContainer.HeightInternal);
+ }
+ }
+ else
+ m_TabDockItems.Visible = false;
+ }
+ break;
+ }
+ default:
+ {
+ p = new Point(0, this.Height - dockTabStripHeight);
+ sz = new Size(this.Width, dockTabStripHeight);
+ if (this.DockSide == eDockSide.Top && m_BarState == eBarState.Docked)
+ {
+ p = new Point(0, this.Height - dockTabStripHeight - Dpi.Height1);
+ sz = new Size(this.Width, dockTabStripHeight);
+ }
+ if (m_BarState == eBarState.Docked)
+ {
+ if (m_DockedBorder != eBorderType.None)
+ {
+ p = new Point(Dpi.Width2, this.Height - dockTabStripHeight - Dpi.Height3);
+ sz = new Size(this.Width - Dpi.Width4, dockTabStripHeight);
+ }
+ }
+ else if (m_BarState == eBarState.Floating)
+ {
+ if (this.IsThemed)
+ {
+ p = new Point(m_ThemeWindowMargins.Left, this.Height - dockTabStripHeight - m_ThemeWindowMargins.Right);
+ sz = new Size(this.Width - (m_ThemeWindowMargins.Left + m_ThemeWindowMargins.Right), dockTabStripHeight);
+ }
+ else
+ {
+ p = new Point(3, this.Height - dockTabStripHeight - Dpi.Height3);
+ sz = new Size(this.Width - Dpi.Width6, dockTabStripHeight);
+ }
+ }
+ else
+ m_TabDockItems.Visible = false;
+ break;
+ }
+ }
+ m_TabDockItems.SetBounds(p.X, p.Y, sz.Width, sz.Height);
+ }
+ }
+
+ ///
+ /// Returns the reference to internal TabStrip control used to display contained DockContainerItems.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(false)]
+ public TabStrip DockTabControl
+ {
+ get
+ {
+ return m_TabDockItems;
+ }
+ }
+
+ private void TabStripTabChanging(object sender, TabStripTabChangingEventArgs e)
+ {
+ if (m_RefreshingDockTab)
+ return;
+ e.Cancel = InvokeDockTabChange((e.OldTab == null ? null : e.OldTab.AttachedItem), (e.NewTab == null ? null : e.NewTab.AttachedItem));
+ }
+
+ private void SyncBarCaption(BaseItem selected)
+ {
+ if (m_AutoSyncBarCaption && this.LayoutType == eLayoutType.DockContainer)
+ {
+ DockContainerItem sel = this.SelectedDockContainerItem;
+ if (sel != null && sel.Visible || selected != null)
+ {
+ if (selected == null)
+ selected = sel; // this.Items[this.SelectedDockTab];
+
+ this.Text = selected.Text;
+ }
+ else
+ {
+ foreach (BaseItem item in this.Items)
+ {
+ if (item.Visible && item.Displayed)
+ {
+ this.Text = item.Text;
+ break;
+ }
+ }
+ }
+ }
+ }
+ internal void SyncBarCaption()
+ {
+ SyncBarCaption(null);
+ }
+
+ private bool InvokeDockTabChange(BaseItem oldItem, BaseItem newItem)
+ {
+ DockTabChangeEventArgs dockarg = null;
+ IOwnerBarSupport ownersupport = m_Owner as IOwnerBarSupport;
+ bool bCancel = false;
+ if (DockTabChange != null)
+ {
+ dockarg = new DockTabChangeEventArgs(oldItem, newItem);
+ DockTabChange(this, dockarg);
+ bCancel = dockarg.Cancel;
+ if (bCancel)
+ return bCancel;
+ }
+ if (m_Owner != null)
+ {
+ if (dockarg == null)
+ dockarg = new DockTabChangeEventArgs(oldItem, newItem);
+ if (ownersupport != null)
+ ownersupport.InvokeDockTabChange(this, dockarg);
+ bCancel = dockarg.Cancel;
+ }
+ if (!bCancel)
+ {
+ SyncBarCaption(newItem);
+ UpdateCloseButtonVisibility();
+ }
+
+ if (!bCancel)
+ OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.SelectedDockTabChanging, newItem));
+
+ return bCancel;
+ }
+
+ internal void InvokeBeforeDockTabDisplayed(BaseItem item)
+ {
+ if (BeforeDockTabDisplayed != null)
+ BeforeDockTabDisplayed(item, new EventArgs());
+
+ IOwnerBarSupport ownersupport = m_Owner as IOwnerBarSupport;
+ if (ownersupport != null)
+ ownersupport.InvokeBeforeDockTabDisplay(item, new EventArgs());
+ }
+
+ private void TabStripTabMoved(object sender, TabStripTabMovedEventArgs e)
+ {
+ List hiddenList = new List();
+ foreach (BaseItem item in m_ItemContainer.SubItems)
+ {
+ if (!item.Visible)
+ hiddenList.Add(item);
+ }
+ foreach (BaseItem item in hiddenList)
+ {
+ m_ItemContainer.SubItems._Remove(item);
+ }
+ m_ItemContainer.SubItems._Remove((DockContainerItem)e.Tab.AttachedItem);
+ m_ItemContainer.SubItems._Add((DockContainerItem)e.Tab.AttachedItem, e.NewIndex);
+ foreach (BaseItem item in hiddenList)
+ {
+ m_ItemContainer.SubItems._Add(item);
+ }
+ m_TabsRearranged = true;
+ OnBarStateChanged(new BarStateChangedEventArgs(this, eBarStateChange.DockTabMoved, e.Tab.AttachedItem));
+ }
+
+ ///
+ /// Gets or sets the selected DockContainerItem if bar represents dockable window.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public DockContainerItem SelectedDockContainerItem
+ {
+ get
+ {
+ if (m_ItemContainer.LayoutType != eLayoutType.DockContainer) return null;
+ int si = this.SelectedDockTab;
+ if (si >= 0)
+ return this.Items[si] as DockContainerItem;
+ if (this.VisibleItemCount > 0)
+ {
+ foreach (BaseItem item in this.Items)
+ {
+ if (item.Visible && item.Displayed) return item as DockContainerItem;
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if (m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ throw new InvalidOperationException("Bar type is not dockable window. LayoutType must be set to eLayoutType.DockContainer");
+ if (!this.Items.Contains(value))
+ throw new InvalidOperationException("Bar.Items collection does not contain the item");
+ this.SelectedDockTab = this.Items.IndexOf(value);
+ }
+ }
+
+ ///
+ /// Gets or sets the tab (DockContainerItem) index for Bars with LayoutType set to eLayoutType.DockContainer. Index corresponds to the index of the DockContainerItem in Bar.Items collection.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Gets or sets the tab (DockContainerItem) index for Bars with LayoutType set to eLayoutType.DockContainer."),DefaultValue(-1)]
+ public int SelectedDockTab
+ {
+ get
+ {
+ if (m_ItemContainer.LayoutType != eLayoutType.DockContainer || m_TabDockItems == null)
+ return -1;
+ if (m_TabDockItems.SelectedTab != null)
+ return m_ItemContainer.SubItems.IndexOf(m_TabDockItems.SelectedTab.AttachedItem);
+
+ return -1;
+ }
+ set
+ {
+ if (m_TabDockItems == null || m_TabDockItems != null && this.AutoHide)
+ {
+ if (value < this.Items.Count)
+ {
+ for (int i = 0; i < this.Items.Count; i++)
+ {
+ if (i == value && this.Items[i].Visible)
+ this.Items[i].Displayed = true;
+ else
+ this.Items[i].Displayed = false;
+ }
+ if (m_TabDockItems == null)
+ {
+ if (this.Items[value].Displayed)
+ InvokeDockTabChange(null, this.Items[value]);
+ RefreshAutoHidePanel();
+ }
+ }
+ if (m_TabDockItems == null) return;
+ }
+ if (m_ItemContainer.LayoutType != eLayoutType.DockContainer)
+ throw new InvalidOperationException("SelectedDockTab property can be set only for LayoutType=eLayoutType.DockContainer.");
+ if (value < 0) value = 0;
+ if (value >= m_ItemContainer.SubItems.Count)
+ throw new InvalidOperationException("Invalid tab index.");
+ //if(this.AutoHide)
+ //{
+ // m_LastDockSiteInfo.DockedHeight=0;
+ // m_LastDockSiteInfo.DockedWidth=0;
+ //}
+ BaseItem item = m_ItemContainer.SubItems[value];
+ foreach (TabItem tab in m_TabDockItems.Tabs)
+ {
+ if (tab.AttachedItem == item)
+ {
+ if (m_TabDockItems.SelectedTab == tab && this.AutoHide)
+ InvokeBeforeDockTabDisplayed(item);
+ m_TabDockItems.SelectedTab = tab;
+ if (this.AutoHide)
+ {
+ AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
+ panel.SelectedDockContainerItem = item as DockContainerItem;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ #region Inherited properties hiding
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override Cursor Cursor
+ {
+ get
+ { return base.Cursor; }
+ set
+ { base.Cursor = value; }
+ }
+ ///
+ /// Indicates Bar background image.
+ ///
+ [Browsable(true), DevCoBrowsable(true),Category("Appearance"),Description("Indicates Bar background image.")]
+ public override Image BackgroundImage
+ {
+ get { return base.BackgroundImage; }
+ set { base.BackgroundImage = value; }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override Color ForeColor
+ {
+ get { return base.ForeColor; }
+ set { base.ForeColor = value; }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override RightToLeft RightToLeft
+ {
+ get { return base.RightToLeft; }
+ set { base.RightToLeft = value; }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override ContextMenu ContextMenu
+ {
+ get { return base.ContextMenu; }
+ set { base.ContextMenu = value; }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public new ImeMode ImeMode
+ {
+ get { return base.ImeMode; }
+ set { base.ImeMode = value; }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public new int TabIndex
+ {
+ get { return base.TabIndex; }
+ set { base.TabIndex = value; }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public new bool TabStop
+ {
+ get { return base.TabStop; }
+ set { base.TabStop = value; }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public new bool CausesValidation
+ {
+ get { return base.CausesValidation; }
+ set { base.CausesValidation = value; }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override AnchorStyles Anchor
+ {
+ get { return base.Anchor; }
+ set { base.Anchor = value; }
+ }
+ [Browsable(true), DevCoBrowsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override DockStyle Dock
+ {
+ get { return base.Dock; }
+ set
+ {
+ if (this.DockSide == eDockSide.Document && value != DockStyle.None && this.Parent is DockSite)
+ return;
+ base.Dock = value;
+ }
+ }
+
+ [Browsable(false)]
+ public new Point Location
+ {
+ get { return base.Location; }
+ set
+ {
+ if (m_BarState == eBarState.Floating)
+ {
+ if (m_Float != null)
+ m_Float.Location = value;
+ }
+ else
+ base.Location = value;
+ }
+ }
+ [Browsable(false)]
+ public new Size Size
+ {
+ get { return base.Size; }
+ set { base.Size = value; }
+ }
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override bool AllowDrop
+ {
+ get { return base.AllowDrop; }
+ set { base.AllowDrop = value; }
+ }
+#if FRAMEWORK20
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public new System.Windows.Forms.Padding Padding
+ {
+ get { return base.Padding; }
+ set { base.Padding = value; }
+ }
+#endif
+ #endregion
+
+ ///
+ /// Gets or sets whether caption button menu for bars with grab handle task pane is automatically created.
+ /// Caption menu when automatically created will display the list of all items from Items collection
+ /// and it will maintain only one item from the list as visible item.
+ /// To create custom caption menu that is displayed when user clicks the caption button handle CaptionButtonClick event.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(true),Category("Behavior"),Description("Indicates whether caption button drop-down menu is automatically created")]
+ public virtual bool AutoCreateCaptionMenu
+ {
+ get
+ {
+ return m_AutoCreateCaptionMenu;
+ }
+ set
+ {
+ m_AutoCreateCaptionMenu = value;
+ if (this.Visible)
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets whether caption (text) of the bars with dock container layout is automatically set to the
+ /// selected dock container item text.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(false),Category("Behavior"),Description("Indicates whether caption is automatically set to the active dock container item text.")]
+ public virtual bool AutoSyncBarCaption
+ {
+ get { return m_AutoSyncBarCaption; }
+ set
+ {
+ m_AutoSyncBarCaption = value;
+ SyncBarCaption();
+ }
+ }
+
+ // IDockInfo Interface implementation
+ ///
+ /// Returns the Minimum Size for specified orientation.
+ ///
+ /// Orientation to return minimum size for.
+ ///
+ public System.Drawing.Size MinimumDockSize(eOrientation dockOrientation)
+ {
+ if (m_ItemContainer == null) return new Size(32, 32);
+ if (m_ItemContainer.LayoutType == eLayoutType.DockContainer && (m_ItemContainer.Stretch || m_DockStretch))
+ {
+ if (m_ItemContainer.SubItems.Count > 0 && m_ItemContainer.SubItems[0] is DockContainerItem)
+ return ((DockContainerItem)m_ItemContainer.SubItems[0]).MinimumSize;
+ return new Size(32, 32);
+ }
+
+ if (m_ItemContainer.Stretch || m_DockStretch)
+ return PreferredDockSize(dockOrientation);
+
+ if (m_ItemContainer.SubItems.Count > 0)
+ {
+ BaseItem objItem = m_ItemContainer.SubItems[0];
+ if (objItem != null)
+ {
+ return new Size(objItem.WidthInternal + m_ClientRect.Left * 2, objItem.HeightInternal);
+ }
+ }
+
+ return new Size(0, 0);
+ }
+ internal Size GetAdjustedFullSize(Size size)
+ {
+ const int TOTAL_BORDER_SIZE = 6;
+ Size newSize = size;
+ if (m_TabDockItems != null && m_TabDockItems.Visible && (this.DockTabAlignment == eTabStripAlignment.Top || this.DockTabAlignment == eTabStripAlignment.Bottom))
+ newSize.Height += (m_TabDockItems.Height);
+ newSize.Height += (TOTAL_BORDER_SIZE + SystemInformation.ToolWindowCaptionHeight);
+ newSize.Width += TOTAL_BORDER_SIZE;
+ return newSize;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int GetBarDockedSize(eOrientation o)
+ {
+ int TOTAL_BORDER_SIZE = Dpi.Width6;
+ if (m_ItemContainer == null)
+ return 0;
+ if (o == eOrientation.Horizontal && m_LastDockSiteInfo.DockedHeight > 0 && (m_LastDockSiteInfo.DockSide == DockStyle.Top || m_LastDockSiteInfo.DockSide == DockStyle.Bottom))
+ return m_LastDockSiteInfo.DockedHeight;
+ else if (o == eOrientation.Vertical && m_LastDockSiteInfo.DockedWidth > 0 && (m_LastDockSiteInfo.DockSide == DockStyle.Left || m_LastDockSiteInfo.DockSide == DockStyle.Right))
+ return m_LastDockSiteInfo.DockedWidth;
+
+ if (o == eOrientation.Horizontal && m_ItemContainer.MinHeight > 0 && m_ItemContainer.MinHeight + SystemInformation.ToolWindowCaptionHeight < this.GetFormClientHeight())
+ return m_ItemContainer.MinHeight + SystemInformation.ToolWindowCaptionHeight;
+ else if (o == eOrientation.Vertical && m_ItemContainer.MinWidth > 0 && m_ItemContainer.MinWidth + SystemInformation.ToolWindowCaptionHeight < this.GetFormClientWidth())
+ return m_ItemContainer.MinWidth + SystemInformation.ToolWindowCaptionHeight;
+
+ if (this.SelectedDockTab >= 0 || this.VisibleItemCount > 0 && this.LayoutType == eLayoutType.DockContainer)
+ {
+ DockContainerItem item = null;
+ if (this.SelectedDockTab >= 0)
+ item = this.Items[this.SelectedDockTab] as DockContainerItem;
+ else
+ item = GetFirstVisibleItem() as DockContainerItem;
+ if (item != null)
+ {
+ if (o == eOrientation.Horizontal)
+ {
+ if (item.MinimumSize.Height > 0)
+ {
+ int height = this.Height;
+ if (this.Parent != null && (this.DockSide == eDockSide.Left || this.DockSide == eDockSide.Right) ||
+ this.Parent == null && (LastDockSide == eDockSide.Left || LastDockSide == eDockSide.Right))
+ height = this.Width;
+
+ if (height > item.MinimumSize.Height)
+ return height;
+ return item.MinimumSize.Height * 2 + Dpi.Height(DockTabStripHeight) + TOTAL_BORDER_SIZE;
+ }
+ }
+ else
+ {
+ if (item.MinimumSize.Width > 0)
+ {
+ int width = this.Width;
+ if (this.Parent != null && (this.DockSide == eDockSide.Top || this.DockSide == eDockSide.Bottom) ||
+ this.Parent == null && (LastDockSide == eDockSide.Top || LastDockSide == eDockSide.Bottom))
+ width = this.Height;
+ if (width > item.MinimumSize.Width)
+ return width;
+ return item.MinimumSize.Width * 2 + TOTAL_BORDER_SIZE;
+ }
+ }
+ }
+ }
+
+ if (o == eOrientation.Horizontal)
+ return this.Height;
+ else
+ return this.Width;
+ }
+
+ ///
+ /// Returns the preferred size of the Bar when docked.
+ ///
+ /// Orientation to return preferred size for.
+ ///
+ public System.Drawing.Size PreferredDockSize(eOrientation dockOrientation)
+ {
+ // Return preffered size for this container
+ IOwner owner = m_Owner as IOwner;
+ if (dockOrientation == eOrientation.Horizontal)
+ {
+ if (m_DockedSizeH.IsEmpty)
+ {
+ if (owner != null && owner.ParentForm != null)
+ m_DockedSizeH = RecalcSizeOnly(owner.ParentForm.Size, eOrientation.Horizontal, eBarState.Docked, m_WrapItemsDock);
+ else
+ m_DockedSizeH = RecalcSizeOnly(System.Windows.Forms.Screen.FromControl(this).WorkingArea.Size, eOrientation.Horizontal, eBarState.Docked, m_WrapItemsDock);
+ }
+
+ return m_DockedSizeH;
+ }
+ else
+ {
+ // We will need to calculate that size
+ if (m_DockedSizeV.IsEmpty)
+ {
+ Size size = Size.Empty;
+ if (owner != null && owner.ParentForm != null)
+ size = RecalcSizeOnly(owner.ParentForm.Size, eOrientation.Horizontal, eBarState.Docked, m_WrapItemsDock);
+ else
+ size = RecalcSizeOnly(System.Windows.Forms.Screen.FromControl(this).WorkingArea.Size, eOrientation.Horizontal, eBarState.Docked, m_WrapItemsDock);
+ m_DockedSizeV = new Size(size.Height, size.Width);
+ }
+
+ return m_DockedSizeV;
+ }
+ }
+
+ ///
+ /// Specifies whether Bar can be undocked. Does not apply to stand alone bars.
+ ///
+ [Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Specifies whether Bar can be undocked."),DefaultValue(true)]
+ public bool CanUndock
+ {
+ get
+ {
+ return m_CanUndock;
+ }
+ set
+ {
+ if (m_CanUndock != value)
+ m_CanUndock = value;
+ }
+ }
+
+ ///
+ /// Specifes whether end-user can tear-off (deattach) the tabs on dockable window.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Specifes whether end-user can tear-off (deattach) the tabs on dockable window."),DefaultValue(true)]
+ public bool CanTearOffTabs
+ {
+ get
+ {
+ return m_CanTearOffTabs;
+ }
+ set
+ {
+ if (m_CanTearOffTabs != value)
+ m_CanTearOffTabs = value;
+ }
+ }
+
+ ///
+ /// Specifes whether end-user can reorder the tabs on dockable window.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Specifes whether end-user can reorder the tabs on dockable window."),DefaultValue(true)]
+ public bool CanReorderTabs
+ {
+ get
+ {
+ return m_CanReorderTabs;
+ }
+ set
+ {
+ if (m_CanReorderTabs != value)
+ {
+ m_CanReorderTabs = value;
+ if (m_TabDockItems != null)
+ m_TabDockItems.CanReorderTabs = value;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether bar or DockContainerItem that is torn-off this bar can be docked
+ /// as tab to another bar. Default value is true which indicates that bar can be docked as tab to another bar.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(true),Category("Docking"),Description("Indicates whether bar or DockContainerItem that is torn-off this bar can be docked as tab to another bar.")]
+ public bool CanDockTab
+ {
+ get { return m_CanDockTab; }
+ set { m_CanDockTab = value; }
+ }
+
+ private bool _CanMove = true;
+ ///
+ /// Gets or sets whether dock bar can be moved by dragging its caption using the mouse.
+ ///
+ [DefaultValue(true), Category("Docking"), Description("Indicates whether dock bar can be moved by dragging its caption using the mouse.")]
+ public bool CanMove
+ {
+ get { return _CanMove; }
+ set
+ {
+ _CanMove = value;
+ }
+ }
+
+ ///
+ /// Specifies whether Bar can be docked on Top dock site or not. Does not apply to stand alone bars.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Determines whether bar can be docked to the top edge of container.")]
+ public bool CanDockTop
+ {
+ get
+ {
+ return m_CanDockTop;
+ }
+ set
+ {
+ if (m_CanDockTop != value)
+ m_CanDockTop = value;
+ }
+ }
+
+ ///
+ /// Specifies whether Bar can be docked on Bottom dock site or not. Does not apply to stand alone bars.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(true),Category("Docking"),Description("Determines whether bar can be docked to the bottom edge of container.")]
+ public bool CanDockBottom
+ {
+ get
+ {
+ return m_CanDockBottom;
+ }
+ set
+ {
+ if (m_CanDockBottom != value)
+ m_CanDockBottom = value;
+ }
+ }
+
+ ///
+ /// Specifes whether Bar can be docked on Left dock site or not. Does not apply to stand alone bars.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Determines whether bar can be docked to the left edge of container.")]
+ public bool CanDockLeft
+ {
+ get
+ {
+ return m_CanDockLeft;
+ }
+ set
+ {
+ if (m_CanDockLeft != value)
+ m_CanDockLeft = value;
+ }
+ }
+
+ ///
+ /// Specifes whether Bar can be docked on Right dock site or not. Does not apply to stand alone bars.
+ ///
+ [Browsable(true), DevCoBrowsable(true),DefaultValue(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Determines whether bar can be docked to the right edge of container.")]
+ public bool CanDockRight
+ {
+ get
+ {
+ return m_CanDockRight;
+ }
+ set
+ {
+ if (m_CanDockRight != value)
+ m_CanDockRight = value;
+ }
+ }
+
+ ///
+ /// Specifies whether Bar can be docked as document. Default value is false. See DotNetBarManager.EnableDocumentDocking for more details.
+ ///
+ [Browsable(true), DefaultValue(false) , Category("Docking"), Description("Specifies whether Bar can be docked as document.")]
+ public bool CanDockDocument
+ {
+ get { return m_CanDockDocument; }
+ set { m_CanDockDocument = value; }
+ }
+
+ ///
+ /// Specifies whether Bar will stretch to always fill the space in dock site. Applies to the dockable bars only.
+ ///
+ [Browsable(false), DefaultValue(false),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Specifies whether Bar will stretch to always fill the space in dock site.")/*,DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)*/]
+ public bool Stretch
+ {
+ get
+ {
+ return m_DockStretch;
+ }
+ set
+ {
+ if (m_DockStretch != value)
+ {
+ m_DockStretch = value;
+ this.RecalcLayout();
+ }
+ }
+ }
+
+ protected override void OnDockChanged(EventArgs e)
+ {
+ base.OnDockChanged(e);
+ if (this.Dock != DockStyle.None)
+ m_DockStretch = true;
+ else
+ m_DockStretch = false;
+ this.RecalcLayout();
+ }
+
+ private bool m_DisabledImagesGrayScale = true;
+ ///
+ /// Gets or sets whether gray-scale algorithm is used to create automatic gray-scale images. Default is true.
+ ///
+ [System.ComponentModel.Browsable(true), DefaultValue(true),System.ComponentModel.Category("Appearance"),Description("Gets or sets whether gray-scale algorithm is used to create automatic gray-scale images.")]
+ public bool DisabledImagesGrayScale
+ {
+ get
+ {
+ return m_DisabledImagesGrayScale;
+ }
+ set
+ {
+ m_DisabledImagesGrayScale = value;
+ }
+ }
+
+ // TODO: Merge Implementation
+ // ///
+ // /// Specifies whether Bar is merged with MDI Parent Bars when on MDI Child form.
+ // ///
+ // [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(false),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Specifies whether Bar is merged with MDI Parent Bars when on MDI Child form.")]
+ // public bool MergeEnabled
+ // {
+ // get
+ // {
+ // return m_MergeEnabled;
+ // }
+ // set
+ // {
+ // m_MergeEnabled=value;
+ // if(!this.DesignMode && this.Visible && IsParentMdiChild)
+ // {
+ // this.Visible=false;
+ // }
+ // }
+ // }
+
+ ///
+ /// Gets/Sets the distance from the far left/top side of the docking site or suggests the order of the docked bar. Upon serialization this property
+ /// will contain actual left/top position of the bar. You can use it to re-order the bars docked on the same line. Property value is relative to the other
+ /// bars docked on the same line when it is used to change the order. For example setting DockOffset value to 10 will place the bar just after the last bar on the
+ /// same line that has DockOffset value less than 10. If there is no bar with DockOffset value less than 10 the bar will be placed in first position.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Indicates the distance from the far left/top side of the docking site.."),DefaultValue(0)]
+ public int DockOffset
+ {
+ get
+ {
+ return m_DockOffset;
+ }
+ set
+ {
+ m_DockOffset = value;
+ }
+ }
+ ///
+ /// Gets/Sets the dock line.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Indicates the docking line."),DefaultValue(0)]
+ public int DockLine
+ {
+ get
+ {
+ return m_DockLine;
+ }
+ set
+ {
+ m_DockLine = value;
+ if (m_BarState == eBarState.Docked)
+ {
+ if (this.Parent is DockSite && !m_LayoutSuspended)
+ {
+ ((DockSite)this.Parent).AdjustBarPosition(this);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Sets the dock line but it does not forces the Bar to change position. The position will be changed on next layout request or when dock site needs to recalculate the layout of the bat. Used internally only.
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public void SetDockLine(int iLine)
+ {
+ m_DockLine = iLine;
+ }
+
+ ///
+ /// Gets or sets the dock tab alignment.
+ ///
+ [Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Gets or sets the dock tab alignment."),System.ComponentModel.DefaultValue(eTabStripAlignment.Bottom)]
+ public eTabStripAlignment DockTabAlignment
+ {
+ get { return m_DockTabAlignment; }
+ set
+ {
+ m_DockTabAlignment = value;
+ if (m_TabDockItems != null)
+ {
+ m_TabDockItems.TabAlignment = m_DockTabAlignment;
+ RecalcLayout();
+ ResizeDockTab();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether selected dock tab is closed when Bar caption close button is pressed. Default value is false which indicates that whole bar will be hidden when bars close button is pressed.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Docking"), Description("Indicates whether selected dock tab is closed when Bar caption close button is pressed. Default value is false which indicates that whole bar will be hidden when bars close button is pressed.")]
+ public bool CloseSingleTab
+ {
+ get { return m_CloseSingleTab; }
+ set { m_CloseSingleTab = value; }
+ }
+
+ ///
+ /// Gets or sets whether close button is displayed on each dock tab that allows closing of the tab. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Description("Indicates whether close button is displayed on each dock tab that allows closing of the tab."), Category("Docking")]
+ public bool DockTabCloseButtonVisible
+ {
+ get { return m_DockTabCloseButtonVisible; }
+ set
+ {
+ if (m_DockTabCloseButtonVisible != value)
+ {
+ m_DockTabCloseButtonVisible = value;
+ if (m_TabDockItems != null)
+ {
+ m_TabDockItems.CloseButtonOnTabsVisible = m_DockTabCloseButtonVisible;
+ }
+ }
+ }
+ }
+
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+ {
+ DotNetBarManager manager = this.Owner as DotNetBarManager;
+ bool ctrlTabEnabled = false;
+ if (manager != null)
+ ctrlTabEnabled = manager.EnableDockCtrlTabKey;
+ if (ctrlTabEnabled && this.LayoutType == eLayoutType.DockContainer && this.VisibleItemCount > 1)
+ {
+ if ((keyData & Keys.Control) == Keys.Control && (keyData & Keys.Tab) == Keys.Tab && WinApi.HIWORD(WinApi.GetKeyState(9)) != 0)
+ {
+
+ if ((keyData & Keys.Shift) == Keys.Shift)
+ {
+ SelectPreviousTab(true);
+ }
+ else
+ {
+ SelectNextTab(true);
+ }
+ return true;
+ }
+ }
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+
+ internal bool SelectPreviousTab(bool cycle)
+ {
+ int newIndex = -1;
+ if (this.SelectedDockTab <= 0)
+ {
+ if (cycle)
+ {
+ newIndex = GetTabIndex(this.Items.Count, -1);
+ }
+ else
+ return false;
+ }
+ else
+ {
+ newIndex = GetTabIndex(this.SelectedDockTab, -1);
+ if (newIndex < 0 && cycle)
+ {
+ newIndex = GetTabIndex(this.Items.Count, -1);
+ }
+ }
+ if (newIndex < 0) return false;
+ this.SelectedDockTab = newIndex;
+ return true;
+ }
+
+ internal bool SelectNextTab(bool cycle)
+ {
+ int newIndex = -1;
+ if (this.SelectedDockTab >= this.Items.Count - 1)
+ {
+ if (cycle)
+ {
+ newIndex = GetTabIndex(-1, 1);
+ }
+ else
+ return false;
+ }
+ else
+ {
+ newIndex = GetTabIndex(this.SelectedDockTab, 1);
+ if (newIndex < 0 && cycle)
+ {
+ newIndex = GetTabIndex(-1, 1);
+ }
+ }
+ if (newIndex < 0) return false;
+ this.SelectedDockTab = newIndex;
+ return true;
+ }
+
+ private int GetTabIndex(int start, int direction)
+ {
+ int i = start;
+ int end = this.Items.Count - 1;
+ int increment = 1;
+
+ if (direction < 0)
+ {
+ end = 0;
+ increment = -1;
+ if (start <= 0) return -1;
+ }
+ else if (start >= end) return -1;
+
+ while (end != i)
+ {
+ i += increment;
+ DockContainerItem tab = this.Items[i] as DockContainerItem;
+ if (tab != null && tab.Visible)
+ return i;
+ }
+
+ return -1;
+ }
+
+ ///
+ /// Gets or sets whether tab that shows all dock containers on the bar is visible all the time. By default
+ /// tab is hidden when there is only one item displayed.
+ ///
+ [Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Indicates whether tab that shows all dock containers on the bar is visible all the time."),System.ComponentModel.DefaultValue(false)]
+ public virtual bool AlwaysDisplayDockTab
+ {
+ get { return m_AlwaysDisplayDockTab; }
+ set
+ {
+ if (m_AlwaysDisplayDockTab != value)
+ {
+ m_AlwaysDisplayDockTab = value;
+ RefreshDockTab(false);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether bar is locked to prevent docking below it. Applies to undockable bars only.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Indicates whether bar is locked to prevent docking below it. Applies to undockable bars only."),DefaultValue(false)]
+ public bool LockDockPosition
+ {
+ get { return m_LockDockPosition; }
+ set
+ {
+ if (m_LockDockPosition == value)
+ return;
+ m_LockDockPosition = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets the orientation of the Bar.
+ ///
+ [System.ComponentModel.Browsable(true), DefaultValue(eOrientation.Horizontal),DevCoBrowsable(false)]
+ public eOrientation DockOrientation
+ {
+ get
+ {
+ return m_ItemContainer.Orientation;
+ }
+ set
+ {
+ if (m_ItemContainer.Orientation != value)
+ {
+ m_ItemContainer.Orientation = value;
+ }
+ if (this.DesignMode && !(this.Parent is DockSite))
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Returns whether Bar is docked or not.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public bool Docked
+ {
+ get
+ {
+ return (m_BarState == eBarState.Docked);
+ }
+ }
+
+ ///
+ /// Returns the Bars dock site.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public System.Windows.Forms.Control DockedSite
+ {
+ get
+ {
+ return this.Parent;
+ }
+ }
+
+ public bool ShouldSerializeDockSide()
+ {
+ if (this.Parent is DockSite && ((DockSite)this.Parent).DocumentDockContainer != null)
+ return false;
+ return DockSide != eDockSide.None;
+ }
+
+ private eDockSide _LastDockSidePrivate = eDockSide.None;
+ internal eDockSide LastDockSide
+ {
+ get
+ {
+ return _LastDockSidePrivate;
+ }
+ set
+ {
+ _LastDockSidePrivate = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets the dock side for the Bar.
+ ///
+ [System.ComponentModel.Browsable(false), DevCoBrowsable(true),System.ComponentModel.Category("Docking"),System.ComponentModel.Description("Indicates the dock side for the Bar.")]
+ public eDockSide DockSide
+ {
+ get
+ {
+ if (m_BarState != eBarState.Docked)
+ return eDockSide.None;
+ if (this.Parent == null)
+ return eDockSide.Top;
+ else if (this.Parent.Dock == DockStyle.Left)
+ return eDockSide.Left;
+ else if (this.Parent.Dock == DockStyle.Right)
+ return eDockSide.Right;
+ else if (this.Parent.Dock == DockStyle.Top)
+ return eDockSide.Top;
+ else if (this.Parent.Dock == DockStyle.Bottom)
+ return eDockSide.Bottom;
+ else if (this.Parent.Dock == DockStyle.Fill)
+ return eDockSide.Document;
+ return eDockSide.None;
+ }
+ set
+ {
+ if (this.Owner == null || m_LayoutSuspended)
+ {
+ m_DockSideDelayed = (int)value;
+ return;
+ }
+
+ if (this.AutoHide)
+ {
+ ChangeAutoHidePanel(value);
+ return;
+ }
+
+ DockSiteInfo pDockInfo = new DockSiteInfo();
+ IOwnerBarSupport ownersupport = m_Owner as IOwnerBarSupport;
+ if (ownersupport == null)
+ {
+ m_DockSideDelayed = (int)value;
+ return;
+ //throw(new System.InvalidOperationException("Could not find owner of the Bar or owner does not implement IOwnerBarSupport."));
+ }
+
+ // Use Dock Line and Dock Offset to determine bar insert position
+ pDockInfo.InsertPosition = -10;
+ pDockInfo.DockLine = m_DockLine;
+ pDockInfo.DockOffset = m_DockOffset;
+
+ // Reset the split width and height
+ if (!m_BarDefinitionLoading)
+ {
+ this.SplitDockHeight = 0;
+ this.SplitDockWidth = 0;
+ }
+
+ if (value == eDockSide.Left)
+ {
+ DockSite ds = null;
+ if (this.LayoutType == eLayoutType.Toolbar)
+ {
+ ds = ownersupport.ToolbarLeftDockSite;
+ if (ds == null)
+ throw (new System.InvalidOperationException("DotNetBarManager.ToolbarLeftDockSite dock-site is not set."));
+ }
+ else
+ {
+ ds = ownersupport.LeftDockSite;
+ if (ds == null)
+ throw (new System.InvalidOperationException("DotNetBarManager.LeftDockSite dock-site is not set."));
+ }
+
+ pDockInfo.objDockSite = ds;
+ }
+ else if (value == eDockSide.Right)
+ {
+ DockSite ds = null;
+ if (this.LayoutType == eLayoutType.Toolbar)
+ {
+ ds = ownersupport.ToolbarRightDockSite;
+ if (ds == null)
+ throw (new System.InvalidOperationException("DotNetBarManager.ToolbarRightDockSite dock-site is not set."));
+ }
+ else
+ {
+ ds = ownersupport.RightDockSite;
+ if (ds == null)
+ throw (new System.InvalidOperationException("DotNetBarManager.RightDockSite dock-site is not set."));
+ }
+
+ pDockInfo.objDockSite = ds;
+ }
+ else if (value == eDockSide.Top)
+ {
+ DockSite ds = null;
+ if (this.LayoutType == eLayoutType.Toolbar)
+ {
+ ds = ownersupport.ToolbarTopDockSite;
+ if (ds == null)
+ throw (new System.InvalidOperationException("DotNetBarManager.ToolbarTopDockSite dock-site is not set."));
+ }
+ else
+ {
+ ds = ownersupport.TopDockSite;
+ if (ds == null)
+ throw (new System.InvalidOperationException("DotNetBarManager.TopDockSite dock-site is not set."));
+ }
+
+ pDockInfo.objDockSite = ds;
+ }
+ else if (value == eDockSide.Bottom)
+ {
+ DockSite ds = null;
+ if (this.LayoutType == eLayoutType.Toolbar)
+ {
+ ds = ownersupport.ToolbarBottomDockSite;
+ if (ds == null)
+ throw (new System.InvalidOperationException("DotNetBarManager.ToolbarBottomDockSite dock-site is not set."));
+ }
+ else
+ {
+ ds = ownersupport.BottomDockSite;
+ if (ds == null)
+ throw (new System.InvalidOperationException("DotNetBarManager.BottomDockSite dock-site is not set."));
+ }
+
+ if (ds == null)
+ throw (new System.InvalidOperationException("Bottom dock-site is not set."));
+ pDockInfo.objDockSite = ds;
+ }
+ else if (value == eDockSide.Document)
+ {
+ pDockInfo.objDockSite = ownersupport.FillDockSite;
+ }
+ else
+ pDockInfo.objDockSite = null;
+
+ this.DockingHandler(pDockInfo, m_FloatingRect.Location);
+ }
+ }
+
+ private void ChangeAutoHidePanel(eDockSide side)
+ {
+ if (!this.AutoHide)
+ return;
+ DockStyle dockStyle = DockStyle.Left;
+ if (side == eDockSide.Bottom)
+ dockStyle = DockStyle.Bottom;
+ else if (side == eDockSide.Right)
+ dockStyle = DockStyle.Right;
+ else if (side == eDockSide.Top)
+ dockStyle = DockStyle.Top;
+
+ if (m_LastDockSiteInfo.DockSide == dockStyle || side == eDockSide.None)
+ return;
+
+ AutoHidePanel panel = GetAutoHidePanel(m_LastDockSiteInfo.DockSide);
+ if (panel == null)
+ return;
+
+ IOwnerBarSupport barSupp = m_Owner as IOwnerBarSupport;
+ if (barSupp == null)
+ return;
+
+ AnimateHide();
+
+ panel.RemoveBar(this);
+ m_LastDockSiteInfo.DockSide = dockStyle;
+ switch (dockStyle)
+ {
+ case DockStyle.Left:
+ m_LastDockSiteInfo.objDockSite = barSupp.LeftDockSite;
+ break;
+ case DockStyle.Right:
+ m_LastDockSiteInfo.objDockSite = barSupp.RightDockSite;
+ break;
+ case DockStyle.Top:
+ m_LastDockSiteInfo.objDockSite = barSupp.TopDockSite;
+ break;
+ case DockStyle.Bottom:
+ m_LastDockSiteInfo.objDockSite = barSupp.BottomDockSite;
+ break;
+ }
+
+ panel = GetAutoHidePanel(dockStyle);
+ panel.AddBar(this);
+ }
+
+ ///
+ /// Gets or sets the inital floating location. This location will be used when DockSide is set to None.
+ ///
+ [Browsable(false), DevCoBrowsable(false),Description("Indicates the inital floating location."),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Point InitalFloatLocation
+ {
+ get { return m_FloatingRect.Location; }
+ set { m_FloatingRect.Location = value; }
+ }
+
+ ///
+ /// Indicates whether Tooltips are shown on Bars and menus.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),DefaultValue(true),System.ComponentModel.Category("Run-time Behavior"),System.ComponentModel.Description("Indicates whether Tooltips are shown on Bar and it's sub-items.")]
+ public bool ShowToolTips
+ {
+ get
+ {
+ return m_ShowToolTips;
+ }
+ set
+ {
+ m_ShowToolTips = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether control is selected in designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool DesignerSelection
+ {
+ get { return m_DesignerSelection; }
+ set
+ {
+ if (m_DesignerSelection != value)
+ {
+ m_DesignerSelection = value;
+ this.Refresh();
+ }
+ }
+ }
+
+ #region IOwner
+ // IOwner Implementation
+ BaseItem m_ExpandedItem = null;
+ BaseItem m_FocusItem = null;
+ private Hashtable m_ShortcutTable = new Hashtable();
+ // Only one Popup Item can be expanded at a time. This is used
+ // to track the currently expanded popup item and to close the popup item
+ // if another item is expanding.
+ void IOwner.SetExpandedItem(BaseItem objItem)
+ {
+ if (objItem != null && objItem.Parent is PopupItem)
+ return;
+ if (m_ExpandedItem != null)
+ {
+ if (m_ExpandedItem.Expanded)
+ m_ExpandedItem.Expanded = false;
+ m_ExpandedItem = null;
+ }
+ m_ExpandedItem = objItem;
+ }
+
+ BaseItem IOwner.GetExpandedItem()
+ {
+ return m_ExpandedItem;
+ }
+
+ // Currently we are using this to communicate "focus" when control is in
+ // design mode. This can be used later if we decide to add focus
+ // handling to our BaseItem class.
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler FocusItemChange;
+ void IOwner.SetFocusItem(BaseItem objFocusItem)
+ {
+ if (DockSide == eDockSide.Document && m_Owner != null)
+ {
+ ((IOwner)m_Owner).SetFocusItem(objFocusItem);
+ return;
+ }
+
+ if (m_FocusItem != null && m_FocusItem != objFocusItem)
+ {
+ m_FocusItem.OnLostFocus();
+ }
+ m_FocusItem = objFocusItem;
+ if (m_FocusItem != null)
+ m_FocusItem.OnGotFocus();
+
+ if (FocusItemChange != null)
+ FocusItemChange(this, new EventArgs());
+ }
+
+ BaseItem IOwner.GetFocusItem()
+ {
+ if (DockSide == eDockSide.Document && m_Owner != null && m_Owner is IOwner)
+ {
+ return ((IOwner)m_Owner).GetFocusItem();
+ }
+ return m_FocusItem;
+ }
+ bool IOwner.DesignMode
+ {
+ get { return this.DesignMode; }
+ }
+ void IOwner.DesignTimeContextMenu(BaseItem objItem)
+ {
+ }
+
+ void IOwner.RemoveShortcutsFromItem(BaseItem objItem)
+ {
+ ShortcutTableEntry objEntry = null;
+ if (objItem.ShortcutString != "")
+ {
+ foreach (eShortcut key in objItem.Shortcuts)
+ {
+ if (m_ShortcutTable.ContainsKey(key))
+ {
+ objEntry = (ShortcutTableEntry)m_ShortcutTable[key];
+ try
+ {
+ objEntry.Items.Remove(objItem.Id);
+ if (objEntry.Items.Count == 0)
+ m_ShortcutTable.Remove(objEntry.Shortcut);
+ }
+ catch (System.ArgumentException) { }
+ }
+ }
+ }
+ IOwner owner = this as IOwner;
+ foreach (BaseItem objTmp in objItem.SubItems)
+ owner.RemoveShortcutsFromItem(objTmp);
+ }
+
+ void IOwner.AddShortcutsFromItem(BaseItem objItem)
+ {
+ ShortcutTableEntry objEntry = null;
+ if (objItem.ShortcutString != "")
+ {
+ foreach (eShortcut key in objItem.Shortcuts)
+ {
+ if (m_ShortcutTable.ContainsKey(key))
+ objEntry = (ShortcutTableEntry)m_ShortcutTable[objItem.Shortcuts[0]];
+ else
+ {
+ objEntry = new ShortcutTableEntry(key);
+ m_ShortcutTable.Add(objEntry.Shortcut, objEntry);
+ }
+ try
+ {
+ objEntry.Items.Add(objItem.Id, objItem);
+ }
+ catch (System.ArgumentException) { }
+ }
+ }
+ IOwner owner = this as IOwner;
+ foreach (BaseItem objTmp in objItem.SubItems)
+ owner.AddShortcutsFromItem(objTmp);
+ }
+
+ ///
+ /// Gets or sets whether accelerator letters for menu or toolbar commands are underlined regardless of
+ /// current Windows settings. Accelerator keys allow easy access to menu commands by using
+ /// Alt + choosen key (letter). Default value is false which indicates that system setting is used
+ /// to determine whether accelerator letters are underlined. Setting this property to true
+ /// will always display accelerator letter underlined.
+ ///
+ [Browsable(true), DevCoBrowsable(false),DefaultValue(false),Category("Run-time Behavior"),Description("Indicates whether accelerator letters for menu or toolbar commands are underlined regardless of current Windows settings.")]
+ public bool AlwaysDisplayKeyAccelerators
+ {
+ get { return m_AlwaysDisplayKeyAccelerators; }
+ set
+ {
+ if (m_AlwaysDisplayKeyAccelerators != value)
+ {
+ m_AlwaysDisplayKeyAccelerators = value;
+ this.Refresh();
+ }
+ }
+ }
+
+ Form IOwner.ParentForm
+ {
+ get { return this.FindForm(); }
+ set { }
+ }
+
+ Form IOwner.ActiveMdiChild
+ {
+ get
+ {
+ Form form = this.FindForm();
+ if (form == null)
+ return null;
+ if (form.IsMdiContainer)
+ return form.ActiveMdiChild;
+ return null;
+ }
+ }
+ System.Windows.Forms.MdiClient IOwner.GetMdiClient(System.Windows.Forms.Form MdiForm)
+ {
+ return BarFunctions.GetMdiClient(MdiForm);
+ }
+
+ void IOwner.Customize() { }
+
+ private System.Windows.Forms.ImageList m_ImageList;
+ private System.Windows.Forms.ImageList m_ImageListMedium = null;
+ private System.Windows.Forms.ImageList m_ImageListLarge = null;
+ ///
+ /// ImageList for images used on Items. Images specified here will always be used on menu-items and are by default used on all Bars.
+ ///
+ [Browsable(true), DevCoBrowsable(false),DefaultValue(null),Category("Data"),Description("ImageList for images used on Items. Images specified here will always be used on menu-items and are by default used on all Bars.")]
+ public System.Windows.Forms.ImageList Images
+ {
+ get
+ {
+ return m_ImageList;
+ }
+ set
+ {
+ if (m_ImageList != null)
+ m_ImageList.Disposed -= new EventHandler(this.ImageListDisposed);
+ m_ImageList = value;
+ if (m_ImageList != null)
+ m_ImageList.Disposed += new EventHandler(this.ImageListDisposed);
+ }
+ }
+ ///
+ /// ImageList for medium-sized images used on Items.
+ ///
+ [Browsable(true), DefaultValue(null),Category("Data"),Description("ImageList for medium-sized images used on Items.")]
+ public System.Windows.Forms.ImageList ImagesMedium
+ {
+ get
+ {
+ return m_ImageListMedium;
+ }
+ set
+ {
+ if (m_ImageListMedium != null)
+ m_ImageListMedium.Disposed -= new EventHandler(this.ImageListDisposed);
+ m_ImageListMedium = value;
+ if (m_ImageListMedium != null)
+ m_ImageListMedium.Disposed += new EventHandler(this.ImageListDisposed);
+ }
+ }
+
+ ///
+ /// ImageList for large-sized images used on Items.
+ ///
+ [Browsable(true), DefaultValue(null),Category("Data"),Description("ImageList for large-sized images used on Items.")]
+ public System.Windows.Forms.ImageList ImagesLarge
+ {
+ get
+ {
+ return m_ImageListLarge;
+ }
+ set
+ {
+ if (m_ImageListLarge != null)
+ m_ImageListLarge.Disposed -= new EventHandler(this.ImageListDisposed);
+ m_ImageListLarge = value;
+ if (m_ImageListLarge != null)
+ m_ImageListLarge.Disposed += new EventHandler(this.ImageListDisposed);
+ }
+ }
+ private void ImageListDisposed(object sender, EventArgs e)
+ {
+ if (sender == m_ImageList)
+ {
+ this.Images = null;
+ }
+ else if (sender == m_ImageListLarge)
+ {
+ this.ImagesLarge = null;
+ }
+ else if (sender == m_ImageListMedium)
+ {
+ this.ImagesMedium = null;
+ }
+ }
+ #endregion
+
+ #region ISupportInitialize
+ ///
+ /// ISupportInitialize.BeginInit implementation.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public void BeginInit()
+ {
+ m_LayoutSuspended = true;
+ }
+
+ ///
+ /// ISupportInitialize.EndInit implementation.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ public void EndInit()
+ {
+ m_LayoutSuspended = false;
+ if (this.DockSide == eDockSide.Document && this.Parent is DockSite)
+ {
+ ((DockSite)this.Parent).RecalcLayout();
+ }
+ else
+ this.RecalcSize();
+ if (this.AutoHide != m_AutoHideStateDelayed)
+ this.AutoHide = m_AutoHideStateDelayed;
+ }
+ #endregion
+
+ #region IBarDesignerServices
+ IBarItemDesigner IBarDesignerServices.Designer
+ {
+ get { return m_BarDesigner; }
+ set { m_BarDesigner = value; }
+ }
+ #endregion
+
+ #region IOwner
+ void IOwner.InvokeResetDefinition(BaseItem item, EventArgs e) { }
+ bool IOwner.ShowResetButton { get { return false; } set { } }
+ void IOwner.InvokeUserCustomize(object sender, EventArgs e) { }
+ void IOwner.InvokeEndUserCustomize(object sender, EndUserCustomizeEventArgs e) { }
+ bool IOwner.ShowShortcutKeysInToolTips { get { return true; } set { } }
+ void IOwner.StartItemDrag(BaseItem item)
+ {
+ if (this.DesignMode && m_BarDesigner != null)
+ m_BarDesigner.StartExternalDrag(item);
+ }
+ BaseItem IOwner.DragItem { get { return null; } }
+ bool IOwner.DragInProgress { get { return false; } }
+ void IOwner.OnApplicationActivate() { }
+ void IOwner.OnApplicationDeactivate()
+ {
+ ClosePopups();
+ }
+ void IOwner.OnParentPositionChanging() { }
+
+
+ private void MenuEventSupportHook()
+ {
+ if (m_MenuEventSupport)
+ return;
+ m_MenuEventSupport = true;
+
+ Form parentForm = this.FindForm();
+ if (parentForm == null)
+ {
+ m_MenuEventSupport = false;
+ return;
+ }
+ if (parentForm.IsMdiChild && parentForm.MdiParent != null)
+ parentForm = parentForm.MdiParent;
+
+ parentForm.Resize += new System.EventHandler(this.ParentResize);
+ parentForm.Deactivate += new System.EventHandler(this.ParentDeactivate);
+
+ DotNetBarManager.RegisterParentMsgHandler(this, parentForm);
+ }
+ private void MenuEventSupportUnhook()
+ {
+ if (!m_MenuEventSupport)
+ return;
+ m_MenuEventSupport = false;
+
+ Form parentForm = this.FindForm();
+ if (parentForm == null)
+ return;
+ if (parentForm.IsMdiChild && parentForm.MdiParent != null)
+ parentForm = parentForm.MdiParent;
+ DotNetBarManager.UnRegisterParentMsgHandler(this, parentForm);
+ parentForm.Resize -= new System.EventHandler(this.ParentResize);
+ parentForm.Deactivate -= new System.EventHandler(this.ParentDeactivate);
+ }
+ private void ParentResize(object sender, System.EventArgs e)
+ {
+ Form parentForm = this.FindForm();
+ if (parentForm.IsMdiChild && parentForm.MdiParent != null)
+ parentForm = parentForm.MdiParent;
+
+ if (parentForm != null && parentForm.WindowState == FormWindowState.Minimized)
+ ((IOwner)this).OnApplicationDeactivate();
+ }
+ private void ParentDeactivate(object sender, System.EventArgs e)
+ {
+ Form parentForm = this.FindForm();
+ if (parentForm != null && parentForm.IsMdiChild && parentForm.MdiParent != null)
+ parentForm = parentForm.MdiParent;
+
+ if (parentForm != null && parentForm.WindowState == FormWindowState.Minimized)
+ ((IOwner)this).OnApplicationDeactivate();
+ }
+ #endregion
+
+ #region IOwnerMenuSupport
+ private bool _UseHook = false;
+ ///
+ /// Gets or sets whether hooks are used for internal DotNetBar system functionality. Using hooks is recommended only if DotNetBar is used in hybrid environments like Visual Studio designers or IE.
+ ///
+ [System.ComponentModel.Browsable(false), DefaultValue(false), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Gets or sets whether hooks are used for internal DotNetBar system functionality. Using hooks is recommended only if DotNetBar is used in hybrid environments like Visual Studio designers or IE.")]
+ public bool UseHook
+ {
+ get
+ {
+ return _UseHook;
+ }
+ set
+ {
+ if (_UseHook == value)
+ return;
+ _UseHook = value;
+ }
+ }
+
+ // IOwnerMenuSupport
+ private ArrayList m_RegisteredPopups = new ArrayList();
+ private bool m_FilterInstalled = false;
+ private Hook m_Hook = null;
+ bool IOwnerMenuSupport.PersonalizedAllVisible { get { return false; } set { } }
+ bool IOwnerMenuSupport.ShowFullMenusOnHover { get { return true; } set { } }
+ bool IOwnerMenuSupport.AlwaysShowFullMenus { get { return false; } set { } }
+
+ void IOwnerMenuSupport.RegisterPopup(PopupItem objPopup)
+ {
+ if (m_RegisteredPopups.Contains(objPopup))
+ return;
+
+ if (!this.DesignMode && !_UseHook)
+ {
+ if (!m_FilterInstalled)
+ {
+ //System.Windows.Forms.Application.AddMessageFilter(this);
+ MessageHandler.RegisterMessageClient(this);
+ m_FilterInstalled = true;
+ }
+ if (!m_MenuEventSupport)
+ MenuEventSupportHook();
+ }
+ else
+ {
+ if (m_Hook == null)
+ {
+ m_Hook = new Hook(this);
+ }
+ }
+ if (m_RegisteredPopups.Count == 0)
+ PopupManager.RegisterPopup((IOwnerMenuSupport)this);
+ m_RegisteredPopups.Add(objPopup);
+ if (objPopup.GetOwner() != this)
+ objPopup.SetOwner(this);
+ }
+ void IOwnerMenuSupport.UnregisterPopup(PopupItem objPopup)
+ {
+ if (m_RegisteredPopups.Contains(objPopup))
+ m_RegisteredPopups.Remove(objPopup);
+ if (m_RegisteredPopups.Count == 0)
+ {
+ MenuEventSupportUnhook();
+ if (m_Hook != null)
+ {
+ m_Hook.Dispose();
+ m_Hook = null;
+ }
+ PopupManager.UnregisterPopup((IOwnerMenuSupport)this);
+ }
+ }
+ bool IOwnerMenuSupport.RelayMouseHover()
+ {
+ foreach (PopupItem popup in m_RegisteredPopups)
+ {
+ Control ctrl = popup.PopupControl;
+ if (ctrl != null && ctrl.DisplayRectangle.Contains(Control.MousePosition))
+ {
+ if (ctrl is MenuPanel)
+ ((MenuPanel)ctrl).InternalMouseHover();
+ else if (ctrl is Bar)
+ ((Bar)ctrl).InternalMouseHover();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void IOwnerMenuSupport.ClosePopups()
+ {
+ ClosePopups();
+ }
+
+ internal void ClosePopups()
+ {
+ ArrayList popupList = new ArrayList(m_RegisteredPopups);
+ foreach (PopupItem objPopup in popupList)
+ {
+ if (objPopup.QueryPopupClosing(eEventSource.Mouse))
+ objPopup.ClosePopup();
+ }
+ }
+
+ // Events
+ void IOwnerMenuSupport.InvokePopupClose(PopupItem item, EventArgs e)
+ {
+ if (PopupClose != null)
+ PopupClose(item, e);
+ }
+ void IOwnerMenuSupport.InvokePopupContainerLoad(PopupItem item, EventArgs e)
+ {
+ if (PopupContainerLoad != null)
+ PopupContainerLoad(item, e);
+ }
+ void IOwnerMenuSupport.InvokePopupContainerUnload(PopupItem item, EventArgs e)
+ {
+ if (PopupContainerUnload != null)
+ PopupContainerUnload(item, e);
+ }
+ void IOwnerMenuSupport.InvokePopupOpen(PopupItem item, PopupOpenEventArgs e)
+ {
+ if (PopupOpen != null)
+ PopupOpen(item, e);
+ }
+ void IOwnerMenuSupport.InvokePopupShowing(PopupItem item, EventArgs e)
+ {
+ if (PopupShowing != null)
+ PopupShowing(item, e);
+ }
+ bool IOwnerMenuSupport.ShowPopupShadow { get { return true; } }
+ eMenuDropShadow IOwnerMenuSupport.MenuDropShadow { get { return eMenuDropShadow.SystemDefault; } set { } }
+ ePopupAnimation IOwnerMenuSupport.PopupAnimation { get { return ePopupAnimation.SystemDefault; } set { } }
+ bool IOwnerMenuSupport.AlphaBlendShadow { get { return true; } set { } }
+ #endregion
+
+ #region IMessageHandlerClient
+ internal bool IgnoreSysKeyUp
+ {
+ get { return m_IgnoreSysKeyUp; }
+ set { m_IgnoreSysKeyUp = value; }
+ }
+ internal bool EatSysKeyUp
+ {
+ get { return m_EatSysKeyUp; }
+ set { m_EatSysKeyUp = value; }
+ }
+ // IMessageHandlerClient Implementation
+ private bool m_DispatchShortcuts = false;
+ private bool m_IgnoreSysKeyUp = false, m_EatSysKeyUp = false, m_IgnoreF10Key = false;
+ bool IMessageHandlerClient.IsModal
+ {
+ get
+ {
+ Form form = this.FindForm();
+ if (form != null)
+ return form.Modal;
+ return false;
+ }
+ }
+
+ bool IMessageHandlerClient.OnMouseWheel(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+
+ bool IMessageHandlerClient.OnKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ bool designMode = this.DesignMode;
+
+ int wParamInt = WinApi.ToInt(wParam);
+
+ if (m_RegisteredPopups.Count > 0)
+ {
+ BaseItem popup = ((BaseItem)m_RegisteredPopups[m_RegisteredPopups.Count - 1]);
+ Keys key = (Keys)NativeFunctions.MapVirtualKey((uint)wParam, 2);
+ if (key == Keys.None)
+ key = (Keys)wParamInt;
+ if (popup.Parent == null || IsContextPopup(popup) || (key == Keys.Escape || key == Keys.Enter || key == Keys.Left || key == Keys.Right || key == Keys.Down || key == Keys.Up))
+ {
+ PopupItem objItem = (PopupItem)m_RegisteredPopups[m_RegisteredPopups.Count - 1];
+
+ Control ctrl = objItem.PopupControl as Control;
+ Control ctrl2 = Control.FromChildHandle(hWnd);
+
+ if (ctrl2 != null)
+ {
+ while (ctrl2.Parent != null)
+ ctrl2 = ctrl2.Parent;
+ }
+
+ bool bIsOnHandle = false;
+ if (ctrl2 != null && objItem != null)
+ bIsOnHandle = objItem.IsAnyOnHandle(ctrl2.Handle);
+
+ bool bNoEat = ctrl != null && ctrl2 != null && ctrl.Handle == ctrl2.Handle || bIsOnHandle;
+
+ if (!bIsOnHandle)
+ {
+ objItem.InternalKeyDown(new KeyEventArgsEx(key, WinApi.ToAscii((uint)wParam)));
+ }
+
+ // Don't eat the message if the pop-up window has focus
+ if (bNoEat)
+ return false;
+ return true && !designMode;
+ }
+ }
+
+ Form form = this.FindForm();
+ if (form == null || form != Form.ActiveForm && form.MdiParent == null ||
+ form.MdiParent != null && form.MdiParent.ActiveMdiChild != form)
+ return false;
+
+ if (wParamInt >= 0x70 || System.Windows.Forms.Control.ModifierKeys != Keys.None || (WinApi.ToInt(lParam) & 0x1000000000) != 0 || wParamInt == 0x2E || wParamInt == 0x2D) // 2E=VK_DELETE, 2D=VK_INSERT
+ {
+ int i = (int)System.Windows.Forms.Control.ModifierKeys | wParamInt;
+ return ProcessShortcut((eShortcut)i) && !designMode;
+ }
+ return false;
+ }
+
+ protected virtual bool IsContextPopup(BaseItem popup)
+ {
+ return false;
+ }
+ private bool ProcessShortcut(eShortcut key)
+ {
+ if (!IsHandlingShortcuts)
+ return false;
+ bool eat = BarFunctions.ProcessItemsShortcuts(key, m_ShortcutTable);
+ return !m_DispatchShortcuts && eat;
+ // if(m_ShortcutTable.Contains(key))
+ // {
+ // ShortcutTableEntry objEntry=(ShortcutTableEntry)m_ShortcutTable[key];
+ // // Must convert to independable array, since if this is for example
+ // // close command first Click will destroy the collection we are
+ // // iterating through and exception will be raised.
+ // BaseItem[] arr=new BaseItem[objEntry.Items.Values.Count];
+ // objEntry.Items.Values.CopyTo(arr,0);
+ // Hashtable hnames=new Hashtable(arr.Length);
+ //
+ // bool eat=false;
+ //
+ // foreach(BaseItem objItem in arr)
+ // {
+ // if(objItem.CanRaiseClick && (objItem.Name=="" || !hnames.Contains(objItem.Name)))
+ // {
+ // eat=true;
+ // objItem.RaiseClick();
+ // if(objItem.Name!="")
+ // hnames.Add(objItem.Name,"");
+ // }
+ // }
+ // return !m_DispatchShortcuts && eat; // True will eat the key, false will pass it through
+ // }
+ // return false;
+ }
+ private bool IsHandlingShortcuts
+ {
+ get
+ {
+ Form form = this.FindForm();
+ Form activeForm = Form.ActiveForm;
+ if (form == null)
+ return false;
+
+ if (form.IsMdiChild)
+ {
+ if (form.MdiParent != null)
+ {
+ if (form.MdiParent.ActiveMdiChild == form && (form == activeForm || form.MdiParent == activeForm))
+ return true;
+ return false;
+ }
+ }
+
+ return (form == Form.ActiveForm);
+ }
+ }
+ bool IMessageHandlerClient.OnMouseDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ if (m_RegisteredPopups.Count == 0 || this.DesignMode)
+ return false;
+
+ //foreach(PopupItem objPopup in m_RegisteredPopups)
+ for (int i = m_RegisteredPopups.Count - 1; i >= 0; i--)
+ {
+ PopupItem objPopup = m_RegisteredPopups[i] as PopupItem;
+ System.Windows.Forms.Control objCtrl = objPopup.ContainerControl as System.Windows.Forms.Control;
+ bool bChildHandle = objPopup.IsAnyOnHandle(hWnd);
+
+ if (!bChildHandle)
+ {
+ System.Windows.Forms.Control cTmp = System.Windows.Forms.Control.FromChildHandle(hWnd);
+ if (cTmp != null)
+ {
+ if (cTmp is MenuPanel)
+ {
+ bChildHandle = true;
+ }
+ else
+ {
+ while (cTmp.Parent != null)
+ {
+ cTmp = cTmp.Parent;
+ if (cTmp.GetType().FullName.IndexOf("DropDownHolder") >= 0 || cTmp is MenuPanel || cTmp is PopupContainerControl)
+ {
+ bChildHandle = true;
+ break;
+ }
+ }
+ }
+ if (!bChildHandle)
+ bChildHandle = objPopup.IsAnyOnHandle(cTmp.Handle);
+ }
+ else
+ {
+ string s = NativeFunctions.GetClassName(hWnd);
+ s = s.ToLower();
+ if (s.IndexOf("combolbox") >= 0)
+ bChildHandle = true;
+ }
+ }
+
+ if (!bChildHandle)
+ {
+ Control popupContainer = objPopup.PopupControl;
+ if (popupContainer != null)
+ while (popupContainer.Parent != null) popupContainer = popupContainer.Parent;
+ if (popupContainer != null && popupContainer.Bounds.Contains(Control.MousePosition))
+ bChildHandle = true;
+ }
+
+ if (bChildHandle)
+ break;
+
+ if (objCtrl != null && hWnd != objCtrl.Handle && !bChildHandle)
+ {
+ if (objPopup.Expanded && objPopup.QueryPopupClosing(eEventSource.Mouse))
+ {
+ objPopup.Expanded = !objPopup.Expanded;
+ if (!objPopup.Expanded && objPopup.Parent != null)
+ {
+ objPopup.Parent.AutoExpand = false;
+ }
+ }
+ }
+ else if (objCtrl == null && !bChildHandle)
+ {
+ if (objPopup.QueryPopupClosing(eEventSource.Mouse))
+ objPopup.ClosePopup();
+ }
+
+ if (m_RegisteredPopups.Count == 0)
+ break;
+ }
+ return false;
+ }
+
+ bool IMessageHandlerClient.OnMouseMove(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ if (m_RegisteredPopups.Count > 0)
+ {
+ foreach (BaseItem item in m_RegisteredPopups)
+ {
+ if (item.Parent == null)
+ {
+ Control ctrl = ((PopupItem)item).PopupControl;
+ if (ctrl != null && ctrl.Handle != hWnd && !item.IsAnyOnHandle(hWnd) && !(ctrl.Parent != null && ctrl.Parent.Handle != hWnd))
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private bool _ProcessMnemonics = true;
+ ///
+ /// Indicates whether mnemonic keys, accelerator keys, which are set through item Text property used ampersand character are processed by control.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether mnemonic keys, accelerator keys, which are set through item Text property used ampersand character are processed by control.")]
+ public bool ProcessMnemonics
+ {
+ get { return _ProcessMnemonics; }
+ set
+ {
+ _ProcessMnemonics = value;
+ }
+ }
+
+
+ protected override bool ProcessMnemonic(char charCode)
+ {
+ if (!this.MenuBar && _ProcessMnemonics)
+ {
+ foreach(BaseItem objItem in this.Items)
+ {
+ if (objItem.Visible && objItem.GetEnabled() && objItem.Displayed && objItem.AccessKeyEnabled && objItem.AccessKey == charCode)
+ {
+ objItem.RaiseClick(eEventSource.Keyboard);
+ return true;
+ }
+ }
+ }
+
+ return base.ProcessMnemonic(charCode);
+ }
+
+ protected virtual bool InternalSysKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ int wParamInt = WinApi.ToInt(wParam);
+ if (wParamInt == 18 && System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Alt)
+ this.ClosePopups();
+
+ Form form = this.FindForm();
+ if (form == null || !BarFunctions.IsFormActive(form))
+ return false;
+
+ Bar bar = null;
+ if (this.MenuBar)
+ bar = this;
+ if (bar != null && bar.ItemsContainer != null && !bar.ItemsContainer.DesignMode)
+ {
+ GenericItemContainer cont = bar.ItemsContainer;
+ if (cont == null)
+ return false;
+ if (wParamInt == 18 || (wParamInt == 121 && !m_IgnoreF10Key && (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.None || System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Alt)))
+ {
+ if (cont.ExpandedItem() != null && bar.Focused)
+ {
+ bar.ReleaseFocus();
+ m_IgnoreSysKeyUp = true;
+ return true;
+ }
+ }
+ else
+ {
+ // Check Shortcuts
+ if (System.Windows.Forms.Control.ModifierKeys != Keys.None || wParamInt >= (int)eShortcut.F1 && wParamInt <= (int)eShortcut.F12)
+ {
+ int i = (int)System.Windows.Forms.Control.ModifierKeys | wParamInt;
+ if (ProcessShortcut((eShortcut)i))
+ return true;
+ }
+ m_IgnoreSysKeyUp = true;
+ if (wParamInt >= 27 && wParamInt <= 111) // VK_ESC - VK_DIVIDE range
+ {
+ int key = (int)NativeFunctions.MapVirtualKey((uint)wParam, 2);
+ if (key == 0)
+ key = wParamInt;
+ if (key > 0 && cont.SysKeyDown(key))
+ return true;
+ }
+ }
+ }
+ else if (bar == null && !this.DesignMode)
+ {
+ // Check Shortcuts
+ if (System.Windows.Forms.Control.ModifierKeys != Keys.None || wParamInt >= (int)eShortcut.F1 && wParamInt <= (int)eShortcut.F12)
+ {
+ int i = (int)System.Windows.Forms.Control.ModifierKeys | wParamInt;
+ if (ProcessShortcut((eShortcut)i))
+ return true;
+ }
+ }
+
+ if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Alt && wParamInt > 0x1B)
+ {
+ m_IgnoreSysKeyUp = true;
+ int key = (int)NativeFunctions.MapVirtualKey((uint)wParam, 2);
+ if (key != 0)
+ {
+ if (!this.DesignMode)
+ {
+ if (m_ItemContainer.SysKeyDown(key))
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ bool IMessageHandlerClient.OnSysKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return InternalSysKeyDown(hWnd, wParam, lParam);
+ }
+ bool IMessageHandlerClient.OnSysKeyUp(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ Form form = this.FindForm();
+ if (form == null || this.DesignMode || !BarFunctions.IsFormActive(form))
+ return false;
+
+ int wParamInt = WinApi.ToInt(wParam);
+ if (wParamInt == 18 || wParamInt == 121)
+ {
+ if (m_IgnoreSysKeyUp)
+ {
+ m_IgnoreSysKeyUp = false;
+ return false;
+ }
+ if (m_EatSysKeyUp)
+ {
+ m_EatSysKeyUp = false;
+ return true;
+ }
+ if (wParamInt == 18 || wParamInt == 121 && !m_IgnoreF10Key)
+ {
+ DevComponents.DotNetBar.Bar bar = null;
+ if (this.MenuBar)
+ bar = this;
+ if (bar != null && !bar.ItemsContainer.DesignMode)
+ {
+ if (bar.Focused)
+ bar.ReleaseFocus();
+ else
+ bar.SetSystemFocus();
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ #endregion
+
+ #region BarAccessibleObject
+ public class BarAccessibleObject : System.Windows.Forms.Control.ControlAccessibleObject
+ {
+ Bar m_Owner = null;
+ public BarAccessibleObject(Bar owner)
+ : base(owner)
+ {
+ m_Owner = owner;
+ }
+
+ internal void GenerateEvent(BaseItem sender, System.Windows.Forms.AccessibleEvents e)
+ {
+ int iChild = m_Owner.Items.IndexOf(sender);
+ if (iChild >= 0)
+ {
+ if (m_Owner != null && !m_Owner.IsDisposed)
+ m_Owner.AccessibilityNotifyClients(e, iChild);
+ }
+ }
+
+ public override AccessibleRole Role
+ {
+ get
+ {
+ if (m_Owner != null && !m_Owner.IsDisposed)
+ return m_Owner.AccessibleRole;
+ return System.Windows.Forms.AccessibleRole.None;
+ }
+ }
+
+ public override AccessibleObject Parent
+ {
+ get
+ {
+ if (m_Owner != null && m_Owner.Parent is DockSite)
+ return m_Owner.Parent.AccessibilityObject;
+ return base.Parent;
+ }
+ }
+
+ public override Rectangle Bounds
+ {
+ get
+ {
+ if (m_Owner != null && !m_Owner.IsDisposed && m_Owner.Parent != null)
+ return this.m_Owner.Parent.RectangleToScreen(m_Owner.Bounds);
+ return Rectangle.Empty;
+ }
+ }
+
+ public override int GetChildCount()
+ {
+ if (m_Owner != null && !m_Owner.IsDisposed && m_Owner.Items != null)
+ return m_Owner.Items.Count;
+ return 0;
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetChild(int iIndex)
+ {
+ if (m_Owner != null && !m_Owner.IsDisposed && m_Owner.Items != null)
+ return m_Owner.Items[iIndex].AccessibleObject;
+ return null;
+ }
+
+ public override AccessibleStates State
+ {
+ get
+ {
+ AccessibleStates state;
+ if (m_Owner == null || m_Owner.IsDisposed)
+ return AccessibleStates.None;
+
+ if (m_Owner.GrabHandleStyle != eGrabHandleStyle.None && m_Owner.GrabHandleStyle != eGrabHandleStyle.ResizeHandle)
+ {
+ state = AccessibleStates.Moveable;
+ if (m_Owner.DockSide == eDockSide.None)
+ state = state | AccessibleStates.Floating;
+ }
+ else
+ state = AccessibleStates.None;
+ return state;
+ }
+ }
+
+ public override AccessibleObject Navigate(AccessibleNavigation navdir)
+ {
+ if (navdir == AccessibleNavigation.FirstChild)
+ {
+ if (m_Owner.Items.Count > 0) return m_Owner.Items[0].AccessibleObject;
+ }
+ else if (navdir == AccessibleNavigation.LastChild)
+ {
+ if (m_Owner.Items.Count > 0) return m_Owner.Items[m_Owner.Items.Count - 1].AccessibleObject;
+ }
+ else if (navdir == AccessibleNavigation.Next)
+ {
+ return null;
+ Control parent = m_Owner.Parent;
+ if (parent != null && parent.Controls.IndexOf(m_Owner) < parent.Controls.Count - 1)
+ {
+ return parent.Controls[parent.Controls.IndexOf(m_Owner) + 1].AccessibilityObject;
+ }
+ }
+ else if (navdir == AccessibleNavigation.Previous)
+ {
+ return null;
+ Control parent = m_Owner.Parent;
+ if (parent != null && parent.Controls.IndexOf(m_Owner) > 0)
+ {
+ return parent.Controls[parent.Controls.IndexOf(m_Owner) - 1].AccessibilityObject;
+ }
+ }
+ else if (navdir == AccessibleNavigation.Down)
+ {
+ return null;
+ if (m_Owner.Items.Count > 0) return m_Owner.Items[0].AccessibleObject;
+ }
+ else if (navdir == AccessibleNavigation.Up)
+ {
+ return null;
+ if (m_Owner.Parent != null) return m_Owner.Parent.AccessibilityObject;
+ }
+ return base.Navigate(navdir);
+ }
+ }
+ #endregion
+
+ #region IDockInfo
+ ///
+ /// Specifes whether Bar can be docked on Top dock site or not. Does not apply to stand alone bars.
+ ///
+ bool IDockInfo.CanDockTop
+ {
+ get { return this.CanDockTop; }
+ }
+
+ ///
+ /// Specifes whether Bar can be docked on Bottom dock site or not. Does not apply to stand alone bars.
+ ///
+ bool IDockInfo.CanDockBottom
+ {
+ get { return this.CanDockBottom; }
+ }
+
+ ///
+ /// Specifes whether Bar can be docked on Left dock site or not. Does not apply to stand alone bars.
+ ///
+ bool IDockInfo.CanDockLeft
+ {
+ get { return this.CanDockLeft; }
+ }
+
+ ///
+ /// Specifes whether Bar can be docked on Right dock site or not. Does not apply to stand alone bars.
+ ///
+ bool IDockInfo.CanDockRight
+ {
+ get { return this.CanDockRight; }
+ }
+
+ ///
+ /// Specifes whether Bar can be docked as document. Default value is false. See DotNetBarManager.EnableDocumentDocking for more details.
+ ///
+ bool IDockInfo.CanDockDocument
+ {
+ get { return this.CanDockDocument; }
+ }
+
+ ///
+ /// Returns Minimum docked size of the control.
+ ///
+ System.Drawing.Size IDockInfo.MinimumDockSize(eOrientation dockOrientation)
+ {
+ return this.MinimumDockSize(dockOrientation);
+ }
+ ///
+ /// Returns Preferrred size of the docked control.
+ ///
+ System.Drawing.Size IDockInfo.PreferredDockSize(eOrientation dockOrientation)
+ {
+ return this.PreferredDockSize(dockOrientation);
+ }
+
+ ///
+ /// Indicated whether control can be stretched to fill dock site.
+ ///
+ bool IDockInfo.Stretch
+ {
+ get { return this.Stretch; }
+ set { this.Stretch = value; }
+ }
+ ///
+ /// Holds the left position (dock offset) of the control.
+ ///
+ int IDockInfo.DockOffset
+ {
+ get { return this.DockOffset; }
+ set { this.DockOffset = value; }
+ }
+ ///
+ /// Specifies the dock line for the control.
+ ///
+ int IDockInfo.DockLine
+ {
+ get { return this.DockLine; }
+ set { this.DockLine = value; }
+ }
+ ///
+ /// Specifies current dock orientation.
+ ///
+ eOrientation IDockInfo.DockOrientation
+ {
+ get { return this.DockOrientation; }
+ set { this.DockOrientation = value; }
+ }
+ ///
+ /// Gets whether control is docked.
+ ///
+ bool IDockInfo.Docked
+ {
+ get { return this.Docked; }
+ }
+ ///
+ /// Returns the dock site of the control.
+ ///
+ System.Windows.Forms.Control IDockInfo.DockedSite
+ {
+ get { return this.DockedSite; }
+ }
+ ///
+ /// Gets or sets the control dock side.
+ ///
+ eDockSide IDockInfo.DockSide
+ {
+ get { return this.DockSide; }
+ set { this.DockSide = value; }
+ }
+ ///
+ /// Sets the dock line for the control. Used internaly by dock manager.
+ ///
+ /// New Dock line.
+ void IDockInfo.SetDockLine(int iLine)
+ {
+ this.SetDockLine(iLine);
+ }
+ ///
+ /// Gets or sets whether bar is locked to prevent docking below it.
+ ///
+ bool IDockInfo.LockDockPosition
+ {
+ get { return this.LockDockPosition; }
+ set { this.LockDockPosition = value; }
+ }
+ #endregion
+
+ #region Design Time Drag & Drop
+ private bool m_DragDropInProgress = false;
+ private int m_InsertPosition = -1;
+ private bool m_InsertBefore = false;
+ private IDesignTimeProvider m_DesignTimeProvider = null;
+ private BaseItem m_DragItem = null;
+ private IDesignTimeProvider m_DragDropDesignTimeProvider = null;
+
+ private ISite GetSite()
+ {
+ ISite site = null;
+ IOwner owner = this.Owner as IOwner;
+ Control c = null;
+ if (owner is Control)
+ {
+ c = owner as Control;
+ }
+
+ if (m_ParentItem != null && m_ParentItem.ContainerControl is Control && (c == null || c != null && c.Site == null))
+ {
+ c = m_ParentItem.ContainerControl as Control;
+ }
+
+ if (c != null)
+ {
+ while (site == null && c != null)
+ {
+ if (c.Site != null && c.Site.DesignMode)
+ site = c.Site;
+ else
+ c = c.Parent;
+ }
+ }
+
+ if (site == null && m_ParentItem != null)
+ {
+ BaseItem item = m_ParentItem;
+ while (site == null && item != null)
+ {
+ if (item.Site != null && item.Site.DesignMode)
+ site = item.Site;
+ else
+ item = item.Parent;
+ }
+ }
+
+ return site;
+ }
+
+ private void DesignTimeMouseMove(MouseEventArgs e)
+ {
+ if (m_DragDropInProgress)
+ {
+ try
+ {
+ if (m_DesignTimeProvider != null)
+ {
+ m_DesignTimeProvider.DrawReversibleMarker(m_InsertPosition, m_InsertBefore);
+ m_DesignTimeProvider = null;
+ }
+
+ InsertPosition pos = m_DragDropDesignTimeProvider.GetInsertPosition(Control.MousePosition, m_DragItem);
+ if (pos != null)
+ {
+ if (pos.TargetProvider == null)
+ {
+ // Cursor is over drag item
+ System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.No;
+ }
+ else
+ {
+ pos.TargetProvider.DrawReversibleMarker(pos.Position, pos.Before);
+ m_InsertPosition = pos.Position;
+ m_InsertBefore = pos.Before;
+ m_DesignTimeProvider = pos.TargetProvider;
+ System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;
+ }
+ }
+ else
+ {
+ System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.No;
+ }
+ }
+ catch
+ {
+ m_DesignTimeProvider = null;
+ }
+ }
+ else
+ {
+ if (m_Owner is IOwner)
+ m_DragItem = ((IOwner)m_Owner).GetFocusItem();
+ if (m_DragItem != null)
+ {
+ // Get top level design-time provider
+ BaseItem item = m_ParentItem;
+ while (item.Parent is IDesignTimeProvider)
+ item = item.Parent;
+ m_DragDropDesignTimeProvider = (IDesignTimeProvider)item;
+
+ m_DragDropInProgress = true;
+ this.Capture = true;
+ }
+ }
+ }
+
+ private void DesignTimeMouseUp(MouseEventArgs e)
+ {
+ ISite site = GetSite();
+ if (site == null)
+ return;
+ IComponentChangeService cc = site.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+
+ if (m_DesignTimeProvider != null)
+ {
+ m_DesignTimeProvider.DrawReversibleMarker(m_InsertPosition, m_InsertBefore);
+ BaseItem objParent = m_DragItem.Parent;
+ if (objParent != null)
+ {
+ if (objParent == (BaseItem)m_DesignTimeProvider && m_InsertPosition > 0)
+ {
+ if (objParent.SubItems.IndexOf(m_DragItem) < m_InsertPosition)
+ m_InsertPosition--;
+ }
+ if (cc != null)
+ cc.OnComponentChanging(objParent, TypeDescriptor.GetProperties(objParent)["SubItems"]);
+
+ objParent.SubItems.Remove(m_DragItem);
+
+ if (cc != null)
+ cc.OnComponentChanged(objParent, TypeDescriptor.GetProperties(objParent)["SubItems"], null, null);
+
+ Control ctrl = objParent.ContainerControl as Control;
+ if (ctrl is Bar)
+ ((Bar)ctrl).RecalcLayout();
+ else if (ctrl is MenuPanel)
+ ((MenuPanel)ctrl).RecalcSize();
+ }
+
+ m_DesignTimeProvider.InsertItemAt(m_DragItem, m_InsertPosition, m_InsertBefore);
+
+ m_DesignTimeProvider = null;
+
+ }
+ m_DragDropDesignTimeProvider = null;
+ m_DragItem = null;
+ m_DragDropInProgress = false;
+ this.Capture = false;
+ }
+
+ private void DesignTimeMouseDown(MouseEventArgs e)
+ {
+ IOwner owner = this.Owner as IOwner;
+ BaseItem objNew = m_ItemContainer.ItemAtLocation(e.X, e.Y);
+ // Ignore system items
+ if (objNew != null && objNew.SystemItem)
+ objNew = null;
+
+ if (objNew == null)
+ return;
+
+ if (owner != null)
+ {
+ owner.SetFocusItem(objNew);
+ ISite site = GetSite();
+ if (site != null)
+ {
+ ISelectionService selection = (ISelectionService)site.GetService(typeof(ISelectionService));
+ if (selection != null)
+ {
+ ArrayList arr = new ArrayList(1);
+ arr.Add(objNew);
+#if FRAMEWORK20
+ selection.SetSelectedComponents(arr, SelectionTypes.Primary);
+#else
+ selection.SetSelectedComponents(arr,SelectionTypes.MouseDown);
+#endif
+ }
+ if (e.Button == MouseButtons.Right)
+ {
+ IMenuCommandService service1 = (IMenuCommandService)site.GetService(typeof(IMenuCommandService));
+ if (service1 != null)
+ {
+ service1.ShowContextMenu(new CommandID(new Guid("{74D21312-2AEE-11d1-8BFB-00A0C90F26F7}"), 0x500)/*System.Windows.Forms.Design.MenuCommands.SelectionMenu*/, Control.MousePosition.X, Control.MousePosition.Y);
+ }
+ }
+ }
+ }
+ owner = null;
+ if (objNew != null)
+ objNew.InternalMouseDown(e);
+ }
+ #endregion
+
+ #region IOwnerLocalize Implementation
+ void IOwnerLocalize.InvokeLocalizeString(LocalizeEventArgs e)
+ {
+ if (LocalizeString != null)
+ LocalizeString(this, e);
+ }
+ #endregion
+ }
+
+ #region FloatingContainer
+ [ToolboxItem(false)]
+ internal class FloatingContainer : Form
+ {
+ const int WM_MOUSEACTIVATE = 0x21;
+ const int MA_NOACTIVATE = 3;
+ //const int MA_NOACTIVATEANDEAT = 4;
+ Bar m_Bar;
+ private Size m_OldSize = Size.Empty;
+ public FloatingContainer(Bar objBar)
+ {
+ m_Bar = objBar;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.ControlBox = false;
+ this.ShowInTaskbar = false;
+ IOwner owner = objBar.Owner as IOwner;
+ if (owner != null)
+ this.Owner = owner.ParentForm;
+ this.StartPosition = FormStartPosition.Manual;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.SetStyle(ControlStyles.Selectable, false);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.Font = objBar.Font;
+ }
+ private bool m_CodeClose = false;
+ public new void Close()
+ {
+ m_CodeClose = true;
+ base.Close();
+ }
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ if (this.Visible)
+ {
+ if (!m_CodeClose)
+ {
+ e.Cancel = true;
+ if (m_Bar != null)
+ m_Bar.CloseBar();
+ }
+ }
+ base.OnClosing(e);
+ }
+
+ public void RefreshRegion(System.Drawing.Size sz)
+ {
+ if (m_Bar == null || m_OldSize == sz)
+ return;
+
+ if (!m_Bar.IsThemed)
+ return;
+
+ m_OldSize = sz;
+
+ ThemeWindow theme = m_Bar.ThemeWindow;
+ Graphics g = this.CreateGraphics();
+ try
+ {
+ IntPtr r = theme.GetThemeBackgroundRegion(g, ThemeWindowParts.SmallCaption, ThemeWindowStates.CaptionActive, new Rectangle(0, 0, sz.Width, sz.Height));
+ if (r != IntPtr.Zero)
+ {
+ NativeFunctions.SetWindowRgn(this.Handle, r, true);
+ }
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ }
+ protected override void WndProc(ref Message m)
+ {
+ if (m.Msg == WM_MOUSEACTIVATE && m_Bar.LayoutType != eLayoutType.DockContainer)
+ {
+ m.Result = new System.IntPtr(MA_NOACTIVATE);
+ return;
+ }
+ base.WndProc(ref m);
+ }
+ protected override void OnActivated(EventArgs e)
+ {
+ base.OnActivated(e);
+ if (m_Bar != null && m_Bar.LayoutType == eLayoutType.DockContainer)
+ {
+ m_Bar.SetHasFocus(true);
+ }
+ }
+
+ protected override void OnDeactivate(EventArgs e)
+ {
+ base.OnDeactivate(e);
+ if (m_Bar != null && m_Bar.LayoutType == eLayoutType.DockContainer)
+ {
+ m_Bar.SetHasFocus(false);
+ }
+ }
+ }
+ #endregion
+
+ #region Custom Rendering Support
+ ///
+ /// Defines delegate for the PreRender and PostRender Bar control events.
+ ///
+ public delegate void RenderBarEventHandler(object sender, RenderBarEventArgs e);
+
+ ///
+ /// Represents event arguments for PreRender and PostRender Bar control event.
+ ///
+ public class RenderBarEventArgs : EventArgs
+ {
+ ///
+ /// Gets the reference to the Bar being rendered.
+ ///
+ public readonly Bar Bar;
+
+ ///
+ /// Gets or sets the rectangle of the part being rendered. Certain parts of bar like the title buttons allow you to set this property to the custom size of your button.
+ /// Default value is the system size of the part being rendered.
+ ///
+ public Rectangle Bounds = Rectangle.Empty;
+
+ ///
+ /// Gets the Bar part being rendered.
+ ///
+ public readonly eBarRenderPart Part = eBarRenderPart.Background;
+
+ ///
+ /// When used in PreRender event allows you to cancel the default rendering by setting this property to true.
+ ///
+ public bool Cancel = false;
+
+ ///
+ /// Gets the reference to the Graphics object to render the tab on.
+ ///
+ public readonly Graphics Graphics;
+
+ ///
+ /// Creates new instance of the class and initializes it with default values.
+ ///
+ public RenderBarEventArgs(Bar bar, Graphics g, eBarRenderPart part, Rectangle bounds)
+ {
+ this.Bar = bar;
+ this.Part = part;
+ this.Bounds = bounds;
+ this.Graphics = g;
+ }
+ }
+
+ ///
+ /// Defines the part of the Bar control for custom rendering.
+ ///
+ public enum eBarRenderPart
+ {
+ ///
+ /// Indicates the Bar background and border.
+ ///
+ Background,
+ ///
+ /// Indicates the Bar caption.
+ ///
+ Caption,
+ ///
+ /// Indicates the Bar close button displayed inside of caption.
+ ///
+ CloseButton,
+ ///
+ /// Indicates the Bar customize button displayed inside of caption.
+ ///
+ CustomizeButton,
+ ///
+ /// Indicates the Bar caption text.
+ ///
+ CaptionText,
+ ///
+ /// Indicates the Bar grab handle.
+ ///
+ GrabHandle,
+ ///
+ /// Indicates the Bar resize handle.
+ ///
+ ResizeHandle,
+ ///
+ /// Indicates the Bar auto-hide button displayed inside of caption.
+ ///
+ AutoHideButton,
+ ///
+ /// Indicates the Bar caption task pane.
+ ///
+ CaptionTaskPane,
+ ///
+ /// Indicates the Bar maximize button displayed inside of caption.
+ ///
+ MaximizeButton,
+ ///
+ /// Indicates the complete bar area. This part is used for the PostRender event.
+ ///
+ All
+
+ }
+ #endregion
+
+ #region BarStateChanged Event Support
+ ///
+ /// Defines delegate for BarStateChanged event.
+ ///
+ ///
+ ///
+ public delegate void BarStateChangedEventHandler(object sender, BarStateChangedEventArgs e);
+ ///
+ /// Provides event arguments for ActiveDockContainerChanged event.
+ ///
+ public class BarStateChangedEventArgs : EventArgs
+ {
+ ///
+ /// Gets the Bar that is changed.
+ ///
+ public readonly Bar Bar;
+ ///
+ /// Gets the type of the change that affected the bar.
+ ///
+ public readonly eBarStateChange AffectedState;
+ ///
+ /// Provides any optional context information about the state change.
+ ///
+ public object ContextInformation;
+ ///
+ /// Initializes a new instance of the BarStateChangedEventArgs class.
+ ///
+ ///
+ ///
+ public BarStateChangedEventArgs(Bar bar, eBarStateChange affectedState)
+ {
+ Bar = bar;
+ AffectedState = affectedState;
+ }
+ ///
+ /// Initializes a new instance of the BarStateChangedEventArgs class.
+ ///
+ ///
+ ///
+ ///
+ public BarStateChangedEventArgs(Bar bar, eBarStateChange affectedState, object contextInformation)
+ {
+ Bar = bar;
+ AffectedState = affectedState;
+ ContextInformation = contextInformation;
+ }
+ }
+ ///
+ /// Defines bar state changes for BarStateChanged event.
+ ///
+ public enum eBarStateChange
+ {
+ ///
+ /// Indicates that Bar selected dock tab is about to change.
+ ///
+ SelectedDockTabChanging,
+ ///
+ /// Indicates that Bar selected dock tab has changed.
+ ///
+ SelectedDockTabChanged,
+ ///
+ /// Indicates that bar docking has changed and bar was docked.
+ ///
+ BarDocked,
+ ///
+ /// Indicates that bar has been undocked from dock site.
+ ///
+ BarUndocked,
+ ///
+ /// Indicates that bar dock tab has closed.
+ ///
+ DockTabClosed,
+ ///
+ /// Indicates that bar in auto-hide state has been folded, i.e. returned to collapsed state.
+ ///
+ AutoHideFolded,
+ ///
+ /// Indicates that bar in auto-hide state has been open, shown.
+ ///
+ AutoHideOpen,
+ ///
+ /// Indicates that bar AutoHide property has changed meaning that bar has been either placed in auto-hide mode or taken out of auto-hide mode.
+ ///
+ AutoHideChanged,
+ ///
+ /// Indicates that tab has been moved within a bar tab-strip by end user.
+ ///
+ DockTabMoved
+ }
+ #endregion
+
+ public class KeyEventArgsEx:KeyEventArgs
+ {
+ public char KeyChar = '\0';
+ public KeyEventArgsEx(Keys keyData, char keyChar):base(keyData)
+ {
+ this.KeyChar = keyChar;
+ }
+ }
+
+ ///
+ /// Specifies the behavior of bar when its title is double clicked.
+ ///
+ public enum eDoubleClickBarBehavior
+ {
+ ///
+ /// Double clicking bar title does not do anything.
+ ///
+ None,
+ ///
+ /// Double clicking bar title when bar is docked will float the bar if CanUndock=true
+ ///
+ Float,
+ ///
+ /// Double clicking floating bar title will re-dock it if any of CanDock*** properties is true.
+ ///
+ ReDock,
+ ///
+ /// Double clicking will toggle bar state between float and dock state if all CanDock*** and CanUndock properties allow it.
+ ///
+ FloatAndReDock
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Bar.ico b/PROMS/DotNetBar Source Code/Bar.ico
new file mode 100644
index 00000000..494cb4e6
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Bar.ico differ
diff --git a/PROMS/DotNetBar Source Code/BarBaseControl.cs b/PROMS/DotNetBar Source Code/BarBaseControl.cs
new file mode 100644
index 00000000..e69faed3
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BarBaseControl.cs
@@ -0,0 +1,2337 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents base control for bars.
+ ///
+ [ToolboxItem(false),System.Runtime.InteropServices.ComVisible(false)]
+ public abstract class BarBaseControl: System.Windows.Forms.Control,
+ IOwner, IOwnerMenuSupport, IMessageHandlerClient, IOwnerItemEvents, IThemeCache, IOwnerLocalize, IBarDesignerServices, IRenderingSupport,
+ IAccessibilitySupport
+ {
+ // Events
+ #region Event Definition
+ ///
+ /// Occurs when Checked property of an button has changed.
+ ///
+ public event EventHandler ButtonCheckedChanged;
+ ///
+ /// Represents the method that will handle the ItemRemoved event.
+ ///
+ public delegate void ItemRemovedEventHandler(object sender, ItemRemovedEventArgs e);
+
+ ///
+ /// Occurs when Item is clicked.
+ ///
+ [System.ComponentModel.Description("Occurs when Item is clicked.")]
+ public event EventHandler ItemClick;
+
+ ///
+ /// Occurs when Item is clicked.
+ ///
+ [Description("Occurs when Item is double-clicked.")]
+ public event MouseEventHandler ItemDoubleClick;
+
+ ///
+ /// Occurs when popup of type container is loading.
+ ///
+ [System.ComponentModel.Description("Occurs when popup of type container is loading.")]
+ public event EventHandler PopupContainerLoad;
+
+ ///
+ /// Occurs when popup of type container is unloading.
+ ///
+ [System.ComponentModel.Description("Occurs when popup of type container is unloading.")]
+ public event EventHandler PopupContainerUnload;
+
+ ///
+ /// Occurs when popup item is about to open.
+ ///
+ [System.ComponentModel.Description("Occurs when popup item is about to open.")]
+ public event EventHandler PopupOpen;
+
+ ///
+ /// Occurs when popup item is closing.
+ ///
+ [System.ComponentModel.Description("Occurs when popup item is closing.")]
+ public event EventHandler PopupClose;
+
+ ///
+ /// Occurs just before popup window is shown.
+ ///
+ [System.ComponentModel.Description("Occurs just before popup window is shown.")]
+ public event EventHandler PopupShowing;
+
+ ///
+ /// Occurs when Item Expanded property has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when Item Expanded property has changed.")]
+ public event EventHandler ExpandedChange;
+
+ private MouseEventHandler EventMouseDown;
+ ///
+ /// Occurs when mouse button is pressed.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse button is pressed.")]
+ new public event MouseEventHandler MouseDown
+ {
+ add { EventMouseDown += value; }
+ remove { EventMouseDown -= value; }
+ }
+
+ private MouseEventHandler EventMouseUp;
+ ///
+ /// Occurs when mouse button is released.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse button is released.")]
+ new public event MouseEventHandler MouseUp
+ {
+ add { EventMouseUp += value; }
+ remove { EventMouseUp -= value; }
+ }
+
+ private EventHandler EventMouseEnter;
+ ///
+ /// Occurs when mouse enters the item.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse enters the item.")]
+ new public event EventHandler MouseEnter
+ {
+ add { EventMouseEnter += value; }
+ remove { EventMouseEnter -= value; }
+ }
+
+ private EventHandler EventMouseLeave;
+ ///
+ /// Occurs when mouse leaves the item.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse leaves the item.")]
+ new public event EventHandler MouseLeave
+ {
+ add { EventMouseLeave += value; }
+ remove { EventMouseLeave -= value; }
+ }
+
+ private MouseEventHandler EventMouseMove;
+ ///
+ /// Occurs when mouse moves over the item.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse moves over the item.")]
+ new public event MouseEventHandler MouseMove
+ {
+ add { EventMouseMove += value; }
+ remove { EventMouseMove -= value; }
+ }
+
+ private EventHandler EventMouseHover;
+ ///
+ /// Occurs when mouse remains still inside an item for an amount of time.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse remains still inside an item for an amount of time.")]
+ new public event EventHandler MouseHover
+ {
+ add { EventMouseHover += value; }
+ remove { EventMouseHover -= value; }
+ }
+
+ private EventHandler EventLostFocus;
+ ///
+ /// Occurs when item loses input focus.
+ ///
+ [System.ComponentModel.Description("Occurs when item loses input focus.")]
+ new public event EventHandler LostFocus
+ {
+ add { EventLostFocus += value; }
+ remove { EventLostFocus -= value; }
+ }
+
+ private EventHandler EventGotFocus;
+ ///
+ /// Occurs when item receives input focus.
+ ///
+ [System.ComponentModel.Description("Occurs when item receives input focus.")]
+ new public event EventHandler GotFocus
+ {
+ add { EventGotFocus += value; }
+ remove { EventGotFocus -= value; }
+ }
+
+ ///
+ /// Occurs when user changes the item position, removes the item, adds new item or creates new bar.
+ ///
+ [System.ComponentModel.Description("Occurs when user changes the item position.")]
+ public event EventHandler UserCustomize;
+
+ ///
+ /// Occurs after an Item is removed from SubItemsCollection.
+ ///
+ [System.ComponentModel.Description("Occurs after an Item is removed from SubItemsCollection.")]
+ public event ItemRemovedEventHandler ItemRemoved;
+
+ ///
+ /// Occurs after an Item has been added to the SubItemsCollection.
+ ///
+ [System.ComponentModel.Description("Occurs after an Item has been added to the SubItemsCollection.")]
+ public event EventHandler ItemAdded;
+
+ ///
+ /// Occurs when ControlContainerControl is created and contained control is needed.
+ ///
+ [System.ComponentModel.Description("Occurs when ControlContainerControl is created and contained control is needed.")]
+ public event EventHandler ContainerLoadControl;
+
+ ///
+ /// Occurs when Text property of an Item has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when Text property of an Item has changed.")]
+ public event EventHandler ItemTextChanged;
+
+ ///
+ /// Use this event if you want to serialize the hosted control state directly into the DotNetBar definition file.
+ ///
+ public event ControlContainerItem.ControlContainerSerializationEventHandler ContainerControlSerialize;
+ ///
+ /// Use this event if you want to deserialize the hosted control state directly from the DotNetBar definition file.
+ ///
+ public event ControlContainerItem.ControlContainerSerializationEventHandler ContainerControlDeserialize;
+
+ ///
+ /// Occurs after DotNetBar definition is loaded.
+ ///
+ [System.ComponentModel.Description("Occurs after DotNetBar definition is loaded.")]
+ public event EventHandler DefinitionLoaded;
+
+ ///
+ /// Occurs when DotNetBar is looking for translated text for one of the internal text that are
+ /// displayed on menus, toolbars and customize forms. You need to set Handled=true if you want
+ /// your custom text to be used instead of the built-in system value.
+ ///
+ public event DotNetBarManager.LocalizeStringEventHandler LocalizeString;
+
+ ///
+ /// Occurs before an item in option group is checked and provides opportunity to cancel that.
+ ///
+ public event OptionGroupChangingEventHandler OptionGroupChanging;
+
+ ///
+ /// Occurs before tooltip for an item is shown. Sender could be the BaseItem or derived class for which tooltip is being displayed or it could be a ToolTip object itself it tooltip is not displayed for any item in particular.
+ ///
+ public event EventHandler ToolTipShowing;
+
+ ///
+ /// Occurs after main application form is activated.
+ ///
+ internal event EventHandler ApplicationActivate;
+ ///
+ /// Occurs after main application form is deacticated.
+ ///
+ internal event EventHandler ApplicationDeactivate;
+ ///
+ /// Occurs on application wide mouse down event.
+ ///
+ internal event HandlerMessageEventHandler ApplicationMouseDown;
+ #endregion
+
+ #region Private Variables
+ private BaseItem m_BaseItemContainer=null;
+ private BaseItem m_ExpandedItem=null;
+ private BaseItem m_FocusItem=null;
+ private Hashtable m_ShortcutTable=new Hashtable();
+ private System.Windows.Forms.ImageList m_ImageList;
+ private System.Windows.Forms.ImageList m_ImageListMedium=null;
+ private System.Windows.Forms.ImageList m_ImageListLarge=null;
+ private BaseItem m_DragItem=null;
+ private bool m_DragDropSupport=false;
+ private bool m_DragLeft=false;
+ private bool m_AllowExternalDrop=false;
+ private bool m_UseNativeDragDrop=false;
+ private bool m_DragInProgress=false;
+ private bool m_ExternalDragInProgress=false;
+ private Cursor m_MoveCursor, m_CopyCursor, m_NACursor;
+ private bool m_ShowToolTips=true;
+ private bool m_ShowShortcutKeysInToolTips=false;
+ private bool m_FilterInstalled=false;
+ private bool m_DispatchShortcuts=false;
+ private bool m_MenuEventSupport=false;
+ private IDesignTimeProvider m_DesignTimeProvider=null;
+ private int m_InsertPosition;
+ private bool m_InsertBefore=false;
+ private System.Windows.Forms.Timer m_ClickTimer=null;
+ private BaseItem m_ClickRepeatItem=null;
+ // Theme Caching Support
+ private ThemeWindow m_ThemeWindow=null;
+ private ThemeRebar m_ThemeRebar=null;
+ private ThemeToolbar m_ThemeToolbar=null;
+ private ThemeHeader m_ThemeHeader=null;
+ private ThemeScrollBar m_ThemeScrollBar=null;
+ private ThemeExplorerBar m_ThemeExplorerBar=null;
+ private ThemeProgress m_ThemeProgress=null;
+ private ThemeButton m_ThemeButton = null;
+
+ private ColorScheme m_ColorScheme=null;
+ private bool m_ThemeAware=false;
+ private string m_EmptyContainerDesignTimeHint="Right-click to add more items...";
+ private ItemStyle m_BackgroundStyle=new ItemStyle();
+ private bool m_DesignModeInternal=false;
+ private IBarItemDesigner m_BarDesigner=null;
+ private BaseItem m_DoDefaultActionItem = null;
+ private bool m_AntiAlias = false;
+ #endregion
+
+ #region Constructor
+ public BarBaseControl()
+ {
+ if(!ColorFunctions.ColorsLoaded)
+ {
+ NativeFunctions.RefreshSettings();
+ NativeFunctions.OnDisplayChange();
+ ColorFunctions.LoadColors();
+ }
+
+ this.SetStyle(ControlStyles.UserPaint,true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);
+ this.SetStyle(ControlStyles.Opaque,true);
+ this.SetStyle(ControlStyles.ResizeRedraw,true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag,true);
+
+ try
+ {
+ m_MoveCursor=new Cursor(typeof(DevComponents.DotNetBar.DotNetBarManager),"DRAGMOVE.CUR");
+ m_CopyCursor=new Cursor(typeof(DevComponents.DotNetBar.DotNetBarManager),"DRAGCOPY.CUR");
+ m_NACursor=new Cursor(typeof(DevComponents.DotNetBar.DotNetBarManager),"DRAGNONE.CUR");
+ }
+ catch(Exception)
+ {
+ m_MoveCursor=null;
+ m_CopyCursor=null;
+ m_NACursor=null;
+ }
+
+ m_ColorScheme=new ColorScheme(eDotNetBarStyle.Office2003);
+
+ m_BackgroundStyle.BackColor1.Color=SystemColors.Control;
+ m_BackgroundStyle.VisualPropertyChanged+=new EventHandler(this.VisualPropertyChanged);
+
+ this.IsAccessible=true;
+ }
+
+ protected bool GetDesignMode()
+ {
+ if(!m_DesignModeInternal)
+ return this.DesignMode;
+ return m_DesignModeInternal;
+ }
+
+ internal void SetDesignMode(bool mode)
+ {
+ m_DesignModeInternal=mode;
+ m_BaseItemContainer.SetDesignMode(mode);
+ }
+
+ protected override AccessibleObject CreateAccessibilityInstance()
+ {
+ return new BarBaseControlAccessibleObject(this);
+ }
+
+ ///
+ /// Notifies the accessibility client applications of the specified AccessibleEvents for the specified child control.
+ ///
+ /// The AccessibleEvents object to notify the accessibility client applications of.
+ /// The child Control to notify of the accessible event.
+ internal void InternalAccessibilityNotifyClients(AccessibleEvents accEvent,int childID)
+ {
+ this.AccessibilityNotifyClients(accEvent,childID);
+ }
+ #endregion
+
+ #region IOwner Implementation
+ ///
+ /// Gets or sets the form SideBar is attached to.
+ ///
+ Form IOwner.ParentForm
+ {
+ get
+ {
+ return base.FindForm();
+ }
+ set {}
+ }
+
+ ///
+ /// Returns the collection of items with the specified name.
+ ///
+ /// Item name to look for.
+ ///
+ public virtual ArrayList GetItems(string ItemName)
+ {
+ ArrayList list=new ArrayList(15);
+ BarFunctions.GetSubItemsByName(m_BaseItemContainer,ItemName,list);
+ return list;
+ }
+
+ ///
+ /// Returns the collection of items with the specified name and type.
+ ///
+ /// Item name to look for.
+ /// Item type to look for.
+ ///
+ public virtual ArrayList GetItems(string ItemName, Type itemType)
+ {
+ ArrayList list=new ArrayList(15);
+ BarFunctions.GetSubItemsByNameAndType(m_BaseItemContainer,ItemName,list,itemType);
+ return list;
+ }
+
+ ///
+ /// Returns the collection of items with the specified name and type.
+ ///
+ /// Item name to look for.
+ /// Item type to look for.
+ ///
+ public virtual ArrayList GetItems(string ItemName, Type itemType, bool useGlobalName)
+ {
+ ArrayList list = new ArrayList(15);
+ BarFunctions.GetSubItemsByNameAndType(m_BaseItemContainer, ItemName, list, itemType, useGlobalName);
+ return list;
+ }
+
+ ///
+ /// Returns the first item that matches specified name.
+ ///
+ /// Item name to look for.
+ ///
+ public virtual BaseItem GetItem(string ItemName)
+ {
+ BaseItem item=BarFunctions.GetSubItemByName(m_BaseItemContainer,ItemName);
+ if(item!=null)
+ return item;
+ return null;
+ }
+
+ // Only one Popup Item can be expanded at a time. This is used
+ // to track the currently expanded popup item and to close the popup item
+ // if another item is expanding.
+ void IOwner.SetExpandedItem(BaseItem objItem)
+ {
+ if(objItem!=null && objItem.Parent is PopupItem)
+ return;
+ if(m_ExpandedItem!=null)
+ {
+ if(m_ExpandedItem.Expanded)
+ m_ExpandedItem.Expanded=false;
+ m_ExpandedItem=null;
+ }
+ m_ExpandedItem=objItem;
+ }
+
+ BaseItem IOwner.GetExpandedItem()
+ {
+ return m_ExpandedItem;
+ }
+
+ // Currently we are using this to communicate "focus" when control is in
+ // design mode. This can be used later if we decide to add focus
+ // handling to our BaseItem class.
+ void IOwner.SetFocusItem(BaseItem objFocusItem)
+ {
+ if(m_FocusItem!=null && m_FocusItem!=objFocusItem)
+ {
+ m_FocusItem.OnLostFocus();
+ }
+ OnSetFocusItem(objFocusItem);
+ m_FocusItem=objFocusItem;
+ if(m_FocusItem!=null)
+ m_FocusItem.OnGotFocus();
+ }
+
+ protected virtual void OnSetFocusItem(BaseItem objFocusItem)
+ {
+ }
+
+ BaseItem IOwner.GetFocusItem()
+ {
+ return m_FocusItem;
+ }
+
+ void IOwner.DesignTimeContextMenu(BaseItem objItem)
+ {
+ }
+
+ bool IOwner.DesignMode
+ {
+ get {return this.GetDesignMode();}
+ }
+
+ void IOwner.RemoveShortcutsFromItem(BaseItem objItem)
+ {
+ ShortcutTableEntry objEntry=null;
+ if(objItem.ShortcutString!="")
+ {
+ foreach(eShortcut key in objItem.Shortcuts)
+ {
+ if(m_ShortcutTable.ContainsKey(key))
+ {
+ objEntry=(ShortcutTableEntry)m_ShortcutTable[key];
+ try
+ {
+ objEntry.Items.Remove(objItem.Id);
+ if(objEntry.Items.Count==0)
+ m_ShortcutTable.Remove(objEntry.Shortcut);
+ }
+ catch(System.ArgumentException) {}
+ }
+ }
+ }
+ IOwner owner=this as IOwner;
+ foreach(BaseItem objTmp in objItem.SubItems)
+ owner.RemoveShortcutsFromItem(objTmp);
+ }
+
+ void IOwner.AddShortcutsFromItem(BaseItem objItem)
+ {
+ ShortcutTableEntry objEntry=null;
+ if(objItem.ShortcutString!="")
+ {
+ foreach(eShortcut key in objItem.Shortcuts)
+ {
+ if(m_ShortcutTable.ContainsKey(key))
+ objEntry=(ShortcutTableEntry)m_ShortcutTable[objItem.Shortcuts[0]];
+ else
+ {
+ objEntry=new ShortcutTableEntry(key);
+ m_ShortcutTable.Add(objEntry.Shortcut,objEntry);
+ }
+ try
+ {
+ objEntry.Items.Add(objItem.Id,objItem);
+ }
+ catch(System.ArgumentException) {}
+ }
+ }
+ IOwner owner=this as IOwner;
+ foreach(BaseItem objTmp in objItem.SubItems)
+ owner.AddShortcutsFromItem(objTmp);
+ }
+
+ Form IOwner.ActiveMdiChild
+ {
+ get
+ {
+ Form form=base.FindForm();
+ if(form==null)
+ return null;
+ if(form.IsMdiContainer)
+ {
+ return form.ActiveMdiChild;
+ }
+ return null;
+ }
+ }
+
+ bool IOwner.AlwaysDisplayKeyAccelerators
+ {
+ get {return false;}
+ set {}
+ }
+
+ ///
+ /// Invokes the DotNetBar Customize dialog.
+ ///
+ void IOwner.Customize()
+ {
+ }
+
+ void IOwner.InvokeResetDefinition(BaseItem item,EventArgs e)
+ {
+ }
+
+ ///
+ /// Indicates whether Reset buttons is shown that allows end-user to reset the toolbar state.
+ ///
+ bool IOwner.ShowResetButton
+ {
+ get{return false;}
+ set {}
+ }
+
+ void IOwner.OnApplicationActivate()
+ {
+ if (ApplicationActivate != null)
+ ApplicationActivate(this, new EventArgs());
+ }
+ void IOwner.OnApplicationDeactivate()
+ {
+ ClosePopups();
+ if (ApplicationDeactivate != null)
+ ApplicationDeactivate(this, new EventArgs());
+ }
+ void IOwner.OnParentPositionChanging(){}
+
+ void IOwner.StartItemDrag(BaseItem item)
+ {
+ if(!m_DragDropSupport)
+ return;
+
+ if(m_DragItem==null)
+ {
+ m_DragItem=item;
+ if(!m_UseNativeDragDrop)
+ {
+ this.Capture=true;
+ if(m_MoveCursor!=null)
+ System.Windows.Forms.Cursor.Current=m_MoveCursor;
+ else
+ System.Windows.Forms.Cursor.Current=System.Windows.Forms.Cursors.Hand;
+ m_DragInProgress=true;
+ }
+ else
+ {
+ m_DragInProgress=true;
+ this.DoDragDrop(item,DragDropEffects.All);
+ if(m_DragInProgress)
+ MouseDragDrop(-1,-1,null);
+ }
+
+ }
+ }
+
+ bool IOwner.DragInProgress
+ {
+ get{ return m_DragInProgress;}
+ }
+
+ BaseItem IOwner.DragItem
+ {
+ get {return m_DragItem;}
+ }
+
+ void IOwner.InvokeUserCustomize(object sender,EventArgs e)
+ {
+ if(UserCustomize!=null)
+ UserCustomize(sender,e);
+ }
+
+ void IOwner.InvokeEndUserCustomize(object sender,EndUserCustomizeEventArgs e){}
+
+ System.Windows.Forms.MdiClient IOwner.GetMdiClient(System.Windows.Forms.Form MdiForm)
+ {
+ return BarFunctions.GetMdiClient(MdiForm);
+ }
+
+ ///
+ /// ImageList for images used on Items. Images specified here will always be used on menu-items and are by default used on all Bars.
+ ///
+ [System.ComponentModel.Browsable(true),System.ComponentModel.Category("Data"),DefaultValue(null),System.ComponentModel.Description("ImageList for images used on Items. Images specified here will always be used on menu-items and are by default used on all Bars.")]
+ public System.Windows.Forms.ImageList Images
+ {
+ get
+ {
+ return m_ImageList;
+ }
+ set
+ {
+ if(m_ImageList!=null)
+ m_ImageList.Disposed-=new EventHandler(this.ImageListDisposed);
+ m_ImageList=value;
+ if(m_ImageList!=null)
+ m_ImageList.Disposed+=new EventHandler(this.ImageListDisposed);
+ }
+ }
+
+ ///
+ /// ImageList for medium-sized images used on Items.
+ ///
+ [System.ComponentModel.Browsable(true),System.ComponentModel.Category("Data"),DefaultValue(null),System.ComponentModel.Description("ImageList for medium-sized images used on Items.")]
+ public System.Windows.Forms.ImageList ImagesMedium
+ {
+ get
+ {
+ return m_ImageListMedium;
+ }
+ set
+ {
+ if(m_ImageListMedium!=null)
+ m_ImageListMedium.Disposed-=new EventHandler(this.ImageListDisposed);
+ m_ImageListMedium=value;
+ if(m_ImageListMedium!=null)
+ m_ImageListMedium.Disposed+=new EventHandler(this.ImageListDisposed);
+ }
+ }
+
+ ///
+ /// ImageList for large-sized images used on Items.
+ ///
+ [System.ComponentModel.Browsable(true),System.ComponentModel.Category("Data"),DefaultValue(null),System.ComponentModel.Description("ImageList for large-sized images used on Items.")]
+ public System.Windows.Forms.ImageList ImagesLarge
+ {
+ get
+ {
+ return m_ImageListLarge;
+ }
+ set
+ {
+ if(m_ImageListLarge!=null)
+ m_ImageListLarge.Disposed-=new EventHandler(this.ImageListDisposed);
+ m_ImageListLarge=value;
+ if(m_ImageListLarge!=null)
+ m_ImageListLarge.Disposed+=new EventHandler(this.ImageListDisposed);
+ }
+ }
+
+ private void ImageListDisposed(object sender, EventArgs e)
+ {
+ if(sender==m_ImageList)
+ {
+ m_ImageList=null;
+ }
+ else if(sender==m_ImageListLarge)
+ {
+ m_ImageListLarge=null;
+ }
+ else if(sender==m_ImageListMedium)
+ {
+ m_ImageListMedium=null;
+ }
+ }
+
+ protected override void OnParentChanged(EventArgs e)
+ {
+ base.OnParentChanged(e);
+ if(this.Parent!=null && (this.Images!=null || this.ImagesLarge!=null || this.ImagesMedium!=null))
+ {
+ foreach(BaseItem panel in m_BaseItemContainer.SubItems)
+ {
+ foreach(BaseItem item in panel.SubItems)
+ {
+ if(item is ImageItem)
+ ((ImageItem)item).OnImageChanged();
+ }
+ }
+ }
+
+ if(this.DesignMode)
+ m_BaseItemContainer.SetDesignMode(this.DesignMode);
+ }
+
+ void IOwner.InvokeDefinitionLoaded(object sender,EventArgs e)
+ {
+ if(DefinitionLoaded!=null)
+ DefinitionLoaded(sender,e);
+ }
+
+ ///
+ /// Indicates whether Tooltips are shown on Bars and menus.
+ ///
+ [System.ComponentModel.Browsable(true),DefaultValue(true),System.ComponentModel.Category("Run-time Behavior"),System.ComponentModel.Description("Indicates whether Tooltips are shown on Bars and menus.")]
+ public bool ShowToolTips
+ {
+ get
+ {
+ return m_ShowToolTips;
+ }
+ set
+ {
+ m_ShowToolTips=value;
+ }
+ }
+
+ ///
+ /// Indicates whether item shortcut is displayed in Tooltips.
+ ///
+ [System.ComponentModel.Browsable(true),DefaultValue(false),System.ComponentModel.Category("Run-time Behavior"),System.ComponentModel.Description("Indicates whether item shortcut is displayed in Tooltips.")]
+ public bool ShowShortcutKeysInToolTips
+ {
+ get
+ {
+ return m_ShowShortcutKeysInToolTips;
+ }
+ set
+ {
+ m_ShowShortcutKeysInToolTips=value;
+ }
+ }
+
+
+ #endregion
+
+ #region IOwnerMenuSupport Implementation
+ // IOwnerMenuSupport
+ private Hook m_Hook = null;
+ private ArrayList m_RegisteredPopups=new ArrayList();
+ bool IOwnerMenuSupport.PersonalizedAllVisible {get{return false;}set{}}
+ bool IOwnerMenuSupport.ShowFullMenusOnHover {get{return true;}set{}}
+ bool IOwnerMenuSupport.AlwaysShowFullMenus {get{return false;}set{}}
+
+ void IOwnerMenuSupport.RegisterPopup(PopupItem objPopup)
+ {
+ if(m_RegisteredPopups.Contains(objPopup))
+ return;
+
+ if(!this.GetDesignMode())
+ {
+ if(!m_FilterInstalled)
+ {
+ //System.Windows.Forms.Application.AddMessageFilter(this);
+ MessageHandler.RegisterMessageClient(this);
+ m_FilterInstalled=true;
+ }
+ }
+ else
+ {
+ if (m_Hook == null)
+ {
+ m_Hook = new Hook(this);
+ }
+ }
+
+ if(!m_MenuEventSupport)
+ MenuEventSupportHook();
+
+ if (m_RegisteredPopups.Count == 0)
+ PopupManager.RegisterPopup((IOwnerMenuSupport)this);
+
+ m_RegisteredPopups.Add(objPopup);
+ if(objPopup.GetOwner()!=this)
+ objPopup.SetOwner(this);
+ }
+ void IOwnerMenuSupport.UnregisterPopup(PopupItem objPopup)
+ {
+ if(m_RegisteredPopups.Contains(objPopup))
+ m_RegisteredPopups.Remove(objPopup);
+ if (m_RegisteredPopups.Count == 0)
+ {
+ MenuEventSupportUnhook();
+ if (m_Hook != null)
+ {
+ m_Hook.Dispose();
+ m_Hook = null;
+ }
+ PopupManager.UnregisterPopup((IOwnerMenuSupport)this);
+ }
+ }
+ bool IOwnerMenuSupport.RelayMouseHover()
+ {
+ foreach(PopupItem popup in m_RegisteredPopups)
+ {
+ Control ctrl=popup.PopupControl;
+ if(ctrl!=null && ctrl.DisplayRectangle.Contains(Control.MousePosition))
+ {
+ if(ctrl is MenuPanel)
+ ((MenuPanel)ctrl).InternalMouseHover();
+ else if(ctrl is Bar)
+ ((Bar)ctrl).InternalMouseHover();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void IOwnerMenuSupport.ClosePopups()
+ {
+ ClosePopups();
+ }
+
+ private void ClosePopups()
+ {
+ ArrayList popupList = new ArrayList(m_RegisteredPopups);
+ foreach (PopupItem objPopup in popupList)
+ objPopup.ClosePopup();
+ }
+
+ // Events
+ void IOwnerMenuSupport.InvokePopupClose(PopupItem item,EventArgs e)
+ {
+ if(PopupClose!=null)
+ PopupClose(item,e);
+ }
+ void IOwnerMenuSupport.InvokePopupContainerLoad(PopupItem item,EventArgs e)
+ {
+ if(PopupContainerLoad!=null)
+ PopupContainerLoad(item,e);
+ }
+ void IOwnerMenuSupport.InvokePopupContainerUnload(PopupItem item,EventArgs e)
+ {
+ if(PopupContainerUnload!=null)
+ PopupContainerUnload(item,e);
+ }
+ void IOwnerMenuSupport.InvokePopupOpen(PopupItem item,PopupOpenEventArgs e)
+ {
+ if(PopupOpen!=null)
+ PopupOpen(item,e);
+ }
+ void IOwnerMenuSupport.InvokePopupShowing(PopupItem item,EventArgs e)
+ {
+ if(PopupShowing!=null)
+ PopupShowing(item,e);
+ }
+ bool IOwnerMenuSupport.ShowPopupShadow {get{return false;}}
+ eMenuDropShadow IOwnerMenuSupport.MenuDropShadow{get{return eMenuDropShadow.Hide;}set{}}
+ ePopupAnimation IOwnerMenuSupport.PopupAnimation{get {return ePopupAnimation.SystemDefault;}set{}}
+ bool IOwnerMenuSupport.AlphaBlendShadow{get {return true;}set{}}
+ #endregion
+
+ #region IOwnerItemEvents Implementation
+ void IOwnerItemEvents.InvokeCheckedChanged(ButtonItem item, EventArgs e)
+ {
+ if (ButtonCheckedChanged != null)
+ ButtonCheckedChanged(item, e);
+ }
+ void IOwnerItemEvents.InvokeItemAdded(BaseItem item,EventArgs e)
+ {
+ if(ItemAdded!=null)
+ ItemAdded(item,e);
+ }
+ void IOwnerItemEvents.InvokeItemRemoved(BaseItem item, BaseItem parent, int itemIndex)
+ {
+ if(ItemRemoved!=null)
+ {
+ ItemRemoved(item,new ItemRemovedEventArgs(parent, itemIndex));
+ }
+ }
+ void IOwnerItemEvents.InvokeMouseEnter(BaseItem item,EventArgs e)
+ {
+ if(EventMouseEnter!=null)
+ EventMouseEnter(item,e);
+ }
+ void IOwnerItemEvents.InvokeMouseHover(BaseItem item,EventArgs e)
+ {
+ if(EventMouseHover!=null)
+ EventMouseHover(item,e);
+ }
+ void IOwnerItemEvents.InvokeMouseLeave(BaseItem item,EventArgs e)
+ {
+ if(EventMouseLeave!=null)
+ EventMouseLeave(item,e);
+ }
+ void IOwnerItemEvents.InvokeMouseDown(BaseItem item, System.Windows.Forms.MouseEventArgs e)
+ {
+ if (EventMouseDown!= null)
+ EventMouseDown(item, e);
+ //if(this.MouseDown!=null)
+ // this.MouseDown(item,e);
+ if(item.ClickAutoRepeat && e.Button==MouseButtons.Left)
+ {
+ m_ClickRepeatItem=item;
+ if(m_ClickTimer==null)
+ m_ClickTimer=new Timer();
+ m_ClickTimer.Interval=item.ClickRepeatInterval;
+ m_ClickTimer.Tick+=new EventHandler(this.ClickTimerTick);
+ m_ClickTimer.Start();
+ }
+ }
+ void IOwnerItemEvents.InvokeMouseUp(BaseItem item, System.Windows.Forms.MouseEventArgs e)
+ {
+ if(EventMouseUp!=null)
+ EventMouseUp(item, e);
+
+ if(m_ClickTimer!=null && m_ClickTimer.Enabled)
+ {
+ m_ClickTimer.Stop();
+ m_ClickTimer.Enabled=false;
+ }
+ }
+ private void ClickTimerTick(object sender, EventArgs e)
+ {
+ if(m_ClickRepeatItem!=null)
+ m_ClickRepeatItem.RaiseClick();
+ else
+ m_ClickTimer.Stop();
+ }
+ void IOwnerItemEvents.InvokeMouseMove(BaseItem item, System.Windows.Forms.MouseEventArgs e)
+ {
+ if(EventMouseMove!=null)
+ EventMouseMove(item,e);
+ }
+ void IOwnerItemEvents.InvokeItemDoubleClick(BaseItem objItem, MouseEventArgs e)
+ {
+ OnItemDoubleClick(objItem, e);
+ }
+ ///
+ /// Invokes ItemDoubleClick event.
+ ///
+ /// Reference to item double-clicked
+ /// Event arguments
+ protected virtual void OnItemDoubleClick(BaseItem objItem, MouseEventArgs e)
+ {
+ MouseEventHandler handler = ItemDoubleClick;
+ if (handler != null)
+ handler(objItem, e);
+ }
+ void IOwnerItemEvents.InvokeItemClick(BaseItem objItem)
+ {
+ if(ItemClick!=null)
+ ItemClick(objItem,new EventArgs());
+ }
+ void IOwnerItemEvents.InvokeGotFocus(BaseItem item,EventArgs e)
+ {
+ if(EventGotFocus!=null)
+ EventGotFocus(item,e);
+ }
+ void IOwnerItemEvents.InvokeLostFocus(BaseItem item,EventArgs e)
+ {
+ if(EventLostFocus!=null)
+ EventLostFocus(item,e);
+ }
+ void IOwnerItemEvents.InvokeExpandedChange(BaseItem item,EventArgs e)
+ {
+ if(ExpandedChange!=null)
+ ExpandedChange(item,e);
+ }
+ void IOwnerItemEvents.InvokeItemTextChanged(BaseItem item, EventArgs e)
+ {
+ if(ItemTextChanged!=null)
+ ItemTextChanged(item,e);
+ }
+
+ void IOwnerItemEvents.InvokeContainerControlDeserialize(BaseItem item,ControlContainerSerializationEventArgs e)
+ {
+ if(ContainerControlDeserialize!=null)
+ ContainerControlDeserialize(item,e);
+ }
+ void IOwnerItemEvents.InvokeContainerControlSerialize(BaseItem item,ControlContainerSerializationEventArgs e)
+ {
+ if(ContainerControlSerialize!=null)
+ ContainerControlSerialize(item,e);
+ }
+ void IOwnerItemEvents.InvokeContainerLoadControl(BaseItem item,EventArgs e)
+ {
+ if(ContainerLoadControl!=null)
+ ContainerLoadControl(item,e);
+ }
+
+ void IOwnerItemEvents.InvokeOptionGroupChanging(BaseItem item, OptionGroupChangingEventArgs e)
+ {
+ if(OptionGroupChanging!=null)
+ OptionGroupChanging(item,e);
+ }
+
+ void IOwnerItemEvents.InvokeToolTipShowing(object item, EventArgs e)
+ {
+ if(ToolTipShowing!=null)
+ ToolTipShowing(item,e);
+ }
+ #endregion
+
+ #region IMessageHandlerClient Implementation
+
+ bool IMessageHandlerClient.IsModal
+ {
+ get
+ {
+ Form form=this.FindForm();
+ if(form!=null)
+ return form.Modal;
+ return false;
+ }
+ }
+ bool IMessageHandlerClient.OnMouseWheel(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+ bool IMessageHandlerClient.OnKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ int wParamInt = WinApi.ToInt(wParam);
+ if (m_RegisteredPopups.Count > 0)
+ {
+ if (((BaseItem)m_RegisteredPopups[m_RegisteredPopups.Count - 1]).Parent == null)
+ {
+ PopupItem objItem = (PopupItem)m_RegisteredPopups[m_RegisteredPopups.Count - 1];
+
+ Control ctrl = objItem.PopupControl as Control;
+ Control ctrl2 = Control.FromChildHandle(hWnd);
+
+ if (ctrl2 != null)
+ {
+ while (ctrl2.Parent != null)
+ ctrl2 = ctrl2.Parent;
+ }
+
+ bool bIsOnHandle = false;
+ if (ctrl2 != null && objItem != null)
+ bIsOnHandle = objItem.IsAnyOnHandle(ctrl2.Handle);
+
+ bool bNoEat = ctrl != null && ctrl2 != null && ctrl.Handle == ctrl2.Handle || bIsOnHandle;
+
+ if (!bIsOnHandle)
+ {
+ Keys key = (Keys)NativeFunctions.MapVirtualKey((uint)wParam, 2);
+ if (key == Keys.None)
+ key = (Keys)wParamInt;
+ objItem.InternalKeyDown(new KeyEventArgs(key));
+ }
+
+ // Don't eat the message if the pop-up window has focus
+ if (bNoEat)
+ return false;
+ return true;
+ }
+ }
+
+ if (!this.IsParentFormActive)
+ return false;
+
+ if (wParamInt>= 0x70 || System.Windows.Forms.Control.ModifierKeys != Keys.None || (WinApi.ToInt(lParam) & 0x1000000000) != 0 || wParamInt== 0x2E || wParamInt== 0x2D) // 2E=VK_DELETE, 2D=VK_INSERT
+ {
+ int i = (int)System.Windows.Forms.Control.ModifierKeys | wParamInt;
+ return ProcessShortcut((eShortcut)i);
+ }
+ return false;
+ }
+ private bool ProcessShortcut(eShortcut key)
+ {
+ bool eat=BarFunctions.ProcessItemsShortcuts(key,m_ShortcutTable);
+ return !m_DispatchShortcuts && eat;
+
+// if(m_ShortcutTable.Contains(key))
+// {
+// ShortcutTableEntry objEntry=(ShortcutTableEntry)m_ShortcutTable[key];
+// // Must convert to independable array, since if this is for example
+// // close command first Click will destroy the collection we are
+// // iterating through and exception will be raised.
+// BaseItem[] arr=new BaseItem[objEntry.Items.Values.Count];
+// objEntry.Items.Values.CopyTo(arr,0);
+// Hashtable hnames=new Hashtable(arr.Length);
+//
+// bool eat=false;
+//
+// foreach(BaseItem objItem in arr)
+// {
+// if(objItem.CanRaiseClick && (objItem.Name=="" || !hnames.Contains(objItem.Name)))
+// {
+// eat=true;
+// objItem.RaiseClick();
+// if(objItem.Name!="")
+// hnames.Add(objItem.Name,"");
+// }
+// }
+// return !m_DispatchShortcuts && eat; // True will eat the key, false will pass it through
+// }
+// return false;
+ }
+ protected bool IsParentFormActive
+ {
+ get
+ {
+ // Process only if parent form is active
+ Form form=this.FindForm();
+ if(form==null)
+ return false;
+ if(form.IsMdiChild)
+ {
+ if(form.MdiParent==null)
+ return false;
+ if(form.MdiParent.ActiveMdiChild!=form)
+ return false;
+ }
+ else if(form!=Form.ActiveForm)
+ return false;
+ return true;
+ }
+ }
+ bool IMessageHandlerClient.OnMouseDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ if(ApplicationMouseDown!=null)
+ ApplicationMouseDown(this,new HandlerMessageEventArgs(hWnd,wParam,lParam));
+
+ if(m_RegisteredPopups.Count==0)
+ return false;
+
+ for(int i=m_RegisteredPopups.Count-1;i>=0;i--)
+ {
+ PopupItem objPopup=m_RegisteredPopups[i] as PopupItem;
+ bool bChildHandle=objPopup.IsAnyOnHandle(hWnd);
+
+ if(!bChildHandle)
+ {
+ System.Windows.Forms.Control cTmp = System.Windows.Forms.Control.FromChildHandle(hWnd);
+ if (cTmp != null)
+ {
+ if (cTmp is MenuPanel)
+ {
+ bChildHandle = true;
+ }
+ else
+ {
+ while (cTmp.Parent != null)
+ {
+ cTmp = cTmp.Parent;
+ if (cTmp.GetType().FullName.IndexOf("DropDownHolder") >= 0 || cTmp is MenuPanel || cTmp is PopupContainerControl)
+ {
+ bChildHandle = true;
+ break;
+ }
+ }
+ }
+ if (!bChildHandle)
+ bChildHandle = objPopup.IsAnyOnHandle(cTmp.Handle);
+ }
+ else
+ {
+ string s = NativeFunctions.GetClassName(hWnd);
+ s = s.ToLower();
+ if (s.IndexOf("combolbox") >= 0)
+ bChildHandle = true;
+ }
+ }
+
+ if (!bChildHandle)
+ {
+ Control popupContainer = objPopup.PopupControl;
+ if (popupContainer != null)
+ while (popupContainer.Parent != null) popupContainer = popupContainer.Parent;
+ if (popupContainer != null && popupContainer.Bounds.Contains(Control.MousePosition))
+ bChildHandle = true;
+ }
+
+ if(bChildHandle)
+ break;
+
+ if(objPopup.Displayed)
+ {
+ // Do not close if mouse is inside the popup parent button
+ Point p=this.PointToClient(Control.MousePosition);
+ if(objPopup.DisplayRectangle.Contains(p))
+ break;
+ }
+
+ objPopup.ClosePopup();
+
+ if(m_RegisteredPopups.Count==0)
+ break;
+ }
+ return false;
+ }
+ bool IMessageHandlerClient.OnMouseMove(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ if(m_RegisteredPopups.Count>0)
+ {
+ foreach(BaseItem item in m_RegisteredPopups)
+ {
+ if(item.Parent==null)
+ {
+ Control ctrl=((PopupItem)item).PopupControl;
+ if(ctrl!=null && ctrl.Handle!=hWnd && !item.IsAnyOnHandle(hWnd) && !(ctrl.Parent!=null && ctrl.Parent.Handle!=hWnd))
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ bool IMessageHandlerClient.OnSysKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ if (!this.GetDesignMode())
+ {
+ // Check Shortcuts
+ int wParamInt = WinApi.ToInt(wParam);
+ if (System.Windows.Forms.Control.ModifierKeys != Keys.None || wParamInt>= (int)eShortcut.F1 && wParamInt<= (int)eShortcut.F12)
+ {
+ int i = (int)System.Windows.Forms.Control.ModifierKeys | wParamInt;
+ if (ProcessShortcut((eShortcut)i))
+ return true;
+ }
+ }
+ return false;
+ }
+ bool IMessageHandlerClient.OnSysKeyUp(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+
+ private void MenuEventSupportHook()
+ {
+ if(m_MenuEventSupport)
+ return;
+ m_MenuEventSupport=true;
+
+ Form parentForm=this.FindForm();
+ if(parentForm==null)
+ {
+ m_MenuEventSupport=false;
+ return;
+ }
+
+ parentForm.Resize+=new System.EventHandler(this.ParentResize);
+ parentForm.Deactivate+=new System.EventHandler(this.ParentDeactivate);
+
+ DotNetBarManager.RegisterParentMsgHandler(this,parentForm);
+ }
+
+ private void MenuEventSupportUnhook()
+ {
+ if(!m_MenuEventSupport)
+ return;
+ m_MenuEventSupport=false;
+
+ Form parentForm=this.FindForm();
+ if(parentForm==null)
+ return;
+ DotNetBarManager.UnRegisterParentMsgHandler(this, parentForm);
+ parentForm.Resize-=new System.EventHandler(this.ParentResize);
+ parentForm.Deactivate-=new System.EventHandler(this.ParentDeactivate);
+ }
+ private void ParentResize(object sender, System.EventArgs e)
+ {
+ Form parentForm=this.FindForm();
+ if(parentForm!=null && parentForm.WindowState==FormWindowState.Minimized)
+ ((IOwner)this).OnApplicationDeactivate();
+ }
+ private void ParentDeactivate(object sender, System.EventArgs e)
+ {
+ Form parentForm=this.FindForm();
+ if(parentForm!=null && parentForm.WindowState==FormWindowState.Minimized)
+ ((IOwner)this).OnApplicationDeactivate();
+ }
+ #endregion
+
+ #region IThemeCache Implementation
+ protected override void WndProc(ref Message m)
+ {
+ if(m.Msg==NativeFunctions.WM_THEMECHANGED)
+ {
+ this.RefreshThemes();
+ }
+ else if (m.Msg == NativeFunctions.WM_USER + 107)
+ {
+ if (m_DoDefaultActionItem != null)
+ {
+ m_DoDefaultActionItem.DoAccesibleDefaultAction();
+ m_DoDefaultActionItem = null;
+ }
+
+ }
+ base.WndProc(ref m);
+ }
+ protected void RefreshThemes()
+ {
+ if(m_ThemeWindow!=null)
+ {
+ m_ThemeWindow.Dispose();
+ m_ThemeWindow=new ThemeWindow(this);
+ }
+ if(m_ThemeRebar!=null)
+ {
+ m_ThemeRebar.Dispose();
+ m_ThemeRebar=new ThemeRebar(this);
+ }
+ if(m_ThemeToolbar!=null)
+ {
+ m_ThemeToolbar.Dispose();
+ m_ThemeToolbar=new ThemeToolbar(this);
+ }
+ if(m_ThemeHeader!=null)
+ {
+ m_ThemeHeader.Dispose();
+ m_ThemeHeader=new ThemeHeader(this);
+ }
+ if(m_ThemeScrollBar!=null)
+ {
+ m_ThemeScrollBar.Dispose();
+ m_ThemeScrollBar=new ThemeScrollBar(this);
+ }
+ if(m_ThemeProgress!=null)
+ {
+ m_ThemeProgress.Dispose();
+ m_ThemeProgress=new ThemeProgress(this);
+ }
+ if(m_ThemeExplorerBar!=null)
+ {
+ m_ThemeExplorerBar.Dispose();
+ m_ThemeExplorerBar=new ThemeExplorerBar(this);
+ }
+ if (m_ThemeButton != null)
+ {
+ m_ThemeButton.Dispose();
+ m_ThemeButton = new ThemeButton(this);
+ }
+ }
+ private void DisposeThemes()
+ {
+ if(m_ThemeWindow!=null)
+ {
+ m_ThemeWindow.Dispose();
+ m_ThemeWindow=null;
+ }
+ if(m_ThemeRebar!=null)
+ {
+ m_ThemeRebar.Dispose();
+ m_ThemeRebar=null;
+ }
+ if(m_ThemeToolbar!=null)
+ {
+ m_ThemeToolbar.Dispose();
+ m_ThemeToolbar=null;
+ }
+ if(m_ThemeHeader!=null)
+ {
+ m_ThemeHeader.Dispose();
+ m_ThemeHeader=null;
+ }
+ if(m_ThemeScrollBar!=null)
+ {
+ m_ThemeScrollBar.Dispose();
+ m_ThemeScrollBar=null;
+ }
+ if (m_ThemeProgress != null)
+ {
+ m_ThemeProgress.Dispose();
+ m_ThemeProgress = null;
+ }
+ if (m_ThemeExplorerBar != null)
+ {
+ m_ThemeExplorerBar.Dispose();
+ m_ThemeExplorerBar = null;
+ }
+ if (m_ThemeButton != null)
+ {
+ m_ThemeButton.Dispose();
+ m_ThemeButton = null;
+ }
+ }
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ base.OnHandleCreated(e);
+
+ if(!m_FilterInstalled && !this.DesignMode)
+ {
+ MessageHandler.RegisterMessageClient(this);
+ m_FilterInstalled=true;
+ }
+ }
+ protected override void OnHandleDestroyed(EventArgs e)
+ {
+ DisposeThemes();
+ MenuEventSupportUnhook();
+ base.OnHandleDestroyed(e);
+
+ if(m_FilterInstalled)
+ {
+ MessageHandler.UnregisterMessageClient(this);
+ m_FilterInstalled=false;
+ }
+ }
+ DevComponents.DotNetBar.ThemeWindow IThemeCache.ThemeWindow
+ {
+ get
+ {
+ if(m_ThemeWindow==null)
+ m_ThemeWindow=new ThemeWindow(this);
+ return m_ThemeWindow;
+ }
+ }
+ DevComponents.DotNetBar.ThemeRebar IThemeCache.ThemeRebar
+ {
+ get
+ {
+ if(m_ThemeRebar==null)
+ m_ThemeRebar=new ThemeRebar(this);
+ return m_ThemeRebar;
+ }
+ }
+ DevComponents.DotNetBar.ThemeToolbar IThemeCache.ThemeToolbar
+ {
+ get
+ {
+ if(m_ThemeToolbar==null)
+ m_ThemeToolbar=new ThemeToolbar(this);
+ return m_ThemeToolbar;
+ }
+ }
+ DevComponents.DotNetBar.ThemeHeader IThemeCache.ThemeHeader
+ {
+ get
+ {
+ if(m_ThemeHeader==null)
+ m_ThemeHeader=new ThemeHeader(this);
+ return m_ThemeHeader;
+ }
+ }
+ DevComponents.DotNetBar.ThemeScrollBar IThemeCache.ThemeScrollBar
+ {
+ get
+ {
+ if(m_ThemeScrollBar==null)
+ m_ThemeScrollBar=new ThemeScrollBar(this);
+ return m_ThemeScrollBar;
+ }
+ }
+ DevComponents.DotNetBar.ThemeExplorerBar IThemeCache.ThemeExplorerBar
+ {
+ get
+ {
+ if(m_ThemeExplorerBar==null)
+ m_ThemeExplorerBar=new ThemeExplorerBar(this);
+ return m_ThemeExplorerBar;
+ }
+ }
+ DevComponents.DotNetBar.ThemeProgress IThemeCache.ThemeProgress
+ {
+ get
+ {
+ if(m_ThemeProgress==null)
+ m_ThemeProgress=new ThemeProgress(this);
+ return m_ThemeProgress;
+ }
+ }
+ DevComponents.DotNetBar.ThemeButton IThemeCache.ThemeButton
+ {
+ get
+ {
+ if (m_ThemeButton == null)
+ m_ThemeButton = new ThemeButton(this);
+ return m_ThemeButton;
+ }
+ }
+ #endregion
+
+ #region Mouse & Keyboard Support
+ protected override void OnClick(EventArgs e)
+ {
+ m_BaseItemContainer.InternalClick(Control.MouseButtons,Control.MousePosition);
+ base.OnClick(e);
+ }
+
+ protected override void OnDoubleClick(EventArgs e)
+ {
+ m_BaseItemContainer.InternalDoubleClick(Control.MouseButtons,Control.MousePosition);
+ base.OnDoubleClick(e);
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ ExKeyDown(e);
+ base.OnKeyDown(e);
+ }
+
+ internal void ExKeyDown(KeyEventArgs e)
+ {
+ m_BaseItemContainer.InternalKeyDown(e);
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ m_BaseItemContainer.InternalMouseDown(e);
+ base.OnMouseDown(e);
+ }
+
+ protected override void OnMouseHover(EventArgs e)
+ {
+ base.OnMouseHover(e);
+ m_BaseItemContainer.InternalMouseHover();
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ // If we had hot sub item pass the mouse leave message to it...
+ if(this.Cursor!=System.Windows.Forms.Cursors.Arrow)
+ this.Cursor=System.Windows.Forms.Cursors.Arrow;
+ m_BaseItemContainer.InternalMouseLeave();
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+ if(m_DragDropSupport && !m_UseNativeDragDrop)
+ MouseDragDrop(e.X,e.Y,null);
+
+ m_BaseItemContainer.InternalMouseUp(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if(m_DragDropSupport && m_DragInProgress)
+ {
+ if(!m_UseNativeDragDrop)
+ MouseDragOver(e.X,e.Y,null);
+ }
+ else
+ m_BaseItemContainer.InternalMouseMove(e);
+ }
+
+ protected override void OnDragOver(DragEventArgs e)
+ {
+ if(m_DragDropSupport && (m_DragInProgress || m_ExternalDragInProgress))
+ {
+ Point p=this.PointToClient(new Point(e.X,e.Y));
+ MouseDragOver(p.X,p.Y,e);
+ m_DragLeft=false;
+ }
+ base.OnDragOver(e);
+ }
+
+ protected override void OnDragLeave(EventArgs e)
+ {
+ if(m_DragDropSupport)
+ {
+ if(m_DragInProgress || m_ExternalDragInProgress)
+ MouseDragOver(-1,-1,null);
+ m_DragLeft=true;
+ m_ExternalDragInProgress=false;
+ }
+ base.OnDragLeave(e);
+ }
+
+ protected override void OnDragEnter(DragEventArgs e)
+ {
+ base.OnDragEnter(e);
+ if(m_DragDropSupport)
+ {
+ if(m_DragInProgress || !m_AllowExternalDrop)
+ return;
+ if(e.Data.GetData(typeof(ButtonItem))==null)
+ {
+ if(e.Effect!=DragDropEffects.None)
+ m_ExternalDragInProgress=true;
+ return;
+ }
+ if((e.AllowedEffect & DragDropEffects.Move)==DragDropEffects.Move)
+ e.Effect=DragDropEffects.Move;
+ else if((e.AllowedEffect & DragDropEffects.Copy)==DragDropEffects.Copy)
+ e.Effect=DragDropEffects.Move;
+ else if((e.AllowedEffect & DragDropEffects.Link)==DragDropEffects.Link)
+ e.Effect=DragDropEffects.Move;
+ else
+ return;
+ m_ExternalDragInProgress=true;
+ }
+ }
+
+ protected override void OnDragDrop(DragEventArgs e)
+ {
+ if(m_DragDropSupport)
+ {
+ if(m_DragInProgress)
+ {
+ Point p=this.PointToClient(new Point(e.X,e.Y));
+ MouseDragDrop(p.X,p.Y,null);
+ }
+ else if(m_ExternalDragInProgress)
+ {
+ Point p=this.PointToClient(new Point(e.X,e.Y));
+ MouseDragDrop(p.X,p.Y,e);
+ }
+ }
+ base.OnDragDrop(e);
+ }
+
+ protected override void OnQueryContinueDrag(QueryContinueDragEventArgs e)
+ {
+ if(m_DragDropSupport)
+ {
+ if(m_DragInProgress)
+ {
+ if(m_DragLeft && e.Action==DragAction.Drop || e.Action==DragAction.Cancel)
+ MouseDragDrop(-1,-1,null);
+ }
+ }
+ base.OnQueryContinueDrag(e);
+ }
+
+ private void MouseDragOver(int x, int y, DragEventArgs dragArgs)
+ {
+ if(!m_DragInProgress && !m_ExternalDragInProgress)
+ return;
+ BaseItem dragItem=m_DragItem;
+
+ if(m_ExternalDragInProgress && dragArgs!=null)
+ dragItem=dragArgs.Data.GetData(typeof(ButtonItem)) as BaseItem;
+
+ if(m_DesignTimeProvider!=null)
+ {
+ m_DesignTimeProvider.DrawReversibleMarker(m_InsertPosition,m_InsertBefore);
+ m_DesignTimeProvider=null;
+ }
+
+ if(m_ExternalDragInProgress && dragItem==null)
+ return;
+
+ Point pScreen=this.PointToScreen(new Point(x,y));
+ foreach(SideBarPanelItem panel in m_BaseItemContainer.SubItems)
+ {
+ if(!panel.Visible)
+ continue;
+ InsertPosition pos=((IDesignTimeProvider)panel).GetInsertPosition(pScreen, dragItem);
+
+ if(pos!=null)
+ {
+ if(pos.TargetProvider==null)
+ {
+ // Cursor is over drag item
+ if(!m_UseNativeDragDrop)
+ {
+ if(m_NACursor!=null)
+ System.Windows.Forms.Cursor.Current=m_NACursor;
+ else
+ System.Windows.Forms.Cursor.Current=System.Windows.Forms.Cursors.No;
+ }
+ break;
+ }
+ pos.TargetProvider.DrawReversibleMarker(pos.Position,pos.Before);
+ m_InsertPosition=pos.Position;
+ m_InsertBefore=pos.Before;
+ m_DesignTimeProvider=pos.TargetProvider;
+ if(!m_UseNativeDragDrop)
+ {
+ if(m_MoveCursor!=null)
+ System.Windows.Forms.Cursor.Current=m_MoveCursor;
+ else
+ System.Windows.Forms.Cursor.Current=System.Windows.Forms.Cursors.Hand;
+ }
+ else if(dragArgs!=null)
+ dragArgs.Effect=DragDropEffects.Move;
+ break;
+ }
+ else
+ {
+ if(!m_UseNativeDragDrop)
+ {
+ if(m_NACursor!=null)
+ System.Windows.Forms.Cursor.Current=m_NACursor;
+ else
+ System.Windows.Forms.Cursor.Current=System.Windows.Forms.Cursors.No;
+ }
+ else if(dragArgs!=null)
+ dragArgs.Effect=DragDropEffects.None;
+ }
+ }
+ }
+ #endregion
+
+ #region IOwnerLocalize Implementation
+ void IOwnerLocalize.InvokeLocalizeString(LocalizeEventArgs e)
+ {
+ if(LocalizeString!=null)
+ LocalizeString(this,e);
+ }
+ #endregion
+
+ ///
+ /// Gets or sets the item default accessibility action will be performed on.
+ ///
+ BaseItem IAccessibilitySupport.DoDefaultActionItem
+ {
+ get { return m_DoDefaultActionItem; }
+ set { m_DoDefaultActionItem = value; }
+ }
+
+ protected void SetBaseItemContainer(BaseItem item)
+ {
+ m_BaseItemContainer=item;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public BaseItem GetBaseItemContainer()
+ {
+ return m_BaseItemContainer;
+ }
+
+#if FRAMEWORK20
+ protected override void OnBindingContextChanged(EventArgs e)
+ {
+ base.OnBindingContextChanged(e);
+ if (m_BaseItemContainer != null)
+ m_BaseItemContainer.UpdateBindings();
+ }
+#endif
+
+ protected virtual string EmptyContainerDesignTimeHint
+ {
+ get {return m_EmptyContainerDesignTimeHint;}
+ set {m_EmptyContainerDesignTimeHint=value;}
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(m_ClickTimer!=null)
+ {
+ m_ClickTimer.Stop();
+ m_ClickTimer.Dispose();
+ m_ClickTimer=null;
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ ///
+ /// Specifies the background style of the Explorer Bar.
+ ///
+ [Browsable(true),DevCoBrowsable(true),Category("Style"),Description("Gets or sets bar background style."),DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ItemStyle BackgroundStyle
+ {
+ get {return m_BackgroundStyle;}
+ }
+
+ public void ResetBackgroundStyle()
+ {
+ m_BackgroundStyle.VisualPropertyChanged-=new EventHandler(this.VisualPropertyChanged);
+ m_BackgroundStyle=new ItemStyle();
+ m_BackgroundStyle.VisualPropertyChanged+=new EventHandler(this.VisualPropertyChanged);
+ }
+
+ private void VisualPropertyChanged(object sender, EventArgs e)
+ {
+ if(m_BackgroundStyle!=null)
+ m_BackgroundStyle.ApplyColorScheme(this.ColorScheme);
+ if(this.GetDesignMode())
+ this.Refresh();
+ }
+
+ protected virtual void MouseDragDrop(int x, int y, DragEventArgs dragArgs)
+ {
+ if(!m_DragInProgress && !m_ExternalDragInProgress)
+ return;
+ BaseItem dragItem=m_DragItem;
+ if(m_ExternalDragInProgress)
+ dragItem=dragArgs.Data.GetData(typeof(ButtonItem)) as BaseItem;
+
+ if(dragItem!=null)
+ dragItem.InternalMouseLeave();
+
+ if(m_DesignTimeProvider!=null)
+ {
+ if(x==-1 && y==-1)
+ {
+ // Cancel state
+ m_DesignTimeProvider.DrawReversibleMarker(m_InsertPosition, m_InsertBefore);
+ }
+ else
+ {
+ m_DesignTimeProvider.DrawReversibleMarker(m_InsertPosition, m_InsertBefore);
+ if(dragItem!=null)
+ {
+ BaseItem objParent=dragItem.Parent;
+ if(objParent!=null)
+ {
+ if(objParent==(BaseItem)m_DesignTimeProvider && m_InsertPosition>0)
+ {
+ if(objParent.SubItems.IndexOf(dragItem)
+ /// Indicates whether shortucts handled by items are dispatched to the next handler or control.
+ ///
+ [System.ComponentModel.Browsable(true),DefaultValue(false),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates whether shortucts handled by items are dispatched to the next handler or control.")]
+ public bool DispatchShortcuts
+ {
+ get {return m_DispatchShortcuts;}
+ set {m_DispatchShortcuts=value;}
+ }
+
+ ///
+ /// Gets or sets Bar Color Scheme.
+ ///
+ [Browsable(false),DevCoBrowsable(false),Category("Appearance"),Description("Gets or sets Bar Color Scheme."),DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public DevComponents.DotNetBar.ColorScheme ColorScheme
+ {
+ get {return m_ColorScheme;}
+ set
+ {
+ if(value==null)
+ throw new ArgumentException("NULL is not a valid value for this property.");
+ m_ColorScheme=value;
+ if(this.Visible)
+ this.Refresh();
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeColorScheme()
+ {
+ return m_ColorScheme.SchemeChanged;
+ }
+
+ protected bool IsThemed
+ {
+ get
+ {
+ if (m_ThemeAware && m_BaseItemContainer.EffectiveStyle != eDotNetBarStyle.Office2000 && BarFunctions.ThemedOS && Themes.ThemesActive)
+ return true;
+ return false;
+ }
+ }
+
+ private bool m_DisabledImagesGrayScale=true;
+ ///
+ /// Gets or sets whether gray-scale algorithm is used to create automatic gray-scale images. Default is true.
+ ///
+ [System.ComponentModel.Browsable(true),DefaultValue(true),System.ComponentModel.Category("Appearance"),Description("Gets or sets whether gray-scale algorithm is used to create automatic gray-scale images.")]
+ public bool DisabledImagesGrayScale
+ {
+ get
+ {
+ return m_DisabledImagesGrayScale;
+ }
+ set
+ {
+ m_DisabledImagesGrayScale=value;
+ }
+ }
+
+ ///
+ /// Specifies whether SideBar is drawn using Themes when running on OS that supports themes like Windows XP.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(false),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Specifies whether SideBar is drawn using Themes when running on OS that supports themes like Windows XP.")]
+ public virtual bool ThemeAware
+ {
+ get
+ {
+ return m_ThemeAware;
+ }
+ set
+ {
+ m_ThemeAware=value;
+ m_BaseItemContainer.ThemeAware=value;
+ if(this.GetDesignMode())
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Applies design-time defaults to control.
+ ///
+ public virtual void SetDesignTimeDefaults()
+ {
+ }
+
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting. Default value is false.
+ ///
+ [DefaultValue(false), Browsable(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting.")]
+ public bool AntiAlias
+ {
+ get { return m_AntiAlias; }
+ set
+ {
+ if (m_AntiAlias != value)
+ {
+ m_AntiAlias = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ ///
+ /// Creates the Graphics object for the control.
+ ///
+ /// The Graphics object for the control.
+ public new Graphics CreateGraphics()
+ {
+ Graphics g = base.CreateGraphics();
+ if (m_AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+#if FRAMEWORK20
+ if (!SystemInformation.IsFontSmoothingEnabled)
+#endif
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+ return g;
+ }
+
+ #region Painting Support
+ private Rendering.BaseRenderer m_DefaultRenderer = null;
+ private Rendering.BaseRenderer m_Renderer = null;
+ private eRenderMode m_RenderMode = eRenderMode.Global;
+ ///
+ /// Returns the renderer control will be rendered with.
+ ///
+ /// The current renderer.
+ public virtual Rendering.BaseRenderer GetRenderer()
+ {
+ if (m_RenderMode == eRenderMode.Global && Rendering.GlobalManager.Renderer != null)
+ return Rendering.GlobalManager.Renderer;
+ else if (m_RenderMode == eRenderMode.Custom && m_Renderer != null)
+ return m_Renderer;
+
+ if (m_DefaultRenderer == null)
+ m_DefaultRenderer = new Rendering.Office2007Renderer();
+
+ return m_Renderer;
+ }
+
+ ///
+ /// Gets or sets the redering mode used by control. Default value is eRenderMode.Global which means that static GlobalManager.Renderer is used. If set to Custom then Renderer property must
+ /// also be set to the custom renderer that will be used.
+ ///
+ [Browsable(false), DefaultValue(eRenderMode.Global)]
+ public eRenderMode RenderMode
+ {
+ get { return m_RenderMode; }
+ set
+ {
+ if (m_RenderMode != value)
+ {
+ m_RenderMode = value;
+ this.Invalidate(true);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the custom renderer used by the items on this control. RenderMode property must also be set to eRenderMode.Custom in order renderer
+ /// specified here to be used.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public DevComponents.DotNetBar.Rendering.BaseRenderer Renderer
+ {
+ get
+ {
+ return m_Renderer;
+ }
+ set { m_Renderer = value; }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ColorScheme GetColorScheme()
+ {
+ if (BarFunctions.IsOffice2007Style(m_BaseItemContainer.EffectiveStyle))
+ {
+ Office2007Renderer r = this.GetRenderer() as Office2007Renderer;
+ if (r != null && r.ColorTable.LegacyColors != null)
+ return r.ColorTable.LegacyColors;
+ }
+ return m_ColorScheme;
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if(m_BaseItemContainer==null || this.IsDisposed)
+ return;
+
+ ItemPaintArgs pa=new ItemPaintArgs(this as IOwner,this,e.Graphics,GetColorScheme());
+ pa.Renderer = this.GetRenderer();
+ if (m_AntiAlias)
+ {
+ pa.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ pa.Graphics.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ PaintControlBackground(pa);
+
+ pa.Graphics.SetClip(this.GetItemContainerRectangle());
+ PaintItemContainer(pa);
+ pa.Graphics.ResetClip();
+
+ if(m_BaseItemContainer.SubItems.Count==0 && this.GetDesignMode())
+ PaintDesignTimeEmptyHint(pa);
+
+ PaintContentOnTop(pa);
+ }
+ ///
+ /// Called after control has painted its content and allows painting on top of the controls content.
+ ///
+ /// Paint arguments.
+ protected virtual void PaintContentOnTop(ItemPaintArgs pa) { }
+ protected virtual void PaintControlBackground(ItemPaintArgs pa)
+ {
+ if (m_BackgroundStyle != null)
+ {
+ m_BackgroundStyle.ApplyColorScheme(pa.Colors);
+ m_BackgroundStyle.Paint(pa.Graphics, this.ClientRectangle);
+ }
+ }
+
+ protected virtual void PaintItemContainer(ItemPaintArgs pa)
+ {
+ m_BaseItemContainer.Paint(pa);
+ }
+
+ protected virtual void PaintDesignTimeEmptyHint(ItemPaintArgs pa)
+ {
+ string info=m_EmptyContainerDesignTimeHint;
+ Rectangle rText=this.GetItemContainerRectangle();
+ rText.Inflate(-2,-2);
+ if(rText.Width<0 || rText.Height<0)
+ return;
+ eTextFormat format = eTextFormat.Default | eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.WordBreak;
+ TextDrawing.DrawString(pa.Graphics,info,this.Font,SystemColors.ControlDark,rText,format);
+ }
+ #endregion
+
+ #region Layout Support
+ protected virtual Rectangle GetItemContainerRectangle()
+ {
+ if(m_BackgroundStyle==null)
+ return this.ClientRectangle;
+
+ Rectangle r=this.ClientRectangle;
+
+ if(m_BackgroundStyle.Border==eBorderType.SingleLine)
+ {
+ if(m_BackgroundStyle.BorderSide==eBorderSide.All)
+ r.Inflate(-1,-1);
+ else
+ {
+ if((m_BackgroundStyle.BorderSide & eBorderSide.Left)!=0)
+ r.X++;
+ if((m_BackgroundStyle.BorderSide & eBorderSide.Right)!=0)
+ r.Width--;
+ if((m_BackgroundStyle.BorderSide & eBorderSide.Top)!=0)
+ r.Y++;
+ if((m_BackgroundStyle.BorderSide & eBorderSide.Bottom)!=0)
+ r.Height--;
+ }
+ }
+ else if(m_BackgroundStyle.Border!=eBorderType.None)
+ {
+ if(m_BackgroundStyle.BorderSide==eBorderSide.All)
+ r.Inflate(-2,-2);
+ else
+ {
+ if((m_BackgroundStyle.BorderSide & eBorderSide.Left)!=0)
+ r.X+=2;
+ if((m_BackgroundStyle.BorderSide & eBorderSide.Right)!=0)
+ r.Width-=2;
+ if((m_BackgroundStyle.BorderSide & eBorderSide.Top)!=0)
+ r.Y+=2;
+ if((m_BackgroundStyle.BorderSide & eBorderSide.Bottom)!=0)
+ r.Height-=2;
+ }
+ }
+
+ return r;
+ }
+
+ protected virtual void RecalcSize()
+ {
+ if(m_BaseItemContainer.IsRecalculatingSize)
+ return;
+ Rectangle r=this.GetItemContainerRectangle();
+ m_BaseItemContainer.IsRightToLeft = (this.RightToLeft == RightToLeft.Yes);
+ m_BaseItemContainer.LeftInternal=r.X;
+ m_BaseItemContainer.TopInternal=r.Y;
+ m_BaseItemContainer.WidthInternal =r.Width;
+ m_BaseItemContainer.HeightInternal=r.Height;
+
+ m_BaseItemContainer.RecalcSize();
+
+ OnItemLayoutUpdated(EventArgs.Empty);
+ }
+
+ ///
+ /// Occurs after internal item layout has been updated and items have valid bounds assigned.
+ ///
+ public event EventHandler ItemLayoutUpdated;
+ ///
+ /// Raises ItemLayoutUpdated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnItemLayoutUpdated(EventArgs e)
+ {
+ EventHandler handler = ItemLayoutUpdated;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Applies any layout changes and repaint the control.
+ ///
+ public virtual void RecalcLayout()
+ {
+ if(m_BaseItemContainer.IsRecalculatingSize)
+ return;
+ this.RecalcSize();
+ this.Invalidate();
+ }
+ #endregion
+
+ #region IBarDesignerServices
+ IBarItemDesigner IBarDesignerServices.Designer
+ {
+ get {return m_BarDesigner;}
+ set {m_BarDesigner=value;}
+ }
+ #endregion
+ }
+
+ #region HandlerMessageEventArgs
+ internal class HandlerMessageEventArgs : EventArgs
+ {
+ public IntPtr hWnd = IntPtr.Zero;
+ public IntPtr wParam = IntPtr.Zero;
+ public IntPtr lParam = IntPtr.Zero;
+
+ public HandlerMessageEventArgs(IntPtr hwnd, IntPtr wparam, IntPtr lparam)
+ {
+ this.hWnd = hwnd;
+ this.wParam = wparam;
+ this.lParam = lparam;
+ }
+ }
+
+ internal delegate void HandlerMessageEventHandler(object sender, HandlerMessageEventArgs e);
+ #endregion
+
+
+ #region BarAccessibleObject
+ ///
+ /// Represents class for Accessibility support.
+ ///
+ public class BarBaseControlAccessibleObject : System.Windows.Forms.Control.ControlAccessibleObject
+ {
+ BarBaseControl m_Owner = null;
+ ///
+ /// Creates new instance of the object and initializes it with owner control.
+ ///
+ /// Reference to owner control.
+ public BarBaseControlAccessibleObject(BarBaseControl owner):base(owner)
+ {
+ m_Owner = owner;
+ }
+
+ internal void GenerateEvent(BaseItem sender, System.Windows.Forms.AccessibleEvents e)
+ {
+ int iChild = m_Owner.GetBaseItemContainer().SubItems.IndexOf(sender);
+ if(iChild>=0)
+ {
+ if(m_Owner!=null && !m_Owner.IsDisposed)
+ m_Owner.InternalAccessibilityNotifyClients(e,iChild);
+ }
+ }
+
+ /////
+ ///// Gets or sets accessible name.
+ /////
+ //public override string Name
+ //{
+ // get
+ // {
+ // if(m_Owner!=null && !m_Owner.IsDisposed)
+ // return m_Owner.AccessibleName;
+ // return "";
+ // }
+ // set
+ // {
+ // if(m_Owner!=null && !m_Owner.IsDisposed)
+ // m_Owner.AccessibleName = value;
+ // }
+ //}
+
+ /////
+ ///// Gets accessible description.
+ /////
+ //public override string Description
+ //{
+ // get
+ // {
+ // if(m_Owner!=null && !m_Owner.IsDisposed)
+ // return m_Owner.AccessibleDescription;
+ // return "";
+ // }
+ //}
+
+ ///
+ /// Gets accessible role.
+ ///
+ public override AccessibleRole Role
+ {
+ get
+ {
+ if(m_Owner!=null && !m_Owner.IsDisposed)
+ return m_Owner.AccessibleRole;
+ return System.Windows.Forms.AccessibleRole.None;
+ }
+ }
+
+ ///
+ /// Gets parent accessibility object.
+ ///
+ public override AccessibleObject Parent
+ {
+ get
+ {
+ if(m_Owner!=null && !m_Owner.IsDisposed)
+ return m_Owner.Parent.AccessibilityObject;
+ return null;
+ }
+ }
+
+ ///
+ /// Returns bounds of the control.
+ ///
+ public override Rectangle Bounds
+ {
+ get
+ {
+ if(m_Owner!=null && !m_Owner.IsDisposed && m_Owner.Parent!=null)
+ return this.m_Owner.Parent.RectangleToScreen(m_Owner.Bounds);
+ return Rectangle.Empty;
+ }
+ }
+
+ ///
+ /// Returns number of child objects.
+ ///
+ /// Total number of child objects.
+ public override int GetChildCount()
+ {
+ if(m_Owner!=null && !m_Owner.IsDisposed && m_Owner.GetBaseItemContainer()!=null)
+ return m_Owner.GetBaseItemContainer().SubItems.Count;
+ return 0;
+ }
+
+ ///
+ /// Returns reference to child object given the index.
+ ///
+ /// 0 based index of child object.
+ /// Reference to child object.
+ public override System.Windows.Forms.AccessibleObject GetChild(int iIndex)
+ {
+ if(m_Owner!=null && !m_Owner.IsDisposed && m_Owner.GetBaseItemContainer()!=null)
+ return m_Owner.GetBaseItemContainer().SubItems[iIndex].AccessibleObject;
+ return null;
+ }
+
+ ///
+ /// Returns current accessible state.
+ ///
+ public override AccessibleStates State
+ {
+ get
+ {
+ AccessibleStates state;
+ if(m_Owner==null || m_Owner.IsDisposed)
+ return AccessibleStates.None;
+
+ state=AccessibleStates.None;
+ return state;
+ }
+ }
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/BarBaseControlDesigner.cs b/PROMS/DotNetBar Source Code/BarBaseControlDesigner.cs
new file mode 100644
index 00000000..6165cda1
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BarBaseControlDesigner.cs
@@ -0,0 +1,1317 @@
+using System;
+using System.Windows.Forms;
+using System.Windows.Forms.Design;
+using System.Collections;
+using System.Drawing;
+using System.ComponentModel.Design;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for BarBaseControlDesigner.
+ ///
+ public class BarBaseControlDesigner:System.Windows.Forms.Design.ParentControlDesigner,IDesignerServices
+ {
+ #region Private Variables
+ const string TEMP_NAME="tempDragDropItem";
+ private bool m_EnableItemDragDrop=false;
+ private bool m_AcceptExternalControls=true;
+ private Point m_MouseDownPoint=Point.Empty;
+ private BaseItem m_DragItem=null;
+ private bool m_DragInProgress=false;
+ private IDesignTimeProvider m_DesignTimeProvider=null;
+ private int m_InsertPosition;
+ private bool m_InsertBefore;
+ private bool m_Capture=false;
+ private System.Windows.Forms.Control m_DesignerHost=null;
+ private Timer m_TimerAdded=null;
+ private Timer m_TimerDragDrop=null;
+ private bool m_NewControlAdded=false;
+ private bool m_SuspendInternalCursor=false;
+ private bool m_DragLeave=false;
+ private bool m_ControlRemoved=false;
+ private DateTime m_JustAdded=DateTime.MinValue;
+ private bool m_MouseDownSelectionPerformed=false;
+ #endregion
+
+ #region Designer Implementation
+ public BarBaseControlDesigner()
+ {
+
+ }
+
+ public override void Initialize(IComponent component)
+ {
+ base.Initialize(component);
+ if(!component.Site.DesignMode)
+ return;
+
+ ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null)
+ ss.SelectionChanged+=new EventHandler(OnSelectionChanged);
+
+ // If our component is removed we need to clean-up
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ {
+ cc.ComponentRemoving+=new ComponentEventHandler(this.OnComponentRemoving);
+ cc.ComponentRemoved+=new ComponentEventHandler(this.OnComponentRemoved);
+ }
+
+ IDesignerEventService ds=GetService(typeof(IDesignerEventService)) as IDesignerEventService;
+ if(ds!=null)
+ {
+ ds.ActiveDesignerChanged+=new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
+ ds.SelectionChanged+=new EventHandler(DesignerSelectionChanged);
+ }
+
+ if(this.Control is IBarDesignerServices)
+ ((IBarDesignerServices)this.Control).Designer=this;
+
+ if(component is System.Windows.Forms.Control)
+ {
+ ((Control)component).ControlAdded+=new ControlEventHandler(this.ComponentAdded);
+ ((Control)component).ControlRemoved+=new ControlEventHandler(this.ComponentRemoved);
+ }
+ //this.EnableDragDrop(false);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ // Unhook events
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ {
+ cc.ComponentRemoving-=new ComponentEventHandler(this.OnComponentRemoving);
+ cc.ComponentRemoved-=new ComponentEventHandler(this.OnComponentRemoved);
+ }
+
+ ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null)
+ ss.SelectionChanged-=new EventHandler(OnSelectionChanged);
+
+ IDesignerEventService ds=GetService(typeof(IDesignerEventService)) as IDesignerEventService;
+ if(ds!=null)
+ {
+ ds.ActiveDesignerChanged-=new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
+ ds.SelectionChanged-=new EventHandler(DesignerSelectionChanged);
+ }
+
+ if(this.Component is System.Windows.Forms.Control)
+ {
+ ((Control)this.Component).ControlAdded-=new ControlEventHandler(this.ComponentAdded);
+ ((Control)this.Component).ControlRemoved-=new ControlEventHandler(this.ComponentRemoved);
+ }
+
+ base.Dispose(disposing);
+ }
+
+ public override bool CanParent(Control control)
+ {
+ BaseItem item = GetControlItem(control);
+ if (item != null && item != m_DragItem && !m_NewControlAdded)
+ return false;
+ return base.CanParent(control);
+ }
+
+ private void ComponentAdded(object sender, ControlEventArgs e)
+ {
+ if(!m_NewControlAdded || !m_EnableItemDragDrop || !m_AcceptExternalControls || this.IsDockableWindow)
+ {
+ if(!m_NewControlAdded)
+ {
+ if(!OnControlAdded(e))
+ return;
+ }
+ else
+ return;
+ }
+
+ m_TimerAdded=new Timer();
+ m_TimerAdded.Tick+=new EventHandler(this.TimerTick);
+ m_TimerAdded.Interval=50;
+ m_TimerAdded.Enabled=true;
+ m_TimerAdded.Start();
+ m_NewControlAdded=false;
+ }
+
+ ///
+ /// Called after control has been added to container but not through drag & drop. Control added could also be
+ /// internal control by the bar container.
+ ///
+ /// Event arguments
+ /// true if acted upon this new control otherwise false.
+ protected virtual bool OnControlAdded(ControlEventArgs e)
+ {
+ return false;
+ }
+
+ private void ComponentRemoved(object sender, ControlEventArgs e)
+ {
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh==null || dh.Loading)
+ return;
+
+ if(m_JustAdded!=DateTime.MinValue && DateTime.Now.Subtract(m_JustAdded).Seconds<2)
+ {
+ m_JustAdded=DateTime.MinValue;
+ return;
+ }
+ m_JustAdded=DateTime.MinValue;
+ if(m_DragLeave)
+ ControlRemoved(e.Control);
+ else if(m_TimerDragDrop!=null)
+ m_ControlRemoved=true;
+ else
+ {
+ ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null && ss.PrimarySelection==e.Control && this.GetControlItem(e.Control)!=null)
+ {
+ ControlRemoved(e.Control);
+ }
+ }
+ }
+
+ private void ControlRemoved(Control control)
+ {
+ if(control!=null)
+ {
+ BaseItem item=this.GetControlItem(control);
+ if(item!=null)
+ {
+ MouseDragDrop(-1,-1);
+ if(item.Parent!=null)
+ item.Parent.SubItems.Remove(item);
+ this.DestroyComponent(item);
+ this.RecalcLayout();
+ }
+ }
+ }
+
+ private void TimerTick(object sender, EventArgs e)
+ {
+ m_TimerAdded.Stop();
+ m_TimerAdded.Enabled=false;
+ m_TimerAdded=null;
+ this.RecalcLayout();
+ ISelectionService sel=(ISelectionService)this.GetService(typeof(ISelectionService));
+ if(sel!=null && sel.PrimarySelection is Control && this.Control.Controls.Contains((Control)sel.PrimarySelection))
+ {
+ IComponentChangeService cc=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ cc.OnComponentChanged(sel.PrimarySelection,null,null,null);
+ }
+ }
+
+ private void OnSelectionChanged(object sender, EventArgs e)
+ {
+ DesignTimeSelectionChanged(sender as ISelectionService);
+ }
+
+ private void OnActiveDesignerChanged(object sender, ActiveDesignerEventArgs e)
+ {
+ this.ActiveDesignerChanged(e);
+ }
+
+ ///
+ /// Support for popup menu closing.
+ ///
+ ///
+ protected virtual void ActiveDesignerChanged(ActiveDesignerEventArgs e)
+ {
+ if((this.GetItemContainerControl() as IOwner)!=null)
+ {
+ ((IOwner)this.GetItemContainerControl()).OnApplicationDeactivate(); // Closes all popups
+ }
+ }
+
+ ///
+ /// Support for popup menu closing.
+ ///
+ protected virtual void DesignTimeSelectionChanged(ISelectionService ss)
+ {
+ if(ss==null)
+ return;
+ if(this.Control==null || this.Control.IsDisposed)
+ return;
+
+ if(ss.PrimarySelection!=this.Control)
+ {
+ BaseItem container=this.GetItemContainer();
+ if(container==null)
+ return;
+ if(ss.PrimarySelection is BaseItem)
+ {
+ BaseItem item=ss.PrimarySelection as BaseItem;
+ if(item.ContainerControl==this.GetItemContainerControl())
+ return;
+
+ if(this.GetAllAssociatedComponents().Contains(item))
+ return;
+
+ if((this.GetItemContainerControl() as IOwner)!=null)
+ ((IOwner)this.GetItemContainerControl()).SetFocusItem(null);
+ }
+ else
+ {
+ if((this.GetItemContainerControl() as IOwner)!=null)
+ {
+ ((IOwner)this.GetItemContainerControl()).SetFocusItem(null);
+ ((IOwner)this.GetItemContainerControl()).OnApplicationDeactivate(); // Closes all popups
+ }
+ }
+ }
+ else
+ {
+ if((this.GetItemContainerControl() as IOwner)!=null)
+ ((IOwner)this.GetItemContainerControl()).OnApplicationDeactivate(); // Closes all popups
+ }
+ }
+
+ protected virtual BaseItem GetItemContainer()
+ {
+ BarBaseControl bar=this.Control as BarBaseControl;
+ if(bar!=null)
+ return bar.GetBaseItemContainer();
+ return null;
+ }
+
+ protected virtual System.Windows.Forms.Control GetItemContainerControl()
+ {
+ return this.Control;
+ }
+
+ protected bool m_InternalRemoving=false;
+ private void OnComponentRemoving(object sender,ComponentEventArgs e)
+ {
+ if(e.Component==this.Component)
+ ThisComponentRemoving(sender,e);
+ else
+ OtherComponentRemoving(sender,e);
+ }
+
+ private void OnComponentRemoved(object sender,ComponentEventArgs e)
+ {
+ ComponentRemoved(sender,e);
+ }
+
+ protected virtual void ComponentRemoved(object sender, ComponentEventArgs e){}
+
+ ///
+ /// Removes all subitems from container.
+ ///
+ protected virtual void ThisComponentRemoving(object sender, ComponentEventArgs e)
+ {
+ if(!m_InternalRemoving)
+ {
+ m_InternalRemoving=true;
+ try
+ {
+ // Unhook events
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ cc.ComponentRemoving-=new ComponentEventHandler(this.OnComponentRemoving);
+
+ BaseItem container=this.GetItemContainer();
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+
+ if(dh==null || container==null)
+ return;
+
+ foreach(BaseItem item in container.SubItems)
+ {
+ // Covers the undo case in designer
+ if(item.Parent==container)
+ {
+ DestroySubItems(item,dh);
+ dh.DestroyComponent(item);
+ }
+ }
+ }
+ finally
+ {
+ m_InternalRemoving=false;
+ }
+ }
+ }
+
+ ///
+ /// Triggered when some other component on the form is removed.
+ ///
+ protected virtual void OtherComponentRemoving(object sender, ComponentEventArgs e)
+ {
+ if(e.Component is BaseItem)
+ {
+ BaseItem item=e.Component as BaseItem;
+ if(item.ContainerControl==GetItemContainerControl())
+ {
+ if(item.Parent!=null && item.Parent.SubItems.Contains(item))
+ item.Parent.SubItems.Remove(item);
+ if(item!=null)
+ DestroySubItems(item);
+ this.RecalcLayout();
+ }
+ }
+ }
+
+ protected virtual void DestroySubItems(BaseItem parent, IDesignerHost dh)
+ {
+ if(parent is ControlContainerItem)
+ {
+ if(((ControlContainerItem)parent).Control!=null)
+ {
+ Control c=((ControlContainerItem)parent).Control;
+ ((ControlContainerItem)parent).Control=null;
+ dh.DestroyComponent(c);
+ }
+ }
+ else if(parent is DockContainerItem)
+ {
+ if(((DockContainerItem)parent).Control!=null)
+ {
+ Control c=((DockContainerItem)parent).Control;
+ ((DockContainerItem)parent).Control=null;
+ dh.DestroyComponent(c);
+ }
+ }
+
+ BaseItem[] subitems=new BaseItem[parent.SubItems.Count];
+ parent.SubItems.CopyTo(subitems,0);
+ foreach(BaseItem item in subitems)
+ {
+ DestroySubItems(item,dh);
+ dh.DestroyComponent(item);
+ }
+ }
+
+ protected virtual void DestroySubItems(BaseItem parent)
+ {
+ IDesignerHost dh=GetService(typeof(IDesignerHost)) as IDesignerHost;
+ if(dh!=null)
+ DestroySubItems(parent,dh);
+ }
+
+ ///
+ /// Selection support for items on container.
+ ///
+ protected override void WndProc(ref Message m)
+ {
+ if(m_DesignerHost==null)
+ m_DesignerHost=System.Windows.Forms.Control.FromHandle(m.HWnd);
+ BaseItem container=this.GetItemContainer();
+ System.Windows.Forms.Control ctrl=this.GetItemContainerControl();
+ if(container==null || ctrl==null || ctrl.IsDisposed)
+ {
+ base.WndProc(ref m);
+ return;
+ }
+
+ switch(m.Msg)
+ {
+ case NativeFunctions.WM_LBUTTONDOWN:
+ case NativeFunctions.WM_RBUTTONDOWN:
+ {
+ if(OnMouseDown(ref m))
+ return;
+ break;
+ }
+ case NativeFunctions.WM_RBUTTONUP:
+ case NativeFunctions.WM_LBUTTONUP:
+ {
+ if(OnMouseUp(ref m))
+ return;
+
+ break;
+ }
+ case NativeFunctions.WM_MOUSEMOVE:
+ {
+ if(OnMouseMove(ref m))
+ {
+ m.Result=IntPtr.Zero;
+ return;
+ }
+ break;
+ }
+ case NativeFunctions.WM_MOUSELEAVE:
+ {
+ if(OnMouseLeave(ref m))
+ return;
+ break;
+ }
+ case NativeFunctions.WM_LBUTTONDBLCLK:
+ {
+ if(OnMouseDoubleClick(m))
+ return;
+ break;
+ }
+ }
+
+ base.WndProc(ref m);
+ }
+
+ protected virtual bool OnMouseDown(ref Message m)
+ {
+ if(this.IsDockableWindow)
+ return false;
+
+ System.Windows.Forms.Control ctrl=this.GetItemContainerControl();
+ BaseItem container=this.GetItemContainer();
+
+ if(ctrl==null || (ctrl as IOwner)==null || container==null)
+ return false;
+
+ if(m.Msg==NativeFunctions.WM_RBUTTONDOWN)
+ {
+ Point pos=ctrl.PointToClient(System.Windows.Forms.Control.MousePosition);
+ MouseEventArgs e=new MouseEventArgs(MouseButtons.Left,0,pos.X,pos.Y,0);
+ container.InternalMouseDown(e);
+ if(((IOwner)ctrl).GetFocusItem()!=null)
+ {
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(selection!=null)
+ {
+ ArrayList arr=new ArrayList(1);
+ arr.Add(((IOwner)ctrl).GetFocusItem());
+#if FRAMEWORK20
+ selection.SetSelectedComponents(arr,SelectionTypes.Primary);
+#else
+ selection.SetSelectedComponents(arr,SelectionTypes.MouseDown);
+#endif
+ OnItemSelected(((IOwner)ctrl).GetFocusItem());
+ this.OnContextMenu(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected virtual bool OnMouseUp(ref Message m)
+ {
+ bool bProcessed=false;
+
+ if(m_Capture)
+ {
+ m_Capture=false;
+ System.Windows.Forms.Control c=System.Windows.Forms.Control.FromHandle(m.HWnd);
+ if(c!=null)
+ c.Capture=false;
+ }
+
+ System.Windows.Forms.Control ctrl=this.GetItemContainerControl();
+ BaseItem container=this.GetItemContainer();
+
+ if(ctrl==null || (ctrl as IOwner)==null || container==null)
+ return false;
+
+ Point pos=ctrl.PointToClient(System.Windows.Forms.Control.MousePosition);
+ MouseEventArgs e=new MouseEventArgs(MouseButtons.Left,0,pos.X,pos.Y,0);
+ container.InternalMouseUp(e);
+
+// if(((IOwner)ctrl).GetFocusItem()==null && !m_MouseDownSelectionPerformed)
+// {
+// ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+// if(selection!=null && selection.PrimarySelection!=this.Control && !(selection.PrimarySelection.GetType() == this.Control.GetType()))
+// {
+// ArrayList arr=new ArrayList(1);
+// arr.Add(this.Control);
+// selection.SetSelectedComponents(arr,SelectionTypes.Click);
+// }
+// }
+ if (m_MouseDownSelectionPerformed)
+ bProcessed = true;
+ m_MouseDownSelectionPerformed=false;
+
+ if(m_DragItem!=null && m_DragItem is ControlContainerItem)
+ MouseDragDrop(pos.X,pos.Y);
+
+ return bProcessed;
+ }
+
+ protected virtual bool OnMouseMove(ref Message m)
+ {
+ return false;
+ }
+
+ protected override void OnMouseDragBegin(int x, int y)
+ {
+ Control bar=this.GetItemContainerControl();
+ System.Windows.Forms.Control ctrl=this.GetItemContainerControl();
+
+ BaseItem container=this.GetItemContainer();
+ Point pos=ctrl.PointToClient(new Point(x,y));
+ MouseEventArgs e=new MouseEventArgs(MouseButtons.Left,0,pos.X,pos.Y,0);
+
+ BaseItem dragItem=null;
+ container.InternalMouseDown(e);
+ dragItem=((IOwner)ctrl).GetFocusItem();
+
+ if(dragItem!=null)
+ {
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(selection!=null)
+ {
+ ArrayList arr=new ArrayList(1);
+ arr.Add(dragItem);
+#if FRAMEWORK20
+ selection.SetSelectedComponents(arr, SelectionTypes.Primary);
+#else
+ selection.SetSelectedComponents(arr,SelectionTypes.MouseDown);
+#endif
+ OnItemSelected(((IOwner)ctrl).GetFocusItem());
+ }
+ }
+
+ if(bar==null || dragItem==null || this.IsDockableWindow || !m_EnableItemDragDrop || !CanDragItem(dragItem))
+ {
+ if(dragItem==null)
+ base.OnMouseDragBegin(x,y);
+ else
+ this.Control.Capture = true; // Does same as base implementation
+ return;
+ }
+
+ bar.Capture = true;
+ NativeFunctions.RECT rect = new NativeFunctions.RECT(0,0,0,0);
+ NativeFunctions.GetWindowRect(bar.Handle, ref rect);
+ Rectangle r=Rectangle.FromLTRB(rect.Left, rect.Top, rect.Right, rect.Bottom);
+ Cursor.Clip=r;
+ StartItemDrag(dragItem);
+
+ // Does same as base implementation
+ this.Control.Capture = true;
+ }
+ protected virtual bool CanDragItem(BaseItem item)
+ {
+ return true;
+ }
+ protected override void OnMouseDragMove(int x, int y)
+ {
+ if(m_DragInProgress)
+ {
+ Point p=this.Control.PointToClient(new Point(x,y));
+ MouseDragOver(p.X,p.Y);
+ }
+ }
+ protected override void OnMouseDragEnd(bool cancel)
+ {
+ if(!this.IsDockableWindow)
+ {
+ this.Control.Capture = false;
+ Cursor.Clip = Rectangle.Empty;
+
+ if(m_DragInProgress)
+ {
+ if(cancel)
+ MouseDragDrop(-1,-1);
+ else
+ {
+ Point p=this.Control.PointToClient(Control.MousePosition);
+ MouseDragDrop(p.X,p.Y);
+ }
+ cancel=true;
+ }
+ else
+ {
+ System.Windows.Forms.Control ctrl=this.GetItemContainerControl();
+ if(ctrl is IOwner && ((IOwner)ctrl).GetFocusItem()!=null)
+ cancel=true;
+ }
+ }
+
+ base.OnMouseDragEnd(cancel);
+ }
+
+ protected virtual bool OnMouseLeave(ref Message m)
+ {
+ return false;
+ }
+
+ protected virtual bool OnMouseDoubleClick(Message m)
+ {
+ bool processed=false;
+
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(selection!=null && selection.PrimarySelection is ButtonItem && ((ButtonItem)selection.PrimarySelection).ContainerControl==this.GetItemContainerControl())
+ {
+ IDesignerHost host=(IDesignerHost) this.GetService(typeof(IDesignerHost));
+ if(host!=null)
+ {
+ IDesigner designer=host.GetDesigner(selection.PrimarySelection as IComponent);
+ if(designer!=null)
+ {
+ designer.DoDefaultAction();
+ processed=true;
+ }
+ }
+ }
+
+ return processed;
+ }
+
+ protected virtual void OnItemSelected(BaseItem item)
+ {
+
+ }
+
+ protected virtual void RecalcLayout()
+ {
+ BarBaseControl bar=this.GetItemContainerControl() as BarBaseControl;
+ if(bar!=null)
+ bar.RecalcLayout();
+ }
+
+ ///
+ /// Indicates to the designed control that it has been selected or one of the elements managed by the control is selected in designer.
+ ///
+ /// true if selected otherwise false
+ protected virtual void SetComponentSelected(bool selected)
+ {
+
+ }
+
+ public override System.Collections.ICollection AssociatedComponents
+ {
+ get
+ {
+ ArrayList c=new ArrayList(base.AssociatedComponents);
+ BaseItem container=this.GetItemContainer();
+ if(container!=null)
+ {
+ foreach(BaseItem item in container.SubItems)
+ {
+ if(item.DesignMode)
+ c.Add(item);
+ }
+ }
+ return c;
+ }
+ }
+
+ private ArrayList GetAllAssociatedComponents()
+ {
+ ArrayList c=new ArrayList(base.AssociatedComponents);
+ BaseItem container=this.GetItemContainer();
+ if(container!=null)
+ {
+ AddSubItems(container,c);
+ }
+ return c;
+ }
+
+ private void AddSubItems(BaseItem parent, ArrayList list)
+ {
+ foreach(BaseItem item in parent.SubItems)
+ {
+ if(item.DesignMode)
+ list.Add(item);
+ AddSubItems(item,list);
+ }
+ }
+ #endregion
+
+ #region Design-Time Item Creation
+ protected virtual void CreateButton(object sender, EventArgs e)
+ {
+ OnSubItemsChanging();
+ CreateButton(this.GetItemContainer());
+ OnSubItemsChanged();
+ }
+
+ protected virtual void CreateButton(BaseItem parent)
+ {
+ if(parent==null)
+ return;
+
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh!=null)
+ {
+ ButtonItem item=dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
+ if(item==null)
+ return;
+
+ TypeDescriptor.GetProperties(item)["Text"].SetValue(item,item.Name);
+
+ IComponentChangeService cc=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(parent!=this.GetItemContainer() && cc!=null)
+ cc.OnComponentChanging(parent,TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"]);
+
+ parent.SubItems.Add(item);
+ this.RecalcLayout();
+
+ if(parent!=this.GetItemContainer() && cc!=null)
+ cc.OnComponentChanged(parent,TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"],null,null);
+ }
+ }
+
+ protected virtual void CreateTextBox(object sender, EventArgs e)
+ {
+ OnSubItemsChanging();
+ CreateTextBox(this.GetItemContainer());
+ OnSubItemsChanged();
+ }
+
+ protected virtual void CreateTextBox(BaseItem parent)
+ {
+ if(parent==null)
+ return;
+
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh!=null)
+ {
+ TextBoxItem item=dh.CreateComponent(typeof(TextBoxItem)) as TextBoxItem;
+ if(item==null)
+ return;
+
+ IComponentChangeService cc=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(parent!=this.GetItemContainer() && cc!=null)
+ cc.OnComponentChanging(parent,TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"]);
+
+ parent.SubItems.Add(item);
+ this.RecalcLayout();
+
+ if(parent!=this.GetItemContainer() && cc!=null)
+ cc.OnComponentChanged(parent,TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"],null,null);
+ }
+ }
+
+
+ protected virtual void CreateComboBox(object sender, EventArgs e)
+ {
+ OnSubItemsChanging();
+ CreateComboBox(this.GetItemContainer());
+ OnSubItemsChanged();
+ }
+
+ protected virtual void CreateComboBox(BaseItem parent)
+ {
+ if(parent==null)
+ return;
+
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh!=null)
+ {
+ ComboBoxItem item=dh.CreateComponent(typeof(ComboBoxItem)) as ComboBoxItem;
+ if(item==null)
+ return;
+
+ IComponentChangeService cc=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(parent!=this.GetItemContainer() && cc!=null)
+ cc.OnComponentChanging(parent,TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"]);
+
+ parent.SubItems.Add(item);
+ this.RecalcLayout();
+
+ if(parent!=this.GetItemContainer() && cc!=null)
+ cc.OnComponentChanged(parent,TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"],null,null);
+ }
+ }
+
+ protected virtual void CreateLabel(object sender, EventArgs e)
+ {
+ OnSubItemsChanging();
+ CreateLabel(this.GetItemContainer());
+ OnSubItemsChanged();
+ }
+
+ protected virtual void CreateLabel(BaseItem parent)
+ {
+ if(parent==null)
+ return;
+
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh!=null)
+ {
+ LabelItem item=dh.CreateComponent(typeof(LabelItem)) as LabelItem;
+ if(item==null)
+ return;
+
+ TypeDescriptor.GetProperties(item)["Text"].SetValue(item,item.Name);
+
+ IComponentChangeService cc=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(parent!=this.GetItemContainer() && cc!=null)
+ cc.OnComponentChanging(parent,TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"]);
+
+ parent.SubItems.Add(item);
+ this.RecalcLayout();
+
+ if(parent!=this.GetItemContainer() && cc!=null)
+ cc.OnComponentChanged(parent,TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"],null,null);
+ }
+ }
+
+ protected virtual void CreateDocument(object sender, EventArgs e)
+ {
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh==null)
+ return;
+ DockContainerItem item=dh.CreateComponent(typeof(DockContainerItem)) as DockContainerItem;
+ item.Text=item.Name;
+ OnSubItemsChanging();
+ this.GetItemContainer().SubItems.Add(item);
+ PanelDockContainer panel=dh.CreateComponent(typeof(PanelDockContainer)) as PanelDockContainer;
+ this.Control.Controls.Add(panel);
+ panel.ColorSchemeStyle=this.Style;
+ panel.ApplyLabelStyle();
+ item.Control=panel;
+ OnSubItemsChanged();
+
+
+ this.RecalcLayout();
+ }
+
+ protected virtual void OnSubItemsChanging() {}
+ protected virtual void OnSubItemsChanged() {}
+
+ protected virtual eDotNetBarStyle Style
+ {
+ get {return eDotNetBarStyle.Office2003;}
+ }
+ #endregion
+
+ #region Drag & Drop support
+ private void TimerTickDragDrop(object sender, EventArgs e)
+ {
+ Point p=this.Control.PointToClient(System.Windows.Forms.Control.MousePosition);
+ if(this.Control.Bounds.Contains(p))
+ m_DragLeave=false;
+ else
+ m_DragLeave=true;
+
+ if(System.Windows.Forms.Control.MouseButtons!=MouseButtons.Left)
+ {
+ m_TimerDragDrop.Enabled=false;
+ m_TimerDragDrop.Stop();
+ m_TimerDragDrop.Tick-=new EventHandler(TimerTickDragDrop);
+ m_TimerDragDrop.Dispose();
+ m_TimerDragDrop=null;
+ if(m_ControlRemoved)
+ {
+ m_ControlRemoved=false;
+ ISelectionService sel=this.GetService(typeof(ISelectionService)) as ISelectionService;
+ if(sel!=null && sel.PrimarySelection is System.Windows.Forms.Control)
+ ControlRemoved((System.Windows.Forms.Control)sel.PrimarySelection);
+ }
+ }
+ }
+
+ protected override void OnDragLeave(EventArgs e)
+ {
+ if(m_DragInProgress)
+ {
+ MouseDragDrop(-1,-1);
+ }
+ base.OnDragLeave (e);
+ }
+
+ protected override void OnDragOver(DragEventArgs de)
+ {
+ if(m_DragInProgress)
+ {
+ Point p=this.Control.PointToClient(new Point(de.X,de.Y));
+ MouseDragOver(p.X,p.Y);
+ de.Effect=DragDropEffects.Move;
+ return;
+ }
+
+ if(m_EnableItemDragDrop && m_AcceptExternalControls && !this.IsDockableWindow)
+ {
+ ISelectionService sel=(ISelectionService)this.GetService(typeof(ISelectionService));
+ if(sel!=null && sel.PrimarySelection!=this.Component)
+ {
+ if(sel.PrimarySelection is Control && this.Control.Controls.Contains((Control)sel.PrimarySelection))
+ {
+ BaseItem item=GetControlItem(sel.PrimarySelection as Control);
+ if(item!=null)
+ {
+ m_MouseDownPoint=this.Control.PointToClient(new Point(de.X,de.Y));
+ m_SuspendInternalCursor=true;
+ StartItemDrag(item);
+ if(m_TimerDragDrop==null)
+ {
+ m_TimerDragDrop=new Timer();
+ m_TimerDragDrop.Tick+=new EventHandler(this.TimerTickDragDrop);
+ m_TimerDragDrop.Interval=100;
+ m_TimerDragDrop.Enabled=true;
+ m_TimerDragDrop.Start();
+ }
+ }
+ return;
+ }
+ else if(sel.SelectionCount>1)
+ {
+ de.Effect=DragDropEffects.None;
+ return;
+ }
+ else if(sel.PrimarySelection is Control && ((Control)sel.PrimarySelection).Parent!=null)
+ {
+ // New control being added to the container
+ BaseItem dragItem=null;
+ if(this.IsDockableWindow)
+ {
+ DockContainerItem dc=new DockContainerItem();
+ dc.Name=TEMP_NAME;
+ //dc.Control=sel.PrimarySelection as System.Windows.Forms.Control;
+ dragItem=dc;
+ }
+ else
+ {
+ ControlContainerItem cc=new ControlContainerItem();
+ cc.Name=TEMP_NAME;
+ //cc.Control=sel.PrimarySelection as System.Windows.Forms.Control;
+ dragItem=cc;
+ }
+ m_MouseDownPoint=this.Control.PointToClient(new Point(de.X,de.Y));
+ m_SuspendInternalCursor=true;
+ StartItemDrag(dragItem);
+ }
+ }
+ }
+ base.OnDragOver (de);
+ }
+
+ protected override void OnDragDrop(DragEventArgs de)
+ {
+ if(m_EnableItemDragDrop && m_AcceptExternalControls && !this.IsDockableWindow)
+ {
+ ISelectionService sel=(ISelectionService)this.GetService(typeof(ISelectionService));
+ if(sel!=null && sel.PrimarySelection is Control && this.Control.Controls.Contains((Control)sel.PrimarySelection))
+ {
+ de.Effect=DragDropEffects.Move;
+ Point p=this.Control.PointToClient(new Point(de.X,de.Y));
+ MouseDragDrop(p.X,p.Y);
+ }
+ else
+ {
+ if(sel.SelectionCount>1)
+ {
+ de.Effect=DragDropEffects.None;
+ return;
+ }
+ else
+ {
+ if(m_DragItem!=null && m_DragItem.Name==TEMP_NAME && (m_DragItem is ControlContainerItem || m_DragItem is DockContainerItem))
+ {
+ m_JustAdded=DateTime.Now;
+ BaseItem dragItem=null;
+ if(m_DragItem is ControlContainerItem)
+ {
+ ControlContainerItem cc=m_DragItem as ControlContainerItem;
+ cc.Control=null;
+ cc=this.CreateComponent(typeof(ControlContainerItem)) as ControlContainerItem;
+ TypeDescriptor.GetProperties(cc)["Control"].SetValue(cc,sel.PrimarySelection as System.Windows.Forms.Control);
+ dragItem=cc;
+ }
+ else if(m_DragItem is DockContainerItem)
+ {
+ DockContainerItem dc=m_DragItem as DockContainerItem;
+ dc.Control=null;
+ dc=this.CreateComponent(typeof(DockContainerItem)) as DockContainerItem;
+ TypeDescriptor.GetProperties(dc)["Control"].SetValue(dc,sel.PrimarySelection as System.Windows.Forms.Control);
+ dragItem=dc;
+ }
+ m_DragItem=dragItem;
+ Point p=this.Control.PointToClient(new Point(de.X,de.Y));
+ MouseDragDrop(p.X,p.Y);
+ }
+ m_NewControlAdded=true;
+ }
+ }
+ }
+
+ base.OnDragDrop(de);
+ }
+
+ protected virtual BaseItem GetControlItem(System.Windows.Forms.Control control)
+ {
+ BaseItem parent=this.GetItemContainer();
+ if(parent==null)
+ return null;
+ return GetControlItem(control,parent);
+ }
+
+ private BaseItem GetControlItem(System.Windows.Forms.Control control, BaseItem parent)
+ {
+ if(parent is ControlContainerItem && ((ControlContainerItem)parent).Control==control)
+ return parent;
+ else if(parent is DockContainerItem && ((DockContainerItem)parent).Control==control)
+ return parent;
+
+ foreach(BaseItem item in parent.SubItems)
+ {
+ BaseItem i2=GetControlItem(control,item);
+ if(i2!=null)
+ return i2;
+ }
+ return null;
+ }
+
+ protected virtual bool DragInProgress
+ {
+ get {return m_DragInProgress;}
+ set {m_DragInProgress=value;}
+ }
+
+ protected void StartItemDrag(BaseItem item)
+ {
+ if(item==null)
+ return;
+
+ if(m_DragItem==null)
+ {
+ m_DragItem=item;
+ if(!m_SuspendInternalCursor)
+ System.Windows.Forms.Cursor.Current=System.Windows.Forms.Cursors.Hand;
+ m_DragInProgress=true;
+ }
+ }
+
+ private void MouseDragOver(int x, int y)
+ {
+ if(!m_DragInProgress)
+ return;
+ BaseItem dragItem=m_DragItem;
+ BaseItem container=this.GetItemContainer();
+
+ if(m_DesignTimeProvider!=null)
+ {
+ m_DesignTimeProvider.DrawReversibleMarker(m_InsertPosition,m_InsertBefore);
+ m_DesignTimeProvider=null;
+ }
+
+ Control control=this.GetItemContainerControl();
+ Point pScreen=control.PointToScreen(new Point(x,y));
+
+ InsertPosition pos=((IDesignTimeProvider)container).GetInsertPosition(pScreen, dragItem);
+
+ if(pos!=null)
+ {
+ if(pos.TargetProvider==null)
+ {
+ // Cursor is over drag item
+ if(!m_SuspendInternalCursor)
+ System.Windows.Forms.Cursor.Current=System.Windows.Forms.Cursors.No;
+ }
+ else
+ {
+ pos.TargetProvider.DrawReversibleMarker(pos.Position,pos.Before);
+ m_InsertPosition=pos.Position;
+ m_InsertBefore=pos.Before;
+ m_DesignTimeProvider=pos.TargetProvider;
+ if(!m_SuspendInternalCursor)
+ System.Windows.Forms.Cursor.Current=System.Windows.Forms.Cursors.Hand;
+ }
+ }
+ else
+ {
+ if(!m_SuspendInternalCursor)
+ System.Windows.Forms.Cursor.Current=System.Windows.Forms.Cursors.No;
+ }
+ }
+
+ private void MouseDragDrop(int x, int y)
+ {
+ if(!m_DragInProgress)
+ return;
+ BaseItem dragItem=m_DragItem;
+ BaseItem container=this.GetItemContainer();
+ bool changed=false;
+
+ if(m_DesignTimeProvider!=null)
+ {
+ if(x==-1 && y==-1)
+ {
+ // Cancel state
+ m_DesignTimeProvider.DrawReversibleMarker(m_InsertPosition, m_InsertBefore);
+ }
+ else
+ {
+ m_DesignTimeProvider.DrawReversibleMarker(m_InsertPosition, m_InsertBefore);
+ if(dragItem!=null)
+ {
+ BaseItem objParent=dragItem.Parent;
+ if(objParent!=null)
+ {
+ if(objParent==(BaseItem)m_DesignTimeProvider && m_InsertPosition>0)
+ {
+ if(objParent.SubItems.IndexOf(dragItem)
+ /// Gets or sets whether drag and drop of BaseItems is enabled. Default is false.
+ ///
+ protected virtual bool EnableItemDragDrop
+ {
+ get {return m_EnableItemDragDrop;}
+ set {m_EnableItemDragDrop=value;}
+ }
+
+ ///
+ /// Gets or sets whether dropping of external control into Bar is enabled. Default is false.
+ ///
+ protected virtual bool AcceptExternalControls
+ {
+ get {return m_AcceptExternalControls;}
+ set {m_AcceptExternalControls=value;}
+ }
+
+ public void StartExternalDrag(BaseItem item)
+ {
+ if(!m_DragInProgress && m_DesignerHost!=null)
+ {
+ m_SuspendInternalCursor=false;
+ m_MouseDownPoint=this.Control.PointToClient(System.Windows.Forms.Control.MousePosition);
+ this.StartItemDrag(item);
+ m_DesignerHost.Capture=true;
+ }
+ }
+
+ protected virtual bool IsDockableWindow
+ {
+ get {return false;}
+ }
+
+ protected virtual void SelectComponent(IComponent comp, SelectionTypes selectionType)
+ {
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(selection!=null)
+ {
+ ArrayList arr=new ArrayList(1);
+ arr.Add(comp);
+ selection.SetSelectedComponents(arr,selectionType);
+ }
+ }
+
+ protected virtual bool MouseDownSelectionPerformed
+ {
+ get {return m_MouseDownSelectionPerformed;}
+ set {m_MouseDownSelectionPerformed=value;}
+ }
+ #endregion
+
+ #region IDesignerServices Implementation
+ public object CreateComponent(System.Type componentClass)
+ {
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh==null)
+ return null;
+ return dh.CreateComponent(componentClass);
+ }
+
+ public void DestroyComponent(IComponent c)
+ {
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh==null)
+ return;
+ dh.DestroyComponent(c);
+ }
+
+ object IDesignerServices.GetService(Type serviceType)
+ {
+ return this.GetService(serviceType);
+ }
+ #endregion
+
+ private void DesignerSelectionChanged(object sender, EventArgs e)
+ {
+ ISelectionService sel=this.GetService(typeof(ISelectionService)) as ISelectionService;
+ if(sel==null)
+ {
+ SetComponentSelected(false);
+ return;
+ }
+ bool selected=false;
+ if(sel.PrimarySelection==this.Control || sel.PrimarySelection==this.GetItemContainerControl())
+ selected=true;
+ else if(sel.PrimarySelection is BaseItem && ((BaseItem)sel.PrimarySelection).ContainerControl==this.GetItemContainerControl())
+ selected=true;
+
+ SetComponentSelected(selected);
+ }
+ }
+
+ #region IDesignerServices
+ ///
+ /// Classes used for internal support of design-time features.
+ ///
+ public interface IDesignerServices
+ {
+ ///
+ /// Creates new component.
+ ///
+ /// Component type to create
+ /// New instance of component
+ object CreateComponent(System.Type componentClass);
+ ///
+ /// Destroys component
+ ///
+ /// Component to destroy
+ void DestroyComponent(IComponent c);
+
+ ///
+ /// Gets specified designer service.
+ ///
+ /// Type of the service to get
+ /// Returns reference to the service.
+ object GetService(Type serviceType);
+ }
+
+ ///
+ /// Interface implemented by target Bar interested in access to designer.
+ ///
+ public interface IBarDesignerServices
+ {
+ ///
+ /// Gets or sets the BarBaseControlDesigner instance.
+ ///
+ BarBaseControlDesigner Designer {get;set;}
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/BarDesigner.cs b/PROMS/DotNetBar Source Code/BarDesigner.cs
new file mode 100644
index 00000000..b1cd258c
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BarDesigner.cs
@@ -0,0 +1,701 @@
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Windows.Forms;
+using System.ComponentModel.Design.Serialization;
+using System.CodeDom;
+using System.Drawing;
+using System.Collections;
+using System.Windows.Forms.Design;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents Windows Forms designer for Bar control.
+ ///
+ public class BarDesigner:BarBaseControlDesigner
+ {
+ #region Internal Implementation
+ private int m_MouseDownSelectedTabIndex=-1;
+ private bool m_IsDocking=false;
+ private Form m_OutlineForm=null;
+ private DockSiteInfo m_DockInfo;
+ private bool m_DragDrop=false;
+
+ public BarDesigner():base()
+ {
+ m_DockInfo=new DockSiteInfo();
+ this.EnableItemDragDrop=true;
+ }
+
+ public override DesignerVerbCollection Verbs
+ {
+ get
+ {
+ Bar bar=this.Control as Bar;
+ DesignerVerb[] verbs=null;
+ if(this.IsDockableWindow)
+ {
+ verbs = new DesignerVerb[]
+ {
+ new DesignerVerb("Create Document", new EventHandler(CreateDocument))};
+ }
+ else
+ {
+ verbs = new DesignerVerb[]
+ {
+ new DesignerVerb("Create Button", new EventHandler(CreateButton)),
+ new DesignerVerb("Create Text Box", new EventHandler(CreateTextBox)),
+ new DesignerVerb("Create Combo Box", new EventHandler(CreateComboBox)),
+ new DesignerVerb("Create Label", new EventHandler(CreateLabel)),
+ new DesignerVerb("Open Bar Designer", new EventHandler(EditBar))};
+ }
+
+ return new DesignerVerbCollection(verbs);
+ }
+ }
+
+ private void EditBar(object sender, EventArgs e)
+ {
+ OpenDesigner();
+ }
+
+ public override void DoDefaultAction()
+ {
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(!this.IsDockableWindow && selection!=null && selection.PrimarySelection==this.Control)
+ OpenDesigner();
+ else
+ base.DoDefaultAction();
+ }
+
+ private void OpenDesigner()
+ {
+ Bar bar=this.Control as Bar;
+ if(bar!=null)
+ {
+ DotNetBarManagerDesigner.OpenDesignerEditor(null,bar,this);
+ }
+ }
+
+#if FRAMEWORK20
+ public override void InitializeNewComponent(IDictionary defaultValues)
+ {
+ base.InitializeNewComponent(defaultValues);
+ SetDesignTimeDefaults();
+ }
+#else
+ public override void OnSetComponentDefaults()
+ {
+ base.OnSetComponentDefaults();
+ SetDesignTimeDefaults();
+ }
+#endif
+
+ private void SetDesignTimeDefaults()
+ {
+ Bar bar = this.Component as Bar;
+ if (bar == null)
+ return;
+ bar.Style = eDotNetBarStyle.Office2003;
+ }
+
+ protected override BaseItem GetItemContainer()
+ {
+ Bar bar=this.Control as Bar;
+ if(bar!=null)
+ return bar.ItemsContainer;
+ return null;
+ }
+
+ protected override void RecalcLayout()
+ {
+ Bar bar=this.GetItemContainerControl() as Bar;
+ if(bar!=null)
+ bar.RecalcLayout();
+ }
+
+ protected override void OnSubItemsChanging()
+ {
+ base.OnSubItemsChanging();
+ IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(change!=null)
+ {
+ Bar bar=this.GetItemContainerControl() as Bar;
+ change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("Items",true));
+ }
+ }
+
+ protected override void OnSubItemsChanged()
+ {
+ base.OnSubItemsChanged();
+ IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(change!=null)
+ {
+ Bar bar=this.GetItemContainerControl() as Bar;
+ change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("Items",true),null,null);
+ }
+ }
+
+
+ #endregion
+
+ #region Support For Dockable Windows
+
+ public override SelectionRules SelectionRules
+ {
+ get
+ {
+ if(this.IsDockableWindow)
+ return (SelectionRules.Locked);
+ return base.SelectionRules;
+ }
+ }
+
+ public override bool CanParent(Control control)
+ {
+ if(control.Contains(this.Control))
+ return false;
+ if(this.IsDockableWindow && !(control is PanelDockContainer))
+ return false;
+ return base.CanParent(control);
+ }
+
+ protected override bool IsDockableWindow
+ {
+ get
+ {
+ Bar bar=this.Control as Bar;
+ if(bar!=null && bar.LayoutType==eLayoutType.DockContainer)
+ return true;
+ return false;
+ }
+ }
+
+ private void SelectDockTab(int index)
+ {
+ Bar bar=this.Control as Bar;
+ if(bar==null) return;
+
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ cc.OnComponentChanging(bar,TypeDescriptor.GetProperties(typeof(Bar))["SelectedDockTab"]);
+ bar.SelectedDockTab=index;
+ if(cc!=null)
+ cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["SelectedDockTab"],null,null);
+ if(bar.SelectedDockTab>=0)
+ {
+#if FRAMEWORK20
+ SelectComponent(bar.Items[bar.SelectedDockTab], SelectionTypes.Primary);
+#else
+ SelectComponent(bar.Items[bar.SelectedDockTab],SelectionTypes.MouseDown);
+#endif
+ DockContainerItem dock=bar.Items[bar.SelectedDockTab] as DockContainerItem;
+ if(dock!=null && dock.Control!=null)
+ {
+ dock.Control.BringToFront();
+ if(cc!=null)
+ cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null);
+ }
+ }
+ }
+
+ protected override eDotNetBarStyle Style
+ {
+ get
+ {
+ Bar bar=this.Control as Bar;
+ if(bar!=null)
+ return bar.Style;
+ return base.Style;;
+ }
+ }
+
+ protected override void OtherComponentRemoving(object sender, ComponentEventArgs e)
+ {
+ Bar bar=this.Control as Bar;
+ if(e.Component is Control)
+ {
+ BaseItem item=GetControlItem(e.Component as Control);
+ if(item!=null && item.Parent!=null && item.Parent.SubItems.Contains(item))
+ {
+ if(item is DockContainerItem)
+ ((DockContainerItem)item).Control=null;
+ else if(item is ControlContainerItem)
+ ((ControlContainerItem)item).Control = null;
+ item.Parent.SubItems.Remove(item);
+ DestroySubItems(item);
+ this.RecalcLayout();
+ if(bar!=null && bar.Items.Count>0)
+ SelectDockTab(0);
+ }
+ }
+ else if(!m_InternalRemoving && bar!=null && e.Component is DockContainerItem && bar.Items.Contains((BaseItem)e.Component))
+ {
+ // Throw exception to stop removing the last dock container item.
+ if(bar.VisibleItemCount==1)
+ throw new InvalidOperationException("Cannot delete last DockContainerItem object. Select and Delete Bar object instead");
+ }
+ base.OtherComponentRemoving(sender,e);
+ }
+
+ protected override bool OnMouseDown(ref Message m)
+ {
+ Bar bar=this.Control as Bar;
+ if(!this.IsDockableWindow || bar==null)
+ return base.OnMouseDown(ref m);
+ Point p=Control.MousePosition;
+ int i=GetTabAt(p.X,p.Y);
+ if(i>=0 && m.Msg==NativeFunctions.WM_RBUTTONDOWN)
+ {
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(selection!=null && selection.PrimarySelection!=bar.Items[i])
+ {
+ ArrayList arr=new ArrayList(1);
+ arr.Add(bar.Items[i]);
+#if FRAMEWORK20
+ selection.SetSelectedComponents(arr, SelectionTypes.Primary);
+#else
+ selection.SetSelectedComponents(arr,SelectionTypes.MouseDown);
+#endif
+
+ SelectDockTab(i);
+ this.OnContextMenu(System.Windows.Forms.Control.MousePosition.X,System.Windows.Forms.Control.MousePosition.Y);
+ return true;
+ }
+ }
+
+
+ return base.OnMouseDown(ref m);
+ }
+
+ protected override void OnMouseDragBegin(int x, int y)
+ {
+ Bar bar=this.Control as Bar;
+ m_DragDrop=false;
+
+ if(bar!=null && this.IsDockableWindow)
+ {
+ m_MouseDownSelectedTabIndex=GetTabAt(x,y);
+ if(m_MouseDownSelectedTabIndex!=-1)
+ {
+ if(bar.SelectedDockTab!=m_MouseDownSelectedTabIndex)
+ SelectDockTab(m_MouseDownSelectedTabIndex);
+ m_DragDrop=true;
+ }
+ else if(IsInTabSystemBox(x,y))
+ {
+ MouseDownTabSystemBox(x,y);
+ }
+ else if(IsCaptionGrabHandle(bar))
+ {
+ Point clientPos=bar.PointToClient(new Point(x,y));
+ if(bar.GrabHandleRect.Contains(clientPos))
+ m_DragDrop=true;
+ }
+ }
+ base.OnMouseDragBegin(x,y);
+
+ if(m_MouseDownSelectedTabIndex!=-1)
+ {
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(selection!=null && selection.PrimarySelection!=bar.Items[m_MouseDownSelectedTabIndex])
+ {
+ ArrayList arr=new ArrayList(1);
+ arr.Add(bar.Items[m_MouseDownSelectedTabIndex]);
+#if FRAMEWORK20
+ selection.SetSelectedComponents(arr, SelectionTypes.Primary);
+#else
+ selection.SetSelectedComponents(arr,SelectionTypes.Click);
+#endif
+ }
+ }
+
+ if(m_DragDrop)
+ {
+ bar.Capture = true;
+ NativeFunctions.RECT rect = new NativeFunctions.RECT(0,0,0,0);
+ NativeFunctions.GetWindowRect(bar.Parent.Handle, ref rect);
+ Rectangle r=Rectangle.FromLTRB(rect.Left, rect.Top, rect.Right, rect.Bottom);
+ Cursor.Clip=r;
+ }
+ }
+
+ private bool IsCaptionGrabHandle(Bar bar)
+ {
+ return (bar.GrabHandleStyle==eGrabHandleStyle.Caption || bar.GrabHandleStyle==eGrabHandleStyle.CaptionTaskPane);
+ }
+
+ protected override void OnMouseDragMove(int x, int y)
+ {
+ if(!this.IsDockableWindow || !m_DragDrop)
+ {
+ base.OnMouseDragMove(x,y);
+ return;
+ }
+
+ Point screenPos=new Point(x,y);
+
+ Bar bar=this.Control as Bar;
+ if(bar==null) return;
+
+ Point tabPos=bar.DockTabControl.PointToClient(screenPos);
+ if(bar.DockTabControl!=null && bar.DockTabControl.ClientRectangle.Contains(tabPos))
+ {
+ if(m_IsDocking)
+ {
+ EndBarOwnerDocking(bar);
+ m_IsDocking=false;
+ m_DockInfo=new DockSiteInfo();
+ }
+ MouseEventArgs e=new MouseEventArgs(MouseButtons.Left,0,tabPos.X,tabPos.Y,0);
+ bar.DockTabControl.InternalOnMouseMove(e);
+ }
+ else
+ {
+ m_IsDocking=true;
+ IOwnerBarSupport ownerDock=bar.Owner as IOwnerBarSupport;
+ m_DockInfo=ownerDock.GetDockInfo(bar,screenPos.X,screenPos.Y);
+ if(m_DockInfo.objDockSite==null)
+ {
+ if(m_OutlineForm!=null)
+ m_OutlineForm.Hide();
+ }
+ else
+ {
+ Rectangle r=m_DockInfo.objDockSite.GetBarDockRectangle(bar,ref m_DockInfo);
+ if(!r.IsEmpty)
+ {
+ if(m_OutlineForm==null)
+ m_OutlineForm=BarFunctions.CreateOutlineForm();
+ NativeFunctions.SetWindowPos(m_OutlineForm.Handle.ToInt32(),NativeFunctions.HWND_TOP,r.X,r.Y,r.Width,r.Height,NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
+ }
+ else if(m_OutlineForm!=null)
+ m_OutlineForm.Hide();
+ }
+ }
+ }
+
+ protected override void OnMouseDragEnd(bool cancel)
+ {
+ if(!this.IsDockableWindow)
+ {
+ base.OnMouseDragEnd(cancel);
+ return;
+ }
+
+ this.Control.Capture = false;
+ Cursor.Clip = Rectangle.Empty;
+
+ Bar bar=this.Control as Bar;
+
+ if(cancel || bar==null || !m_DragDrop)
+ {
+ base.OnMouseDragEnd(cancel);
+ return;
+ }
+
+ m_DragDrop=false;
+
+ IDesignerHost designerHost=this.GetService(typeof(IDesignerHost)) as IDesignerHost;
+ if(designerHost==null)
+ {
+ EndBarOwnerDocking(bar);
+ m_IsDocking=false;
+ m_MouseDownSelectedTabIndex=-1;
+ base.OnMouseDragEnd(cancel);
+ return;
+ }
+
+ if(m_IsDocking)
+ {
+ EndBarOwnerDocking(bar);
+ // Moves and docks the selected DockContainerItem or bar
+ Bar referenceBar=m_DockInfo.MouseOverBar;
+ if(m_DockInfo.MouseOverDockSide!=eDockSide.None && m_DockInfo.MouseOverDockSide!=eDockSide.Document && (referenceBar!=bar || m_MouseDownSelectedTabIndex!=-1 && bar.VisibleItemCount>1))
+ {
+ DesignerTransaction trans=designerHost.CreateTransaction("DotNetBar Docking");
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ try
+ {
+ Bar newBar=null;
+ if(m_MouseDownSelectedTabIndex!=-1 && bar.VisibleItemCount>1)
+ newBar=BarFunctions.CreateDuplicateDockBar(bar,this);
+ else
+ newBar=bar;
+
+ cc.OnComponentChanging(bar,TypeDescriptor.GetProperties(typeof(Bar))["SelectedDockTab"]);
+
+ if(m_MouseDownSelectedTabIndex!=-1 && bar.VisibleItemCount>1)
+ {
+ DockContainerItem item=bar.Items[bar.SelectedDockTab] as DockContainerItem;
+ cc.OnComponentChanging(bar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"]);
+ cc.OnComponentChanging(bar,TypeDescriptor.GetProperties(typeof(Bar))["Items"]);
+ bar.Items.Remove(item);
+ cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["Items"],null,null);
+ cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null);
+
+ cc.OnComponentChanging(newBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"]);
+ cc.OnComponentChanging(newBar,TypeDescriptor.GetProperties(typeof(Bar))["Items"]);
+ newBar.Items.Add(item);
+ cc.OnComponentChanged(newBar,TypeDescriptor.GetProperties(typeof(Bar))["Items"],null,null);
+ cc.OnComponentChanged(newBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null);
+ }
+
+ cc.OnComponentChanging(m_DockInfo.objDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["Controls"]);
+ cc.OnComponentChanging(newBar,null);
+ cc.OnComponentChanging(referenceBar,null);
+ cc.OnComponentChanging(m_DockInfo.objDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["DocumentDockContainer"]);
+ m_DockInfo.objDockSite.GetDocumentUIManager().Dock(referenceBar,newBar,m_DockInfo.MouseOverDockSide);
+ cc.OnComponentChanged(m_DockInfo.objDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["DocumentDockContainer"],null,null);
+ cc.OnComponentChanged(referenceBar,null,null,null);
+ cc.OnComponentChanged(newBar,null,null,null);
+ cc.OnComponentChanged(m_DockInfo.objDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["Controls"],null,null);
+
+ }
+ catch
+ {
+ trans.Cancel();
+ throw;
+ }
+ finally
+ {
+ if(!trans.Canceled)
+ trans.Commit();
+ }
+ }
+ else if(m_DockInfo.MouseOverDockSide==eDockSide.Document && bar!=referenceBar)
+ {
+ BarDesigner referenceDesigner=designerHost.GetDesigner(referenceBar) as BarDesigner;
+ if(referenceDesigner!=null)
+ referenceDesigner.DelayedDockTabs(bar,m_MouseDownSelectedTabIndex);
+ }
+
+ m_DockInfo=new DockSiteInfo();
+ }
+ else if(m_MouseDownSelectedTabIndex!=-1)
+ {
+ if(m_MouseDownSelectedTabIndex!=bar.SelectedDockTab)
+ {
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ {
+ cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["Items"],null,null);
+ cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["SelectedDockTab"],null,null);
+ cc.OnComponentChanged(bar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null);
+ }
+ }
+ }
+ m_IsDocking=false;
+ m_MouseDownSelectedTabIndex=-1;
+ base.OnMouseDragEnd(cancel);
+ }
+
+ private Timer m_TimerDelayRemove=null;
+ private Bar m_DelayDockBar=null;
+ private int m_DelayDockTabIndex=-1;
+ internal void DelayedDockTabs(Bar bar, int tabIndex)
+ {
+ if(m_TimerDelayRemove==null)
+ {
+ m_DelayDockBar=bar;
+ m_DelayDockTabIndex=tabIndex;
+ m_TimerDelayRemove=new Timer();
+ m_TimerDelayRemove.Tick+=new EventHandler(this.TimerTickDelayRemove);
+ m_TimerDelayRemove.Interval=200;
+ m_TimerDelayRemove.Enabled=true;
+ m_TimerDelayRemove.Start();
+ }
+ }
+ private void TimerTickDelayRemove(object sender, EventArgs e)
+ {
+ m_TimerDelayRemove.Stop();
+ m_TimerDelayRemove.Enabled=false;
+ m_TimerDelayRemove.Dispose();
+ m_TimerDelayRemove=null;
+
+ DockTabs(m_DelayDockBar,m_DelayDockTabIndex,this.Control as Bar);
+
+ m_DelayDockBar=null;
+ m_DelayDockTabIndex=-1;
+ }
+
+ private void DockTabs(Bar sourceBar, int selectedTabIndex, Bar targetBar)
+ {
+ // Move Dock-container item to different bar
+ IDesignerHost designerHost=this.GetService(typeof(IDesignerHost)) as IDesignerHost;
+ DesignerTransaction trans=designerHost.CreateTransaction("DotNetBar Docking");
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ try
+ {
+ DockContainerItem[] items=null;
+ if(selectedTabIndex!=-1)
+ items=new DockContainerItem[] {sourceBar.Items[sourceBar.SelectedDockTab] as DockContainerItem};
+ else
+ {
+ items=new DockContainerItem[sourceBar.Items.Count];
+ sourceBar.Items.CopyTo(items,0);
+ }
+
+ cc.OnComponentChanging(sourceBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"]);
+ cc.OnComponentChanging(sourceBar,TypeDescriptor.GetProperties(typeof(Bar))["Items"]);
+ sourceBar.Items.RemoveRange(items);
+ cc.OnComponentChanged(sourceBar,TypeDescriptor.GetProperties(typeof(Bar))["Items"],null,null);
+ cc.OnComponentChanged(sourceBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null);
+
+ cc.OnComponentChanging(targetBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"]);
+ cc.OnComponentChanging(targetBar,TypeDescriptor.GetProperties(typeof(Bar))["Items"]);
+ targetBar.Items.AddRange(items);
+ cc.OnComponentChanged(targetBar,TypeDescriptor.GetProperties(typeof(Bar))["Items"],null,null);
+ cc.OnComponentChanged(targetBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null);
+
+ if(sourceBar.Items.Count==0)
+ {
+ DockSite sourceDockSite=sourceBar.Parent as DockSite;
+ cc.OnComponentChanging(sourceDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["DocumentDockContainer"]);
+ cc.OnComponentChanging(sourceBar,null);
+ sourceDockSite.GetDocumentUIManager().UnDock(sourceBar,false);
+ cc.OnComponentChanged(sourceBar,null,null,null);
+ cc.OnComponentChanged(sourceDockSite,TypeDescriptor.GetProperties(typeof(DockSite))["DocumentDockContainer"],null,null);
+
+ designerHost.DestroyComponent(sourceBar);
+ }
+
+ if(targetBar!=null && targetBar.SelectedDockTab>=0)
+ {
+ DockContainerItem dock=targetBar.Items[targetBar.SelectedDockTab] as DockContainerItem;
+ if(dock!=null && dock.Control!=null)
+ {
+ cc.OnComponentChanged(targetBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null);
+ dock.Control.BringToFront();
+ cc.OnComponentChanged(targetBar,TypeDescriptor.GetProperties(typeof(Bar))["Controls"],null,null);
+ }
+ }
+ }
+ catch
+ {
+ trans.Cancel();
+ throw;
+ }
+ finally
+ {
+ if(!trans.Canceled)
+ trans.Commit();
+ }
+ }
+
+ private void EndBarOwnerDocking(Bar bar)
+ {
+ IOwnerBarSupport barSupport=bar.Owner as IOwnerBarSupport;
+ if(barSupport!=null)
+ barSupport.DockComplete();
+ if(m_OutlineForm!=null)
+ {
+ m_OutlineForm.Hide();
+ m_OutlineForm.Dispose();
+ m_OutlineForm=null;
+ }
+ }
+
+ ///
+ /// Returns tab index under specified coordinates.
+ ///
+ /// Screen X coordinate
+ /// Screen Y coordinate
+ /// Tab index or -1 if tab was not found
+ private int GetTabAt(int x, int y)
+ {
+ Bar bar=this.Control as Bar;
+ if(bar==null) return -1;
+
+ // Select dockable tab if mouse is clicked over the tab
+ if(this.IsDockableWindow && bar.DockTabControl!=null)
+ {
+ Point posTab=bar.DockTabControl.PointToClient(new Point(x,y));
+ if(bar.DockTabControl._TabSystemBox.Visible && bar.DockTabControl._TabSystemBox.DisplayRectangle.Contains(posTab))
+ {
+ return -1;
+ }
+ TabItem tab=bar.DockTabControl.HitTest(posTab.X,posTab.Y);
+ if(tab!=null)
+ return bar.Items.IndexOf(tab.AttachedItem);
+ }
+
+ return -1;
+ }
+
+ private bool IsInTabSystemBox(int x, int y)
+ {
+ Bar bar=this.Control as Bar;
+ if(bar==null) return false;
+
+ // Select dockable tab if mouse is clicked over the tab
+ if(this.IsDockableWindow && bar.DockTabControl!=null)
+ {
+ Point posTab=bar.DockTabControl.PointToClient(new Point(x,y));
+ if(bar.DockTabControl._TabSystemBox.Visible && bar.DockTabControl._TabSystemBox.DisplayRectangle.Contains(posTab))
+ return true;
+ }
+
+ return false;
+ }
+
+ private void MouseDownTabSystemBox(int x, int y)
+ {
+ Bar bar=this.Control as Bar;
+ if(bar==null) return;
+
+ // Select dockable tab if mouse is clicked over the tab
+ if(this.IsDockableWindow && bar.DockTabControl!=null)
+ {
+ Point posTab=bar.DockTabControl.PointToClient(new Point(x,y));
+ if(bar.DockTabControl._TabSystemBox.Visible && bar.DockTabControl._TabSystemBox.DisplayRectangle.Contains(posTab))
+ {
+ if(bar.DockTabControl._TabSystemBox.ForwardEnabled && bar.DockTabControl._TabSystemBox.ForwardRect.Contains(posTab))
+ {
+ bar.DockTabControl.ScrollForward();
+ }
+ else if(bar.DockTabControl._TabSystemBox.BackEnabled && bar.DockTabControl._TabSystemBox.BackRect.Contains(posTab))
+ {
+ bar.DockTabControl.ScrollBackwards();
+ }
+ }
+ }
+
+ }
+
+ ///
+ /// Removes all subitems from container.
+ ///
+ protected override void ThisComponentRemoving(object sender, ComponentEventArgs e)
+ {
+ if(!m_InternalRemoving)
+ {
+ m_InternalRemoving=true;
+ try
+ {
+ if(this.IsDockableWindow)
+ {
+ Bar bar=this.Control as Bar;
+ if(bar!=null && bar.DockSide==eDockSide.Document && bar.Parent is DockSite)
+ {
+ IComponentChangeService cc=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(cc!=null)
+ cc.OnComponentChanging(((DockSite)bar.Parent),TypeDescriptor.GetProperties(typeof(DockSite)).Find("DocumentDockContainer",true));
+ ((DockSite)bar.Parent).GetDocumentUIManager().UnDock(bar,false);
+ if(cc!=null)
+ cc.OnComponentChanged(((DockSite)bar.Parent),TypeDescriptor.GetProperties(typeof(DockSite)).Find("DocumentDockContainer",true),null,null);
+ }
+ }
+ }
+ finally
+ {
+ m_InternalRemoving=false;
+ }
+ }
+
+ base.ThisComponentRemoving(sender,e);
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BarEditor.cs b/PROMS/DotNetBar Source Code/BarEditor.cs
new file mode 100644
index 00000000..e0acfce6
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BarEditor.cs
@@ -0,0 +1,2106 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for BarEditor.
+ ///
+ public class BarEditor : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.TreeView barTree;
+ private System.Windows.Forms.PropertyGrid propertyGrid1;
+ private System.Windows.Forms.Splitter splitter1;
+ private System.ComponentModel.IContainer components;
+ private DevComponents.DotNetBar.DockSite barTopDockSite;
+ private DevComponents.DotNetBar.DockSite barBottomDockSite;
+ private DevComponents.DotNetBar.DockSite barLeftDockSite;
+ private DevComponents.DotNetBar.DockSite barRightDockSite;
+ private DevComponents.DotNetBar.DotNetBarManager barManager;
+ private System.Windows.Forms.ImageList imageList;
+
+ private DotNetBarManager m_DotNetBar;
+ private Bar m_Bar=null;
+ private TreeNode m_BarsNode=null,m_CategoriesNode=null,m_PopupsNode=null;
+
+ private System.Windows.Forms.Button btnClose;
+ private System.Windows.Forms.Button btnCancel;
+ private System.Windows.Forms.OpenFileDialog m_OpenFileDialog;
+ private Hashtable m_catTable;
+ private System.Windows.Forms.SaveFileDialog m_SaveFileDialog;
+ private System.Windows.Forms.ImageList m_BarImages;
+ private string m_DefinitionFileName="";
+ private bool m_ShowItemText=true;
+ private GridViewSubclass m_GridViewSubclass=null;
+ private bool m_DataChanged=false;
+ private HTMLHelp m_HtmlHelp=null;
+
+ internal IDesignerServices _barDesigner=null;
+
+ public BarEditor(DotNetBarManager dotnetbar)
+ {
+ m_DotNetBar=dotnetbar;
+ Initialize();
+ }
+
+ public BarEditor(Bar bar)
+ {
+ m_Bar=bar;
+ Initialize();
+ }
+
+ private void Initialize()
+ {
+ InitializeComponent();
+ if(m_Bar!=null)
+ propertyGrid1.BrowsableAttributes=new AttributeCollection(new Attribute[] {BrowsableAttribute.Yes});
+ else
+ propertyGrid1.BrowsableAttributes=new AttributeCollection(new Attribute[] {DevCoBrowsable.Yes});
+ propertyGrid1.CommandsVisibleIfAvailable=false;
+ LoadResourceImages();
+ m_catTable=new Hashtable(20);
+
+ m_GridViewSubclass=new GridViewSubclass();
+ m_GridViewSubclass.OnRightMouseDown+=new EventHandler(this.GridViewMouseDown);
+
+ foreach(Control ctrl in propertyGrid1.Controls)
+ {
+ if(ctrl.GetType().ToString().IndexOf("PropertyGridView")>=0)
+ {
+ m_GridViewSubclass.AssignHandle(ctrl.Handle);
+ break;
+ }
+ }
+
+ if(m_DotNetBar!=null && !m_DotNetBar.IsDesignTime() || m_Bar!=null)
+ {
+ btnCancel.Visible=false;
+ btnClose.Location=btnCancel.Location;
+ }
+
+ CreateToolbar();
+ RefreshView();
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(BarEditor));
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
+ this.splitter1 = new System.Windows.Forms.Splitter();
+ this.barTree = new System.Windows.Forms.TreeView();
+ this.imageList = new System.Windows.Forms.ImageList(this.components);
+ #if TRIAL
+ this.barManager = new DevComponents.DotNetBar.DotNetBarManager(this.components);
+ #else
+ this.barManager = new DevComponents.DotNetBar.DotNetBarManager(this.components,false);
+ #endif
+ this.barBottomDockSite = new DevComponents.DotNetBar.DockSite();
+ this.m_BarImages = new System.Windows.Forms.ImageList(this.components);
+ this.barLeftDockSite = new DevComponents.DotNetBar.DockSite();
+ this.barRightDockSite = new DevComponents.DotNetBar.DockSite();
+ this.barTopDockSite = new DevComponents.DotNetBar.DockSite();
+ this.m_OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
+ this.m_SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
+ this.btnClose = new System.Windows.Forms.Button();
+ this.btnCancel = new System.Windows.Forms.Button();
+ this.panel1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // panel1
+ //
+ this.panel1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right);
+ this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.propertyGrid1,
+ this.splitter1,
+ this.barTree});
+ this.panel1.Location = new System.Drawing.Point(8, 48);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(520, 232);
+ this.panel1.TabIndex = 5;
+ //
+ // propertyGrid1
+ //
+ this.propertyGrid1.CommandsVisibleIfAvailable = true;
+ this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.propertyGrid1.LargeButtons = false;
+ this.propertyGrid1.LineColor = System.Drawing.SystemColors.ScrollBar;
+ this.propertyGrid1.Location = new System.Drawing.Point(182, 0);
+ this.propertyGrid1.Name = "propertyGrid1";
+ this.propertyGrid1.Size = new System.Drawing.Size(338, 232);
+ this.propertyGrid1.TabIndex = 1;
+ this.propertyGrid1.Text = "propertyGrid1";
+ this.propertyGrid1.ViewBackColor = System.Drawing.SystemColors.Window;
+ this.propertyGrid1.ViewForeColor = System.Drawing.SystemColors.WindowText;
+ this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.OnPropertyValueChanged);
+ //
+ // splitter1
+ //
+ this.splitter1.Location = new System.Drawing.Point(176, 0);
+ this.splitter1.Name = "splitter1";
+ this.splitter1.Size = new System.Drawing.Size(6, 232);
+ this.splitter1.TabIndex = 2;
+ this.splitter1.TabStop = false;
+ //
+ // barTree
+ //
+ this.barTree.Dock = System.Windows.Forms.DockStyle.Left;
+ this.barTree.HideSelection = false;
+ this.barTree.ImageList = this.imageList;
+ this.barTree.Name = "barTree";
+ this.barTree.Size = new System.Drawing.Size(176, 232);
+ this.barTree.TabIndex = 0;
+ this.barTree.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TreeKeyDown);
+ this.barTree.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TreeMouseDown);
+ this.barTree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.ItemSelected);
+ this.barTree.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.BeforeItemSelect);
+ this.barTree.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.ItemEdited);
+ this.barTree.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.NodeCollapsing);
+ this.barTree.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.NodeExpanding);
+ //
+ // imageList
+ //
+ this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
+ this.imageList.ImageSize = new System.Drawing.Size(16, 16);
+ this.imageList.TransparentColor = System.Drawing.Color.Magenta;
+ //
+ // barManager
+ //
+ this.barManager.BottomDockSite = this.barBottomDockSite;
+ this.barManager.Images = this.m_BarImages;
+ this.barManager.ImagesLarge = null;
+ this.barManager.ImagesMedium = null;
+ this.barManager.LeftDockSite = this.barLeftDockSite;
+ this.barManager.ParentForm = this;
+ this.barManager.RightDockSite = this.barRightDockSite;
+ this.barManager.TopDockSite = this.barTopDockSite;
+ this.barManager.UseHook = true;
+ this.barManager.ItemClick += new System.EventHandler(this.BarItemClick);
+ //
+ // barBottomDockSite
+ //
+ this.barBottomDockSite.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.barBottomDockSite.Location = new System.Drawing.Point(0, 325);
+ this.barBottomDockSite.Name = "barBottomDockSite";
+ this.barBottomDockSite.Size = new System.Drawing.Size(536, 0);
+ this.barBottomDockSite.TabIndex = 8;
+ this.barBottomDockSite.TabStop = false;
+ //
+ // m_BarImages
+ //
+ this.m_BarImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
+ this.m_BarImages.ImageSize = new System.Drawing.Size(16, 16);
+ this.m_BarImages.TransparentColor = System.Drawing.Color.Magenta;
+ //
+ // barLeftDockSite
+ //
+ this.barLeftDockSite.Dock = System.Windows.Forms.DockStyle.Left;
+ this.barLeftDockSite.Name = "barLeftDockSite";
+ this.barLeftDockSite.Size = new System.Drawing.Size(0, 325);
+ this.barLeftDockSite.TabIndex = 9;
+ this.barLeftDockSite.TabStop = false;
+ //
+ // barRightDockSite
+ //
+ this.barRightDockSite.Dock = System.Windows.Forms.DockStyle.Right;
+ this.barRightDockSite.Location = new System.Drawing.Point(536, 0);
+ this.barRightDockSite.Name = "barRightDockSite";
+ this.barRightDockSite.Size = new System.Drawing.Size(0, 325);
+ this.barRightDockSite.TabIndex = 10;
+ this.barRightDockSite.TabStop = false;
+ //
+ // barTopDockSite
+ //
+ this.barTopDockSite.Dock = System.Windows.Forms.DockStyle.Top;
+ this.barTopDockSite.Name = "barTopDockSite";
+ this.barTopDockSite.Size = new System.Drawing.Size(536, 0);
+ this.barTopDockSite.TabIndex = 7;
+ this.barTopDockSite.TabStop = false;
+ //
+ // m_OpenFileDialog
+ //
+ this.m_OpenFileDialog.Filter = "DotNetBar Files (*.dnb)|*.dnb|All Files (*.*)|*.*";
+ this.m_OpenFileDialog.ShowReadOnly = true;
+ this.m_OpenFileDialog.Title = "Open DotNetBar Definition File";
+ //
+ // m_SaveFileDialog
+ //
+ this.m_SaveFileDialog.CreatePrompt = false;
+ this.m_SaveFileDialog.DefaultExt = "dnb";
+ this.m_SaveFileDialog.FileName = "dotnetbardefinition";
+ this.m_SaveFileDialog.Filter = "DotNetBar Files (*.dnb)|*.dnb|XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
+ this.m_SaveFileDialog.Title = "Save DotNetBar Definition";
+ //
+ // btnClose
+ //
+ this.btnClose.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.btnClose.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.btnClose.Location = new System.Drawing.Point(376, 291);
+ this.btnClose.Name = "btnClose";
+ this.btnClose.Size = new System.Drawing.Size(73, 24);
+ this.btnClose.TabIndex = 6;
+ this.btnClose.Text = "OK";
+ this.btnClose.Click += new System.EventHandler(this.CloseClick);
+ //
+ // btnCancel
+ //
+ this.btnCancel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.btnCancel.Location = new System.Drawing.Point(455, 291);
+ this.btnCancel.Name = "btnCancel";
+ this.btnCancel.Size = new System.Drawing.Size(73, 24);
+ this.btnCancel.TabIndex = 7;
+ this.btnCancel.Text = "Cancel";
+ this.btnCancel.Click += new System.EventHandler(this.CloseClick);
+ //
+ // BarEditor
+ //
+ //this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(536, 325);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.panel1,
+ this.btnClose,
+ this.btnCancel,
+ this.barTopDockSite,
+ this.barBottomDockSite,
+ this.barLeftDockSite,
+ this.barRightDockSite});
+ this.MinimizeBox = false;
+ this.Name = "BarEditor";
+ this.Text = "DotNetBar Editor";
+ this.Closing += new System.ComponentModel.CancelEventHandler(this.FormClosing);
+ this.Load += new EventHandler(this.FormLoad);
+ this.panel1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ private void FormLoad(object sender, EventArgs e)
+ {
+ try
+ {
+ Microsoft.Win32.RegistryKey key=Microsoft.Win32.Registry.LocalMachine;
+ string helpfile="";
+ try
+ {
+ key=key.OpenSubKey("Software\\DevComponents\\DotNetBar");
+ helpfile=key.GetValue("InstallationFolder","").ToString();
+ }
+ finally{key.Close();}
+
+ if(helpfile.Substring(helpfile.Length-1,1)!="\\")
+ helpfile+="\\";
+
+ if(System.IO.File.Exists(helpfile+"dotnetbar.chm"))
+ helpfile+="dotnetbar.chm";
+ else
+ helpfile="";
+
+ if(helpfile!="")
+ m_HtmlHelp=new HTMLHelp(this,helpfile);
+ }
+ catch(Exception)
+ {
+ }
+
+ // Load position if any
+ try
+ {
+ Microsoft.Win32.RegistryKey key=Microsoft.Win32.Registry.CurrentUser;
+ key=key.OpenSubKey("Software\\DevComponents\\DotNetBar");
+ if(key!=null)
+ {
+ try
+ {
+ string s=key.GetValue("DesignerPosition","").ToString();
+ if(s!="")
+ {
+ if(s=="1")
+ {
+ this.WindowState=FormWindowState.Maximized;
+ }
+ else
+ {
+ string[] arr=s.Split(',');
+ if(arr.Length==4)
+ {
+ Rectangle r=new Rectangle(int.Parse(arr[0]),int.Parse(arr[1]),int.Parse(arr[2]),int.Parse(arr[3]));
+ foreach(Screen screen in Screen.AllScreens)
+ {
+ if(screen.Bounds.IntersectsWith(r))
+ {
+ this.StartPosition=FormStartPosition.Manual;
+ this.DesktopLocation=r.Location;
+ this.Size=r.Size;
+ break;
+ }
+ }
+ }
+ }
+ }
+ s=key.GetValue("DesignerPanelSize","").ToString();
+ barTree.Width=int.Parse(s);
+ }
+ finally
+ {
+ key.Close();
+ }
+ }
+ }
+ catch(Exception)
+ {
+ }
+ }
+
+ #region Toolbar Definition Code
+ private void CreateToolbar()
+ {
+ Bar bar, barToolbar;
+ ButtonItem item, item2, item3, popupmain;
+ ButtonItem popup=new ButtonItem("popup");
+ barManager.Items.Add(popup);
+ bar=new Bar("Main Menu");
+ barManager.Bars.Add(bar);
+ bar.MenuBar=true;
+ bar.Stretch=true;
+
+ barToolbar=new Bar("Item Navigation");
+ barManager.Bars.Add(barToolbar);
+
+ // File Menu
+ item=new ButtonItem("file");
+ item.Text="&File";
+ item.PopupType=ePopupType.Menu;
+ bar.Items.Add(item);
+ item2=new ButtonItem("open");
+ item2.Shortcuts.Add(eShortcut.CtrlO);
+ item.SubItems.Add(item2);
+ item2.Text="&Open definition...";
+ item2.ImageIndex=4;
+ barToolbar.Items.Add(item2.Copy());
+
+ item2=new ButtonItem("save");
+ item2.Shortcuts.Add(eShortcut.CtrlS);
+ item.SubItems.Add(item2);
+ item2.Text="&Save definition...";
+ item2.ImageIndex=5;
+ barToolbar.Items.Add(item2.Copy());
+ item2.BeginGroup=true;
+
+ item2=new ButtonItem("saveas");
+ item2.Text="&Save definition as...";
+ item.SubItems.Add(item2);
+
+ item2=new ButtonItem("loadbar");
+ item2.Shortcuts.Add(eShortcut.CtrlL);
+ item.SubItems.Add(item2);
+ item2.Text="Load Bar...";
+ barManager.Items.Add(item2.Copy());
+ item2.BeginGroup=true;
+ item2.Enabled=true;
+
+ item2=new ButtonItem("savebaras");
+ item2.Shortcuts.Add(eShortcut.CtrlD);
+ item.SubItems.Add(item2);
+ item2.Text="Save Bar as...";
+ barManager.Items.Add(item2.Copy());
+ item2.Enabled=false;
+
+ item2=new ButtonItem("close");
+ item2.Text="&Close Designer";
+ item2.BeginGroup=true;
+ item.SubItems.Add(item2);
+
+ // Tools
+ item=new ButtonItem("tools");
+ item.Text="&Tools";
+ item.PopupType=ePopupType.Menu;
+ bar.Items.Add(item);
+ item2=new ButtonItem("barscreation","Create Bar");
+ item.SubItems.Add(item2);
+ popupmain=item2.Copy() as ButtonItem;
+ popup.SubItems.Add(popupmain);
+ if(m_Bar!=null)
+ item2.Visible=false;
+ else if(m_DotNetBar.LeftDockSite==null && m_DotNetBar.RightDockSite==null && m_DotNetBar.TopDockSite==null && m_DotNetBar.BottomDockSite==null)
+ item2.Enabled=false;
+ item3=new ButtonItem("createbar");
+ item3.Text="&Toolbar";
+ item2.SubItems.Add(item3);
+ popupmain.SubItems.Add(item3.Copy());
+ item3=new ButtonItem("createmenubar");
+ item3.Text="&Menu Bar";
+ item2.SubItems.Add(item3);
+ popupmain.SubItems.Add(item3.Copy());
+ item3=new ButtonItem("createstatusbar","&Status Bar");
+ item2.SubItems.Add(item3);
+ popupmain.SubItems.Add(item3.Copy());
+ item3=new ButtonItem("createdockwindow","&Dockable Window");
+ item2.SubItems.Add(item3);
+ popupmain.SubItems.Add(item3.Copy());
+ item3=new ButtonItem("createtaskpane","&Task Pane");
+ item2.SubItems.Add(item3);
+ popupmain.SubItems.Add(item3.Copy());
+
+ item2=new ButtonItem("buttonitem");
+ item2.Text="Add &ButtonItem";
+ item2.BeginGroup=true;
+ item.SubItems.Add(item2);
+ popup.SubItems.Add(item2.Copy());
+ item2=new ButtonItem("textboxitem");
+ item2.Text="Add &TextBoxItem";
+ item.SubItems.Add(item2);
+ popup.SubItems.Add(item2.Copy());
+ item2=new ButtonItem("comboboxitem");
+ item2.Text="Add &ComboBoxItem";
+ item.SubItems.Add(item2);
+ popup.SubItems.Add(item2.Copy());
+ item2=new ButtonItem("labelitem");
+ item2.Text="Add &LabelItem";
+ item.SubItems.Add(item2);
+ popup.SubItems.Add(item2.Copy());
+ // Progress Bar Item
+ item2=new ButtonItem("progressbaritem");
+ item2.Tooltip="Displays a progress bar.";
+ item2.Text="Add &ProgressBarItem";
+ item.SubItems.Add(item2);
+ popup.SubItems.Add(item2.Copy());
+
+ item2=new ButtonItem("customizeitem");
+ item2.BeginGroup=true;
+ item2.Tooltip="Lets end users hide/show Bar items as well as open the Customize dialog.";
+ item2.Text="Add Custo&mizeItem";
+ item.SubItems.Add(item2);
+ popup.SubItems.Add(item2.Copy());
+ item2=new ButtonItem("mdiwindowlistitem");
+ item2.Tooltip="Displays list of MDI Child forms.";
+ item2.Text="Add &MdiWindowListItem";
+ item.SubItems.Add(item2);
+ popup.SubItems.Add(item2.Copy());
+ item2=new ButtonItem("controlcontaineritem");
+ item2.Tooltip="Allows you to host any Control on Bar or Menu-bar.";
+ item2.Text="Add &ControlContainerItem";
+ item.SubItems.Add(item2);
+ popup.SubItems.Add(item2.Copy());
+ item2=new ButtonItem("dockcontaineritem");
+ item2.Tooltip="Helps you create dockable windows.";
+ item2.Text="Add &DockContainerItem";
+ item.SubItems.Add(item2);
+ popup.SubItems.Add(item2.Copy());
+
+ // Pop-up specific items
+ item2=new ButtonItem("copyto");
+ item2.Text="Copy To";
+ item2.BeginGroup=true;
+ item2.PopupType=ePopupType.Menu;
+ popup.SubItems.Add(item2);
+ item2=new ButtonItem("moveto");
+ item2.Text="Move To";
+ item2.PopupType=ePopupType.Menu;
+ popup.SubItems.Add(item2);
+
+ item2=new ButtonItem("delselected");
+ item.SubItems.Add(item2);
+ item2.Text="&Delete Selected Item";
+ item2.BeginGroup=true;
+ item2.ImageIndex=7;
+ popup.SubItems.Add(item2.Copy());
+
+ // Help
+ item=new ButtonItem("help");
+ item.Text="&Help";
+ item.PopupType=ePopupType.Menu;
+ bar.Items.Add(item);
+ item2=new ButtonItem("contents");
+ item2.Text="&Contents...";
+ item.SubItems.Add(item2);
+// item2=new ButtonItem("index");
+// item2.Text="&Index...";
+// item.SubItems.Add(item2);
+// item2=new ButtonItem("search");
+// item2.Text="&Search...";
+// item.SubItems.Add(item2);
+ item2=new ButtonItem("about");
+ item2.Text="&About";
+ item2.BeginGroup=true;
+ item.SubItems.Add(item2);
+
+ bar.DockSide=eDockSide.Top;
+
+ // Create left bar with the item navigation buttons
+ item=new ButtonItem("addnewitems");
+ barToolbar.Items.Add(item);
+ item.PopupType=ePopupType.Menu;
+ item.ImageIndex=6;
+ item.Text="Create new item";
+ item.Tooltip="Press to see available items that can be created";
+ item.BeginGroup=true;
+ item.Enabled=true;
+ item.SubItems.Add(barManager.Items["buttonitem"].Copy());
+ item.SubItems.Add(barManager.Items["textboxitem"].Copy());
+ item.SubItems.Add(barManager.Items["comboboxitem"].Copy());
+ item.SubItems.Add(barManager.Items["customizeitem"].Copy());
+ item.SubItems.Add(barManager.Items["mdiwindowlistitem"].Copy());
+ item.SubItems.Add(barManager.Items["controlcontaineritem"].Copy());
+ item.SubItems.Add(barManager.Items["dockcontaineritem"].Copy());
+ item.SubItems.Add(barManager.Items["progressbaritem"].Copy());
+ barToolbar.Items.Add(barManager.Items["delselected"].Copy());
+
+
+ item=new ButtonItem("moveleft");
+ barToolbar.Items.Add(item);
+ item.ImageIndex=0;
+ item.Text="Move Left";
+ item.Tooltip="Move selected item left";
+ item.BeginGroup=true;
+ item.Enabled=false;
+ item.ClickAutoRepeat=true;
+ barManager.Items.Add(item.Copy());
+
+ item=new ButtonItem("moveright");
+ barToolbar.Items.Add(item);
+ item.ImageIndex=1;
+ item.Text="Move Right";
+ item.Tooltip="Move selected item right";
+ item.Enabled=false;
+ item.ClickAutoRepeat=true;
+ barManager.Items.Add(item.Copy());
+
+ item=new ButtonItem("moveup");
+ barToolbar.Items.Add(item);
+ item.ImageIndex=2;
+ item.Text="Move Up";
+ item.Tooltip="Move selected item up";
+ item.Enabled=false;
+ item.ClickAutoRepeat=true;
+ barManager.Items.Add(item.Copy());
+
+ item=new ButtonItem("movedown");
+ barToolbar.Items.Add(item);
+ item.ImageIndex=3;
+ item.Text="Move Down";
+ item.Tooltip="Move selected item down";
+ item.Enabled=false;
+ item.ClickAutoRepeat=true;
+ barManager.Items.Add(item.Copy());
+
+ item=new ButtonItem("synccat");
+ barToolbar.Items.Add(item);
+ item.ImageIndex=8;
+ item.Text="Sync Categories";
+ item.Tooltip="Recreates Categories from your current definition.";
+ item.Enabled=true;
+ item.ButtonStyle=eButtonStyle.ImageAndText;
+ item.ClickAutoRepeat=false;
+
+ barToolbar.DockLine=1;
+ barToolbar.DockSide=eDockSide.Top;
+
+ popup=new ButtonItem("resetimagepopup");
+ item=new ButtonItem("resetimage","Reset");
+ popup.SubItems.Add(item);
+ barManager.ContextMenus.Add(popup);
+
+ barManager.Style=eDotNetBarStyle.Office2003;
+
+ }
+ #endregion
+
+ protected void CloseClick (object sender, System.EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void RefreshView()
+ {
+ barTree.Nodes.Clear();
+
+ if(m_Bar!=null)
+ {
+ try
+ {
+ this.Cursor=Cursors.WaitCursor;
+ m_BarsNode=barTree.Nodes.Add("Bar");
+ m_BarsNode.ImageIndex=2;
+ m_BarsNode.SelectedImageIndex=2;
+
+ TreeNode barNode=m_BarsNode.Nodes.Add(m_Bar.Text);
+ barNode.Tag=m_Bar;
+ barNode.ImageIndex=1;
+ barNode.SelectedImageIndex=1;
+ foreach(BaseItem objItem in m_Bar.Items)
+ {
+ TreeNode itemNode=barNode.Nodes.Add(GetTreeItemText(objItem));
+ itemNode.Tag=objItem;
+
+ itemNode.ImageIndex=GetItemImageIndex(objItem);
+ itemNode.SelectedImageIndex=itemNode.ImageIndex;
+
+ AddSubItems(objItem,itemNode);
+ }
+ m_BarsNode.Expand();
+ barNode.Expand();
+ }
+ finally
+ {
+ this.Cursor=Cursors.Arrow;
+ }
+ return;
+ }
+
+ if(m_DotNetBar==null)
+ return;
+
+ this.Cursor=Cursors.WaitCursor;
+
+ if(m_DotNetBar.TopDockSite==null && m_DotNetBar.BottomDockSite==null && m_DotNetBar.LeftDockSite==null && m_DotNetBar.RightDockSite==null)
+ {
+ m_CategoriesNode=null;
+ m_BarsNode=null;
+ }
+ else
+ {
+ m_CategoriesNode=barTree.Nodes.Add("Categories");
+ m_CategoriesNode.ImageIndex=5;
+ m_CategoriesNode.SelectedImageIndex=5;
+
+ m_BarsNode=barTree.Nodes.Add("Bars");
+ m_BarsNode.ImageIndex=2;
+ m_BarsNode.SelectedImageIndex=2;
+ }
+
+ m_PopupsNode=barTree.Nodes.Add("Context Menus");
+ m_PopupsNode.ImageIndex=12;
+ m_PopupsNode.SelectedImageIndex=12;
+
+ if(m_BarsNode!=null)
+ {
+ foreach(Bar bar in m_DotNetBar.Bars)
+ {
+ TreeNode barNode=m_BarsNode.Nodes.Add(bar.Text);
+ barNode.Tag=bar;
+ barNode.ImageIndex=1;
+ barNode.SelectedImageIndex=1;
+ foreach(BaseItem objItem in bar.Items)
+ {
+ TreeNode itemNode=barNode.Nodes.Add(GetTreeItemText(objItem));
+ itemNode.Tag=objItem;
+
+ itemNode.ImageIndex=GetItemImageIndex(objItem);
+ itemNode.SelectedImageIndex=itemNode.ImageIndex;
+
+ AddSubItems(objItem,itemNode);
+ }
+ }
+ }
+
+ // Load nodes from items
+ m_catTable.Clear();
+ if(m_CategoriesNode!=null)
+ {
+ foreach(DictionaryEntry o in m_DotNetBar.Items)
+ {
+ BaseItem objItem=o.Value as BaseItem;
+ TreeNode itemNode=CategorizeItem(objItem);
+ itemNode.Tag=objItem;
+
+ itemNode.ImageIndex=GetItemImageIndex(objItem);
+ itemNode.SelectedImageIndex=itemNode.ImageIndex;
+
+ AddSubItems(objItem,itemNode);
+ }
+ }
+
+ // Load all popups
+ foreach(BaseItem objItem in m_DotNetBar.ContextMenus)
+ {
+ TreeNode itemNode=m_PopupsNode.Nodes.Add(GetTreeItemText(objItem));
+ itemNode.Tag=objItem;
+
+ itemNode.ImageIndex=GetItemImageIndex(objItem);
+ itemNode.SelectedImageIndex=itemNode.ImageIndex;
+
+ AddSubItems(objItem,itemNode);
+ }
+
+ if(m_BarsNode!=null)
+ m_BarsNode.Expand();
+ if(m_CategoriesNode!=null)
+ m_CategoriesNode.Expand();
+ m_PopupsNode.Expand();
+
+ this.Cursor=Cursors.Arrow;
+ }
+ private void AddSubItems(BaseItem objItem, TreeNode parentNode)
+ {
+ if(objItem.SubItems.Count==0)
+ return;
+ foreach(BaseItem objChild in objItem.SubItems)
+ {
+ TreeNode itemNode=parentNode.Nodes.Add(GetTreeItemText(objChild));
+ itemNode.Tag=objChild;
+
+ itemNode.ImageIndex=GetItemImageIndex(objChild);
+ itemNode.SelectedImageIndex=itemNode.ImageIndex;
+
+ AddSubItems(objChild,itemNode);
+ }
+ }
+ // TODO: Make sure that when designing the Menu Bar when new item is added default
+ // PopupType is MENU not TOOLBAR
+ private void ItemSelected(object sender,TreeViewEventArgs e)
+ {
+ barTree.LabelEdit=false;
+ if(e.Node.Tag==null)
+ {
+ propertyGrid1.SelectedObject=null;
+ return;
+ }
+
+ if(e.Node.Tag is BaseItem)
+ {
+ propertyGrid1.SelectedObject=e.Node.Tag;
+ barTree.LabelEdit=true;
+
+ // Now way to detect when Items collection has changed, reset changed flag if combo box is selected...
+ if(e.Node.Tag is ComboBoxItem)
+ m_DataChanged=true;
+ }
+ else if(e.Node.Tag is Bar)
+ {
+ propertyGrid1.SelectedObject=(Bar)e.Node.Tag;
+
+ }
+ else
+ {
+ propertyGrid1.SelectedObject=null;
+ }
+
+ }
+
+ private void BeforeItemSelect(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
+ {
+ // Disable/Enable toolbar items...
+ bool bLeftEnabled=false, bRightEnabled=false, bUpEnabled=false, bDownEnabled=false;
+
+ BaseItem popupItem=barManager.Items["popup"];
+
+ if(e.Node!=null && e.Node.Tag is BaseItem)
+ {
+ if(e.Node.Parent==m_PopupsNode)
+ {
+ bRightEnabled=true;
+ }
+ else
+ {
+ BaseItem objItem=e.Node.Tag as BaseItem;
+ int i=0;
+ if(objItem.Parent!=null)
+ i=objItem.Parent.SubItems.IndexOf(objItem);
+ else
+ i=e.Node.Index;
+ if(i>0)
+ {
+ bUpEnabled=true;
+ bRightEnabled=true;
+ }
+ int iCount=0;
+ if(objItem.Parent!=null)
+ iCount=objItem.Parent.SubItems.Count-1;
+ else
+ iCount=e.Node.Parent.Nodes.Count-1;
+
+ if(i0)
+ if(MessageBox.Show(this,"Are you sure you want to delete selected item?","DotNetBar Editor",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.No)
+ return;
+
+ if(barTree.SelectedNode.Tag is BaseItem)
+ {
+ BaseItem item=barTree.SelectedNode.Tag as BaseItem;
+ Bar cont=item.ContainerControl as Bar;
+
+ TreeNode topParentNode=barTree.SelectedNode;
+ while(topParentNode.Parent!=null)
+ topParentNode=topParentNode.Parent;
+
+ if(item.Parent!=null)
+ item.Parent.SubItems.Remove(item);
+ else if(topParentNode==m_CategoriesNode)
+ m_DotNetBar.Items.Remove(item);
+ else if(barTree.SelectedNode.Parent==m_PopupsNode)
+ m_DotNetBar.ContextMenus.Remove(item);
+
+ if(_barDesigner!=null)
+ _barDesigner.DestroyComponent(item);
+ else
+ item.Dispose();
+
+ barTree.SelectedNode.Tag=null;
+ TreeNode parentNode=barTree.SelectedNode.Parent;
+ barTree.Nodes.Remove(barTree.SelectedNode);
+ // If it is last node under one of the categories remove parent too
+ if(parentNode!=null && parentNode.Parent==m_CategoriesNode && parentNode.Nodes.Count==0)
+ barTree.Nodes.Remove(parentNode);
+ if(cont!=null)
+ cont.RecalcLayout();
+
+ }
+ else if(barTree.SelectedNode.Tag is Bar)
+ {
+ Bar bar=barTree.SelectedNode.Tag as Bar;
+
+ m_DotNetBar.Bars.Remove(bar);
+
+ barTree.SelectedNode.Tag=null;
+ barTree.Nodes.Remove(barTree.SelectedNode);
+ }
+ else if(m_CategoriesNode!=null && barTree.SelectedNode.Parent==m_CategoriesNode)
+ {
+ // Delete all items within this category
+ foreach(TreeNode node in barTree.SelectedNode.Nodes)
+ {
+ objItem=node.Tag as BaseItem;
+ if(objItem!=null)
+ {
+ m_DotNetBar.Items.Remove(objItem);
+ objItem.Dispose();
+ }
+ node.Tag=null;
+ }
+ barTree.SelectedNode.Remove();
+ }
+
+ return;
+ }
+ else if(objItem.Name=="open")
+ {
+ if(m_OpenFileDialog.ShowDialog()==DialogResult.OK && System.IO.File.Exists(m_OpenFileDialog.FileName))
+ {
+ m_DotNetBar.Bars.Owner.LoadDefinition(m_OpenFileDialog.FileName);
+ m_DefinitionFileName=m_OpenFileDialog.FileName;
+ RefreshView();
+ m_DataChanged=true;
+ }
+ return;
+ }
+ else if(objItem.Name=="save" && m_DefinitionFileName!="")
+ {
+ m_DotNetBar.Bars.Owner.SaveDefinition(m_DefinitionFileName);
+ return;
+ }
+ else if(objItem.Name=="saveas" || objItem.Name=="save" && m_DefinitionFileName=="")
+ {
+ if(m_SaveFileDialog.ShowDialog()==DialogResult.OK)
+ {
+ m_DotNetBar.Bars.Owner.SaveDefinition(m_SaveFileDialog.FileName);
+ m_DefinitionFileName=m_SaveFileDialog.FileName;
+ }
+ return;
+ }
+ else if(objItem.Name=="savebaras")
+ {
+ // Save currently selected bar
+ if(barTree.SelectedNode==null || !(barTree.SelectedNode.Tag is Bar))
+ return;
+
+ Bar bar=barTree.SelectedNode.Tag as Bar;
+ string stitle=m_SaveFileDialog.Title;
+ string defaultExt=m_SaveFileDialog.DefaultExt;
+ string fileName=m_SaveFileDialog.FileName;
+ string filter=m_SaveFileDialog.Filter;
+
+ m_SaveFileDialog.Title="Save Bar Definition";
+ m_SaveFileDialog.DefaultExt = "xml";
+ m_SaveFileDialog.FileName = (bar.Name!=""?bar.Name:"MyBar");
+ m_SaveFileDialog.Filter = "DotNetBar Bar Files (*.xml)|*.xml|All Files (*.*)|*.*";
+
+ if(m_SaveFileDialog.ShowDialog()==DialogResult.OK)
+ {
+ bar.SaveDefinition(m_SaveFileDialog.FileName);
+ }
+
+ m_SaveFileDialog.Title=stitle;
+ m_SaveFileDialog.DefaultExt=defaultExt;
+ m_SaveFileDialog.FileName=fileName;
+ m_SaveFileDialog.Filter=filter;
+
+ return;
+ }
+ else if(objItem.Name=="loadbar")
+ {
+ string defaultExt=m_OpenFileDialog.DefaultExt;
+ string filter=m_OpenFileDialog.Filter;
+ m_OpenFileDialog.DefaultExt="xml";
+ m_OpenFileDialog.Filter = "DotNetBar Bar Files (*.xml)|*.xml|All Files (*.*)|*.*";
+ if(m_OpenFileDialog.ShowDialog()==DialogResult.OK && System.IO.File.Exists(m_OpenFileDialog.FileName))
+ {
+ Bar bar=new Bar();
+ try
+ {
+ bar.LoadDefinition(m_OpenFileDialog.FileName);
+ }
+ catch(Exception ex)
+ {
+ MessageBox.Show("File '"+m_OpenFileDialog.FileName+"' does not appear to be valid Bar file.\n\rException has been generated while loading: "+ex.Source+": "+ex.Message+"\n\r"+ex.StackTrace);
+ return;
+ }
+ bar.Dispose();
+ bar=new Bar();
+ m_DotNetBar.SuspendLayout=true;
+ m_DotNetBar.Bars.Add(bar);
+ bar.LoadDefinition(m_OpenFileDialog.FileName);
+ m_DotNetBar.SuspendLayout=false;
+ }
+ m_OpenFileDialog.DefaultExt=defaultExt;
+ m_OpenFileDialog.Filter=filter;
+ }
+ else if(objItem.Name=="moveleft" || objItem.Name=="moveright" || objItem.Name=="moveup" || objItem.Name=="movedown")
+ MoveSelectedItem(objItem.Name);
+ else if(objItem.Name=="addnewitems")
+ objItem.Expanded=true;
+ else if(objItem.Name=="synccat")
+ {
+ RescanCategories();
+ return;
+ }
+
+ m_DataChanged=true;
+
+ // Creation of new items only below this point
+ if(objItem.Name!="buttonitem" && objItem.Name!="textboxitem" && objItem.Name!="comboboxitem" && objItem.Name!="customizeitem" && objItem.Name!="labelitem" && objItem.Name!="mdiwindowlistitem" && objItem.Name!="controlcontaineritem" && objItem.Name!="dockcontaineritem" && objItem.Name!="progressbaritem")
+ return;
+
+ // Item creation buttons only below!!!
+ if(objItem.Name=="buttonitem")
+ {
+ ButtonItem btn=CreateObject(typeof(ButtonItem)) as ButtonItem;
+ btn.Text="New Button";
+ newItem=btn;
+ }
+ else if(objItem.Name=="textboxitem")
+ {
+ TextBoxItem tb=CreateObject(typeof(TextBoxItem)) as TextBoxItem;
+ tb.Text="Text Box";
+ newItem=tb;
+ }
+ else if(objItem.Name=="comboboxitem")
+ {
+ ComboBoxItem cb=CreateObject(typeof(ComboBoxItem)) as ComboBoxItem;
+ cb.Text="Combo Box";
+ newItem=cb;
+ }
+ else if(objItem.Name=="customizeitem")
+ {
+ CustomizeItem cust=CreateObject(typeof(CustomizeItem)) as CustomizeItem;
+ newItem=cust;
+ }
+ else if(objItem.Name=="labelitem")
+ {
+ LabelItem li=CreateObject(typeof(LabelItem)) as LabelItem;
+ li.Text="Label";
+ li.BorderType=eBorderType.SingleLine;
+ newItem=li;
+ }
+ else if(objItem.Name=="mdiwindowlistitem")
+ {
+ MdiWindowListItem mdi=CreateObject(typeof(MdiWindowListItem)) as MdiWindowListItem;
+ mdi.Text="MDI Window List";
+ newItem=mdi;
+ }
+ else if(objItem.Name=="controlcontaineritem")
+ {
+ ControlContainerItem cci=CreateObject(typeof(ControlContainerItem)) as ControlContainerItem;
+ newItem=cci;
+ }
+ else if(objItem.Name=="dockcontaineritem")
+ {
+ DockContainerItem dci=CreateObject(typeof(DockContainerItem)) as DockContainerItem;
+ dci.Text="Dockable Window";
+ newItem=dci;
+ }
+ else if(objItem.Name=="progressbaritem")
+ {
+ ProgressBarItem pb=CreateObject(typeof(ProgressBarItem)) as ProgressBarItem;
+ pb.Text="Progress Bar";
+ pb.SetDesignMode(true);
+ pb.Style=m_DotNetBar.Style;
+ pb.ResetBackgroundStyle();
+ newItem=pb;
+ }
+
+ if(_barDesigner==null)
+ {
+ string name="item_";
+ long id=newItem.Id;
+ if(m_DotNetBar!=null)
+ {
+ while(m_DotNetBar.GetItem(name+id,true)!=null)
+ id++;
+ }
+ else if(m_Bar!=null)
+ {
+ while(m_Bar.GetItem(name+id)!=null)
+ id++;
+ }
+ newItem.Name=name+id;
+ }
+
+ if(barTree.SelectedNode.Tag is BaseItem)
+ {
+ newItem.Style=((BaseItem)barTree.SelectedNode.Tag).Style;
+ if(barTree.SelectedNode.Tag is PopupItem && newItem is PopupItem)
+ ((PopupItem)newItem).PopupType=((PopupItem)barTree.SelectedNode.Tag).PopupType;
+ }
+ else if(barTree.SelectedNode.Tag is Bar)
+ {
+ newItem.Style=((Bar)barTree.SelectedNode.Tag).Style;
+ if(newItem is PopupItem && ((Bar)barTree.SelectedNode.Tag).MenuBar)
+ ((PopupItem)newItem).PopupType=ePopupType.Menu;
+ }
+
+ // We need to determine is new item being added to the Categories
+ TreeNode itemNode=barTree.SelectedNode;
+ while(itemNode.Parent!=null)
+ itemNode=itemNode.Parent;
+
+ if(itemNode==m_CategoriesNode)
+ {
+ // Assign category to new item
+ if(barTree.SelectedNode==m_CategoriesNode)
+ newItem.Category="(Untitled)";
+ else if(barTree.SelectedNode.Parent==m_CategoriesNode)
+ newItem.Category=barTree.SelectedNode.Text;
+ else
+ newItem.Category=((BaseItem)barTree.SelectedNode.Tag).Category;
+
+ m_DotNetBar.Items.Add(newItem);
+ itemNode=CategorizeItem(newItem);
+ }
+ else if(itemNode==m_PopupsNode)
+ {
+ //if(barTree.SelectedNode.Tag is BaseItem && barTree.SelectedNode.Parent.Tag is BaseItem)
+ if(barTree.SelectedNode.Tag is BaseItem)
+ {
+ //itemNode=barTree.SelectedNode.Parent.Nodes.Add(GetTreeItemText(newItem));
+ itemNode=barTree.SelectedNode.Nodes.Add(GetTreeItemText(newItem));
+
+ //BaseItem objParent=((BaseItem)barTree.SelectedNode.Tag).Parent;
+ BaseItem objParent=(BaseItem)barTree.SelectedNode.Tag;
+ int iPos=-1;
+ // New Items are always added before any system items which are by default kept at the end
+ if(objParent.SubItems.Count>0 && !newItem.SystemItem)
+ {
+ iPos=GetAppendPosition(objParent);
+ }
+ objParent.SubItems.Add(newItem,iPos);
+ }
+ else
+ {
+ itemNode=m_PopupsNode.Nodes.Add(GetTreeItemText(newItem));
+ m_DotNetBar.ContextMenus.Add(newItem);
+ }
+ }
+ else
+ {
+ Control cont=null;
+ if(barTree.SelectedNode.Tag is BaseItem)
+ {
+ //itemNode=barTree.SelectedNode.Parent.Nodes.Add(GetTreeItemText(newItem));
+ itemNode=barTree.SelectedNode.Nodes.Add(GetTreeItemText(newItem));
+ //BaseItem objParent=((BaseItem)barTree.SelectedNode.Tag).Parent;
+ BaseItem objParent=(BaseItem)barTree.SelectedNode.Tag;
+ int iPos=-1;
+ // New Items are always added before any system items which are by default kept at the end
+ if(objParent.SubItems.Count>0 && !newItem.SystemItem)
+ {
+ iPos=GetAppendPosition(objParent);
+ }
+ objParent.SubItems.Add(newItem,iPos);
+ cont=newItem.ContainerControl as Control;
+ if(cont==null)
+ ((BaseItem)barTree.SelectedNode.Tag).Refresh();
+
+ }
+ else if(barTree.SelectedNode.Tag is Bar)
+ {
+ itemNode=barTree.SelectedNode.Nodes.Add(GetTreeItemText(newItem));
+ Bar bar=(Bar)barTree.SelectedNode.Tag;
+ int iPos=-1;
+ // New Items are always added before any system items which are by default kept at the end
+ if(bar.Items.Count>0 && !newItem.SystemItem)
+ {
+ iPos=GetAppendPosition(bar.ItemsContainer);
+ }
+ bar.Items.Add(newItem,iPos);
+ cont=bar;
+ }
+ if(cont!=null && cont is Bar)
+ ((Bar)cont).RecalcLayout();
+ }
+
+ itemNode.Tag=newItem;
+ itemNode.ImageIndex=GetItemImageIndex(newItem);
+ itemNode.SelectedImageIndex=itemNode.ImageIndex;
+
+ itemNode.EnsureVisible();
+ barTree.SelectedNode=itemNode;
+ //itemNode.BeginEdit();
+ }
+
+ public void RescanCategories()
+ {
+ if(m_DotNetBar==null)
+ return;
+ if(m_DotNetBar.Bars.Count==0)
+ return;
+ m_DotNetBar.Items.Clear();
+ foreach(Bar bar in m_DotNetBar.Bars)
+ {
+ foreach(BaseItem item in bar.Items)
+ AutoCategorizeItem(item);
+ }
+ m_DataChanged=true;
+ RefreshView();
+ }
+
+ private void AutoCategorizeItem(BaseItem item)
+ {
+ if(item.Category!="" && item.Name!="" && !m_DotNetBar.Items.Contains(item.Name))
+ m_DotNetBar.Items.Add(item.Copy());
+ foreach(BaseItem i in item.SubItems)
+ AutoCategorizeItem(i);
+ }
+
+ private void MoveSelectedItem(string Direction)
+ {
+ if(barTree.SelectedNode==null)
+ return;
+ m_DataChanged=true;
+ BaseItem objItem=barTree.SelectedNode.Tag as BaseItem;
+ if(objItem==null)
+ return;
+
+ bool bCategoryItem=false;
+ if(barTree.SelectedNode.Parent==m_CategoriesNode)
+ bCategoryItem=true;
+
+ bool bPopupsItem=false;
+ if(barTree.SelectedNode.Parent==m_PopupsNode)
+ bPopupsItem=true;
+
+
+ TreeNode selNode=barTree.SelectedNode;
+ TreeNode parentNode=selNode.Parent;
+
+ BaseItem objParent=objItem.Parent;
+
+ int i=0;
+ if(objParent!=null)
+ i=objParent.SubItems.IndexOf(objItem);
+ else
+ i=selNode.Index;
+
+ if(Direction=="moveup" && i>0)
+ {
+ if(objParent!=null)
+ {
+ objParent.SubItems.Remove(objItem);
+ objParent.SubItems.Add(objItem,i-1);
+ if(objParent.ContainerControl is Bar)
+ ((Bar)objParent.ContainerControl).RecalcLayout();
+ }
+
+ i=selNode.Index;
+ selNode.Remove();
+ parentNode.Nodes.Insert(i-1,selNode);
+ barTree.SelectedNode=selNode;
+ selNode.EnsureVisible();
+ }
+ else if(Direction=="moveright" && i>0)
+ {
+ BaseItem objNewParent=null;
+
+ if(bCategoryItem)
+ m_DotNetBar.Items.Remove(objItem);
+ else if(bPopupsItem)
+ m_DotNetBar.ContextMenus.Remove(objItem);
+
+ if(objParent!=null)
+ {
+ objNewParent=objParent.SubItems[i-1];
+ objParent.SubItems.Remove(objItem);
+ if(objParent.ContainerControl is Bar)
+ ((Bar)objParent.ContainerControl).RecalcLayout();
+ }
+ else
+ {
+ objNewParent=selNode.PrevNode.Tag as BaseItem;
+ }
+ objNewParent.SubItems.Add(objItem,GetAppendPosition(objNewParent));
+ objNewParent.Refresh();
+ if(objNewParent.ContainerControl is Bar)
+ ((Bar)objNewParent.ContainerControl).RecalcLayout();
+
+ i=selNode.Index;
+ TreeNode newParent=selNode.PrevNode;
+ selNode.Remove();
+ newParent.Nodes.Add(selNode);
+ barTree.SelectedNode=selNode;
+ selNode.EnsureVisible();
+ }
+ else if(Direction=="movedown" && ((objParent!=null && i=0;i--)
+ {
+ if(objParent.SubItems[i].SystemItem)
+ iPos=i;
+ else
+ break;
+ }
+ return iPos;
+ }
+
+ private void OnPropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
+ {
+ m_DataChanged=true;
+ // If user changes the category of the item that is in categories we need to
+ // reflect that change and move item to the right category
+ TreeNode node=barTree.SelectedNode;
+ BaseItem item=node.Tag as BaseItem;
+
+ if(e.ChangedItem.PropertyDescriptor.Name=="Category" && e.ChangedItem.Value!=e.OldValue)
+ {
+ if(node.Tag==null || !(node.Tag is BaseItem))
+ return;
+ while(node.Parent!=null)
+ node=node.Parent;
+ if(node!=m_CategoriesNode)
+ return;
+
+ node=barTree.SelectedNode;
+ BaseItem objItem=node.Tag as BaseItem;
+ node.Remove();
+ node=CategorizeItem(objItem);
+ node.ImageIndex=GetItemImageIndex(objItem);
+ node.SelectedImageIndex=node.ImageIndex;
+ AddSubItems(objItem,node);
+ node.EnsureVisible();
+ barTree.SelectedNode=node;
+ }
+ else if(e.ChangedItem.PropertyDescriptor.Name=="Name" && e.ChangedItem.Value!=e.OldValue && !m_ShowItemText)
+ {
+ node.Text=(string)e.ChangedItem.Value;
+ }
+ else if(e.ChangedItem.PropertyDescriptor.Name=="Text" && e.ChangedItem.Value!=e.OldValue && m_ShowItemText)
+ {
+ node.Text=(string)e.ChangedItem.Value;
+ }
+ else if(e.ChangedItem.PropertyDescriptor.Name=="DockLine" || e.ChangedItem.PropertyDescriptor.Name=="DockOffset")
+ {
+ Bar bar=node.Tag as Bar;
+ if(bar!=null)
+ bar.RecalcLayout();
+ }
+
+ if(e.ChangedItem.PropertyDescriptor.Name=="Name" && m_DotNetBar!=null)
+ {
+ TreeNode parent=node;
+ while(parent.Parent!=null)
+ parent=parent.Parent;
+ if(parent==m_CategoriesNode)
+ {
+ if(m_DotNetBar.Items.Contains(e.ChangedItem.Value.ToString()))
+ {
+ item.Name=e.OldValue.ToString();
+ propertyGrid1.Refresh();
+ MessageBox.Show("Item with that name already exists.");
+ }
+ else
+ {
+ m_DotNetBar.Items.Remove(e.OldValue.ToString());
+ m_DotNetBar.Items.Add(item);
+ }
+ }
+ }
+
+ if(item!=null)
+ {
+ Bar barContainer=item.ContainerControl as Bar;
+ if(barContainer!=null)
+ barContainer.RecalcLayout();
+ }
+ }
+
+ private TreeNode CategorizeItem(BaseItem newItem)
+ {
+ // Assign item to category
+ if(newItem.Category=="")
+ newItem.Category="(Untitled)";
+
+ TreeNode parentNode=null;
+ if(m_catTable.ContainsKey(newItem.Category))
+ parentNode=m_catTable[newItem.Category] as TreeNode;
+ else
+ {
+ parentNode=m_CategoriesNode.Nodes.Add(newItem.Category);
+ parentNode.ImageIndex=5;
+ parentNode.SelectedImageIndex=5;
+ m_catTable.Add(newItem.Category,parentNode);
+ }
+
+ TreeNode newNode=parentNode.Nodes.Add(GetTreeItemText(newItem));
+ newNode.ImageIndex=GetItemImageIndex(newItem);
+ newNode.SelectedImageIndex=newNode.ImageIndex;
+ newNode.Tag=newItem;
+ return newNode;
+ }
+
+ private void CopyMoveToClick(object sender, System.EventArgs e)
+ {
+ BaseItem item=sender as BaseItem;
+ BaseItem itemSel=barTree.SelectedNode.Tag as BaseItem;
+ BaseItem itemOriginal=barTree.SelectedNode.Tag as BaseItem;
+
+ bool bMove=(item.Parent.Name=="moveto");
+ if(!bMove)
+ {
+ itemSel=itemSel.Copy();
+ if((Control.ModifierKeys & Keys.Control)==Keys.Control)
+ itemSel.Name=itemOriginal.Name;
+ else
+ itemSel.Name="item_"+itemSel.Id;
+ }
+
+ if((item.Tag is string && (string)item.Tag=="cat") || item.Name=="tocategories")
+ {
+ // To Categories
+ if(item.Name!="tocategories")
+ itemSel.Category=item.Text;
+ if(bMove)
+ {
+ if(itemSel.Parent!=null)
+ itemSel.Parent.SubItems.Remove(itemSel);
+ barTree.SelectedNode.Remove();
+ }
+ if(m_DotNetBar.Items.Contains(itemSel.Name))
+ {
+ string sDupName=itemSel.Name;
+ itemSel.Name="item_"+itemSel.Id;
+ MessageBox.Show("Item with name: '"+sDupName+"' already exists. Item that you are trying to move will be renamed.");
+ }
+ m_DotNetBar.Items.Add(itemSel);
+ barTree.SelectedNode=CategorizeItem(itemSel);
+ barTree.SelectedNode.EnsureVisible();
+ }
+ else if(item.Name=="topopups" || item.Tag is BaseItem)
+ {
+ if(bMove)
+ {
+ if(itemSel.Parent!=null)
+ itemSel.Parent.SubItems.Remove(itemSel);
+ barTree.SelectedNode.Remove();
+ }
+
+ if(item.Name=="topopups")
+ {
+ TreeNode itemNode=m_PopupsNode.Nodes.Add(GetTreeItemText(itemSel));
+ itemNode.Tag=itemSel;
+ itemNode.ImageIndex=GetItemImageIndex(itemSel);
+ itemNode.SelectedImageIndex=itemNode.ImageIndex;
+ AddSubItems(itemSel,itemNode);
+ m_DotNetBar.ContextMenus.Add(itemSel);
+ itemNode.EnsureVisible();
+ }
+ else
+ {
+ BaseItem objParent=item.Tag as BaseItem;
+ objParent.SubItems.Add(itemSel);
+ foreach(TreeNode node in m_PopupsNode.Nodes)
+ {
+ if(node.Tag==objParent)
+ {
+ TreeNode itemNode=node.Nodes.Add(GetTreeItemText(itemSel));
+ itemNode.Tag=itemSel;
+ itemNode.ImageIndex=GetItemImageIndex(itemSel);
+ itemNode.SelectedImageIndex=itemNode.ImageIndex;
+ AddSubItems(itemSel,itemNode);
+ itemNode.EnsureVisible();
+ break;
+ }
+ }
+ }
+ }
+ else if(item.Tag is TreeNode)
+ {
+ // To Bar
+ TreeNode barNode=item.Tag as TreeNode;
+ Bar bar=barNode.Tag as Bar;
+ if(bMove)
+ {
+ if(itemSel.Parent!=null)
+ itemSel.Parent.SubItems.Remove(itemSel);
+ barTree.SelectedNode.Remove();
+ }
+
+ bar.Items.Add(itemSel,GetAppendPosition(bar.ItemsContainer));
+ TreeNode itemNode=barNode.Nodes.Add(GetTreeItemText(itemSel));
+ itemNode.Tag=itemSel;
+ itemNode.ImageIndex=GetItemImageIndex(itemSel);
+ itemNode.SelectedImageIndex=itemNode.ImageIndex;
+ AddSubItems(itemSel,itemNode);
+ barTree.SelectedNode=itemNode;
+ barTree.SelectedNode.EnsureVisible();
+ bar.RecalcLayout();
+ }
+
+ // Clear Copy To and Move To
+ item=barManager.Items["popup"];
+ item.SubItems["copyto"].SubItems.Clear();
+ item.SubItems["moveto"].SubItems.Clear();
+ }
+
+ private void ItemEdited(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
+ {
+ if(e.CancelEdit)
+ return;
+
+ BaseItem objItem=e.Node.Tag as BaseItem;
+ if(m_ShowItemText)
+ objItem.Text=e.Label;
+ else
+ objItem.Name=e.Label;
+
+ propertyGrid1.Refresh();
+ m_DataChanged=true;
+ }
+
+ private string GetTreeItemText(BaseItem objItem)
+ {
+ if(objItem==null)
+ return "";
+
+ if(m_ShowItemText)
+ return objItem.Text;
+ else
+ return objItem.Name;
+ }
+
+ private int GetItemImageIndex(BaseItem objItem)
+ {
+ int index=0;
+ if(objItem is ButtonItem)
+ {
+ index=7;
+ }
+ else if(objItem is ComboBoxItem)
+ {
+ index=8;
+ }
+ else if(objItem is TextBoxItem)
+ {
+ index=9;
+ }
+ else if(objItem is CustomizeItem)
+ {
+ index=10;
+ }
+ else if(objItem is LabelItem)
+ {
+ index=11;
+ }
+ return index;
+ }
+
+ private void TreeKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
+ {
+ if(e.KeyCode==Keys.F2 && barTree.SelectedNode!=null && barTree.LabelEdit)
+ barTree.SelectedNode.BeginEdit();
+ }
+
+ private void GridViewMouseDown(object sender, EventArgs e)
+ {
+ if(propertyGrid1.SelectedGridItem==null)
+ return;
+ if(!(propertyGrid1.SelectedGridItem.PropertyDescriptor.PropertyType==typeof(System.Drawing.Image)))
+ return;
+ PopupItem popup=barManager.ContextMenus["resetimagepopup"] as PopupItem;
+ popup.PopupMenu(Control.MousePosition);
+ }
+
+ private void FormClosing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ m_GridViewSubclass.ReleaseHandle();
+ m_GridViewSubclass=null;
+
+ if(m_HtmlHelp!=null)
+ m_HtmlHelp.CloseHelpWindow();
+
+ // ColorScheme property when changed is not detected, so try to fix it here...
+ if(m_DotNetBar!=null)
+ {
+ foreach(Bar bar in m_DotNetBar.Bars)
+ {
+ if(bar.ColorScheme._DesignTimeSchemeChanged)
+ {
+ m_DataChanged=true;
+ bar.ColorScheme._DesignTimeSchemeChanged=false;
+ }
+ }
+ }
+ else if(m_Bar!=null)
+ {
+ if(m_Bar.ColorScheme._DesignTimeSchemeChanged)
+ {
+ m_DataChanged=true;
+ m_Bar.ColorScheme._DesignTimeSchemeChanged=false;
+ }
+ }
+
+
+ // Save form position
+ if(this.WindowState!=FormWindowState.Minimized)
+ {
+ string s="";
+ if(this.WindowState==FormWindowState.Maximized)
+ {
+ s="1";
+ }
+ else
+ {
+ s=this.DesktopLocation.X+","+this.DesktopLocation.Y+","+this.Width+","+this.Height;
+ }
+ try
+ {
+ Microsoft.Win32.RegistryKey key=Microsoft.Win32.Registry.CurrentUser;
+ key=key.CreateSubKey("Software\\DevComponents\\DotNetBar");
+ key.SetValue("DesignerPosition",s);
+ // Save Panel size
+ key.SetValue("DesignerPanelSize",barTree.Width);
+ key.Close();
+ }
+ catch(Exception)
+ {
+ }
+ }
+ }
+
+ private class GridViewSubclass:NativeWindow
+ {
+ public event EventHandler OnRightMouseDown;
+ protected override void WndProc(ref Message m)
+ {
+ if(m.Msg==NativeFunctions.WM_CONTEXTMENU)
+ {
+ if(OnRightMouseDown!=null)
+ OnRightMouseDown(this,new EventArgs());
+ return;
+ }
+ base.WndProc(ref m);
+ }
+ }
+
+ public bool DataChanged
+ {
+ get { return m_DataChanged;}
+ set { m_DataChanged=value;}
+ }
+
+ public DotNetBarManager FormBarManager
+ {
+ get
+ {
+ return barManager;
+ }
+ }
+
+ private void LoadResourceImages()
+ {
+ Image img=null;
+ try
+ {
+ m_BarImages.Images.Clear();
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.MoveItemLeft.bmp");
+ m_BarImages.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.MoveItemRight.bmp");
+ m_BarImages.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.MoveItemUp.bmp");
+ m_BarImages.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.MoveItemDown.bmp");
+ m_BarImages.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.FileOpen.bmp");
+ m_BarImages.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.FileSave.bmp");
+ m_BarImages.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.CreateItem.bmp");
+ m_BarImages.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.DeleteItem.bmp");
+ m_BarImages.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.RescanCategories.bmp");
+ m_BarImages.Images.Add(img,Color.Magenta);
+
+ imageList.Images.Clear();
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.Item.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.Toolbar.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.Toolbars.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.Toolbar.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.Item.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.Folder.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.FolderOpen.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.ButtonItem.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.ComboItem.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.TextBoxItem.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.CustomizeItem.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.LableItem.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+ img=new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager),"BarEditorImages.PopupMenu.bmp");
+ imageList.Images.Add(img,Color.Magenta);
+
+ }
+ catch(Exception e)
+ {
+ MessageBox.Show("Could not load resource images. Exception was thrown: "+e.ToString());
+ }
+ }
+
+ private object CreateObject(Type type)
+ {
+ if(_barDesigner!=null)
+ return _barDesigner.CreateComponent(type);
+ else
+ return type.Assembly.CreateInstance(type.FullName);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BarEditor.resx b/PROMS/DotNetBar Source Code/BarEditor.resx
new file mode 100644
index 00000000..af96e84f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BarEditor.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 419, 17
+
+
+ 518, 17
+
+
+ 298, 17
+
+
+ 17, 17
+
+
+ 159, 17
+
+
+ BarEditor
+
+
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/ButtonItem.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/ButtonItem.bmp
new file mode 100644
index 00000000..eff482aa
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/ButtonItem.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/ComboItem.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/ComboItem.bmp
new file mode 100644
index 00000000..4b9f807a
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/ComboItem.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/CreateItem.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/CreateItem.bmp
new file mode 100644
index 00000000..6eb00f55
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/CreateItem.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/CustomizeItem.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/CustomizeItem.bmp
new file mode 100644
index 00000000..c5b6aa58
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/CustomizeItem.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/DeleteItem.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/DeleteItem.bmp
new file mode 100644
index 00000000..96d9e054
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/DeleteItem.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/FileClose.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/FileClose.bmp
new file mode 100644
index 00000000..d51e2df4
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/FileClose.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/FileCloseSol.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/FileCloseSol.bmp
new file mode 100644
index 00000000..0d540644
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/FileCloseSol.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/FileNew.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/FileNew.bmp
new file mode 100644
index 00000000..318ff541
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/FileNew.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/FileOpen.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/FileOpen.bmp
new file mode 100644
index 00000000..520b24c4
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/FileOpen.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/FileOpenSol.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/FileOpenSol.bmp
new file mode 100644
index 00000000..47d0de66
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/FileOpenSol.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/FileSave.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/FileSave.bmp
new file mode 100644
index 00000000..9a43d0e2
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/FileSave.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/Folder.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/Folder.bmp
new file mode 100644
index 00000000..e469bcc4
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/Folder.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/FolderOpen.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/FolderOpen.bmp
new file mode 100644
index 00000000..6a24e1fb
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/FolderOpen.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/Item.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/Item.bmp
new file mode 100644
index 00000000..e0c64c5f
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/Item.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/LableItem.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/LableItem.bmp
new file mode 100644
index 00000000..4d5ca551
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/LableItem.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemDown.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemDown.bmp
new file mode 100644
index 00000000..15adffd9
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemDown.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemLeft.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemLeft.bmp
new file mode 100644
index 00000000..20c9c53e
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemLeft.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemRight.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemRight.bmp
new file mode 100644
index 00000000..74574131
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemRight.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemUp.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemUp.bmp
new file mode 100644
index 00000000..fbf0c715
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/MoveItemUp.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/PopupMenu.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/PopupMenu.bmp
new file mode 100644
index 00000000..c3ebaf4d
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/PopupMenu.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/RescanCategories.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/RescanCategories.bmp
new file mode 100644
index 00000000..75412cdf
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/RescanCategories.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/TextBoxItem.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/TextBoxItem.bmp
new file mode 100644
index 00000000..b5896f4f
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/TextBoxItem.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/Toolbar.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/Toolbar.bmp
new file mode 100644
index 00000000..4d56068c
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/Toolbar.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarEditorImages/Toolbars.bmp b/PROMS/DotNetBar Source Code/BarEditorImages/Toolbars.bmp
new file mode 100644
index 00000000..4630ed96
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BarEditorImages/Toolbars.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BarFunctions.cs b/PROMS/DotNetBar Source Code/BarFunctions.cs
new file mode 100644
index 00000000..081a4c02
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BarFunctions.cs
@@ -0,0 +1,2363 @@
+using System;
+using System.Drawing;
+using System.Reflection;
+using System.Xml;
+using System.Resources;
+using System.Collections;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Drawing.Drawing2D;
+using System.IO;
+using System.Collections.Generic;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for BarFunctions.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public sealed class BarFunctions
+ {
+ public const int ANIMATION_INTERVAL = 100;
+
+ private static string ms_ResourceName = "";
+ const string DEFAULT_RESOURCE = ".Strings";
+ private static bool m_ThemedOS = false;
+ private static bool m_IsVista = false;
+ private static bool _IsWindows7 = false;
+ private static bool _IsWindows8 = false;
+ private static bool _IsWindows10 = false;
+ private static bool m_SupportsAnimation = true;
+ private static bool _IsWindowsXP = false;
+
+ static BarFunctions()
+ {
+
+ m_ThemedOS = false;
+
+ NativeFunctions.OSVERSIONINFO os = new NativeFunctions.OSVERSIONINFO();
+ os.dwOSVersionInfoSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(NativeFunctions.OSVERSIONINFO));
+ NativeFunctions.GetVersionEx(ref os);
+ if (os.dwPlatformId == 2 && os.dwMajorVersion == 4)
+ m_SupportsAnimation = false;
+ if (os.dwMajorVersion == 5 && os.dwMinorVersion >= 1 && os.dwPlatformId == 2 ||
+ os.dwMajorVersion > 5 && os.dwPlatformId == 2)
+ m_ThemedOS = System.Windows.Forms.OSFeature.Feature.IsPresent(System.Windows.Forms.OSFeature.Themes);
+ Version osVersion = System.Environment.OSVersion.Version;
+ _IsWindowsXP = osVersion.Major <= 5;
+ m_IsVista = osVersion.Major >= 6;
+ _IsWindows7 = (osVersion.Major == 6 && osVersion.Minor >= 1 || osVersion.Major>6) && osVersion.Build >= 7000;
+ _IsWindows8 = (osVersion.Major == 6 && osVersion.Minor >= 2 || osVersion.Major > 6) && osVersion.Build >= 9200;
+ _IsWindows10 = (osVersion.Major == 6 && osVersion.Minor >= 3 || osVersion.Major > 6) && osVersion.Build >= 9600;
+ RefreshScreens();
+ }
+
+ private static Size _Windows10CaptionButtonSize = new Size(46, 28);
+ public static Size CaptionButtonSize
+ {
+ get
+ {
+ if (_IsWindows10)
+ return Dpi.Size(_Windows10CaptionButtonSize);
+ else
+ return SystemInformation.CaptionButtonSize;
+ }
+ }
+
+ public static Size Windows10CaptionButtonSize
+ {
+ get { return _Windows10CaptionButtonSize; }
+ set { _Windows10CaptionButtonSize = value; }
+ }
+
+ public static bool IsWindowsXP
+ {
+ get
+ {
+ return _IsWindowsXP;
+ }
+ }
+
+ public static bool IsVista
+ {
+ get { return m_IsVista; }
+ }
+ public static bool IsWindows7
+ {
+ get
+ {
+ return _IsWindows7;
+ }
+ }
+
+ public static bool IsWindows8
+ {
+ get
+ {
+ return _IsWindows8;
+ }
+ }
+
+ public static bool IsWindows10
+ {
+ get
+ {
+ return _IsWindows10;
+ }
+ }
+
+ internal static char GetCharForKeyValue(int keyValue)
+ {
+ byte[] chars = new byte[2];
+ try
+ {
+ byte[] keyState = new byte[256];
+ if (NativeFunctions.GetKeyboardState(keyState))
+ {
+ if (NativeFunctions.ToAscii((uint)keyValue, 0, keyState, chars, 0) != 0)
+ {
+ return (char)chars[0];
+ }
+ }
+ }
+ catch (Exception)
+ {
+ return char.MinValue;
+ }
+
+ return char.MinValue;
+ }
+
+ public static Color Darken(Color color, int percent)
+ {
+ ColorFunctions.HLSColor h = ColorFunctions.RGBToHSL(color.R, color.G, color.B);
+ h.Lightness *= (double)(100 - percent) / 100;
+ return ColorFunctions.HLSToRGB(h);
+ }
+
+ public static Color Ligten(Color color, int percent)
+ {
+ ColorFunctions.HLSColor h = ColorFunctions.RGBToHSL(color.R, color.G, color.B);
+ h.Lightness *= (1 + (double)percent / 100);
+ return ColorFunctions.HLSToRGB(h);
+ }
+
+ ///
+ /// Tries to invoke the RecalcLayout method on the control and return true if such method was invoked.
+ ///
+ /// Reference to the control
+ /// Indicates whether to invalidate control if no recalc layout method is found
+ /// return true if method is invoked.
+ public static bool InvokeRecalcLayout(Control c, bool invalidate)
+ {
+ if (c is ItemControl)
+ {
+ ((ItemControl)c).RecalcLayout();
+ return true;
+ }
+ else if (c is Bar)
+ {
+ ((Bar)c).RecalcLayout();
+ return true;
+ }
+ else if (c is ExplorerBar)
+ {
+ ((ExplorerBar)c).RecalcLayout();
+ return true;
+ }
+ else if (c is BaseItemControl)
+ {
+ ((BaseItemControl)c).RecalcLayout();
+ return true;
+ }
+ else if (c is BarBaseControl)
+ {
+ ((BarBaseControl)c).RecalcLayout();
+ return true;
+ }
+ else if (c is PopupItemControl)
+ {
+ ((PopupItemControl)c).RecalcLayout();
+ return true;
+ }
+
+
+
+ MethodInfo m = c.GetType().GetMethod("RecalcLayout");
+
+ if (m != null)
+ {
+ m.Invoke(c, null);
+ return true;
+ }
+ else if (invalidate)
+ {
+ c.Invalidate(true);
+ c.Update();
+ }
+ return false;
+ }
+
+ public static bool ThemedOS
+ {
+ get { return m_ThemedOS; }
+ set { m_ThemedOS = value; }
+ }
+
+ public static StringFormat CreateStringFormat()
+ {
+ StringFormat sf = new StringFormat();
+ sf.Alignment = StringAlignment.Near;
+ sf.LineAlignment = StringAlignment.Near;
+ sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
+ sf.Trimming = StringTrimming.Character;
+ return sf;
+ //return new StringFormat(StringFormat.GenericDefault);
+ }
+
+ public static void SetControlVisible(Control c, bool visible)
+ {
+ if (visible)
+ {
+ int indexZOrder = -1;
+ if (c.Parent != null && c.Dock != DockStyle.None) indexZOrder = c.Parent.Controls.IndexOf(c);
+ c.Visible = true;
+ if (indexZOrder != -1) c.Parent.Controls.SetChildIndex(c, indexZOrder);
+ }
+ else
+ c.Visible = false;
+ }
+
+ public static bool ProcessItemsShortcuts(eShortcut key, Hashtable itemsShortcuts)
+ {
+ bool eat = false;
+ if (itemsShortcuts.Contains(key))
+ {
+ ShortcutTableEntry objEntry = (ShortcutTableEntry)itemsShortcuts[key];
+ // Must convert to new array, since if this is for example
+ // close command first Click will destroy the collection we are
+ // iterating through and exception will be raised.
+ BaseItem[] arr = new BaseItem[objEntry.Items.Values.Count];
+ objEntry.Items.Values.CopyTo(arr, 0);
+ Hashtable hnames = new Hashtable(arr.Length);
+ foreach (BaseItem objItem in arr)
+ {
+ if (objItem.CanRaiseClick && (objItem.Name == "" || !hnames.Contains(objItem.Name)))
+ {
+ if (!objItem.GlobalItem || objItem.GlobalName == "" || !hnames.Contains(objItem.GlobalName))
+ {
+ eat = true;
+ objItem.RaiseClick(eEventSource.Keyboard);
+ if (objItem.Name != "")
+ {
+ hnames.Add(objItem.Name, "");
+ }
+ if (objItem.GlobalItem && objItem.GlobalName != "" && objItem.GlobalName != objItem.Name && !hnames.Contains(objItem.GlobalName))
+ hnames.Add(objItem.GlobalName, "");
+ }
+ }
+ }
+ }
+ return eat;
+ }
+
+ ///
+ /// Creates copy of a bar to be used as new dock bar. This function is used to create new bar for tabs that are torn off the existing dock bars.
+ ///
+ /// Original base bar to base the new bar on.
+ /// New instance of a bar. Note that bar is not added to the DotNetBarManager.Bars collection and DockSide is not set.
+ public static Bar CreateDuplicateDockBar(Bar instance)
+ {
+ // Create new Bar and invoke the drag there
+ Bar bar = new Bar(instance.Text);
+ return CreateDuplicateDockBar(instance, bar);
+ }
+
+ /////
+ ///// Creates copy of a bar to be used as new dock bar. This function is used to create new bar for tabs that are torn off the existing dock bars.
+ /////
+ ///// Original base bar to base the new bar on.
+ ///// IDesignerServices to use for creation of the new instance of the object.
+ ///// New instance of a bar. Note that bar is not added to the DotNetBarManager.Bars collection and DockSide is not set.
+ //public static Bar CreateDuplicateDockBar(Bar instance, IDesignerServices services)
+ //{
+ // Bar bar = services.CreateComponent(typeof(Bar)) as Bar;
+ // return CreateDuplicateDockBar(instance, bar);
+ //}
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Bar CreateDuplicateDockBar(Bar instance, Bar bar)
+ {
+ bar.Text = instance.Text;
+ bar.ItemsContainer.MinHeight = instance.MinHeight;
+ bar.ItemsContainer.MinWidth = instance.ItemsContainer.MinWidth;
+ bar.CanDockBottom = instance.CanDockBottom;
+ bar.CanDockLeft = instance.CanDockLeft;
+ bar.CanDockRight = instance.CanDockRight;
+ bar.CanDockTop = instance.CanDockTop;
+ bar.CanDockDocument = instance.CanDockDocument;
+ bar.CanDockTab = instance.CanDockTab;
+ bar.CanUndock = instance.CanUndock;
+ bar.CanMaximizeFloating = instance.CanMaximizeFloating;
+ bar.CanAutoHide = instance.CanAutoHide;
+ bar.DockTabAlignment = instance.DockTabAlignment;
+ bar.CanCustomize = instance.CanCustomize;
+ bar.AutoHideAnimationTime = instance.AutoHideAnimationTime;
+ bar.AlwaysDisplayDockTab = instance.AlwaysDisplayDockTab;
+ bar.AutoCreateCaptionMenu = instance.AutoCreateCaptionMenu;
+ bar.AutoSyncBarCaption = instance.AutoSyncBarCaption;
+ bar.HideFloatingInactive = instance.HideFloatingInactive;
+ bar.CloseSingleTab = instance.CloseSingleTab;
+ bar.DockTabCloseButtonVisible = instance.DockTabCloseButtonVisible;
+ bar.CaptionHeight = instance.CaptionHeight;
+ bar.TabNavigation = instance.TabNavigation;
+
+ if (!instance.CaptionBackColor.IsEmpty)
+ bar.CaptionBackColor = instance.CaptionBackColor;
+ if (!instance.CaptionForeColor.IsEmpty)
+ bar.CaptionForeColor = instance.CaptionForeColor;
+ if (!instance.ItemsContainer.m_BackgroundColor.IsEmpty)
+ bar.ItemsContainer.BackColor = instance.ItemsContainer.m_BackgroundColor;
+ if (instance.DockedBorderStyle != eBorderType.None)
+ bar.DockedBorderStyle = instance.DockedBorderStyle;
+
+ bar.Style = instance.Style;
+
+ if (instance.ColorScheme.SchemeChanged)
+ bar.ColorScheme = instance.ColorScheme;
+
+ bar.LayoutType = instance.LayoutType;
+ bar.GrabHandleStyle = instance.GrabHandleStyle;
+ bar.Stretch = instance.Stretch;
+ bar.CanHide = instance.CanHide;
+ bar.ThemeAware = instance.ThemeAware;
+ bar.DockedBorderStyle = instance.DockedBorderStyle;
+
+ return bar;
+ }
+
+ public static void ApplyAutoDocumentBarStyle(Bar bar)
+ {
+ bar.SetDockTabStyle(bar.Style);
+ bar.TabNavigation = true;
+ if (!bar.AlwaysDisplayDockTab)
+ bar.AlwaysDisplayDockTab = true;
+ if (bar.DockTabAlignment != eTabStripAlignment.Top)
+ bar.DockTabAlignment = eTabStripAlignment.Top;
+ if (bar.GrabHandleStyle != eGrabHandleStyle.None)
+ bar.GrabHandleStyle = eGrabHandleStyle.None;
+ }
+
+ public static void RestoreAutoDocumentBarStyle(Bar bar)
+ {
+ bar.SetDockTabStyle(bar.Style);
+ if (bar.AlwaysDisplayDockTab)
+ bar.AlwaysDisplayDockTab = false;
+ if (bar.DockTabAlignment != eTabStripAlignment.Bottom)
+ bar.DockTabAlignment = eTabStripAlignment.Bottom;
+ if (bar.GrabHandleStyle != eGrabHandleStyle.Caption)
+ bar.GrabHandleStyle = eGrabHandleStyle.Caption;
+ }
+
+ ///
+ /// Returns if passed control is ready for painting.
+ ///
+ /// Control to test.
+ /// true if handle is valid otherwise false
+ public static bool IsHandleValid(System.Windows.Forms.Control objCtrl)
+ {
+ return (objCtrl != null && !objCtrl.Disposing && !objCtrl.IsDisposed && objCtrl.IsHandleCreated);
+ }
+
+ public static void DrawMenuCheckBox(ItemPaintArgs pa, System.Drawing.Rectangle r, eDotNetBarStyle style, bool MouseOver)
+ {
+ System.Drawing.Graphics g = pa.Graphics;
+ Color clr;
+ if (style != eDotNetBarStyle.Office2000)
+ {
+ if (MouseOver)
+ {
+ //clr=g.GetNearestColor(Color.FromArgb(45,SystemColors.Highlight));
+ //SolidBrush objBrush=new SolidBrush(clr);
+ //g.FillRectangle(objBrush,r);
+ //objBrush.Dispose();
+ }
+ else
+ {
+ //clr=g.GetNearestColor(Color.FromArgb(96,ColorFunctions.HoverBackColor()));
+ clr = pa.Colors.ItemCheckedBackground; //ColorFunctions.CheckBoxBackColor(g);
+ SolidBrush objBrush = new SolidBrush(clr);
+ g.FillRectangle(objBrush, r);
+ objBrush.Dispose();
+ }
+ //clr=g.GetNearestColor(Color.FromArgb(200,SystemColors.Highlight));
+ clr = pa.Colors.ItemCheckedBorder; // SystemColors.Highlight;
+ Pen objPen = new Pen(clr, 1);
+ // TODO: Beta 2 fix --> g.DrawRectangle(objPen,r);
+ NativeFunctions.DrawRectangle(g, objPen, r);
+ objPen.Dispose();
+ // Draw checker...
+ Point[] pt = new Point[3];
+ pt[0].X = r.Left + (r.Width - 5) / 2 - 1;
+ pt[0].Y = r.Top + (r.Height - 6) / 2 + 3;
+ pt[1].X = pt[0].X + 2;
+ pt[1].Y = pt[0].Y + 2;
+ pt[2].X = pt[1].X + 4;
+ pt[2].Y = pt[1].Y - 4;
+ objPen = new Pen(pa.Colors.ItemCheckedText);
+ g.DrawLines(objPen, pt);
+ pt[0].X++;
+ pt[1].X++;
+ pt[2].X++;
+ g.DrawLines(objPen, pt);
+ objPen.Dispose();
+ }
+ else if (style == eDotNetBarStyle.Office2000)
+ {
+ // Draw checked box
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.SunkenOuter, System.Windows.Forms.Border3DSide.All);
+ if (!MouseOver)
+ {
+ r.Inflate(-1, -1);
+ g.FillRectangle(ColorFunctions.GetPushedBrush(), r);
+ }
+ // Draw checker...
+ Point[] pt = new Point[3];
+ pt[0].X = r.Left + (r.Width - 6) / 2;
+ pt[0].Y = r.Top + (r.Height - 6) / 2 + 3;
+ pt[1].X = pt[0].X + 2;
+ pt[1].Y = pt[0].Y + 2;
+ pt[2].X = pt[1].X + 4;
+ pt[2].Y = pt[1].Y - 4;
+ g.DrawLines(SystemPens.ControlText, pt);
+ pt[0].X++;
+ pt[1].X++;
+ pt[2].X++;
+ g.DrawLines(SystemPens.ControlText, pt);
+ }
+ }
+
+ public static void SerializeImage(System.Drawing.Image image, XmlElement xml)
+ {
+ if (image == null)
+ return;
+
+ System.IO.MemoryStream mem = new System.IO.MemoryStream(1024);
+ // TODO: Beta 2 issue with the ImageFormat. RawFormat on image object does not return the actual image format
+ // Right now it is hard coded to PNG but in final version we should get the original image format
+ image.Save(mem, System.Drawing.Imaging.ImageFormat.Png);
+
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ System.IO.StringWriter sw = new System.IO.StringWriter(sb);
+
+ System.Xml.XmlTextWriter xt = new System.Xml.XmlTextWriter(sw);
+ xt.WriteBase64(mem.GetBuffer(), 0, (int)mem.Length);
+
+ xml.InnerText = sb.ToString();
+ }
+
+ public static void SerializeIcon(System.Drawing.Icon icon, XmlElement xml)
+ {
+ if (icon == null)
+ return;
+
+ System.IO.MemoryStream mem = new System.IO.MemoryStream(1024);
+ // TODO: Beta 2 issue with the ImageFormat. RawFormat on image object does not return the actual image format
+ // Right now it is hard coded to PNG but in final version we should get the original image format
+ icon.Save(mem);
+
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ System.IO.StringWriter sw = new System.IO.StringWriter(sb);
+
+ System.Xml.XmlTextWriter xt = new System.Xml.XmlTextWriter(sw);
+
+ xml.SetAttribute("encoding", "binhex");
+ //xt.WriteBase64(mem.GetBuffer(),0,(int)mem.Length);
+ xt.WriteBinHex(mem.GetBuffer(), 0, (int)mem.Length);
+
+ xml.InnerText = sb.ToString();
+ }
+
+ public static System.Windows.Forms.Form CreateOutlineForm()
+ {
+ System.Windows.Forms.Form form = new System.Windows.Forms.Form();
+ try
+ {
+ form.Size = new Size(0, 0);
+ }
+ catch
+ {
+ form = new System.Windows.Forms.Form();
+ }
+ form.BackColor = SystemColors.Highlight;
+ form.MinimizeBox = false;
+ form.MaximizeBox = false;
+ form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ if (NativeFunctions.AlphaBlendingSupported)
+ form.Opacity = .5;
+ else
+ form.BackColor = System.Windows.Forms.ControlPaint.LightLight(SystemColors.Highlight);
+ form.ShowInTaskbar = false;
+ form.Text = "";
+ form.CreateControl();
+ return form;
+ }
+
+ public static System.Windows.Forms.Form CreateTransparentOutlineForm()
+ {
+ System.Windows.Forms.Form form = new TransparentForm();
+ try
+ {
+ form.Size = new Size(0, 0);
+ }
+ catch
+ {
+ form = new TransparentForm();
+ }
+ form.BackColor = SystemColors.Highlight;
+ form.MinimizeBox = false;
+ form.MaximizeBox = false;
+ form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ if (NativeFunctions.AlphaBlendingSupported)
+ form.Opacity = .5;
+ else
+ form.BackColor = System.Windows.Forms.ControlPaint.LightLight(SystemColors.Highlight);
+ form.ShowInTaskbar = false;
+ form.Text = "";
+ form.CreateControl();
+ return form;
+ }
+
+ private class TransparentForm : Form
+ {
+ protected override void WndProc(ref Message m)
+ {
+ if (m.Msg == (int)WinApi.WindowsMessages.WM_NCHITTEST)
+ {
+ m.Result = new IntPtr((int)WinApi.WindowHitTestRegions.TransparentOrCovered);
+ return;
+ }
+ base.WndProc(ref m);
+ }
+ }
+
+ ///
+ /// XML element is expected to be something like Image data Base64 encoded
+ ///
+ /// Image data
+ ///
+ public static System.Drawing.Image DeserializeImage(XmlElement xml)
+ {
+ System.Drawing.Image img = null;
+ if (xml == null || xml.InnerText == "")
+ return null;
+
+ System.IO.StringReader sr = new System.IO.StringReader(xml.OuterXml);
+ System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(sr);
+ System.IO.MemoryStream mem = new System.IO.MemoryStream(1024);
+ // Skip to data
+ xr.Read();
+
+ byte[] base64 = new byte[1024];
+ int base64len = 0;
+ do
+ {
+ base64len = xr.ReadBase64(base64, 0, 1024);
+ if (base64len > 0)
+ mem.Write(base64, 0, base64len);
+
+ } while (base64len != 0);
+
+ img = System.Drawing.Image.FromStream(mem);
+
+ return img;
+ }
+
+ public static System.Drawing.Icon DeserializeIcon(XmlElement xml)
+ {
+ System.Drawing.Icon img = null;
+ if (xml == null || xml.InnerText == "")
+ return null;
+ bool bDecodeBinHex = false;
+ if (xml.HasAttribute("encoding") && xml.GetAttribute("encoding") == "binhex")
+ bDecodeBinHex = true;
+ System.IO.StringReader sr = new System.IO.StringReader(xml.OuterXml);
+ System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(sr);
+ System.IO.MemoryStream mem = new System.IO.MemoryStream(1024);
+ // Skip to data
+ xr.Read();
+
+ byte[] base64 = new byte[1024];
+ int base64len = 0;
+ if (bDecodeBinHex)
+ {
+ do
+ {
+ base64len = xr.ReadBinHex(base64, 0, 1024);
+ if (base64len > 0)
+ mem.Write(base64, 0, base64len);
+
+ } while (base64len != 0);
+ }
+ else
+ {
+ do
+ {
+ base64len = xr.ReadBase64(base64, 0, 1024);
+ if (base64len > 0)
+ mem.Write(base64, 0, base64len);
+
+ } while (base64len != 0);
+ }
+ mem.Position = 0;
+ img = new System.Drawing.Icon(mem);
+
+ return img;
+ }
+
+ internal static BaseItem CreateItemFromXml(System.Xml.XmlElement xmlItem)
+ {
+ string cl = xmlItem.GetAttribute("class");
+ BaseItem returnItem = null;
+ switch (cl)
+ {
+ case "DevComponents.DotNetBar.ButtonItem":
+ returnItem = new ButtonItem();
+ break;
+ case "DevComponents.DotNetBar.TextBoxItem":
+ returnItem = new TextBoxItem();
+ break;
+ case "DevComponents.DotNetBar.ComboBoxItem":
+ returnItem = new ComboBoxItem();
+ break;
+ case "DevComponents.DotNetBar.LabelItem":
+ returnItem = new LabelItem();
+ break;
+ case "DevComponents.DotNetBar.CustomizeItem":
+ returnItem = new CustomizeItem();
+ break;
+ case "DevComponents.DotNetBar.ControlContainerItem":
+ returnItem = new ControlContainerItem();
+ break;
+ case "DevComponents.DotNetBar.DockContainerItem":
+ returnItem = new DockContainerItem();
+ break;
+ case "DevComponents.DotNetBar.MdiWindowListItem":
+ returnItem = new MdiWindowListItem();
+ break;
+ case "DevComponents.DotNetBar.SideBarContainerItem":
+ returnItem = new SideBarContainerItem();
+ break;
+ case "DevComponents.DotNetBar.SideBarPanelItem":
+ returnItem = new SideBarPanelItem();
+ break;
+ case "DevComponents.DotNetBar.ExplorerBarGroupItem":
+ returnItem = new ExplorerBarGroupItem();
+ break;
+ case "DevComponents.DotNetBar.ExplorerBarContainerItem":
+ returnItem = new ExplorerBarContainerItem();
+ break;
+ case "DevComponents.DotNetBar.ProgressBarItem":
+ returnItem = new ProgressBarItem();
+ break;
+ case "DevComponents.DotNetBar.ColorPickerDropDown":
+ returnItem = new ColorPickerDropDown();
+ break;
+ default:
+ {
+ try
+ {
+ //System.Windows.Forms.MessageBox.Show("Loading custom: "+xmlItem.GetAttribute("assembly")+" "+xmlItem.GetAttribute("class"));
+ System.Reflection.Assembly a = System.Reflection.Assembly.Load(xmlItem.GetAttribute("assembly"));
+ if (a == null)
+ return null;
+ BaseItem item = a.CreateInstance(xmlItem.GetAttribute("class")) as BaseItem;
+ returnItem = item;
+ }
+ catch (Exception e)
+ {
+ throw new ArgumentException("Could not create item from XML. Assembly=" + xmlItem.GetAttribute("assembly") + ", Class=" + xmlItem.GetAttribute("class") + ", Inner Exception: " + e.Message + ", Source=" + e.Source);
+ }
+ break;
+ }
+ }
+ return returnItem;
+ }
+
+ internal static BaseItem CreateItemFromXml(System.Xml.XmlElement xmlItem, System.ComponentModel.Design.IDesignerHost dh, string name)
+ {
+ string cl = xmlItem.GetAttribute("class");
+ BaseItem returnItem = null;
+ switch (cl)
+ {
+ case "DevComponents.DotNetBar.ButtonItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(ButtonItem), name) as ButtonItem;
+ else
+ returnItem = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
+ break;
+ case "DevComponents.DotNetBar.TextBoxItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(TextBoxItem), name) as TextBoxItem;
+ else
+ returnItem = dh.CreateComponent(typeof(TextBoxItem)) as TextBoxItem;
+ break;
+ case "DevComponents.DotNetBar.ComboBoxItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(ComboBoxItem), name) as ComboBoxItem;
+ else
+ returnItem = dh.CreateComponent(typeof(ComboBoxItem)) as ComboBoxItem;
+ break;
+ case "DevComponents.DotNetBar.LabelItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(LabelItem), name) as LabelItem;
+ else
+ returnItem = dh.CreateComponent(typeof(LabelItem)) as LabelItem;
+ break;
+ case "DevComponents.DotNetBar.CustomizeItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(CustomizeItem), name) as CustomizeItem;
+ else
+ returnItem = dh.CreateComponent(typeof(CustomizeItem)) as CustomizeItem;
+ break;
+ case "DevComponents.DotNetBar.ControlContainerItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(ControlContainerItem), name) as ControlContainerItem;
+ else
+ returnItem = dh.CreateComponent(typeof(ControlContainerItem)) as ControlContainerItem;
+ break;
+ case "DevComponents.DotNetBar.DockContainerItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(DockContainerItem), name) as DockContainerItem;
+ else
+ returnItem = dh.CreateComponent(typeof(DockContainerItem)) as DockContainerItem;
+ break;
+ case "DevComponents.DotNetBar.MdiWindowListItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(MdiWindowListItem), name) as MdiWindowListItem;
+ else
+ returnItem = dh.CreateComponent(typeof(MdiWindowListItem)) as MdiWindowListItem;
+ break;
+ case "DevComponents.DotNetBar.SideBarContainerItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(SideBarContainerItem), name) as SideBarContainerItem;
+ else
+ returnItem = dh.CreateComponent(typeof(SideBarContainerItem)) as SideBarContainerItem;
+ break;
+ case "DevComponents.DotNetBar.SideBarPanelItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(SideBarPanelItem), name) as SideBarPanelItem;
+ else
+ returnItem = dh.CreateComponent(typeof(SideBarPanelItem)) as SideBarPanelItem;
+ break;
+ case "DevComponents.DotNetBar.ExplorerBarGroupItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(ExplorerBarGroupItem), name) as ExplorerBarGroupItem;
+ else
+ returnItem = dh.CreateComponent(typeof(ExplorerBarGroupItem)) as ExplorerBarGroupItem;
+ break;
+ case "DevComponents.DotNetBar.ExplorerBarContainerItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(ExplorerBarContainerItem), name) as ExplorerBarContainerItem;
+ else
+ returnItem = dh.CreateComponent(typeof(ExplorerBarContainerItem)) as ExplorerBarContainerItem;
+ break;
+ case "DevComponents.DotNetBar.ProgressBarItem":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(ProgressBarItem), name) as ProgressBarItem;
+ else
+ returnItem = dh.CreateComponent(typeof(ProgressBarItem)) as ProgressBarItem;
+ break;
+ case "DevComponents.DotNetBar.ColorPickerDropDown":
+ if (name != "")
+ returnItem = dh.CreateComponent(typeof(ColorPickerDropDown), name) as ColorPickerDropDown;
+ else
+ returnItem = dh.CreateComponent(typeof(ColorPickerDropDown)) as ColorPickerDropDown;
+ break;
+ default:
+ {
+ try
+ {
+ //System.Windows.Forms.MessageBox.Show("Loading custom: "+xmlItem.GetAttribute("assembly")+" "+xmlItem.GetAttribute("class"));
+ System.Reflection.Assembly a = System.Reflection.Assembly.Load(xmlItem.GetAttribute("assembly"));
+ if (a == null)
+ return null;
+ BaseItem item = a.CreateInstance(xmlItem.GetAttribute("class")) as BaseItem;
+ returnItem = dh.CreateComponent(item.GetType()) as BaseItem;
+ }
+ catch (Exception e)
+ {
+ throw new ArgumentException("Could not create item from XML. Assembly=" + xmlItem.GetAttribute("assembly") + ", Class=" + xmlItem.GetAttribute("class") + ", Inner Exception: " + e.Message + ", Source=" + e.Source);
+ }
+ break;
+ }
+ }
+ return returnItem;
+ }
+
+ internal static string GetItemErrorInfo(System.Xml.XmlElement xmlItem)
+ {
+ string s = "";
+ if (xmlItem.HasAttribute("assembly"))
+ s = s + xmlItem.GetAttribute("assembly");
+ if (xmlItem.HasAttribute("class"))
+ s = s + xmlItem.GetAttribute("class");
+ return s;
+ }
+
+ internal static void PaintSystemButton(System.Drawing.Graphics g, SystemButton btn, Rectangle r, bool MouseDown, bool MouseOver, bool Disabled)
+ {
+ // Draw state if any
+ if (MouseDown)
+ {
+ g.FillRectangle(new SolidBrush(ColorFunctions.PressedBackColor(g)), r);
+ NativeFunctions.DrawRectangle(g, SystemPens.Highlight, r);
+ }
+ else if (MouseOver)
+ {
+ g.FillRectangle(new SolidBrush(ColorFunctions.HoverBackColor(g)), r);
+ NativeFunctions.DrawRectangle(g, SystemPens.Highlight, r);
+ }
+
+ Bitmap bmp = new Bitmap(r.Width, r.Height, g);
+ Graphics gBmp = Graphics.FromImage(bmp);
+ Rectangle rBtn = new Rectangle(0, 0, r.Width, r.Height);
+ rBtn.Inflate(0, -1);
+ Rectangle rClip = rBtn;
+ rClip.Inflate(-1, -1);
+ using (SolidBrush brush = new SolidBrush(SystemColors.Control))
+ gBmp.FillRectangle(brush, 0, 0, r.Width, r.Height);
+ gBmp.SetClip(rClip);
+ System.Windows.Forms.ControlPaint.DrawCaptionButton(gBmp, rBtn, (System.Windows.Forms.CaptionButton)btn, System.Windows.Forms.ButtonState.Flat);
+ gBmp.ResetClip();
+ gBmp.Dispose();
+
+ bmp.MakeTransparent(SystemColors.Control);
+ if (Disabled)
+ {
+ float[][] array = new float[5][];
+ array[0] = new float[5] { 0, 0, 0, 0, 0 };
+ array[1] = new float[5] { 0, 0, 0, 0, 0 };
+ array[2] = new float[5] { 0, 0, 0, 0, 0 };
+ array[3] = new float[5] { .5f, .5f, .5f, .5f, 0 };
+ array[4] = new float[5] { 0, 0, 0, 0, 0 };
+ System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array);
+ System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes();
+ disabledImageAttr.ClearColorKey();
+ disabledImageAttr.SetColorMatrix(grayMatrix);
+ g.DrawImage(bmp, r, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, disabledImageAttr);
+ }
+ else
+ {
+ if (MouseDown)
+ r.Offset(1, 1);
+ g.DrawImageUnscaled(bmp, r);
+ }
+
+ }
+
+ internal static void SyncProperty(BaseItem item, string propertyName)
+ {
+ if (item.GlobalName.Length > 0)
+ {
+ PropertyDescriptor propDesc = TypeDescriptor.GetProperties(item)[propertyName];
+ SetPropertyByGlobalName(GetOwner(item), item.GetType(), item.GlobalName, propDesc, propDesc.GetValue(item));
+ }
+ else if (item.Name.Length > 0)
+ {
+ PropertyDescriptor propDesc = TypeDescriptor.GetProperties(item)[propertyName];
+ SetProperty(GetOwner(item), item.GetType(), item.Name, propDesc, propDesc.GetValue(item));
+ }
+ }
+
+ private static object GetOwner(BaseItem item)
+ {
+ object owner = item.GetOwner();
+ if (owner is RibbonBar && ((RibbonBar)owner).IsOverflowRibbon)
+ {
+ if (((RibbonBar)owner).IsOnQat)
+ owner = ((RibbonBar)owner).QatButtonParent.GetOwner();
+ else
+ owner = ((RibbonBar)owner).OverflowParent;
+ }
+ return owner;
+ }
+
+ internal static void SetProperty(object owner, System.Type itemType, string itemName, System.ComponentModel.PropertyDescriptor prop, object value)
+ {
+ IOwner manager = owner as IOwner;
+ DotNetBarManager dnbmanager = owner as DotNetBarManager;
+
+ if (manager == null || itemName == "" || prop == null)
+ return;
+
+ System.Collections.ArrayList list = null;
+ if (dnbmanager != null)
+ {
+ if (!dnbmanager.IsDisposed)
+ list = dnbmanager.GetItems(itemName, itemType, true);
+ }
+ else
+ list = manager.GetItems(itemName, itemType);
+ if (list == null)
+ return;
+ foreach (BaseItem objItem in list)
+ {
+ object propertyValue = prop.GetValue(objItem);
+ if (!(propertyValue == value || propertyValue != null && propertyValue.Equals(value)))
+ prop.SetValue(objItem, value);
+ }
+ }
+
+ internal static void SetPropertyByGlobalName(object owner, System.Type itemType, string itemName, System.ComponentModel.PropertyDescriptor prop, object value)
+ {
+ IOwner manager = owner as IOwner;
+ DotNetBarManager dnbmanager = owner as DotNetBarManager;
+
+ if (manager == null || itemName == "" || prop == null)
+ return;
+
+ System.Collections.ArrayList list = null;
+ if (dnbmanager != null)
+ {
+ if (!dnbmanager.IsDisposed)
+ list = dnbmanager.GetItems(itemName, itemType, true, true);
+ }
+ else
+ list = manager.GetItems(itemName, itemType, true);
+ if (list == null)
+ return;
+ foreach (BaseItem objItem in list)
+ {
+ if (prop.GetValue(objItem) != value)
+ prop.SetValue(objItem, value);
+ }
+ }
+
+ internal static ResourceManager GetResourceManager(bool bDefault)
+ {
+ string defaultResource = DEFAULT_RESOURCE;
+ DotNetBarResourcesAttribute att = Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DotNetBarResourcesAttribute)) as DotNetBarResourcesAttribute;
+ if (att != null && att.NamespacePrefix != "")
+ defaultResource = att.NamespacePrefix + defaultResource;
+ else
+ defaultResource = "DevComponents.DotNetBar" + defaultResource;
+
+ ResourceManager rm = new ResourceManager(defaultResource, System.Reflection.Assembly.GetExecutingAssembly());
+ return rm;
+ }
+ internal static ResourceManager GetResourceManager()
+ {
+ string defaultResource = DEFAULT_RESOURCE;
+ DotNetBarResourcesAttribute att = Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DotNetBarResourcesAttribute)) as DotNetBarResourcesAttribute;
+ if (att != null && att.NamespacePrefix != "")
+ defaultResource = att.NamespacePrefix + defaultResource;
+ else
+ defaultResource = "DevComponents.DotNetBar" + defaultResource;
+
+ if (ms_ResourceName == "")
+ {
+ System.Globalization.CultureInfo cu = System.Threading.Thread.CurrentThread.CurrentUICulture;
+ System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
+ string[] arr = assembly.GetManifestResourceNames();
+ int count = 0; // Make sure this exits
+ while (cu.LCID != 127 && count < 16)
+ {
+ if (assembly.GetManifestResourceInfo(defaultResource + "_" + cu.Name.ToLower() + ".resources") != null)
+ {
+ ms_ResourceName = defaultResource + "_" + cu.Name.ToLower();
+ break;
+ }
+ else if (assembly.GetManifestResourceInfo(defaultResource + "_" + cu.TwoLetterISOLanguageName.ToLower() + ".resources") != null)
+ {
+ ms_ResourceName = defaultResource + "_" + cu.TwoLetterISOLanguageName.ToLower();
+ break;
+ }
+ cu = cu.Parent;
+ count++;
+ }
+ if (ms_ResourceName == "")
+ ms_ResourceName = defaultResource;
+ }
+
+ ResourceManager rm = new ResourceManager(ms_ResourceName, System.Reflection.Assembly.GetExecutingAssembly());
+ return rm;
+ }
+
+ internal static void DrawBorder(Graphics g, eBorderType bordertype, Rectangle r, Color singleLineColor)
+ {
+ DrawBorder(g, bordertype, r, singleLineColor, eBorderSide.Left | eBorderSide.Right | eBorderSide.Top | eBorderSide.Bottom);
+ }
+ internal static void DrawBorder(Graphics g, eBorderType bordertype, Rectangle r, Color singleLineColor, eBorderSide side)
+ {
+ DrawBorder(g, bordertype, r, singleLineColor, side, System.Drawing.Drawing2D.DashStyle.Solid);
+ }
+ internal static void DrawBorder(Graphics g, eBorderType bordertype, Rectangle r, Color singleLineColor, eBorderSide side, System.Drawing.Drawing2D.DashStyle borderDashStyle)
+ {
+ DrawBorder(g, bordertype, r, singleLineColor, side, borderDashStyle, 1);
+ }
+ internal static void DrawBorder(Graphics g, eBorderType bordertype, Rectangle r, Color singleLineColor, eBorderSide side, System.Drawing.Drawing2D.DashStyle borderDashStyle, int lineWidth)
+ {
+ if (lineWidth <= 0) return;
+ System.Windows.Forms.Border3DSide border3dside;
+ if (side == eBorderSide.All)
+ border3dside = System.Windows.Forms.Border3DSide.All;
+ else
+ border3dside = (((side | eBorderSide.Left) != 0) ? System.Windows.Forms.Border3DSide.Left : 0) |
+ (((side | eBorderSide.Right) != 0) ? System.Windows.Forms.Border3DSide.Right : 0) |
+ (((side | eBorderSide.Top) != 0) ? System.Windows.Forms.Border3DSide.Top : 0) |
+ (((side | eBorderSide.Bottom) != 0) ? System.Windows.Forms.Border3DSide.Bottom : 0);
+
+ switch (bordertype)
+ {
+ case eBorderType.Bump:
+ {
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.Bump, border3dside);
+ break;
+ }
+ case eBorderType.Etched:
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.Etched, border3dside);
+ break;
+ case eBorderType.Raised:
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, border3dside);
+ break;
+ case eBorderType.Sunken:
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.SunkenOuter, border3dside);
+ break;
+ case eBorderType.SingleLine:
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.None;
+ using (Pen pen = new Pen(singleLineColor, lineWidth))
+ {
+ pen.DashStyle = borderDashStyle;
+ int offset = lineWidth / 2;
+ if ((side & eBorderSide.Left) != 0)
+ g.DrawLine(pen, r.X + offset, r.Y, r.X + offset, r.Bottom - (lineWidth > 1 ? 0 : 1));
+ if ((side & eBorderSide.Top) != 0)
+ g.DrawLine(pen, r.X, r.Y + offset, r.Right - 1, r.Y + offset);
+ if (offset == 0) offset = 1;
+ if ((side & eBorderSide.Right) != 0)
+ g.DrawLine(pen, r.Right - offset, r.Y, r.Right - offset, r.Bottom - (lineWidth>1?0:1));
+ if ((side & eBorderSide.Bottom) != 0)
+ g.DrawLine(pen, r.X, r.Bottom - offset, r.Right - 1, r.Bottom - offset);
+ }
+ g.SmoothingMode = sm;
+ break;
+ }
+ case eBorderType.DoubleLine:
+ {
+ using (Pen pen = new Pen(singleLineColor, lineWidth))
+ {
+ pen.DashStyle = borderDashStyle;
+ for (int i = 0; i < lineWidth + 1; i += lineWidth)
+ {
+ if ((side & eBorderSide.Left) != 0)
+ g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom - 1);
+ if ((side & eBorderSide.Top) != 0)
+ g.DrawLine(pen, r.X, r.Y, r.Right - 1, r.Y);
+ if ((side & eBorderSide.Right) != 0)
+ g.DrawLine(pen, r.Right - 1, r.Y, r.Right - 1, r.Bottom - 1);
+ if ((side & eBorderSide.Bottom) != 0)
+ g.DrawLine(pen, r.X, r.Bottom - 1, r.Right - 1, r.Bottom - 1);
+ r.Inflate(-1, -1);
+ }
+
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ internal static void DrawBorder3D(Graphics g, int x, int y, int width, int height, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide side)
+ {
+ DrawBorder3D(g, x, y, width, height, style, side, SystemColors.Control, true);
+ }
+ internal static void DrawBorder3D(Graphics g, int x, int y, int width, int height, System.Windows.Forms.Border3DStyle style, Color clr)
+ {
+ DrawBorder3D(g, x, y, width, height, style, System.Windows.Forms.Border3DSide.All, clr, true);
+ }
+ internal static void DrawBorder3D(Graphics g, int x, int y, int width, int height, System.Windows.Forms.Border3DStyle style)
+ {
+ DrawBorder3D(g, x, y, width, height, style, System.Windows.Forms.Border3DSide.All, SystemColors.Control, true);
+ }
+ internal static void DrawBorder3D(Graphics g, Rectangle r, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide side, Color baseColor)
+ {
+ DrawBorder3D(g, r.X, r.Y, r.Width, r.Height, style, side, baseColor, true);
+ }
+ internal static void DrawBorder3D(Graphics g, Rectangle r, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide side, Color baseColor, bool bFillInner)
+ {
+ DrawBorder3D(g, r.X, r.Y, r.Width, r.Height, style, side, baseColor, bFillInner);
+ }
+ internal static void DrawBorder3D(Graphics g, Rectangle r, System.Windows.Forms.Border3DStyle style)
+ {
+ DrawBorder3D(g, r.X, r.Y, r.Width, r.Height, style, System.Windows.Forms.Border3DSide.All, SystemColors.Control, true);
+ }
+ internal static void DrawBorder3D(Graphics g, int x, int y, int width, int height, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide side, Color baseColor)
+ {
+ DrawBorder3D(g, x, y, width, height, style, side, baseColor, true);
+ }
+ internal static void DrawBorder3D(Graphics g, int x, int y, int width, int height, System.Windows.Forms.Border3DStyle style, System.Windows.Forms.Border3DSide side, Color baseColor, bool bFillInner)
+ {
+ if (bFillInner)
+ g.FillRectangle(new SolidBrush(baseColor), x, y, width, height);
+
+ Color colorLight = System.Windows.Forms.ControlPaint.Light(baseColor);
+ Color colorDark = System.Windows.Forms.ControlPaint.Dark(baseColor);
+ Pen penLight = null;
+ Pen penDark = null;
+ Pen penBase = new Pen(baseColor);
+ height--;
+ width--;
+ switch (style)
+ {
+ case System.Windows.Forms.Border3DStyle.RaisedInner:
+ {
+ penLight = new Pen(colorLight, 1);
+ penDark = new Pen(colorDark, 1);
+ if ((side & System.Windows.Forms.Border3DSide.Top) != 0)
+ g.DrawLine(penLight, x, y, x + width, y);
+ if ((side & System.Windows.Forms.Border3DSide.Left) != 0)
+ g.DrawLine(penLight, x, y, x, y + height);
+ if ((side & System.Windows.Forms.Border3DSide.Right) != 0)
+ g.DrawLine(penDark, x + width, y, x + width, y + height);
+ if ((side & System.Windows.Forms.Border3DSide.Bottom) != 0)
+ g.DrawLine(penDark, x, y + height, x + width, y + height);
+ break;
+ }
+ case System.Windows.Forms.Border3DStyle.SunkenOuter:
+ {
+ penLight = new Pen(colorLight, 1);
+ penDark = new Pen(colorDark, 1);
+ if ((side & System.Windows.Forms.Border3DSide.Top) != 0)
+ g.DrawLine(penDark, x, y, x + width, y);
+ if ((side & System.Windows.Forms.Border3DSide.Left) != 0)
+ g.DrawLine(penDark, x, y, x, y + height);
+ if ((side & System.Windows.Forms.Border3DSide.Right) != 0)
+ g.DrawLine(penLight, x + width, y, x + width, y + height);
+ if ((side & System.Windows.Forms.Border3DSide.Bottom) != 0)
+ g.DrawLine(penLight, x, y + height, x + width, y + height);
+ break;
+ }
+ case System.Windows.Forms.Border3DStyle.Raised:
+ {
+ if ((side & System.Windows.Forms.Border3DSide.Top) != 0 &&
+ (side & System.Windows.Forms.Border3DSide.Left) != 0 &&
+ (side & System.Windows.Forms.Border3DSide.Right) != 0 &&
+ (side & System.Windows.Forms.Border3DSide.Bottom) != 0)
+ {
+
+ penLight = new Pen(Color.White, 1);
+ g.DrawRectangle(penBase, x, y, width, height);
+ g.DrawLine(penLight, x + 1, y + 1, x + width - 1, y + 1);
+ g.DrawLine(penLight, x + 1, y + 1, x + 1, y + height - 1);
+ }
+ else
+ {
+ penDark = new Pen(colorLight, 1);
+ penLight = new Pen(System.Windows.Forms.ControlPaint.LightLight(baseColor), 1);
+ if ((side & System.Windows.Forms.Border3DSide.Top) != 0)
+ {
+ g.DrawLine(penDark, x, y, x + width, y);
+ g.DrawLine(penLight, x + 1, y + 1, x + width - 2, y + 1);
+ }
+ if ((side & System.Windows.Forms.Border3DSide.Left) != 0)
+ {
+ g.DrawLine(penDark, x, y, x, y + height);
+ g.DrawLine(penLight, x + 1, y + 1, x + 1, y + height - 2);
+ }
+
+ penDark.Dispose();
+ penLight.Dispose();
+
+ penDark = new Pen(System.Windows.Forms.ControlPaint.DarkDark(baseColor), 1);
+ penLight = new Pen(colorDark, 1);
+
+ if ((side & System.Windows.Forms.Border3DSide.Right) != 0)
+ {
+ g.DrawLine(penDark, x + width, y, x + width, y + height);
+ g.DrawLine(penLight, x + width - 1, y + 1, x + width - 1, y + height - 1);
+ }
+ if ((side & System.Windows.Forms.Border3DSide.Bottom) != 0)
+ {
+ g.DrawLine(penDark, x, y + height, x + width, y + height);
+ g.DrawLine(penLight, x + 1, y + height - 1, x + width - 1, y + height - 1);
+ }
+ }
+ break;
+ }
+ case System.Windows.Forms.Border3DStyle.Sunken:
+ {
+ penDark = new Pen(System.Windows.Forms.ControlPaint.DarkDark(baseColor), 1);
+ penLight = new Pen(colorDark, 1);
+
+ if ((side & System.Windows.Forms.Border3DSide.Top) != 0)
+ {
+ g.DrawLine(penDark, x, y, x + width, y);
+ g.DrawLine(penLight, x + 1, y + 1, x + width - 2, y + 1);
+ }
+ if ((side & System.Windows.Forms.Border3DSide.Left) != 0)
+ {
+ g.DrawLine(penDark, x, y, x, y + height);
+ g.DrawLine(penLight, x + 1, y + 1, x + 1, y + height - 2);
+ }
+
+ penDark.Dispose();
+ penLight.Dispose();
+
+ penDark = new Pen(colorLight, 1);
+ penLight = new Pen(System.Windows.Forms.ControlPaint.LightLight(baseColor), 1);
+
+ if ((side & System.Windows.Forms.Border3DSide.Right) != 0)
+ {
+ g.DrawLine(penDark, x + width, y, x + width, y + height);
+ g.DrawLine(penLight, x + width - 1, y + 1, x + width - 1, y + height - 1);
+ }
+ if ((side & System.Windows.Forms.Border3DSide.Bottom) != 0)
+ {
+ g.DrawLine(penDark, x, y + height, x + width, y + height);
+ g.DrawLine(penLight, x + 1, y + height - 1, x + width - 1, y + height - 1);
+ }
+ break;
+ }
+ }
+ if (penLight != null)
+ penLight.Dispose();
+ if (penDark != null)
+ penDark.Dispose();
+ penBase.Dispose();
+ }
+
+ internal static System.Drawing.Drawing2D.LinearGradientBrush CreateLinearGradientBrush(Rectangle r, Color color1, Color color2, float gradientAngle)
+ {
+ if (r.Width <= 0)
+ r.Width = 1;
+ if (r.Height <= 0)
+ r.Height = 1;
+ return new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(r.X, r.Y - 1, r.Width, r.Height + 1), color1, color2, gradientAngle);
+ }
+
+ internal static System.Drawing.Drawing2D.LinearGradientBrush CreateLinearGradientBrush(RectangleF r, Color color1, Color color2, float gradientAngle)
+ {
+ if (r.Width <= 0)
+ r.Width = 1;
+ if (r.Height <= 0)
+ r.Height = 1;
+ return new System.Drawing.Drawing2D.LinearGradientBrush(new RectangleF(r.X, r.Y - 1, r.Width, r.Height + 1), color1, color2, gradientAngle);
+ }
+
+ internal static System.Drawing.Drawing2D.LinearGradientBrush CreateLinearGradientBrush(Rectangle r, Color color1, Color color2, float gradientAngle, bool isAngleScalable)
+ {
+ if (r.Width <= 0)
+ r.Width = 1;
+ if (r.Height <= 0)
+ r.Height = 1;
+ return new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(r.X, r.Y - 1, r.Width, r.Height + 1), color1, color2, gradientAngle, isAngleScalable);
+ }
+
+ public static void DrawDesignTimeSelection(Graphics g, Rectangle r, Color backColor, Color border, int penWidth)
+ {
+ if (r.Width <= 0 || r.Height <= 0)
+ return;
+ if (!backColor.IsEmpty && backColor != Color.Transparent)
+ {
+ if ((double)backColor.GetBrightness() < 0.5)
+ border = System.Windows.Forms.ControlPaint.Light(backColor);
+ else
+ border = System.Windows.Forms.ControlPaint.Dark(backColor);
+ }
+ using (Pen pen = new Pen(border, penWidth))
+ {
+ pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
+ r.Width--;
+ r.Height--;
+ g.DrawRectangle(pen, r);
+ }
+ }
+
+ public static BaseItem GetSubItemByName(BaseItem objParent, string ItemName)
+ {
+ return GetSubItemByName(objParent, ItemName, false);
+ }
+
+ public static BaseItem GetSubItemByName(BaseItem objParent, string ItemName, bool useGlobalName)
+ {
+ if (objParent == null)
+ return null;
+ foreach (BaseItem objItem in objParent.SubItems)
+ {
+ if (useGlobalName && objItem.GlobalName == ItemName || !useGlobalName && objItem.Name == ItemName)
+ return objItem;
+ if (objItem.SubItems.Count > 0)
+ {
+ BaseItem item = GetSubItemByName(objItem, ItemName, useGlobalName);
+ if (item != null)
+ return item;
+ }
+ }
+
+ if (objParent is GalleryContainer)
+ {
+ return GetSubItemByName(((GalleryContainer)objParent).PopupGalleryItem, ItemName, useGlobalName);
+ }
+
+ return null;
+ }
+
+ public static void GetSubItemsByName(BaseItem objParent, string ItemName, ArrayList list)
+ {
+ GetSubItemsByName(objParent, ItemName, list, false);
+ }
+
+ public static void GetSubItemsByName(BaseItem objParent, string ItemName, ArrayList list, bool useGlobalName)
+ {
+ if (objParent == null) return;
+ foreach (BaseItem objItem in objParent.SubItems)
+ {
+ if (useGlobalName && objItem.GlobalName == ItemName || !useGlobalName && objItem.Name == ItemName)
+ list.Add(objItem);
+ else if (objItem is ControlContainerItem)
+ {
+ ControlContainerItem cc = objItem as ControlContainerItem;
+ if (cc.Control is RibbonBar)
+ {
+ RibbonBar rb = cc.Control as RibbonBar;
+ ArrayList rbList = rb.GetItems(ItemName);
+ list.AddRange(rbList);
+ }
+ }
+
+ if (objItem.SubItems.Count > 0)
+ GetSubItemsByName(objItem, ItemName, list, useGlobalName);
+ }
+
+ if (objParent is GalleryContainer)
+ {
+ GetSubItemsByName(((GalleryContainer)objParent).PopupGalleryItem, ItemName, list, useGlobalName);
+ }
+ }
+
+ public static void GetSubItemsByNameAndType(BaseItem objParent, string ItemName, ArrayList list, Type itemType)
+ {
+ GetSubItemsByNameAndType(objParent, ItemName, list, itemType, false);
+ }
+
+ public static void GetSubItemsByNameAndType(BaseItem objParent, string ItemName, ArrayList list, Type itemType, bool useGlobalName)
+ {
+ if (objParent == null) return;
+ foreach (BaseItem objItem in objParent.SubItems)
+ {
+ if (objItem.GetType() == itemType && (useGlobalName && objItem.GlobalName == ItemName || !useGlobalName && objItem.Name == ItemName))
+ list.Add(objItem);
+ else if (objItem is ControlContainerItem)
+ {
+ ControlContainerItem cc = objItem as ControlContainerItem;
+ if (cc.Control is RibbonBar)
+ {
+ RibbonBar rb = cc.Control as RibbonBar;
+ ArrayList rbList = rb.GetItems(ItemName, itemType, useGlobalName);
+ list.AddRange(rbList);
+ }
+ }
+
+ if (objItem.SubItems.Count > 0)
+ GetSubItemsByNameAndType(objItem, ItemName, list, itemType, useGlobalName);
+ }
+ }
+
+ public static string ColorToString(Color clr)
+ {
+ if (clr.IsSystemColor)
+ return ("." + clr.Name);
+ else
+ return clr.ToArgb().ToString();
+ }
+
+ public static Color ColorFromString(string sclr)
+ {
+ if (sclr == "")
+ return Color.Empty;
+ if (sclr[0] == '.')
+ return Color.FromName(sclr.Substring(1));
+ else
+ return Color.FromArgb(System.Xml.XmlConvert.ToInt32(sclr));
+ }
+
+ public static bool SupportsAnimation
+ {
+ get { return m_SupportsAnimation; }
+ }
+
+ internal static ScreenInformation PrimaryScreen
+ {
+ get
+ {
+ if (m_Screens.Count == 0)
+ RefreshScreens();
+ foreach (ScreenInformation s in m_Screens)
+ {
+ if (s.Primary)
+ return s;
+ }
+ if (m_Screens.Count > 0)
+ return m_Screens[0];
+ return new ScreenInformation(new Rectangle(0, 0, 1024, 768), new Rectangle(0, 0, 1024, 768), true);
+ }
+ }
+
+ internal static ScreenInformation ScreenFromPoint(Point pScreen)
+ {
+ if (m_Screens.Count == 0)
+ RefreshScreens();
+ //foreach (System.Windows.Forms.Screen s in System.Windows.Forms.Screen.AllScreens)
+ foreach (ScreenInformation s in m_Screens)
+ {
+ if (s.Bounds.Contains(pScreen))
+ {
+ return s;
+ }
+ }
+
+ System.Windows.Forms.Screen scr = System.Windows.Forms.Screen.FromPoint(pScreen);
+ if (scr != null && scr.Bounds.Contains(pScreen))
+ return new ScreenInformation(scr.Bounds, scr.WorkingArea);
+
+ return null;
+ }
+ internal static ScreenInformation ScreenFromControl(System.Windows.Forms.Control control)
+ {
+ Rectangle r;
+ if (control.Parent != null)
+ {
+ Point screenLocation = control.PointToScreen(Point.Empty);
+ r = new Rectangle(screenLocation, control.Size);
+ }
+ else
+ r = new Rectangle(control.Location, control.Size);
+ if (m_Screens.Count == 0)
+ RefreshScreens();
+ //foreach (System.Windows.Forms.Screen s in System.Windows.Forms.Screen.AllScreens)
+ foreach (ScreenInformation s in m_Screens)
+ {
+ //if(s.Bounds.Contains(r))
+ if (s.Bounds.Contains(r))
+ {
+ return s;
+ }
+ }
+ System.Windows.Forms.Screen scr = System.Windows.Forms.Screen.FromControl(control);
+ if (scr != null)
+ return new ScreenInformation(scr.Bounds, scr.WorkingArea);
+ return null;
+ }
+
+ private static List m_Screens = new List(2);
+ public static void RefreshScreens()
+ {
+ m_Screens.Clear();
+ foreach (System.Windows.Forms.Screen s in System.Windows.Forms.Screen.AllScreens)
+ m_Screens.Add(new ScreenInformation(s.Bounds, s.WorkingArea, s.Primary));
+ }
+
+ public static void SetExplorerBarStyle(ExplorerBar bar, eExplorerBarStockStyle stockStyle)
+ {
+ if (stockStyle == eExplorerBarStockStyle.SystemColors)
+ {
+ bar.BackStyle.Reset();
+ bar.BackStyle.BackColorSchemePart = eColorSchemePart.ExplorerBarBackground;
+ bar.BackStyle.BackColor2SchemePart = eColorSchemePart.ExplorerBarBackground2;
+ bar.BackStyle.BackColorGradientAngle = bar.ColorScheme.ExplorerBarBackgroundGradientAngle;
+ }
+ else if (stockStyle != eExplorerBarStockStyle.Custom)
+ {
+ ePredefinedColorScheme scheme = ePredefinedColorScheme.Blue2003;
+ if (stockStyle == eExplorerBarStockStyle.Silver || stockStyle == eExplorerBarStockStyle.SilverSpecial)
+ scheme = ePredefinedColorScheme.Silver2003;
+ else if (stockStyle == eExplorerBarStockStyle.OliveGreen || stockStyle == eExplorerBarStockStyle.OliveGreenSpecial)
+ scheme = ePredefinedColorScheme.OliveGreen2003;
+ ColorScheme cs = new ColorScheme(eDotNetBarStyle.Office2003);
+ cs.PredefinedColorScheme = scheme;
+
+ bar.BackStyle.Reset();
+ bar.BackStyle.BackColor = cs.ExplorerBarBackground;
+ bar.BackStyle.BackColor2 = cs.ExplorerBarBackground2;
+ bar.BackStyle.BackColorGradientAngle = cs.ExplorerBarBackgroundGradientAngle;
+ }
+ }
+ public static void SetExplorerBarStyle(ExplorerBarGroupItem group, eExplorerBarStockStyle stockStyle)
+ {
+ if (stockStyle == eExplorerBarStockStyle.SystemColors)
+ {
+ eExplorerBarStockStyle stock = eExplorerBarStockStyle.Blue;
+ eExplorerBarStockStyle special = eExplorerBarStockStyle.BlueSpecial;
+
+ if (SystemColors.Control.ToArgb() == Color.FromArgb(224, 223, 227).ToArgb() && SystemColors.Highlight.ToArgb() == Color.FromArgb(178, 180, 191).ToArgb())
+ {
+ stock = eExplorerBarStockStyle.Silver;
+ special = eExplorerBarStockStyle.SilverSpecial;
+ }
+ else if (SystemColors.Control.ToArgb() == Color.FromArgb(236, 233, 216).ToArgb() && SystemColors.Highlight.ToArgb() == Color.FromArgb(147, 160, 112).ToArgb())
+ {
+ stock = eExplorerBarStockStyle.OliveGreen;
+ special = eExplorerBarStockStyle.OliveGreenSpecial;
+ }
+
+ if (group.XPSpecialGroup)
+ stockStyle = special;
+ else
+ stockStyle = stock;
+ }
+
+ if (stockStyle != eExplorerBarStockStyle.Custom)
+ {
+ group.TitleStyle.Reset();
+ group.TitleHotStyle.Reset();
+ group.BackStyle.Reset();
+
+ group.TitleStyle.CornerTypeTopLeft = eCornerType.Rounded;
+ group.TitleStyle.CornerTypeTopRight = eCornerType.Rounded;
+ group.TitleStyle.CornerDiameter = 3;
+ group.TitleHotStyle.CornerTypeTopLeft = eCornerType.Rounded;
+ group.TitleHotStyle.CornerTypeTopRight = eCornerType.Rounded;
+ group.TitleHotStyle.CornerDiameter = 3;
+ }
+
+ switch (stockStyle)
+ {
+ case eExplorerBarStockStyle.Blue:
+ {
+ group.TitleStyle.BackColor = Color.White;
+ group.TitleStyle.BackColor2 = Color.FromArgb(199, 211, 247);
+ group.TitleStyle.TextColor = Color.FromArgb(33, 93, 198);
+ group.TitleHotStyle.TextColor = Color.FromArgb(66, 142, 255);
+ group.TitleHotStyle.BackColor = Color.White;
+ group.TitleHotStyle.BackColor2 = Color.FromArgb(199, 211, 247); ;
+ group.BackStyle.BackColor = Color.FromArgb(214, 223, 247);
+ group.BackStyle.BorderBottom = eStyleBorderType.Solid;
+ group.BackStyle.BorderTop = eStyleBorderType.None;
+ group.BackStyle.BorderLeft = eStyleBorderType.Solid;
+ group.BackStyle.BorderRight = eStyleBorderType.Solid;
+ group.BackStyle.BorderBottomWidth = 1;
+ group.BackStyle.BorderTopWidth = 0;
+ group.BackStyle.BorderLeftWidth = 1;
+ group.BackStyle.BorderRightWidth = 1;
+ group.BackStyle.BorderColor = Color.White;
+ group.ExpandBackColor = Color.White;
+ group.ExpandBorderColor = Color.FromArgb(174, 182, 216);
+ group.ExpandForeColor = Color.FromArgb(0, 60, 165);
+ group.ExpandHotBackColor = Color.White;
+ group.ExpandHotBorderColor = Color.FromArgb(174, 182, 216);
+ group.ExpandHotForeColor = Color.FromArgb(66, 142, 255);
+
+ break;
+ }
+ case eExplorerBarStockStyle.BlueSpecial:
+ {
+ group.TitleStyle.BackColor = Color.FromArgb(0, 73, 181);
+ group.TitleStyle.BackColor2 = Color.FromArgb(41, 93, 206);
+ group.TitleStyle.TextColor = Color.White;
+ group.TitleHotStyle.TextColor = Color.FromArgb(66, 142, 255);
+ group.TitleHotStyle.BackColor = Color.FromArgb(0, 73, 181);
+ group.TitleHotStyle.BackColor2 = Color.FromArgb(41, 93, 206);
+ group.BackStyle.Reset();
+ group.BackStyle.BackColor = Color.FromArgb(239, 243, 255);
+ group.BackStyle.BorderBottom = eStyleBorderType.Solid;
+ group.BackStyle.BorderTop = eStyleBorderType.None;
+ group.BackStyle.BorderLeft = eStyleBorderType.Solid;
+ group.BackStyle.BorderRight = eStyleBorderType.Solid;
+ group.BackStyle.BorderBottomWidth = 1;
+ group.BackStyle.BorderTopWidth = 0;
+ group.BackStyle.BorderLeftWidth = 1;
+ group.BackStyle.BorderRightWidth = 1;
+ group.BackStyle.BorderColor = Color.White;
+
+ group.ExpandBackColor = Color.FromArgb(48, 97, 196);
+ group.ExpandBorderColor = Color.FromArgb(123, 168, 229);
+ group.ExpandForeColor = Color.White;
+ group.ExpandHotBackColor = Color.FromArgb(48, 97, 196);
+ group.ExpandHotBorderColor = Color.FromArgb(123, 168, 229);
+ group.ExpandHotForeColor = Color.FromArgb(172, 205, 255);
+
+ break;
+ }
+ case eExplorerBarStockStyle.OliveGreen:
+ {
+ group.TitleStyle.BackColor = Color.FromArgb(255, 252, 236);
+ group.TitleStyle.BackColor2 = Color.FromArgb(224, 231, 184);
+ group.TitleStyle.TextColor = Color.FromArgb(86, 102, 45);
+ group.TitleHotStyle.TextColor = Color.FromArgb(114, 146, 29);
+ group.TitleHotStyle.BackColor = Color.FromArgb(255, 252, 236);
+ group.TitleHotStyle.BackColor2 = Color.FromArgb(224, 231, 184);
+ group.BackStyle.Reset();
+ group.BackStyle.BackColor = Color.FromArgb(246, 246, 236);
+ group.BackStyle.BorderBottom = eStyleBorderType.Solid;
+ group.BackStyle.BorderTop = eStyleBorderType.None;
+ group.BackStyle.BorderLeft = eStyleBorderType.Solid;
+ group.BackStyle.BorderRight = eStyleBorderType.Solid;
+ group.BackStyle.BorderBottomWidth = 1;
+ group.BackStyle.BorderTopWidth = 0;
+ group.BackStyle.BorderLeftWidth = 1;
+ group.BackStyle.BorderRightWidth = 1;
+ group.BackStyle.BorderColor = Color.White;
+ group.ExpandBackColor = Color.FromArgb(254, 254, 253);
+ group.ExpandBorderColor = Color.FromArgb(194, 206, 185);
+ group.ExpandForeColor = Color.FromArgb(75, 103, 28);
+ group.ExpandHotBackColor = Color.FromArgb(254, 254, 253);
+ group.ExpandHotBorderColor = Color.FromArgb(194, 206, 185);
+ group.ExpandHotForeColor = Color.FromArgb(114, 146, 29);
+
+ break;
+ }
+ case eExplorerBarStockStyle.OliveGreenSpecial:
+ {
+ group.TitleStyle.BackColor = Color.FromArgb(119, 140, 64);
+ group.TitleStyle.BackColor2 = Color.FromArgb(150, 168, 103);
+ group.TitleStyle.TextColor = Color.White;
+ group.TitleHotStyle.TextColor = Color.FromArgb(224, 231, 184);
+ group.TitleHotStyle.BackColor = Color.FromArgb(119, 140, 64);
+ group.TitleHotStyle.BackColor2 = Color.FromArgb(150, 168, 103);
+ group.BackStyle.Reset();
+ group.BackStyle.BackColor = Color.FromArgb(246, 246, 236);
+ group.BackStyle.BorderBottom = eStyleBorderType.Solid;
+ group.BackStyle.BorderTop = eStyleBorderType.None;
+ group.BackStyle.BorderLeft = eStyleBorderType.Solid;
+ group.BackStyle.BorderRight = eStyleBorderType.Solid;
+ group.BackStyle.BorderBottomWidth = 1;
+ group.BackStyle.BorderTopWidth = 0;
+ group.BackStyle.BorderLeftWidth = 1;
+ group.BackStyle.BorderRightWidth = 1;
+ group.BackStyle.BorderColor = Color.White;
+
+ group.ExpandBackColor = Color.FromArgb(129, 163, 79);
+ group.ExpandBorderColor = Color.FromArgb(191, 205, 156);
+ group.ExpandForeColor = Color.White;
+ group.ExpandHotBackColor = Color.FromArgb(130, 164, 80);
+ group.ExpandHotBorderColor = Color.FromArgb(182, 202, 139);
+ group.ExpandHotForeColor = Color.FromArgb(221, 237, 190);
+
+ break;
+ }
+ case eExplorerBarStockStyle.Silver:
+ {
+ group.TitleStyle.BackColor = Color.White;
+ group.TitleStyle.BackColor2 = Color.FromArgb(214, 215, 224);
+ group.TitleStyle.TextColor = Color.FromArgb(63, 61, 61);
+ group.TitleHotStyle.TextColor = Color.FromArgb(126, 124, 124);
+ group.TitleHotStyle.BackColor = Color.White;
+ group.TitleHotStyle.BackColor2 = Color.FromArgb(214, 215, 224);
+ group.BackStyle.Reset();
+ group.BackStyle.BackColor = Color.FromArgb(240, 241, 245);
+ group.BackStyle.BorderBottom = eStyleBorderType.Solid;
+ group.BackStyle.BorderTop = eStyleBorderType.None;
+ group.BackStyle.BorderLeft = eStyleBorderType.Solid;
+ group.BackStyle.BorderRight = eStyleBorderType.Solid;
+ group.BackStyle.BorderBottomWidth = 1;
+ group.BackStyle.BorderTopWidth = 0;
+ group.BackStyle.BorderLeftWidth = 1;
+ group.BackStyle.BorderRightWidth = 1;
+ group.BackStyle.BorderColor = Color.White;
+
+ group.ExpandBackColor = Color.White;
+ group.ExpandBorderColor = Color.FromArgb(188, 189, 203);
+ group.ExpandForeColor = Color.FromArgb(49, 68, 115);
+ group.ExpandHotBackColor = Color.White;
+ group.ExpandHotBorderColor = Color.FromArgb(194, 195, 208);
+ group.ExpandHotForeColor = Color.FromArgb(126, 124, 124);
+
+ break;
+ }
+ case eExplorerBarStockStyle.SilverSpecial:
+ {
+ group.TitleStyle.BackColor = Color.FromArgb(119, 119, 146);
+ group.TitleStyle.BackColor2 = Color.FromArgb(180, 182, 199);
+ group.TitleStyle.TextColor = Color.White;
+ group.TitleHotStyle.BackColor = Color.FromArgb(119, 119, 146);
+ group.TitleHotStyle.BackColor2 = Color.FromArgb(180, 182, 199);
+ group.TitleHotStyle.TextColor = Color.FromArgb(230, 230, 230);
+ group.BackStyle.Reset();
+ group.BackStyle.BackColor = Color.FromArgb(240, 241, 245);
+ group.BackStyle.BorderBottom = eStyleBorderType.Solid;
+ group.BackStyle.BorderTop = eStyleBorderType.None;
+ group.BackStyle.BorderLeft = eStyleBorderType.Solid;
+ group.BackStyle.BorderRight = eStyleBorderType.Solid;
+ group.BackStyle.BorderBottomWidth = 1;
+ group.BackStyle.BorderTopWidth = 0;
+ group.BackStyle.BorderLeftWidth = 1;
+ group.BackStyle.BorderRightWidth = 1;
+ group.BackStyle.BorderColor = Color.White;
+
+ group.ExpandBackColor = Color.FromArgb(111, 117, 151);
+ group.ExpandBorderColor = Color.FromArgb(196, 203, 224);
+ group.ExpandForeColor = Color.White;
+ group.ExpandHotBackColor = Color.FromArgb(111, 117, 151);
+ group.ExpandHotBorderColor = Color.FromArgb(196, 203, 224);
+ group.ExpandHotForeColor = Color.White;
+
+ break;
+ }
+ }
+ }
+ public static void SetExplorerBarStyle(ButtonItem item, eExplorerBarStockStyle stockStyle)
+ {
+ if (stockStyle == eExplorerBarStockStyle.SystemColors)
+ {
+ eExplorerBarStockStyle stock = eExplorerBarStockStyle.Blue;
+
+ if (SystemColors.Control.ToArgb() == Color.FromArgb(224, 223, 227).ToArgb() && SystemColors.Highlight.ToArgb() == Color.FromArgb(178, 180, 191).ToArgb())
+ {
+ stock = eExplorerBarStockStyle.Silver;
+ }
+ else if (SystemColors.Control.ToArgb() == Color.FromArgb(236, 233, 216).ToArgb() && SystemColors.Highlight.ToArgb() == Color.FromArgb(147, 160, 112).ToArgb())
+ {
+ stock = eExplorerBarStockStyle.OliveGreen;
+ }
+
+ stockStyle = stock;
+ }
+
+ switch (stockStyle)
+ {
+ case eExplorerBarStockStyle.Blue:
+ case eExplorerBarStockStyle.BlueSpecial:
+ {
+ item.ForeColor = Color.FromArgb(33, 93, 198);
+ item.HotForeColor = Color.FromArgb(66, 142, 255);
+ break;
+ }
+ case eExplorerBarStockStyle.OliveGreen:
+ case eExplorerBarStockStyle.OliveGreenSpecial:
+ {
+ item.ForeColor = Color.FromArgb(86, 102, 45);
+ item.HotForeColor = Color.FromArgb(114, 146, 29);
+ break;
+ }
+ case eExplorerBarStockStyle.Silver:
+ case eExplorerBarStockStyle.SilverSpecial:
+ {
+ item.ForeColor = Color.FromArgb(63, 61, 61);
+ item.HotForeColor = Color.FromArgb(126, 124, 124);
+ break;
+ }
+ default:
+ {
+ item.ForeColor = SystemColors.ControlText;
+ item.HotForeColor = SystemColors.ControlDark;
+ break;
+ }
+ }
+ }
+
+ public static System.Windows.Forms.MdiClient GetMdiClient(System.Windows.Forms.Form MdiForm)
+ {
+ if (!MdiForm.IsMdiContainer)
+ return null;
+ foreach (System.Windows.Forms.Control ctrl in MdiForm.Controls)
+ {
+ if (ctrl is System.Windows.Forms.MdiClient)
+ return (ctrl as System.Windows.Forms.MdiClient);
+ }
+ return null;
+ }
+
+ //internal static Bitmap CreateDisabledBitmap(Bitmap bmp)
+ //{
+ // if(bmp==null)
+ // return null;
+
+ // Bitmap bmpTarget=null;
+ // try
+ // {
+ // int nWidth = bmp.Width;
+ // int nHeight = bmp.Height;
+ // bmpTarget = new Bitmap(bmp);
+ // for (int iX = 0; iX < nWidth; iX++)
+ // {
+ // for (int iY = 0; iY < nHeight; iY++)
+ // {
+ // Color cr = bmp.GetPixel(iX, iY);
+ // if(cr.IsEmpty || cr==Color.Transparent)
+ // {
+ // bmpTarget.SetPixel(iX, iY, Color.Transparent);
+ // }
+ // else
+ // {
+ // byte nA = cr.A;
+ // byte nB = (byte) ((cr.B + 255) / 2);
+ // byte nG = (byte) ((cr.G + 255) / 2);
+ // byte nR = (byte) ((cr.R + 255) / 2);
+ // nR = nG = nB = (byte) (nR * 0.299 + nG * 0.587 + nB * 0.114);
+ // bmpTarget.SetPixel(iX, iY, Color.FromArgb(nA, nR, nG, nB));
+ // }
+ // }
+ // }
+ // }
+ // catch
+ // {
+ // return null;
+ // }
+
+ // return bmpTarget;
+ //}
+ internal static Icon CreateDisabledIcon(Icon ico)
+ {
+ try
+ {
+ System.IO.MemoryStream memStream = new System.IO.MemoryStream();
+ ico.Save(memStream);
+ byte[] array = memStream.ToArray();
+ int nIconCount = array[4];
+ for (int iIcon = 0; iIcon < nIconCount; iIcon++)
+ {
+ int nBaseOffset = 6 + iIcon * 16;
+ int nWidth = array[nBaseOffset + 0];
+ int nHeight = array[nBaseOffset + 1];
+ int nOffset = GetDWORD(ref array, nBaseOffset + 12);
+ //data at position
+ int nStructSize = GetDWORD(ref array, nOffset);
+ int nPlanes = GetWORD(ref array, nOffset + 12);
+ int nBitCount = GetWORD(ref array, nOffset + 14);
+ //process 32-bit Icons (bitcount=32)
+
+ //process 24-bit icons (bitcount=24)
+
+ //process 8-bit (256 color) icons (bitcount=8)
+ if (nPlanes != 1) continue;
+
+ int nSize = GetDWORD(ref array, nOffset + 20);
+ int nStep = 0;
+
+ switch (nBitCount)
+ {
+ case 32: nStep = 4; nSize = nWidth * nHeight * 4; break;
+ case 24: nStep = 3; nSize = nWidth * nHeight * 3; break;
+ case 8: nStep = 4; nSize = 1024; break; //256 colors x 4 bytes
+ default: continue;
+ }
+
+ int iDataStart = nOffset + nStructSize;
+ for (int iPtr = iDataStart; iPtr < iDataStart + nSize; iPtr += nStep)
+ {
+ byte nB = (byte)((array[iPtr] + 255) / 2);
+ byte nG = (byte)((array[iPtr + 1] + 255) / 2);
+ byte nR = (byte)((array[iPtr + 2] + 255) / 2);
+ if (!(nB == 127 && nG == 127 && nR == 127))
+ {
+ byte nNewRGB = (byte)(nR * 0.299 + nG * 0.587 + nB * 0.114);
+ array[iPtr] = nNewRGB;
+ array[iPtr + 1] = nNewRGB;
+ array[iPtr + 2] = nNewRGB;
+ }
+ }
+ }
+ return new Icon(new System.IO.MemoryStream(array));
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+ private static int GetDWORD(ref byte[] array, int offset)
+ {
+ return array[offset] + (array[offset + 1] << 8) + (array[offset + 2] << 16) + (array[offset + 3] << 24);
+ }
+ private static int GetWORD(ref byte[] array, int offset)
+ {
+ return array[offset] + (array[offset + 1] << 8);
+ }
+
+ internal static void PaintBackgroundImage(Graphics g, Rectangle targetRect, Image backgroundImage, eStyleBackgroundImage backgroundImagePosition, int backgroundImageAlpha)
+ {
+ PaintBackgroundImage(g, targetRect, backgroundImage, (eBackgroundImagePosition)backgroundImagePosition, backgroundImageAlpha);
+ }
+
+ internal static void PaintBackgroundImage(Graphics g, Rectangle targetRect, Image backgroundImage, eBackgroundImagePosition backgroundImagePosition, int backgroundImageAlpha)
+ {
+ if (backgroundImage == null)
+ return;
+
+ Rectangle r = targetRect;
+ System.Drawing.Imaging.ImageAttributes imageAtt = null;
+
+ if (backgroundImageAlpha != 255)
+ {
+ float[][] matrixItems ={
+ new float[] {1, 0, 0, 0, 0},
+ new float[] {0, 1, 0, 0, 0},
+ new float[] {0, 0, 1, 0, 0},
+ new float[] {0, 0, 0, (float)backgroundImageAlpha/255, 0},
+ new float[] {0, 0, 0, 0, 1}};
+ System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(matrixItems);
+
+ //System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix();
+ //colorMatrix.Matrix33 = 255 - backgroundImageAlpha;
+ imageAtt = new System.Drawing.Imaging.ImageAttributes();
+ imageAtt.SetColorMatrix(colorMatrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);
+ }
+
+ switch (backgroundImagePosition)
+ {
+ case eBackgroundImagePosition.Stretch:
+ {
+ if (imageAtt != null)
+ g.DrawImage(backgroundImage, r, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAtt);
+ else
+ g.DrawImage(backgroundImage, r, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel);
+ break;
+ }
+ case eBackgroundImagePosition.CenterLeft:
+ case eBackgroundImagePosition.CenterRight:
+ {
+ Rectangle destRect = new Rectangle(r.X, r.Y, Dpi.Width(backgroundImage.Width), Dpi.Height(backgroundImage.Height));
+ if (r.Width > destRect.Width && backgroundImagePosition == eBackgroundImagePosition.CenterRight)
+ destRect.X += (r.Width - destRect.Width);
+ destRect.Y += (r.Height - destRect.Height) / 2;
+ if (imageAtt != null)
+ g.DrawImage(backgroundImage, destRect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAtt);
+ else
+ g.DrawImage(backgroundImage, destRect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel);
+
+ break;
+ }
+ case eBackgroundImagePosition.Center:
+ {
+ Rectangle destRect = new Rectangle(r.X, r.Y, Dpi.Width(backgroundImage.Width), Dpi.Height(backgroundImage.Height));
+ if (r.Width > destRect.Width)
+ destRect.X += (r.Width - destRect.Width) / 2;
+ if (r.Height > destRect.Height)
+ destRect.Y += (r.Height - destRect.Height) / 2;
+ if (imageAtt != null)
+ g.DrawImage(backgroundImage, destRect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAtt);
+ else
+ g.DrawImage(backgroundImage, destRect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel);
+ break;
+ }
+ case eBackgroundImagePosition.TopLeft:
+ case eBackgroundImagePosition.TopRight:
+ case eBackgroundImagePosition.BottomLeft:
+ case eBackgroundImagePosition.BottomRight:
+ {
+ Rectangle destRect = new Rectangle(r.X, r.Y, Dpi.Width(backgroundImage.Width), Dpi.Height(backgroundImage.Height));
+ if (backgroundImagePosition == eBackgroundImagePosition.TopRight)
+ destRect.X = r.Right - destRect.Width;
+ else if (backgroundImagePosition == eBackgroundImagePosition.BottomLeft)
+ destRect.Y = r.Bottom - destRect.Height;
+ else if (backgroundImagePosition == eBackgroundImagePosition.BottomRight)
+ {
+ destRect.Y = r.Bottom - destRect.Height;
+ destRect.X = r.Right - destRect.Width;
+ }
+
+ if (imageAtt != null)
+ g.DrawImage(backgroundImage, destRect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAtt);
+ else
+ g.DrawImage(backgroundImage, destRect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel);
+ break;
+ }
+ case eBackgroundImagePosition.Tile:
+ {
+ if (imageAtt != null)
+ {
+ int imageWidth = Dpi.Width(backgroundImage.Width);
+ int imageHeight = Dpi.Height(backgroundImage.Height);
+ if (r.Width > imageWidth || r.Height > imageHeight)
+ {
+ int x = r.X, y = r.Y;
+ while (y < r.Bottom)
+ {
+ while (x < r.Right)
+ {
+ Rectangle destRect = new Rectangle(x, y, imageWidth, imageHeight);
+ if (destRect.Right > r.Right)
+ destRect.Width = destRect.Width - (destRect.Right - r.Right);
+ if (destRect.Bottom > r.Bottom)
+ destRect.Height = destRect.Height - (destRect.Bottom - r.Bottom);
+ g.DrawImage(backgroundImage, destRect, 0, 0, imageWidth, imageHeight, GraphicsUnit.Pixel, imageAtt);
+ x += imageWidth;
+ }
+ x = r.X;
+ y += imageHeight;
+ }
+ }
+ else
+ {
+ g.DrawImage(backgroundImage, new Rectangle(0, 0, imageWidth, imageHeight), 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAtt);
+ }
+ }
+ else
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.None;
+ using (TextureBrush brush = new TextureBrush(backgroundImage))
+ {
+ brush.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
+ g.FillRectangle(brush, r);
+ }
+ g.SmoothingMode = sm;
+ }
+ break;
+ }
+ }
+ }
+
+ public static bool IsSystemKey(System.Windows.Forms.Keys key)
+ {
+ if (key == Keys.Add || key == Keys.Alt || key == Keys.Apps || key == Keys.Attn ||
+ key == Keys.Back || key == Keys.Escape || key == Keys.Enter ||
+ (key >= Keys.F1 && key <= Keys.F19) || key == Keys.Tab)
+ return true;
+ return false;
+ }
+
+ public static bool IsFormActive(Form f)
+ {
+ if (f == null) return false;
+
+ if (Form.ActiveForm == f)
+ {
+ if (f.IsMdiChild)
+ {
+ if (f.MdiParent != null)
+ {
+ if (f.MdiParent.ActiveMdiChild == f)
+ return true;
+ else
+ return false;
+ }
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ public static void AnimateControl(System.Windows.Forms.Control control, bool show, int animationTime, Rectangle rectStart, Rectangle rectEnd)
+ {
+ control.Bounds = rectStart;
+ if (!control.Visible)
+ control.Visible = true;
+
+ bool directSet = false;
+ if (animationTime <= 0)
+ directSet = true;
+
+ TimeSpan time = new TimeSpan(0, 0, 0, 0, animationTime);
+ int dxLoc, dyLoc;
+ int dWidth, dHeight;
+ dxLoc = dyLoc = dWidth = dHeight = 0;
+ if (rectStart.Left == rectEnd.Left &&
+ rectStart.Top == rectEnd.Top &&
+ rectStart.Right == rectEnd.Right && rectStart.Height != rectEnd.Height)
+ {
+ dHeight = (rectEnd.Height > rectStart.Height ? 1 : -1);
+ }
+ else if (rectStart.Left == rectEnd.Left &&
+ rectStart.Top == rectEnd.Top &&
+ rectStart.Bottom == rectEnd.Bottom && rectStart.Width != rectEnd.Width)
+ {
+ dWidth = (rectEnd.Width > rectStart.Width ? 1 : -1);
+ }
+ else if (rectStart.Right == rectEnd.Right &&
+ rectStart.Top == rectEnd.Top &&
+ rectStart.Bottom == rectEnd.Bottom && rectStart.Width != rectEnd.Width)
+ {
+ dxLoc = (rectEnd.Width > rectStart.Width ? -1 : 1);
+ dWidth = (rectEnd.Width > rectStart.Width ? 1 : -1);
+ }
+ else if (rectStart.Right == rectEnd.Right &&
+ rectStart.Left == rectEnd.Left &&
+ rectStart.Bottom == rectEnd.Bottom && rectStart.Height != rectEnd.Height)
+ {
+ dyLoc = (rectEnd.Height > rectStart.Height ? -1 : 1);
+ dHeight = (rectEnd.Height > rectStart.Height ? 1 : -1);
+ }
+ else if (rectEnd.X != rectStart.X && rectEnd.Y == rectStart.Y && rectStart.Height == rectEnd.Height && rectEnd.Width == rectStart.Width)
+ {
+ // Simple to left move of the control
+ dxLoc = (rectEnd.X > rectStart.X ? 1 : -1);
+ }
+ else if (rectEnd.Y != rectStart.Y && rectEnd.X == rectStart.X && rectStart.Height == rectEnd.Height && rectEnd.Width == rectStart.Width)
+ {
+ // Simple to left move of the control
+ dxLoc = (rectEnd.Y > rectStart.Y ? 1 : -1);
+ }
+ else
+ directSet = true;
+
+ if (directSet)
+ {
+ control.Bounds = rectEnd;
+ }
+ else
+ {
+ int speedFactor = 1;
+ int totalPixels = (rectStart.Width != rectEnd.Width) ?
+ Math.Abs(rectStart.Width - rectEnd.Width) :
+ Math.Abs(rectStart.Height - rectEnd.Height);
+ if (totalPixels == 0 && rectStart.Width == rectEnd.Width && rectStart.Height == rectEnd.Height)
+ {
+ if (rectEnd.X - rectStart.X != 0)
+ totalPixels = Math.Abs(rectStart.X - rectEnd.X);
+ else if (rectEnd.Y - rectStart.Y != 0)
+ totalPixels = Math.Abs(rectStart.Y - rectEnd.Y);
+ }
+ int remainPixels = totalPixels;
+ DateTime startingTime = DateTime.Now;
+ Rectangle rectAnimation = rectStart;
+ while (rectAnimation != rectEnd)
+ {
+ DateTime startPerMove = DateTime.Now;
+
+ rectAnimation.X += dxLoc * speedFactor;
+ rectAnimation.Y += dyLoc * speedFactor;
+ rectAnimation.Width += dWidth * speedFactor;
+ rectAnimation.Height += dHeight * speedFactor;
+ if (Math.Sign(rectEnd.X - rectAnimation.X) != Math.Sign(dxLoc))
+ rectAnimation.X = rectEnd.X;
+ if (Math.Sign(rectEnd.Y - rectAnimation.Y) != Math.Sign(dyLoc))
+ rectAnimation.Y = rectEnd.Y;
+ if (Math.Sign(rectEnd.Width - rectAnimation.Width) != Math.Sign(dWidth))
+ rectAnimation.Width = rectEnd.Width;
+ if (Math.Sign(rectEnd.Height - rectAnimation.Height) != Math.Sign(dHeight))
+ rectAnimation.Height = rectEnd.Height;
+ control.Bounds = rectAnimation;
+
+ if (control.Parent != null)
+ control.Parent.Update();
+ else
+ control.Update();
+
+ remainPixels -= speedFactor;
+
+ while (true)
+ {
+ DateTime now = DateTime.Now;
+ TimeSpan elapsedPerMove = now - startPerMove;
+ TimeSpan elapsedTime = now - startingTime;
+ if ((time - elapsedTime).TotalMilliseconds <= 0)
+ {
+ speedFactor = remainPixels;
+ break;
+ }
+ else
+ {
+ if ((int)(time - elapsedTime).TotalMilliseconds == 0)
+ speedFactor = 1;
+ else
+ {
+ try
+ {
+
+ speedFactor = remainPixels * (int)elapsedPerMove.TotalMilliseconds / (int)((time - elapsedTime).TotalMilliseconds);
+ }
+ catch { }
+ }
+ }
+ if (speedFactor >= 1)
+ break;
+ }
+ }
+ }
+
+ if (!show)
+ {
+ control.Visible = false;
+ control.Bounds = rectStart;
+ }
+ }
+
+ // internal static Keys GetPressedKey()
+ // {
+ // NativeFunctions.GetKeyboardState
+ //
+ // return Keys.None;
+ // }
+
+ internal static eWinXPColorScheme WinXPColorScheme
+ {
+ get
+ {
+ eWinXPColorScheme c = eWinXPColorScheme.Undetermined;
+ if (BarFunctions.ThemedOS && NativeFunctions.ColorDepth >= 16)
+ {
+ if (m_IsVista)
+ c = eWinXPColorScheme.Blue;
+ else if (SystemColors.Control.ToArgb() == Color.FromArgb(236, 233, 216).ToArgb() && SystemColors.Highlight.ToArgb() == Color.FromArgb(49, 106, 197).ToArgb())
+ c = eWinXPColorScheme.Blue;
+ else if (SystemColors.Control.ToArgb() == Color.FromArgb(224, 223, 227).ToArgb() && SystemColors.Highlight.ToArgb() == Color.FromArgb(178, 180, 191).ToArgb())
+ c = eWinXPColorScheme.Silver;
+ else if (SystemColors.Control.ToArgb() == Color.FromArgb(236, 233, 216).ToArgb() && SystemColors.Highlight.ToArgb() == Color.FromArgb(147, 160, 112).ToArgb())
+ c = eWinXPColorScheme.OliveGreen;
+ }
+
+ return c;
+ }
+ }
+
+ internal static Bitmap LoadBitmap(string imageName)
+ {
+ DotNetBarResourcesAttribute att = Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DotNetBarResourcesAttribute)) as DotNetBarResourcesAttribute;
+ if (att != null && att.NamespacePrefix != "")
+ {
+ return new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream(att.NamespacePrefix + "." + imageName));
+ }
+ else
+ return new Bitmap(typeof(DevComponents.DotNetBar.DotNetBarManager), imageName);
+ }
+
+ internal static Icon LoadIcon(string imageName)
+ {
+ DotNetBarResourcesAttribute att = Attribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DotNetBarResourcesAttribute)) as DotNetBarResourcesAttribute;
+ if (att != null && att.NamespacePrefix != "")
+ {
+ return new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream(att.NamespacePrefix + "." + imageName));
+ }
+ else
+ return new Icon(typeof(DevComponents.DotNetBar.DotNetBarManager), imageName);
+ }
+
+ public static Graphics CreateGraphics(Control objCtrl)
+ {
+ if (objCtrl is ItemControl)
+ return ((ItemControl)objCtrl).CreateGraphics();
+ else if (objCtrl is Bar)
+ return ((Bar)objCtrl).CreateGraphics();
+ else if (objCtrl is ExplorerBar)
+ return ((ExplorerBar)objCtrl).CreateGraphics();
+ else if (objCtrl is BaseItemControl)
+ return ((BaseItemControl)objCtrl).CreateGraphics();
+ else if (objCtrl is BarBaseControl)
+ return ((BarBaseControl)objCtrl).CreateGraphics();
+ else if (objCtrl is PanelControl)
+ return ((PanelControl)objCtrl).CreateGraphics();
+ else if (objCtrl is PopupItemControl)
+ return ((PopupItemControl)objCtrl).CreateGraphics();
+
+ return objCtrl.CreateGraphics();
+ }
+
+ public static bool IsOffice2007Style(eDotNetBarStyle style)
+ {
+ if (style == eDotNetBarStyle.StyleManagerControlled)
+ style = StyleManager.GetEffectiveStyle();
+ return (style == eDotNetBarStyle.Office2007 || style == eDotNetBarStyle.Office2010 || style == eDotNetBarStyle.Windows7 || StyleManager.IsMetro(style));
+ }
+
+ public static bool IsOffice2010Style(eDotNetBarStyle style)
+ {
+ if (style == eDotNetBarStyle.StyleManagerControlled)
+ style = StyleManager.GetEffectiveStyle();
+ return (style == eDotNetBarStyle.Office2010 || style == eDotNetBarStyle.Windows7 || StyleManager.IsMetro(style));
+ }
+
+ public static bool IsOffice2007StyleOnly(eDotNetBarStyle style)
+ {
+ if (style == eDotNetBarStyle.StyleManagerControlled)
+ style = StyleManager.GetEffectiveStyle();
+ return (style == eDotNetBarStyle.Office2007);
+ }
+ }
+
+ internal class ScreenInformation
+ {
+ public Rectangle Bounds = Rectangle.Empty;
+ public Rectangle WorkingArea = Rectangle.Empty;
+ public bool Primary = false;
+ public ScreenInformation(Rectangle bounds, Rectangle workingarea)
+ {
+ this.Bounds = bounds;
+ this.WorkingArea = workingarea;
+ }
+ public ScreenInformation(Rectangle bounds, Rectangle workingarea, bool primary)
+ {
+ this.Bounds = bounds;
+ this.WorkingArea = workingarea;
+ this.Primary = primary;
+ }
+ }
+
+ internal enum eWinXPColorScheme
+ {
+ Undetermined,
+ Blue,
+ OliveGreen,
+ Silver
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class LocalizationManager : IDisposable
+ {
+ private ResourceManager m_ResourceManager = null;
+ private IOwnerLocalize m_Manager = null;
+
+ public LocalizationManager()
+ : this(null)
+ {
+ }
+ public LocalizationManager(IOwnerLocalize manager)
+ {
+ m_Manager = manager;
+ }
+ public void Dispose()
+ {
+ m_ResourceManager = null;
+ m_Manager = null;
+ }
+
+ public string GetDefaultLocalizedString(string key)
+ {
+ string s = GetLocalizedString(key);
+ if (s == "" || s == null)
+ {
+ ResourceManager res = BarFunctions.GetResourceManager(true);
+ s = res.GetString(key);
+ }
+ if (s == null)
+ s = "";
+ return s;
+ }
+
+ public static string GetLocalizedString(string key, string defaultValue)
+ {
+ LocalizeEventArgs e = new LocalizeEventArgs();
+ e.Key = key;
+ e.LocalizedValue = defaultValue;
+ LocalizationKeys.InvokeLocalizeString(e);
+ if (e.Handled)
+ return e.LocalizedValue;
+
+ return defaultValue;
+ }
+
+ public string GetLocalizedString(string key)
+ {
+ string s = "";
+ if (m_ResourceManager == null)
+ m_ResourceManager = BarFunctions.GetResourceManager();
+ if (m_ResourceManager != null)
+ {
+ s = m_ResourceManager.GetString(key);
+ if (s == null)
+ s = "";
+ }
+
+ // Fire static event first
+ LocalizeEventArgs e = new LocalizeEventArgs();
+ e.Key = key;
+ e.LocalizedValue = s;
+ LocalizationKeys.InvokeLocalizeString(e);
+ if (e.Handled)
+ return e.LocalizedValue;
+
+
+ if (m_Manager != null)
+ {
+ m_Manager.InvokeLocalizeString(e);
+ if (e.Handled)
+ return e.LocalizedValue;
+ }
+
+ return s;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BarSerialization/BarSerializationXml.cs b/PROMS/DotNetBar Source Code/BarSerialization/BarSerializationXml.cs
new file mode 100644
index 00000000..b69a675d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BarSerialization/BarSerializationXml.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Holds the XML element and attribute names for bar serialization.
+ ///
+ internal class BarSerializationXml
+ {
+ public static string Bar="bar";
+ public static string Name="name";
+ public static string Custom="custom";
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BarTextBox.cs b/PROMS/DotNetBar Source Code/BarTextBox.cs
new file mode 100644
index 00000000..edf0c230
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BarTextBox.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for BarTextBox.
+ ///
+ internal class BarTextBox:TextBox
+ {
+ private int m_LastFocusWindow;
+ private string m_OriginalText;
+ public BarTextBox()
+ {
+ this.BorderStyle=System.Windows.Forms.BorderStyle.None;
+ this.AutoSize=false;
+ this.TabStop=false;
+ m_LastFocusWindow=0;
+ }
+
+ protected override void WndProc(ref Message m)
+ {
+ if(m.Msg==NativeFunctions.WM_SETFOCUS)
+ {
+ m_LastFocusWindow=m.WParam.ToInt32();
+ m_OriginalText=this.Text;
+ }
+ base.WndProc(ref m);
+ }
+
+ public void ReleaseFocus()
+ {
+ if(this.Focused && m_LastFocusWindow!=0)
+ {
+ int focus=m_LastFocusWindow;
+ m_LastFocusWindow=0;
+ Control ctrl=Control.FromChildHandle(new System.IntPtr(focus));
+ if(ctrl!=this)
+ {
+ Control p=this.Parent;
+ while(p!=null)
+ {
+ if(p==ctrl)
+ return;
+ p=p.Parent;
+ }
+
+ if(ctrl!=null)
+ ctrl.Focus();
+ else
+ {
+ NativeFunctions.SetFocus(focus);
+ }
+ }
+
+ //this.OnLostFocus(new System.EventArgs());
+ //this.InvokeLostFocus(this,new System.EventArgs());
+ }
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ if(e.KeyCode==Keys.Enter)
+ ReleaseFocus();
+ else if(e.KeyCode==Keys.Escape)
+ {
+ this.Text=m_OriginalText;
+ ReleaseFocus();
+ }
+
+ base.OnKeyDown(e);
+ }
+
+ protected override void OnLostFocus(EventArgs e)
+ {
+ m_LastFocusWindow=0;
+ base.OnLostFocus(e);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BarUtilities.cs b/PROMS/DotNetBar Source Code/BarUtilities.cs
new file mode 100644
index 00000000..9e46f569
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BarUtilities.cs
@@ -0,0 +1,422 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Drawing.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents class with static functions that provide commonly used utility functions when working with
+ /// Bar objects and items hosted by Bar object.
+ ///
+ public class BarUtilities
+ {
+ #region Docking
+ ///
+ /// Sets Bar visible property and remembers the auto-hide state.
+ ///
+ /// Bar to set visibility for.
+ /// true if visible otherwise false
+ public static void SetBarVisible(Bar bar, bool visible)
+ {
+ if (bar == null || bar.Visible == visible)
+ return;
+
+ DotNetBarManager manager = bar.Owner as DotNetBarManager;
+ if (manager != null)
+ manager.SuspendLayout = true;
+
+ try
+ {
+ if (visible)
+ {
+ bar.Visible = true;
+ if (bar.PropertyBag.ContainsKey(BarPropertyBagKeys.AutoHideSetting))
+ {
+ bar.PropertyBag.Remove(BarPropertyBagKeys.AutoHideSetting);
+ bar.AutoHide = true;
+ }
+ }
+ else
+ {
+ if (bar.PropertyBag.ContainsKey(BarPropertyBagKeys.AutoHideSetting))
+ bar.PropertyBag.Remove(BarPropertyBagKeys.AutoHideSetting);
+ // Remember auto-hide setting
+ if (bar.AutoHide)
+ bar.PropertyBag.Add(BarPropertyBagKeys.AutoHideSetting, true);
+ bar.CloseBar();
+ }
+ }
+ finally
+ {
+ if (manager != null)
+ manager.SuspendLayout = false;
+ bar.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Sets the visible property of DockContainerItem and hides the bar if the given item is the last visible item on the bar.
+ /// It will also automatically display the bar if bar is not visible.
+ ///
+ /// DockContainerItem to set visibility for.
+ /// Indicates the visibility of the item
+ public static void SetDockContainerVisible(DevComponents.DotNetBar.DockContainerItem item, bool visible)
+ {
+ if(item==null || item.Visible==visible)
+ return;
+
+ DevComponents.DotNetBar.Bar containerBar=item.ContainerControl as DevComponents.DotNetBar.Bar;
+
+ if(containerBar==null)
+ {
+ // If bar has not been assigned yet just set the visible property and exit
+ item.Visible=visible;
+ return;
+ }
+
+ DotNetBarManager manager=containerBar.Owner as DotNetBarManager;
+ if(manager!=null)
+ manager.SuspendLayout=true;
+
+ try
+ {
+ int visibleCount=containerBar.VisibleItemCount;
+
+ if(visible)
+ {
+ item.Visible=true;
+ if(!containerBar.AutoHide && !containerBar.Visible && visibleCount<=1)
+ {
+ containerBar.Visible=true;
+ if(containerBar.PropertyBag.ContainsKey(BarPropertyBagKeys.AutoHideSetting))
+ {
+ containerBar.PropertyBag.Remove(BarPropertyBagKeys.AutoHideSetting);
+ containerBar.AutoHide=true;
+ }
+ }
+ }
+ else
+ {
+ if (visibleCount <= 1)
+ {
+ if (containerBar.PropertyBag.ContainsKey(BarPropertyBagKeys.AutoHideSetting))
+ containerBar.PropertyBag.Remove(BarPropertyBagKeys.AutoHideSetting);
+ // Remember auto-hide setting
+ if (containerBar.AutoHide)
+ containerBar.PropertyBag.Add(BarPropertyBagKeys.AutoHideSetting, true);
+ containerBar.CloseBar();
+ }
+ item.Visible=false;
+ }
+ }
+ finally
+ {
+ if(manager!=null)
+ manager.SuspendLayout=false;
+ containerBar.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Creates new instance of the bar and sets its properties so bar can be used as Document bar.
+ ///
+ /// Returns new instance of the bar.
+ public static Bar CreateDocumentBar()
+ {
+ Bar bar=new Bar();
+ BarUtilities.InitializeDocumentBar(bar);
+ return bar;
+ }
+
+ ///
+ /// Sets the properties on a bar so it can be used as Document bar.
+ ///
+ /// Bar to set properties of.
+ public static void InitializeDocumentBar(Bar bar)
+ {
+ TypeDescriptor.GetProperties(bar)["LayoutType"].SetValue(bar,eLayoutType.DockContainer);
+ TypeDescriptor.GetProperties(bar)["DockTabAlignment"].SetValue(bar,eTabStripAlignment.Top);
+ TypeDescriptor.GetProperties(bar)["AlwaysDisplayDockTab"].SetValue(bar,true);
+ TypeDescriptor.GetProperties(bar)["Stretch"].SetValue(bar,true);
+ TypeDescriptor.GetProperties(bar)["GrabHandleStyle"].SetValue(bar,eGrabHandleStyle.None);
+ TypeDescriptor.GetProperties(bar)["CanDockBottom"].SetValue(bar,false);
+ TypeDescriptor.GetProperties(bar)["CanDockTop"].SetValue(bar,false);
+ TypeDescriptor.GetProperties(bar)["CanDockLeft"].SetValue(bar,false);
+ TypeDescriptor.GetProperties(bar)["CanDockRight"].SetValue(bar,false);
+ TypeDescriptor.GetProperties(bar)["CanDockDocument"].SetValue(bar,true);
+ TypeDescriptor.GetProperties(bar)["CanUndock"].SetValue(bar,false);
+ TypeDescriptor.GetProperties(bar)["CanHide"].SetValue(bar,true);
+ TypeDescriptor.GetProperties(bar)["CanCustomize"].SetValue(bar,false);
+ TypeDescriptor.GetProperties(bar)["TabNavigation"].SetValue(bar,true);
+ }
+
+ #region Win API
+ [DllImport("user32")]
+ private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
+ [DllImport("user32")]
+ private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
+ private const int GWL_EXSTYLE = (-20);
+ private const int WS_EX_CLIENTEDGE = 0x00000200;
+ [DllImport("user32")]
+ private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
+ const int SWP_FRAMECHANGED = 0x0020;
+ const int SWP_NOSIZE = 0x0001;
+ const int SWP_NOMOVE = 0x0002;
+ const int SWP_NOZORDER = 0x0004;
+ #endregion
+
+ ///
+ /// Changes the MDI Client border edge to remove 3D border or to add it.
+ ///
+ /// Reference to MDI Client object.
+ /// Indicates whether to remove border.
+ public static void ChangeMDIClientBorder(System.Windows.Forms.MdiClient c, bool removeBorder)
+ {
+ if (c != null)
+ {
+ int exStyle = GetWindowLong(c.Handle, GWL_EXSTYLE);
+
+ if(removeBorder)
+ exStyle ^= WS_EX_CLIENTEDGE;
+ else
+ exStyle |= WS_EX_CLIENTEDGE;
+
+ SetWindowLong(c.Handle, GWL_EXSTYLE, exStyle);
+ SetWindowPos(c.Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+ }
+ }
+
+ ///
+ /// Changes the MDI Client border edge to remove 3D border or to add it.
+ ///
+ /// Reference to MDI parent form.
+ /// Indicates whether to remove border.
+ public static void ChangeMDIClientBorder(System.Windows.Forms.Form c, bool removeBorder)
+ {
+ if (c.IsMdiContainer && c.IsHandleCreated)
+ {
+ foreach (System.Windows.Forms.Control control in c.Controls)
+ {
+ if (control is System.Windows.Forms.MdiClient)
+ {
+ ChangeMDIClientBorder(control as System.Windows.Forms.MdiClient, removeBorder);
+ break;
+ }
+ }
+ }
+ }
+ #endregion
+
+ #region Item Invalidate
+ internal static void InvalidateFontChange(SubItemsCollection col)
+ {
+ foreach (BaseItem item in col)
+ {
+ InvalidateFontChange(item);
+ }
+ }
+
+ internal static void InvalidateFontChange(BaseItem item)
+ {
+ if (item.TextMarkupBody != null) item.TextMarkupBody.InvalidateElementsSize();
+ if (item.SubItems.Count > 0) InvalidateFontChange(item.SubItems);
+ }
+ #endregion
+
+ internal static void InvokeRecalcLayout(System.Windows.Forms.Control control)
+ {
+ if (control is Bar)
+ ((Bar)control).RecalcLayout();
+ else if (control is ItemControl)
+ ((ItemControl)control).RecalcLayout();
+ else if (control is BaseItemControl)
+ ((BaseItemControl)control).RecalcLayout();
+ else if (control is ExplorerBar)
+ ((ExplorerBar)control).RecalcLayout();
+ else if (control is SideBar)
+ ((SideBar)control).RecalcLayout();
+ }
+
+ private static volatile bool _FadeAnimatorEnabled = true;
+ ///
+ /// Gets or sets whether Fade Animation is enabled on system level for DotNetBar items which use this. Default value is true.
+ ///
+ public static bool FadeAnimatorEnabled
+ {
+ get { return _FadeAnimatorEnabled; }
+ set { _FadeAnimatorEnabled = value; }
+ }
+
+ ///
+ /// Gets or sets whether StringFormat internally used by all DotNetBar controls to render text is GenericDefault. Default value is false
+ /// which indicates that GenericTypographic is used.
+ ///
+ public static bool UseGenericDefaultStringFormat
+ {
+ get { return TextDrawing.UseGenericDefault; }
+ set { TextDrawing.UseGenericDefault = value; }
+ }
+
+ ///
+ /// Gets or sets the anti-alias text rendering hint that will be used to render text on controls that have AntiAlias property set to true.
+ ///
+ public static TextRenderingHint AntiAliasTextRenderingHint
+ {
+ get
+ {
+ return DisplayHelp.AntiAliasTextRenderingHint;
+ }
+ set
+ {
+ DisplayHelp.AntiAliasTextRenderingHint = value;
+ }
+ }
+
+#if FRAMEWORK20
+ ///
+ /// Gets or sets whether .NET Framework TextRenderer class is used for text rendering instead of Graphics.DrawString.
+ /// Default value is false.
+ /// Using TextRenderer will disable the Fade and Animation effects on controls because of issues in TextRenderer when drawing text on transparent
+ /// surfaces.
+ ///
+ public static bool UseTextRenderer
+ {
+ get { return TextDrawing.UseTextRenderer; }
+ set { TextDrawing.UseTextRenderer = value; }
+ }
+#endif
+
+
+ private static bool _AlwaysGenerateAccessibilityFocusEvent = false;
+ ///
+ /// Gets or sets whether items always generate the Focus accessibility event when mouse enters the item. Default value is false which indicates
+ /// that focus event will be raised only when item is on menu bar.
+ ///
+ public static bool AlwaysGenerateAccessibilityFocusEvent
+ {
+ get { return _AlwaysGenerateAccessibilityFocusEvent; }
+ set
+ {
+ _AlwaysGenerateAccessibilityFocusEvent = value;
+ }
+ }
+
+ internal static bool IsModalFormOpen
+ {
+ get
+ {
+#if (FRAMEWORK20)
+ for (int i = 0; i < System.Windows.Forms.Application.OpenForms.Count; i++)
+ {
+ System.Windows.Forms.Form form = System.Windows.Forms.Application.OpenForms[i];
+ if (form.Modal) return true;
+ }
+#endif
+ return false;
+ }
+ }
+
+ private static bool _AutoRemoveMessageFilter = false;
+ ///
+ /// Gets or sets whether Application Message Filter that is registered by popup controls
+ /// is automatically unregistered when last control is disposed. Default value is false and
+ /// in most cases should not be changed.
+ ///
+ public static bool AutoRemoveMessageFilter
+ {
+ get { return _AutoRemoveMessageFilter; }
+ set { _AutoRemoveMessageFilter = value; }
+ }
+
+ private static int _TextMarkupCultureSpecific = 3;
+ ///
+ /// Get or sets the text-markup padding for text measurement when running on Japanese version of Windows.
+ ///
+ public static int TextMarkupCultureSpecificPadding
+ {
+ get { return _TextMarkupCultureSpecific; }
+ set
+ {
+ _TextMarkupCultureSpecific = value;
+ }
+ }
+
+ private static bool _DisposeItemImages = false;
+ ///
+ /// Gets or sets whether Image and Icon resources assigned to items and controls are automatically disposed when
+ /// control or item is disposed. Default value is false.
+ ///
+ public static bool DisposeItemImages
+ {
+ get
+ {
+ return _DisposeItemImages;
+ }
+ set
+ {
+ _DisposeItemImages = value;
+ }
+ }
+
+ ///
+ /// Disposes image reference and sets it to null.
+ ///
+ /// Reference to image to dispose.
+ internal static void DisposeImage(ref System.Drawing.Image image)
+ {
+ if (image == null) return;
+ image.Dispose();
+ image = null;
+ }
+ ///
+ /// Disposes image reference and sets it to null.
+ ///
+ /// Reference to image to dispose.
+ internal static void DisposeImage(ref System.Drawing.Icon icon)
+ {
+ if (icon == null) return;
+ icon.Dispose();
+ icon = null;
+ }
+
+ #region Delayed Invoke
+ ///
+ /// Invokes the method asynchronously using the WinForms Timer.
+ ///
+ /// Method to invoke.
+ public static void InvokeDelayed(MethodInvoker method)
+ {
+ InvokeDelayed(method, 10);
+ }
+ ///
+ /// Invokes the method asynchronously using the WinForms Timer.
+ ///
+ /// Method to invoke.
+ /// Time in milliseconds after which method is invoked.
+ public static void InvokeDelayed(MethodInvoker method, int delayInterval)
+ {
+ Timer delayedInvokeTimer = new Timer();
+ delayedInvokeTimer = new Timer();
+ delayedInvokeTimer.Tag = method;
+ delayedInvokeTimer.Interval = delayInterval;
+ delayedInvokeTimer.Tick += new EventHandler(DelayedInvokeTimerTick);
+ delayedInvokeTimer.Start();
+ }
+ private static void DelayedInvokeTimerTick(object sender, EventArgs e)
+ {
+ Timer timer = (Timer)sender;
+ MethodInvoker method = (MethodInvoker)timer.Tag;
+ timer.Stop();
+ timer.Dispose();
+ method.Invoke();
+ }
+ #endregion
+ }
+
+ internal class BarPropertyBagKeys
+ {
+ public static string AutoHideSetting="autohide";
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Bars.cs b/PROMS/DotNetBar Source Code/Bars.cs
new file mode 100644
index 00000000..42530b22
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Bars.cs
@@ -0,0 +1,192 @@
+using System;
+using System.Collections;
+using System.Runtime.Serialization;
+using System.Xml;
+
+namespace DevComponents.DotNetBar
+{
+
+ ///
+ /// Collection of Bar objects.
+ ///
+ public class Bars:System.Collections.CollectionBase,IDisposable
+ {
+ private DotNetBarManager m_Owner;
+ internal Bars(DotNetBarManager Owner)
+ {
+ m_Owner=Owner;
+ }
+
+ internal DotNetBarManager Owner
+ {
+ get
+ {
+ return m_Owner;
+ }
+ }
+
+ ///
+ /// Releases the resources used by the Component.
+ ///
+ public void Dispose()
+ {
+ m_Owner=null;
+ List.Clear();
+ }
+
+ ///
+ /// Adds an Bar to the end of Bars collection.
+ ///
+ /// The Bar to be added to the end of the Bars collection.
+ public void Add(Bar bar)
+ {
+ if(List.IndexOf(bar)<0)
+ List.Add(bar);
+ else
+ throw new InvalidOperationException("Bar is already in collection.");
+ }
+
+ protected override void OnInsertComplete(int index,object value)
+ {
+ base.OnInsertComplete(index,value);
+ Bar bar=(Bar)value;
+ bar.Owner=m_Owner;
+ bar.ThemeAware=m_Owner.ThemeAware;
+ bar.Style=m_Owner.Style;
+ IOwnerBarSupport ownersupport=m_Owner as IOwnerBarSupport;
+ if(ownersupport!=null)
+ ownersupport.AddShortcutsFromBar(bar);
+ bar.OnAddedToBars();
+ }
+
+ ///
+ /// Gets the Bar at the specified index.
+ ///
+ public Bar this[int Index]
+ {
+ get
+ {
+ return List[Index] as Bar;
+ }
+ }
+
+ ///
+ /// Gets the Bar with the specified name.
+ ///
+ public Bar this[string Name]
+ {
+ get
+ {
+ foreach(Bar bar in List)
+ if(bar.Name==Name)
+ return bar;
+ return null;
+ }
+ }
+
+ ///
+ /// Removes specified bar from collection.
+ ///
+ /// Bar to remove
+ public virtual void Remove(Bar bar)
+ {
+ List.Remove(bar);
+ }
+
+ protected override void OnRemoveComplete(int index,object value)
+ {
+ Bar bar=(Bar)value;
+ IOwnerBarSupport ownersupport=m_Owner as IOwnerBarSupport;
+ if(ownersupport!=null)
+ ownersupport.RemoveShortcutsFromBar(bar);
+
+ if(bar.Visible)
+ bar.HideBar();
+
+ if(bar.Parent!=null)
+ {
+ if(bar.Parent is DockSite && ((DockSite)bar.Parent).IsDocumentDock)
+ ((DockSite)bar.Parent).GetDocumentUIManager().UnDock(bar);
+ if(bar.Parent!=null)
+ bar.Parent.Controls.Remove(bar);
+ }
+
+ base.OnRemoveComplete(index,value);
+ }
+
+ protected override void OnClear()
+ {
+ if (m_Owner != null && m_Owner.GetDesignMode())
+ return;
+
+ foreach(Bar bar in List)
+ {
+ if (bar.GetDesignMode())
+ continue;
+ if(bar.AutoHide)
+ bar.AutoHide=false;
+ if(bar.Visible)
+ bar.HideBar();
+ if (bar.DockSide == eDockSide.Document && bar.Parent is DockSite && ((DockSite)bar.Parent).GetDocumentUIManager()!=null)
+ ((DockSite)bar.Parent).GetDocumentUIManager().UnDock(bar);
+ if(bar!=null && !bar.IsDisposed)
+ ((IOwnerBarSupport)m_Owner).RemoveShortcutsFromBar(bar);
+ if(bar.Parent!=null)
+ bar.Parent.Controls.Remove(bar);
+ if (!bar.GetDesignMode())
+ bar.Dispose();
+ }
+ }
+
+ ///
+ /// Determines whether an Bar is in the collection.
+ ///
+ /// The Bar to locate in the collection.
+ /// true if item is found in the collection; otherwise, false.
+ public bool Contains(Bar bar)
+ {
+ return List.Contains(bar);
+ }
+
+ ///
+ /// Determines whether bar with given name is in collection.
+ ///
+ /// Name of the bar
+ /// True if bar is part of this collection, otherwise false.
+ public bool Contains(string name)
+ {
+ foreach(Bar bar in this.List)
+ if(bar.Name==name)
+ return true;
+ return false;
+ }
+
+ ///
+ /// Returns the zero-based index of the Bar in the collection.
+ ///
+ /// Bar to locate.
+ ///
+ public int IndexOf(Bar bar)
+ {
+ return List.IndexOf(bar);
+ }
+
+ public void CopyTo(System.Array array)
+ {
+ List.CopyTo(array,0);
+ }
+
+ internal void ClearNonDocumentBars()
+ {
+ ArrayList removeList=new ArrayList(this.Count);
+ foreach(Bar bar in this.List)
+ {
+ if(bar.DockSide!=eDockSide.Document)
+ removeList.Add(bar);
+ }
+
+ foreach(Bar bar in removeList)
+ this.Remove(bar);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BaseItem.cs b/PROMS/DotNetBar Source Code/BaseItem.cs
new file mode 100644
index 00000000..ee0af3b7
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BaseItem.cs
@@ -0,0 +1,4880 @@
+using System;
+using System.Collections;
+using DevComponents.UI.ContentManager;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Defines the base class for items that are used by DotNetBar.
+ ///
+ [System.ComponentModel.ToolboxItem(false),System.ComponentModel.DesignTimeVisible(false)]
+ public abstract class BaseItem : Component, ICloneable, IBlock, ICommandSource, IComparable
+#if FRAMEWORK20
+ , IBindableComponent
+#endif
+ {
+ #region Event Definition
+ // Events
+ ///
+ /// Occurs when Item is clicked.
+ ///
+ [System.ComponentModel.Description("Occurs when Item is clicked.")]
+ public event EventHandler Click;
+
+ ///
+ /// Occurs when Item is double-clicked.
+ ///
+ [System.ComponentModel.Description("Occurs when Item is double-clicked.")]
+ public event EventHandler DoubleClick;
+
+ ///
+ /// Occurs when Item Expanded property has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when Item Expanded property has changed.")]
+ public event EventHandler ExpandChange;
+
+ ///
+ /// Occurs when item loses input focus.
+ ///
+ [System.ComponentModel.Description("Occurs when item loses input focus.")]
+ public event EventHandler LostFocus;
+
+ ///
+ /// Occurs when item receives input focus.
+ ///
+ [System.ComponentModel.Description("Occurs when item receives input focus.")]
+ public event EventHandler GotFocus;
+
+ ///
+ /// Occurs when mouse button is pressed.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse button is pressed.")]
+ public event System.Windows.Forms.MouseEventHandler MouseDown;
+
+ ///
+ /// Occurs when mouse button is released.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse button is released.")]
+ public event System.Windows.Forms.MouseEventHandler MouseUp;
+
+ ///
+ /// Occurs when mouse enters the item.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse enters the item.")]
+ public event EventHandler MouseEnter;
+
+ ///
+ /// Occurs when mouse leaves the item.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse leaves the item.")]
+ public event EventHandler MouseLeave;
+
+ ///
+ /// Occurs when mouse moves over the item.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse moves over the item.")]
+ public event System.Windows.Forms.MouseEventHandler MouseMove;
+
+ ///
+ /// Occurs when mouse remains still inside an item for an amount of time.
+ ///
+ [System.ComponentModel.Description("Occurs when mouse remains still inside an item for an amount of time.")]
+ public event EventHandler MouseHover;
+
+ ///
+ /// Occurs when copy of the item is made.
+ ///
+ [System.ComponentModel.Description("Occurs when copy of the item is made.")]
+ public event EventHandler ItemCopied;
+
+ ///
+ /// Occurs when Text property of an Item has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when Text property of an Item has changed.")]
+ public event EventHandler TextChanged;
+
+ ///
+ /// Occurs when Visible property of an Item has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when Visible property of an Item has changed.")]
+ public event EventHandler VisibleChanged;
+
+ ///
+ /// Occurs when Enabled property of an Item has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when Enabled property of an Item has changed.")]
+ public event EventHandler EnabledChanged;
+
+ /////
+ ///// Occurs when component is Disposed.
+ /////
+ //[System.ComponentModel.Description("Occurs when component is Disposed.")]
+ //public event EventHandler Disposed;
+
+ ///
+ /// Occurs when item's tooltip visibility has changed.
+ ///
+ [System.ComponentModel.Description("Occurs when item's tooltip visibility has changed.")]
+ public event EventHandler ToolTipVisibleChanged;
+// ///
+// /// Occurs when actual visiblity on screen of an item has changed i.e. Displayed property change.
+// ///
+// [System.ComponentModel.Description("Occurs when actual visiblity on screen of an item has changed.")]
+// public event EventHandler DisplayedChanged;
+ ///
+ /// Occurs when content of SubItems collection has changed.
+ ///
+ [Description("Occurs when content of SubItems collection has changed")]
+ public event CollectionChangeEventHandler SubItemsChanged;
+ #endregion
+
+ #region Private variables
+ protected string m_Text;
+ protected System.Drawing.Rectangle m_Rect;
+ protected SubItemsCollection m_SubItems;
+ protected bool m_Visible;
+ protected BaseItem m_HotSubItem; // Sub Item with Mouse over it
+ protected bool m_IsContainer;
+ protected BaseItem m_Parent;
+ protected bool m_NeedRecalcSize;
+ protected bool m_Expanded;
+ protected bool m_AutoExpand; // If this is a container should it expand automaticly its child items
+ protected object m_ContainerControl;
+ protected bool m_Displayed; // Set to true when item is shown on screen
+ protected object m_ItemData;
+ protected bool m_Enabled;
+ protected bool m_BeginGroup;
+ protected eDotNetBarStyle m_Style;
+ protected string m_Description; // Item description
+ protected string m_Tooltip; // Tooltip
+ protected string m_Name=""; // Unique Item name that can be used to access item
+ private string m_GlobalName = "";
+ protected string m_Category;
+ protected eOrientation m_Orientation;
+ protected bool m_SystemItem;
+ protected eSupportedOrientation m_SupportedOrientation=eSupportedOrientation.Both;
+ protected bool m_RecalculatingSize=false;
+ protected bool m_CheckMouseMovePressed = false;
+ private bool m_CanCustomize;
+ private int m_Id;
+ private bool m_ShowSubItems;
+ private bool m_Focused;
+ private bool m_Stretch=false;
+ internal Rectangle m_ViewRectangle;
+
+ protected ToolTip m_ToolTipWnd;
+ private static int s_IdCounter;
+ private bool m_IsOnCustomizeMenu;
+ private bool m_IsOnCustomizeDialog;
+ protected char m_AccessKey;
+ private bool m_DesignMode;
+ private eItemAlignment m_ItemAlignment; // Item alignment in containers that support alignment
+
+ private ShortcutsCollection m_Shortcuts;
+ private string m_ShortcutString = "";
+
+ private System.Drawing.Point m_MouseDownPt;
+
+ private object m_Owner;
+
+ private bool m_ClickAutoRepeat=false;
+ private int m_ClickRepeatInterval=600;
+ private bool m_AutoCollapseOnClick=true;
+ private bool m_SuspendLayout=false;
+ private bool m_IsRightToLeft = false;
+ //private System.ComponentModel.ISite m_ComponentSite=null;
+ protected bool m_ThemeAware=false;
+
+ // When item is parented to the Items collection GlobalItem is set to true.
+ // This flag is used to propagate property changes to all items with the same name.
+ // Setting for example Visible property on the item that has GlobalItem true will
+ // set visible property to the same value on all items with the same name.
+ private bool m_GlobalItem=true;
+
+ private eDesignInsertPosition m_DesignInsertMarker=eDesignInsertPosition.None;
+
+ private System.Windows.Forms.Cursor m_Cursor=null;
+ private System.Windows.Forms.Cursor m_ContainerCursor=null;
+ protected bool m_ShouldSerialize=true;
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool _IgnoreClick=false;
+ protected bool m_AllowOnlyOneSubItemExpanded=true; // Controls whether only ONE sub item can be expanded at a time, see InternalMouseDown
+
+ //private System.Windows.Forms.AccessibleObject m_Accessible=null;
+ private string m_AccessibleDefaultActionDescription="";
+ private System.Windows.Forms.AccessibleRole m_AccessibleRole=System.Windows.Forms.AccessibleRole.Default;
+ private string m_AccessibleName="";
+ private string m_AccessibleDescription="";
+ private bool m_IsAccessible=true;
+
+ // Used to save extended information about item customization...
+ private string m_OriginalBarName="";
+ private int m_OriginalPosition=-1;
+ private string m_KeyTips = "";
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Point DesignTimeMouseDownPoint = Point.Empty;
+ internal bool RenderText = true;
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool MouseUpNotification = false;
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool MouseDownCapture = false; // Indicates whether item will receive mouse messages if it is pressed and mouse leaves the item
+ private bool m_UserCustomized = false;
+ private bool m_IsDisposed = false;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Creates new instance of BaseItem.
+ ///
+ public BaseItem():this("","") {}
+ ///
+ /// Creates new instance of BaseItem and assigns item name.
+ ///
+ /// Item name.
+ public BaseItem(string sItemName):this(sItemName,""){}
+ ///
+ /// Creates new instance of BaseItem and assigns item name and item text.
+ ///
+ /// Item Name
+ /// Item Text
+ public BaseItem(string sItemName, string ItemText)
+ {
+ if (ItemText == null)
+ ItemText = "";
+ m_Text=ItemText;
+ if(m_Text!="")
+ m_AccessKey=NativeFunctions.GetAccessKey(m_Text);
+ m_Rect=System.Drawing.Rectangle.Empty;
+ m_ContainerControl=null;
+ m_HotSubItem=null;
+ m_IsContainer=false;
+ m_SubItems=null;
+ m_Parent=null;
+ m_NeedRecalcSize=true;
+ m_Visible=true;
+ m_Expanded=false;
+ m_AutoExpand=false;
+ m_ItemData=null;
+ m_Enabled=true;
+ m_BeginGroup=false;
+ m_Style=eDotNetBarStyle.OfficeXP;
+ m_Description="";
+ m_Tooltip="";
+ m_Name=sItemName;
+ m_Category="";
+ m_Orientation=eOrientation.Horizontal;
+ m_ToolTipWnd=null;
+ m_Id=++s_IdCounter;
+ m_IsOnCustomizeMenu=false;
+ m_IsOnCustomizeDialog=false;
+ m_SystemItem=false;
+ //m_AccessKey=;
+ m_Shortcuts=null;
+ m_DesignMode=false;
+ m_CanCustomize=true;
+ m_ShowSubItems=true;
+ m_ItemAlignment=eItemAlignment.Near;
+ m_Focused=false;
+ m_Owner=null;
+ MarkupTextChanged();
+ }
+ #endregion
+
+ #region Serialization
+ ///
+ /// Serializes the item and all sub-items into the XmlElement.
+ ///
+ /// XmlElement to serialize the item to.
+ protected internal virtual void Serialize(ItemSerializationContext context)
+ {
+ System.Xml.XmlElement ThisItem = context.ItemXmlElement;
+ Type t=this.GetType();
+ System.Reflection.AssemblyName aname=t.Assembly.GetName();
+ if(aname.Name!="DevComponents.DotNetBar")
+ ThisItem.SetAttribute("assembly",aname.Name+", PublicKeyToken="+System.Text.Encoding.ASCII.GetString(aname.GetPublicKey()));
+ else
+ ThisItem.SetAttribute("assembly",aname.Name);
+
+ ThisItem.SetAttribute("class",t.FullName);
+
+ ThisItem.SetAttribute("name",m_Name);
+ ThisItem.SetAttribute("globalname", m_GlobalName);
+ ThisItem.SetAttribute("text",m_Text);
+ ThisItem.SetAttribute("iscontainer",System.Xml.XmlConvert.ToString(m_IsContainer));
+ ThisItem.SetAttribute("visible",System.Xml.XmlConvert.ToString(m_Visible));
+ if(m_ItemData!=null && m_ItemData.ToString()!="")
+ ThisItem.SetAttribute("itemdata",m_ItemData.ToString());
+ else
+ ThisItem.SetAttribute("itemdata","");
+ ThisItem.SetAttribute("enabled",System.Xml.XmlConvert.ToString(m_Enabled));
+ ThisItem.SetAttribute("begingroup",System.Xml.XmlConvert.ToString(m_BeginGroup));
+ ThisItem.SetAttribute("style",System.Xml.XmlConvert.ToString((int)m_Style));
+ ThisItem.SetAttribute("desc",m_Description);
+ ThisItem.SetAttribute("tooltip",m_Tooltip);
+ ThisItem.SetAttribute("category",m_Category);
+ ThisItem.SetAttribute("cancustomize",System.Xml.XmlConvert.ToString(m_CanCustomize));
+ ThisItem.SetAttribute("showsubitems",System.Xml.XmlConvert.ToString(m_ShowSubItems));
+ ThisItem.SetAttribute("itemalignment",System.Xml.XmlConvert.ToString((int)m_ItemAlignment));
+ ThisItem.SetAttribute("stretch",System.Xml.XmlConvert.ToString(m_Stretch));
+ ThisItem.SetAttribute("global",System.Xml.XmlConvert.ToString(m_GlobalItem));
+ ThisItem.SetAttribute("themes",System.Xml.XmlConvert.ToString(m_ThemeAware));
+ if(m_AccessibleDefaultActionDescription!="")
+ ThisItem.SetAttribute("adefdesc",m_AccessibleDefaultActionDescription);
+ if(m_AccessibleDescription!="")
+ ThisItem.SetAttribute("adesc",m_AccessibleDescription);
+ if(m_AccessibleName!="")
+ ThisItem.SetAttribute("aname",m_AccessibleName);
+ if(m_AccessibleRole!=System.Windows.Forms.AccessibleRole.Default)
+ ThisItem.SetAttribute("arole",System.Xml.XmlConvert.ToString((int)m_AccessibleRole));
+ if(!m_AutoCollapseOnClick)
+ ThisItem.SetAttribute("autocollapse",System.Xml.XmlConvert.ToString(m_AutoCollapseOnClick));
+ if(m_ClickAutoRepeat)
+ ThisItem.SetAttribute("autorepeat",System.Xml.XmlConvert.ToString(m_ClickAutoRepeat));
+ if(m_ClickRepeatInterval!=600)
+ ThisItem.SetAttribute("clickrepinterv",System.Xml.XmlConvert.ToString(m_ClickRepeatInterval));
+ //if(m_GenerateCommandLink)
+ // ThisItem.SetAttribute("GenerateCommandLink", System.Xml.XmlConvert.ToString(m_GenerateCommandLink));
+
+
+ if(m_Cursor!=null)
+ {
+ if(m_Cursor==System.Windows.Forms.Cursors.Hand)
+ ThisItem.SetAttribute("cur","4");
+ else if(m_Cursor==System.Windows.Forms.Cursors.AppStarting)
+ ThisItem.SetAttribute("cur","1");
+ else if(m_Cursor==System.Windows.Forms.Cursors.Arrow)
+ ThisItem.SetAttribute("cur","2");
+ else if(m_Cursor==System.Windows.Forms.Cursors.Cross)
+ ThisItem.SetAttribute("cur","3");
+ else if(m_Cursor==System.Windows.Forms.Cursors.Help)
+ ThisItem.SetAttribute("cur","5");
+ else if(m_Cursor==System.Windows.Forms.Cursors.HSplit)
+ ThisItem.SetAttribute("cur","6");
+ else if(m_Cursor==System.Windows.Forms.Cursors.IBeam)
+ ThisItem.SetAttribute("cur","7");
+ else if(m_Cursor==System.Windows.Forms.Cursors.No)
+ ThisItem.SetAttribute("cur","8");
+ else if(m_Cursor==System.Windows.Forms.Cursors.NoMove2D)
+ ThisItem.SetAttribute("cur","9");
+ else if(m_Cursor==System.Windows.Forms.Cursors.NoMoveHoriz)
+ ThisItem.SetAttribute("cur","10");
+ else if(m_Cursor==System.Windows.Forms.Cursors.NoMoveVert)
+ ThisItem.SetAttribute("cur","11");
+ else if(m_Cursor==System.Windows.Forms.Cursors.PanEast)
+ ThisItem.SetAttribute("cur","12");
+ else if(m_Cursor==System.Windows.Forms.Cursors.PanNE)
+ ThisItem.SetAttribute("cur","13");
+ else if(m_Cursor==System.Windows.Forms.Cursors.PanNorth)
+ ThisItem.SetAttribute("cur","14");
+ else if(m_Cursor==System.Windows.Forms.Cursors.PanNW)
+ ThisItem.SetAttribute("cur","15");
+ else if(m_Cursor==System.Windows.Forms.Cursors.PanSE)
+ ThisItem.SetAttribute("cur","16");
+ else if(m_Cursor==System.Windows.Forms.Cursors.PanSouth)
+ ThisItem.SetAttribute("cur","17");
+ else if(m_Cursor==System.Windows.Forms.Cursors.PanSW)
+ ThisItem.SetAttribute("cur","18");
+ else if(m_Cursor==System.Windows.Forms.Cursors.PanWest)
+ ThisItem.SetAttribute("cur","19");
+ else if(m_Cursor==System.Windows.Forms.Cursors.SizeAll)
+ ThisItem.SetAttribute("cur","20");
+ else if(m_Cursor==System.Windows.Forms.Cursors.SizeNESW)
+ ThisItem.SetAttribute("cur","21");
+ else if(m_Cursor==System.Windows.Forms.Cursors.SizeNS)
+ ThisItem.SetAttribute("cur","22");
+ else if(m_Cursor==System.Windows.Forms.Cursors.SizeNWSE)
+ ThisItem.SetAttribute("cur","23");
+ else if(m_Cursor==System.Windows.Forms.Cursors.SizeWE)
+ ThisItem.SetAttribute("cur","24");
+ else if(m_Cursor==System.Windows.Forms.Cursors.UpArrow)
+ ThisItem.SetAttribute("cur","25");
+ else if(m_Cursor==System.Windows.Forms.Cursors.VSplit)
+ ThisItem.SetAttribute("cur","26");
+ else if(m_Cursor==System.Windows.Forms.Cursors.WaitCursor)
+ ThisItem.SetAttribute("cur","27");
+ }
+
+ if(SubItems.Count>0 && this.ShouldSerializeSubItems())
+ {
+ System.Xml.XmlElement subitems=ThisItem.OwnerDocument.CreateElement("subitems");
+ ThisItem.AppendChild(subitems);
+ foreach(BaseItem objItem in this.SubItems)
+ {
+ if(objItem.ShouldSerialize)
+ {
+ System.Xml.XmlElement ChildItem=ThisItem.OwnerDocument.CreateElement("item");
+ t=objItem.GetType();
+ subitems.AppendChild(ChildItem);
+ context.ItemXmlElement = ChildItem;
+ objItem.Serialize(context);
+ context.ItemXmlElement = ThisItem;
+ }
+ }
+ }
+
+ // Serialize Shortcuts
+ if(m_Shortcuts!=null && m_Shortcuts.Count>0)
+ ThisItem.SetAttribute("shortcuts",m_Shortcuts.ToString(","));
+
+ if (context.HasSerializeItemHandlers)
+ {
+ System.Xml.XmlElement customData = ThisItem.OwnerDocument.CreateElement("customData");
+ SerializeItemEventArgs e = new SerializeItemEventArgs(this, ThisItem, customData);
+ context.Serializer.InvokeSerializeItem(e);
+ if (customData.Attributes.Count > 0 || customData.ChildNodes.Count > 0)
+ ThisItem.AppendChild(customData);
+ }
+ }
+
+ ///
+ /// Deserialize the Item from the XmlElement.
+ ///
+ /// Source XmlElement.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void Deserialize(ItemSerializationContext context)
+ {
+ System.Xml.XmlElement ItemXmlSource = context.ItemXmlElement;
+
+ m_Name=ItemXmlSource.GetAttribute("name");
+ if (ItemXmlSource.HasAttribute("globalname"))
+ m_GlobalName = ItemXmlSource.GetAttribute("globalname");
+ m_Text=ItemXmlSource.GetAttribute("text");
+ m_AccessKey=NativeFunctions.GetAccessKey(m_Text);
+ m_IsContainer=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("iscontainer"));
+ if (context._DesignerHost == null)
+ m_Visible = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("visible"));
+ else
+ TypeDescriptor.GetProperties(this)["Visible"].SetValue(this, System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("visible")));
+ if(ItemXmlSource.GetAttribute("itemdata")!="")
+ m_ItemData=ItemXmlSource.GetAttribute("itemdata");
+ else
+ m_ItemData=null;
+ m_Enabled=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("enabled"));
+ m_BeginGroup=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("begingroup"));
+ m_Style=(eDotNetBarStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("style"));
+ m_Description=ItemXmlSource.GetAttribute("desc");
+ m_Tooltip=ItemXmlSource.GetAttribute("tooltip");
+ m_Category=ItemXmlSource.GetAttribute("category");
+ m_CanCustomize=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("cancustomize"));
+ m_ShowSubItems=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("showsubitems"));
+ m_ItemAlignment=(eItemAlignment)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("itemalignment"));
+ if(ItemXmlSource.HasAttribute("stretch"))
+ m_Stretch=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("stretch"));
+ else
+ m_Stretch=false;
+ if(ItemXmlSource.HasAttribute("global"))
+ m_GlobalItem=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("global"));
+
+ if(ItemXmlSource.HasAttribute("themes"))
+ m_ThemeAware=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("themes"));
+
+ if(ItemXmlSource.HasAttribute("adefdesc"))
+ m_AccessibleDefaultActionDescription=ItemXmlSource.GetAttribute("adefdesc");
+ if(ItemXmlSource.HasAttribute("adesc"))
+ m_AccessibleDescription=ItemXmlSource.GetAttribute("adesc");
+ if(ItemXmlSource.HasAttribute("aname"))
+ m_AccessibleName=ItemXmlSource.GetAttribute("aname");
+ if(ItemXmlSource.HasAttribute("arole"))
+ m_AccessibleRole=(System.Windows.Forms.AccessibleRole)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("arole"));
+ if(ItemXmlSource.HasAttribute("autocollapse"))
+ m_AutoCollapseOnClick=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("autocollapse"));
+ else
+ m_AutoCollapseOnClick=true;
+
+ if(ItemXmlSource.HasAttribute("autorepeat"))
+ m_ClickAutoRepeat=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("autorepeat"));
+ else
+ m_ClickAutoRepeat=false;
+ if(ItemXmlSource.HasAttribute("clickrepinterv"))
+ m_ClickRepeatInterval=System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("clickrepinterv"));
+ else
+ m_ClickRepeatInterval=600;
+
+ //if (ItemXmlSource.HasAttribute("GenerateCommandLink"))
+ // m_GenerateCommandLink = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("GenerateCommandLink"));
+ //else
+ // m_GenerateCommandLink = false;
+
+ // Load Cursor
+ if(ItemXmlSource.HasAttribute("cur"))
+ {
+ switch(ItemXmlSource.GetAttribute("cur"))
+ {
+ case "4":
+ m_Cursor=System.Windows.Forms.Cursors.Hand;
+ break;
+ case "1":
+ m_Cursor=System.Windows.Forms.Cursors.AppStarting;
+ break;
+ case "2":
+ m_Cursor=System.Windows.Forms.Cursors.Arrow;
+ break;
+ case "3":
+ m_Cursor=System.Windows.Forms.Cursors.Cross;
+ break;
+ case "5":
+ m_Cursor=System.Windows.Forms.Cursors.Help;
+ break;
+ case "6":
+ m_Cursor=System.Windows.Forms.Cursors.HSplit;
+ break;
+ case "7":
+ m_Cursor=System.Windows.Forms.Cursors.IBeam;
+ break;
+ case "8":
+ m_Cursor=System.Windows.Forms.Cursors.No;
+ break;
+ case "9":
+ m_Cursor=System.Windows.Forms.Cursors.NoMove2D;
+ break;
+ case "10":
+ m_Cursor=System.Windows.Forms.Cursors.NoMoveHoriz;
+ break;
+ case "11":
+ m_Cursor=System.Windows.Forms.Cursors.NoMoveVert;
+ break;
+ case "12":
+ m_Cursor=System.Windows.Forms.Cursors.PanEast;
+ break;
+ case "13":
+ m_Cursor=System.Windows.Forms.Cursors.PanNE;
+ break;
+ case "14":
+ m_Cursor=System.Windows.Forms.Cursors.PanNorth;
+ break;
+ case "15":
+ m_Cursor=System.Windows.Forms.Cursors.PanNW;
+ break;
+ case "16":
+ m_Cursor=System.Windows.Forms.Cursors.PanSE;
+ break;
+ case "17":
+ m_Cursor=System.Windows.Forms.Cursors.PanSouth;
+ break;
+ case "18":
+ m_Cursor=System.Windows.Forms.Cursors.PanSW;
+ break;
+ case "19":
+ m_Cursor=System.Windows.Forms.Cursors.PanWest;
+ break;
+ case "20":
+ m_Cursor=System.Windows.Forms.Cursors.SizeAll;
+ break;
+ case "21":
+ m_Cursor=System.Windows.Forms.Cursors.SizeNESW;
+ break;
+ case "22":
+ m_Cursor=System.Windows.Forms.Cursors.SizeNS;
+ break;
+ case "23":
+ m_Cursor=System.Windows.Forms.Cursors.SizeNWSE;
+ break;
+ case "24":
+ m_Cursor=System.Windows.Forms.Cursors.SizeWE;
+ break;
+ case "25":
+ m_Cursor=System.Windows.Forms.Cursors.UpArrow;
+ break;
+ case "26":
+ m_Cursor=System.Windows.Forms.Cursors.VSplit;
+ break;
+ case "27":
+ m_Cursor=System.Windows.Forms.Cursors.WaitCursor;
+ break;
+ }
+ }
+
+ System.Xml.XmlNodeList list=ItemXmlSource.GetElementsByTagName("subitems");
+ if(list.Count>0)
+ {
+ foreach(System.Xml.XmlElement xmlChild in list[0].ChildNodes)
+ {
+// BaseItem oi=null;
+// System.Reflection.Assembly a=System.Reflection.Assembly.Load(xmlChild.GetAttribute("assembly"));
+// if(a==null) continue;
+// oi=a.CreateInstance(xmlChild.GetAttribute("class")) as BaseItem;
+ BaseItem oi=context.CreateItemFromXml(xmlChild);
+ if(oi!=null)
+ {
+ this.SubItems.Add(oi);
+ context.ItemXmlElement = xmlChild;
+ oi.Deserialize(context);
+ context.ItemXmlElement = ItemXmlSource;
+ }
+ }
+ }
+ if(ItemXmlSource.HasAttribute("shortcuts"))
+ {
+ if(m_Shortcuts==null)
+ m_Shortcuts=new ShortcutsCollection(this);
+ m_Shortcuts.FromString(ItemXmlSource.GetAttribute("shortcuts"),",");
+ }
+
+ if (context.HasDeserializeItemHandlers)
+ {
+ System.Xml.XmlNodeList customDataList=ItemXmlSource.GetElementsByTagName("customData");
+ if (customDataList.Count > 0)
+ {
+ System.Xml.XmlElement customData = customDataList[0] as System.Xml.XmlElement;
+ SerializeItemEventArgs e = new SerializeItemEventArgs(this, ItemXmlSource, customData);
+ context.Serializer.InvokeDeserializeItem(e);
+ }
+ }
+
+ MarkupTextChanged();
+ }
+
+ ///
+ /// Indicates whether SubItems collection is serialized. Default value is true.
+ ///
+ protected virtual bool ShouldSerializeSubItems()
+ {
+ return true;
+ }
+ #endregion
+
+ #region Internal Implementation
+
+ internal void NotifyScaleItem(SizeF factor)
+ {
+ ScaleItem(factor);
+ }
+
+ ///
+ /// Called on each item when ScaleControl method of parent control is called and gives opportunity to item to adjust its displayed based on current scaling.
+ ///
+ /// Scale factor.
+ protected virtual void ScaleItem(SizeF factor)
+ {
+ if (m_SubItems == null) return;
+ foreach (BaseItem item in m_SubItems)
+ {
+ item.NotifyScaleItem(factor);
+ }
+ }
+
+ private bool _IsRendered = true;
+ ///
+ /// Gets or sets whether item is rendered.
+ ///
+ internal bool IsRendered
+ {
+ get { return _IsRendered; }
+ set
+ {
+ _IsRendered = value;
+ }
+ }
+
+ private bool _DesignTimeVisible = true;
+ ///
+ /// Gets or sets whether item is selectable at design-time. Default value is true.
+ ///
+ internal bool DesignTimeVisible
+ {
+ get { return _DesignTimeVisible; }
+ set
+ {
+ _DesignTimeVisible = value;
+ }
+ }
+
+ ///
+ /// Called when item container has changed. If you override this method you must call the base implementation to allow default processing to occur.
+ ///
+ /// Previous container of the item.
+ protected internal virtual void OnContainerChanged(object objOldContainer)
+ {
+ if(m_SubItems==null || !this.IsContainer)
+ return;
+ foreach(BaseItem objItem in m_SubItems)
+ objItem.OnContainerChanged(objOldContainer);
+ }
+
+ ///
+ /// Control Container (System.Windows.Forms.Control or its descendant)
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual object ContainerControl
+ {
+ get
+ {
+ return GetContainerControl(true);
+ //if(m_Parent==null)
+ // return m_ContainerControl;
+
+ //if(m_ContainerControl==null && m_Parent.IsContainer)
+ // return m_Parent.ContainerControl;
+
+ //return m_ContainerControl;
+ }
+ set
+ {
+ object oldContainer=this.ContainerControl;
+ m_ContainerControl=value;
+ //if(oldContainer!=this.ContainerControl)
+ OnContainerChanged(oldContainer);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public object GetContainerControl(bool checkIsContainer)
+ {
+ if (m_Parent == null)
+ return m_ContainerControl;
+
+ if (m_ContainerControl == null && (m_Parent.IsContainer || !checkIsContainer))
+ return m_Parent.GetContainerControl(checkIsContainer);
+
+ return m_ContainerControl;
+ }
+
+ ///
+ /// Returns the Parent of the item.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public virtual BaseItem Parent
+ {
+ get
+ {
+ if(this.ContainerControl is Bar)
+ {
+ Bar bar=this.ContainerControl as Bar;
+ if(bar.ParentItem==this)
+ return null;
+ if(m_Parent==bar.ItemsContainer)
+ return bar.ParentItem;
+ }
+ return m_Parent;
+ }
+ }
+
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void SetParent(BaseItem o)
+ {
+ m_Parent=o;
+ // Do not set recalc size flag on parent...
+ m_NeedRecalcSize=true;
+ OnParentChanged();
+ }
+ ///
+ /// Called when item parent has changed.
+ ///
+ protected virtual void OnParentChanged()
+ {
+
+ }
+
+ ///
+ /// Returns whether item is enabled including the parent control item is on.
+ ///
+ ///
+ internal bool GetEnabled(System.Windows.Forms.Control container)
+ {
+ if (!m_Enabled || container == null) return m_Enabled;
+ if (!container.Enabled) return false;
+ if (m_Parent != null)
+ {
+ BaseItem parent = m_Parent;
+ while (parent != null)
+ {
+ if(!parent.Enabled)
+ return false;
+ parent = parent.Parent;
+ }
+ }
+ return container.Enabled && m_Enabled;
+ }
+
+ ///
+ /// Returns whether item is enabled including the parent control item is on.
+ ///
+ ///
+ internal bool GetEnabled()
+ {
+ return GetEnabled(GetContainerControl(false) as Control);
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the item is enabled.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates whether is item enabled.")]
+ public virtual bool Enabled
+ {
+ get
+ {
+ return m_Enabled;
+ }
+ set
+ {
+ if(m_Enabled!=value)
+ {
+ m_Enabled=value;
+ if(ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "Enabled");
+
+ if(!m_Enabled && m_Expanded)
+ {
+ this.Expanded=false;
+ //CollapseAll(this);
+ }
+ this.Refresh();
+ this.OnEnabledChanged();
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether item separator is shown before this item.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(false),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates whether this item is beginning of the group.")]
+ public virtual bool BeginGroup
+ {
+ get
+ {
+ return m_BeginGroup;
+ }
+ set
+ {
+ if(m_BeginGroup!=value)
+ {
+ NeedRecalcSize=true;
+ m_BeginGroup=value;
+
+ if(ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "BeginGroup");
+
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+
+ ///
+ /// Gets or sets Left position of this item
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual int LeftInternal
+ {
+ get
+ {
+ return m_Rect.Left;
+ }
+ set
+ {
+ if(m_Rect.X!=value)
+ {
+ int old=m_Rect.X;
+ m_Rect.X=value;
+ this.OnLeftLocationChanged(old);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets Top position of this item
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual int TopInternal
+ {
+ get
+ {
+ return m_Rect.Top;
+ }
+ set
+ {
+ if(m_Rect.Y!=value)
+ {
+ int oldValue=m_Rect.Y;
+ m_Rect.Y=value;
+ this.OnTopLocationChanged(oldValue);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets Width of this item
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual int WidthInternal
+ {
+ get
+ {
+ return m_Rect.Width;
+ }
+ set
+ {
+ if(m_Rect.Width!=value)
+ {
+ m_Rect.Width=value;
+ OnExternalSizeChange();
+ }
+ }
+ }
+
+ ///
+ /// Gets whether item is in right-to-left layout mode.
+ ///
+ protected virtual internal bool IsRightToLeft
+ {
+ get { return m_IsRightToLeft; }
+ set
+ {
+ if (m_IsRightToLeft == value)
+ return;
+ m_IsRightToLeft = value;
+ foreach (BaseItem item in this.SubItems)
+ {
+ item.IsRightToLeft = value;
+ }
+ }
+ }
+
+ ///
+ /// Called when size of the item is changed externally.
+ ///
+ protected virtual void OnExternalSizeChange(){}
+
+ ///
+ /// Gets or sets Height of this item
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual int HeightInternal
+ {
+ get
+ {
+ return m_Rect.Height;
+ }
+ set
+ {
+ if(m_Rect.Height!=value)
+ {
+ m_Rect.Height=value;
+ OnExternalSizeChange();
+ }
+ }
+ }
+
+ ///
+ /// Called when Visibility of the items has changed.
+ ///
+ /// New Visible state.
+ protected internal virtual void OnVisibleChanged(bool newValue)
+ {
+ if(this.VisibleChanged!=null)
+ this.VisibleChanged(this,new EventArgs());
+ if (this.DesignMode)
+ {
+ if (this.Parent != null)
+ {
+ this.Parent.NeedRecalcSize = true;
+ this.Parent.Refresh();
+ }
+ }
+ else if (this.Parent != null && this.Parent is ItemContainer)
+ this.Parent.NeedRecalcSize = true;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the item is visible.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Determines whether the item is visible or hidden.")]
+ public virtual bool Visible
+ {
+ get
+ {
+ return m_Visible;
+ }
+ set
+ {
+ if(m_Visible==value)
+ return;
+
+ m_Visible=value;
+ this.NeedRecalcSize = true;
+ if(ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "Visible");
+
+ if(!m_Visible && m_Displayed && m_Parent!=null)
+ {
+ m_Parent.SubItemSizeChanged(this);
+ }
+ if(!m_IsOnCustomizeMenu)
+ this.Displayed=false;
+
+ OnVisibleChanged(value);
+ }
+ }
+
+ internal void SetVisibleDirect(bool b)
+ {
+ m_Visible = b;
+ if (!m_Visible && !m_IsOnCustomizeMenu)
+ m_Displayed = false;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the item is expanded or not. For Popup items this would indicate whether the item is popped up or not.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DefaultValue(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual bool Expanded
+ {
+ get { return m_Expanded; }
+
+ set
+ {
+ if(m_Expanded!=value)
+ {
+ m_Expanded = value;
+
+ OnExpandChange();
+
+ if(m_Parent!=null)
+ m_Parent.OnSubItemExpandChange(this);
+ }
+ }
+ }
+
+ ///
+ /// Indicates whether the item will auto-collapse (fold) when clicked.
+ /// When item is on popup menu and this property is set to false, menu will not
+ /// close when item is clicked.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.DefaultValue(true),System.ComponentModel.Description("Indicates whether the item will auto-collapse (fold) when clicked.")]
+ public virtual bool AutoCollapseOnClick
+ {
+ get
+ {
+ return m_AutoCollapseOnClick;
+ }
+ set
+ {
+ m_AutoCollapseOnClick=value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether item will auto expand when mouse is over the item or not.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DefaultValue(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual bool AutoExpand
+ {
+ get
+ {
+ return m_AutoExpand;
+ }
+ set
+ {
+ if(m_AutoExpand==value)
+ return;
+ m_AutoExpand=value;
+ if(ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "AutoExpand");
+ }
+ }
+
+ ///
+ /// Gets the rectangle that represents the display area of the item.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual System.Drawing.Rectangle DisplayRectangle
+ {
+ get
+ {
+ return m_Rect;
+ }
+ }
+
+ ///
+ /// Gets or sets the size of the item.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual System.Drawing.Size Size
+ {
+ get {return m_Rect.Size;}
+ set
+ {
+ if(m_Rect.Size!=value)
+ {
+ m_Rect.Size=value;
+ OnExternalSizeChange();
+ }
+ }
+ }
+
+ ///
+ /// IBlock member implementation
+ ///
+ [Browsable(false), DevCoBrowsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual System.Drawing.Rectangle Bounds
+ {
+ get { return m_Rect; }
+ set
+ {
+ if (m_Rect != value)
+ {
+ bool sizeChanged = m_Rect.Size != value.Size;
+ //bool topLocationChanged = m_Rect.Top != value.Top;
+ //bool leftLocationChanged = m_Rect.Left != value.Left;
+ //int oldLeft = m_Rect.Left;
+ m_Rect = value;
+ if(sizeChanged)
+ OnExternalSizeChange();
+ //if (leftLocationChanged)
+ // OnLeftLocationChanged(oldLeft);
+ }
+ }
+ }
+
+ internal void SetDisplayRectangle(Rectangle r)
+ {
+ m_Rect = r;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetViewRectangle(Rectangle r)
+ {
+ m_ViewRectangle = r;
+ }
+
+ ///
+ /// Specifies whether this item is visual container or not. For example
+ /// Tool Menu is not container since it drops-down its items and they are
+ /// not "visualy" contained. Also, the pop-up menus, drop-down Bars etc. are not containers.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public virtual bool IsContainer
+ {
+ get
+ {
+ return m_IsContainer;
+ }
+ }
+
+ protected internal void SetIsContainer(bool b)
+ {
+ m_IsContainer=b;
+ }
+
+ ///
+ /// Returns true if this item is currently displayed. This property should not be set directly since it is managed by system and container of the item.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual bool Displayed
+ {
+ get
+ {
+ return m_Displayed;
+ }
+ set
+ {
+ if (m_Displayed != value && !LockDisplayedChange)
+ {
+ m_Displayed=value;
+ OnDisplayedChanged();
+ }
+ }
+ }
+ internal bool LockDisplayedChange = false;
+
+ ///
+ /// Called when item Display state has changed.
+ ///
+ protected virtual void OnDisplayedChanged()
+ {
+// if(DisplayedChanged!=null)
+// DisplayedChanged(this,new EventArgs());
+ if(this.Displayed && this.Visible)
+ this.GenerateAccessibilityEvent(System.Windows.Forms.AccessibleEvents.Show);
+ else
+ this.GenerateAccessibilityEvent(System.Windows.Forms.AccessibleEvents.Hide);
+// IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+// if(owner!=null)
+// owner.InvokeItemDisplayedChanged(this,new EventArgs());
+ }
+
+ protected internal virtual void OnProcessDelayedCommands(){}
+
+ ///
+ /// Called when item owner has changed.
+ ///
+ protected virtual void OnOwnerChanged() {}
+
+ ///
+ /// Raises SubItemsChanged event.
+ ///
+ ///
+ protected virtual void OnSubItemsChanged(CollectionChangeEventArgs e)
+ {
+ CollectionChangeEventHandler eh = SubItemsChanged;
+ if (eh != null) eh(this, e);
+ }
+
+ protected virtual void OnSubItemsChanged(CollectionChangeAction action, BaseItem item)
+ {
+ if (SubItemsChanged != null) OnSubItemsChanged(new CollectionChangeEventArgs(action, item));
+ }
+
+ ///
+ /// Occurs after an item has been added to the container. This procedure is called on both item being added and the parent of the item. To distinguish between those two states check the item parameter.
+ ///
+ /// When occurring on the parent this will hold the reference to the item that has been added. When occurring on the item being added this will be null (Nothing).
+ protected internal virtual void OnItemAdded(BaseItem item)
+ {
+ OnSubItemsChanged(CollectionChangeAction.Add, item);
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null)
+ owner.InvokeItemAdded(item,new EventArgs());
+ }
+ ///
+ /// Occurs after an item has been removed.
+ ///
+ /// Item being removed.
+ protected internal virtual void OnAfterItemRemoved(BaseItem item, int itemIndex)
+ {
+ if(item==null)
+ return;
+ OnSubItemsChanged(CollectionChangeAction.Remove, item);
+
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null)
+ owner.InvokeItemRemoved(item,this,itemIndex);
+ }
+
+ ///
+ /// Occurs just before Click event is fired.
+ ///
+ protected virtual void OnClick(){}
+
+ ///
+ /// Occurs after SubItems Collection has been cleared.
+ ///
+ protected internal virtual void OnSubItemsClear() {}
+ ///
+ /// Occurs before an item is removed.
+ ///
+ /// Item being removed.
+ protected internal virtual void OnBeforeItemRemoved(BaseItem item) {}
+ ///
+ /// Occurs when IsOnCustomizeMenu property has changed.
+ ///
+ protected virtual void OnIsOnCustomizeMenuChanged(){}
+ ///
+ /// Occurs when IsOnCustomizeDialogChanged property has changed.
+ ///
+ protected virtual void OnIsOnCustomizeDialogChanged(){}
+ ///
+ /// Occurs when item enter or exists the design mode.
+ ///
+ protected virtual void OnDesignModeChanged(){}
+ ///
+ /// Occurs when tooltip is about to be shown or hidden.
+ ///
+ /// Specifies whether tooltip is shown or hidden.
+ protected virtual void OnTooltip(bool bShow){}
+ ///
+ /// Occurs after item has received the input focus.
+ ///
+ /// Item that received the focus.
+ protected virtual void OnSubItemGotFocus(BaseItem item){}
+ ///
+ /// Occurs after item has lost the input focus.
+ ///
+ /// Item that lost the input focus.
+ protected virtual void OnSubItemLostFocus(BaseItem item){}
+ ///
+ /// Indicates whether the item enabled property has changed.
+ ///
+ protected virtual void OnEnabledChanged()
+ {
+ if(this.EnabledChanged!=null)
+ this.EnabledChanged(this,new EventArgs());
+ }
+ ///
+ /// Called after TopInternal property has changed
+ ///
+ protected virtual void OnTopLocationChanged(int oldValue){}
+
+ ///
+ /// Called after LeftInternal property has changed
+ ///
+ protected virtual void OnLeftLocationChanged(int oldValue){}
+
+ ///
+ /// Occurs when the mouse pointer enters the item. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void InternalMouseEnter()
+ {
+ if(!m_DesignMode)
+ {
+ if(MouseEnter!=null)
+ MouseEnter(this,new EventArgs());
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeMouseEnter(this,new EventArgs());
+ }
+ if(!this.DesignMode)
+ {
+ ResetHover();
+
+ System.Windows.Forms.Control objContainer=this.ContainerControl as System.Windows.Forms.Control;
+
+ if(m_Cursor!=null && objContainer!=null)
+ {
+ m_ContainerCursor=objContainer.Cursor;
+ objContainer.Cursor=m_Cursor;
+ }
+
+ // Accessibility Narrator support for menu items ONLY
+ if (BarUtilities.AlwaysGenerateAccessibilityFocusEvent && !(objContainer is MenuPanel) || objContainer is Bar && this.IsOnMenuBar)
+ {
+ Bar.BarAccessibleObject acc=objContainer.AccessibilityObject as Bar.BarAccessibleObject;
+ if (acc != null)
+ {
+ //acc.GenerateEvent(this,System.Windows.Forms.AccessibleEvents.SystemMenuStart);
+ acc.GenerateEvent(this, System.Windows.Forms.AccessibleEvents.Focus);
+ }
+ else
+ {
+ ItemControlAccessibleObject ic = objContainer.AccessibilityObject as ItemControlAccessibleObject;
+ if (ic != null)
+ ic.GenerateEvent(this, System.Windows.Forms.AccessibleEvents.Focus);
+ }
+ }
+ else if(objContainer is MenuPanel && !((MenuPanel)objContainer).IsDisposed)
+ {
+ MenuPanel.PopupMenuAccessibleObject a=objContainer.AccessibilityObject as MenuPanel.PopupMenuAccessibleObject;
+ if(a!=null)
+ {
+ a.GenerateEvent(this,System.Windows.Forms.AccessibleEvents.Focus);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Occurs when the mouse pointer hovers the item. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void InternalMouseHover()
+ {
+ if(m_DesignMode)
+ return;
+
+ if(m_HotSubItem!=null)
+ {
+ if(!m_AutoExpand)
+ {
+ BaseItem objItem=ExpandedItem();
+ if(objItem!=null && m_HotSubItem!=objItem && objItem.Visible && (this.IsOnMenu || this.ContainerControl is Bar || this.ContainerControl is RibbonBar))
+ objItem.Expanded=false;
+ }
+ // Changing the Expanded of the item can cause hot sub item to be set to null
+ if(m_HotSubItem!=null)
+ m_HotSubItem.InternalMouseHover();
+ }
+ else
+ {
+ if(System.Windows.Forms.Control.MouseButtons==System.Windows.Forms.MouseButtons.None)
+ ShowToolTip();
+ if(!m_DesignMode)
+ {
+ if(MouseHover!=null)
+ MouseHover(this,new EventArgs());
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeMouseHover(this,new EventArgs());
+ }
+ }
+ }
+
+ ///
+ /// Occurs when the mouse pointer leaves the item. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void InternalMouseLeave()
+ {
+ if(m_ContainerCursor!=null)
+ {
+ System.Windows.Forms.Control objContainer=this.ContainerControl as System.Windows.Forms.Control;
+ if(objContainer!=null)
+ {
+ objContainer.Cursor=m_ContainerCursor;
+ }
+ m_ContainerCursor=null;
+ }
+
+ if(m_DesignMode)
+ return;
+
+ // If we had hot sub item pass the mouse leave message to it...
+ if(m_HotSubItem!=null)
+ {
+ m_HotSubItem.InternalMouseLeave();
+ HotSubItem = null;
+ }
+ else
+ {
+ if (m_TextMarkup != null)
+ m_TextMarkup.MouseLeave(this.ContainerControl as System.Windows.Forms.Control);
+
+ if(MouseLeave!=null)
+ MouseLeave(this,new EventArgs());
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeMouseLeave(this,new EventArgs());
+ }
+ HideToolTip();
+ }
+ ///
+ /// Gets the mouse down coordinates.
+ ///
+ internal Point MouseDownPt
+ {
+ get
+ {
+ return m_MouseDownPt;
+ }
+ }
+
+ protected virtual bool ShouldCollapseParentItem()
+ {
+ return true;
+ }
+ protected void RaiseMouseDown(System.Windows.Forms.MouseEventArgs objArg)
+ {
+ if (MouseDown != null)
+ MouseDown(this, objArg);
+ }
+ ///
+ /// Occurs when the mouse pointer is over the item and a mouse button is pressed. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void InternalMouseDown(System.Windows.Forms.MouseEventArgs objArg)
+ {
+ IOwner owner=null;
+
+ // Colapse any item if expanded
+ m_MouseDownPt=new System.Drawing.Point(objArg.X,objArg.Y);
+ BaseItem objItem=ExpandedItem();
+ if(objItem!=null && objItem!=m_HotSubItem && !this.DesignMode && m_AllowOnlyOneSubItemExpanded && ShouldCollapseParentItem())
+ {
+ objItem.Expanded=false;
+ m_AutoExpand=false;
+ }
+
+ if(m_DesignMode && (m_CanCustomize || this.Site!=null && this.Site.DesignMode))// && !this.SystemItem)
+ {
+ if(this.IsContainer && this.SubItems.Count>0)
+ {
+ BaseItem objNew=ItemAtLocation(objArg.X,objArg.Y);
+
+ if (objNew != null && (objNew.CanCustomize || this.Site != null && this.Site.DesignMode || objNew.Site != null && objNew.Site.DesignMode) && !(objNew.DesignMode && !objNew.DesignTimeVisible))
+ {
+ owner=this.GetOwner() as IOwner;
+ if(owner!=null)
+ owner.SetFocusItem(objNew);
+ }
+ else if(objNew==null)
+ {
+ owner=this.GetOwner() as IOwner;
+ if(owner!=null)
+ owner.SetFocusItem(null);
+ }
+
+ if(objNew!=null && objNew!=this)
+ objNew.InternalMouseDown(objArg);
+ }
+
+ if(objArg.Button==System.Windows.Forms.MouseButtons.Right && !m_IsContainer)
+ {
+ owner=this.GetOwner() as IOwner;
+ if(owner!=null)
+ owner.DesignTimeContextMenu(this);
+ }
+ }
+
+ if(!this.DesignMode)
+ {
+ owner=this.GetOwner() as IOwner;
+ if(owner!=null && owner.GetFocusItem()!=null)
+ {
+ BaseItem objNew=ItemAtLocation(objArg.X,objArg.Y);
+ if(objNew!=owner.GetFocusItem())
+ owner.GetFocusItem().ReleaseFocus();
+ }
+ }
+
+ if(m_HotSubItem!=null)
+ {
+ m_HotSubItem.InternalMouseDown(objArg);
+ }
+ else if(!m_DesignMode)
+ {
+ if (m_TextMarkup != null)
+ m_TextMarkup.MouseDown(this.ContainerControl as System.Windows.Forms.Control, objArg);
+
+ RaiseMouseDown(objArg);
+ //if(owner==null)
+ // owner=this.GetOwner() as IOwner;
+ IOwnerItemEvents ownerEvents=this.GetIOwnerItemEvents();
+ if(ownerEvents!=null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ ownerEvents.InvokeMouseDown(this,objArg);
+ }
+
+ HideToolTip();
+ }
+
+ protected void RaiseMouseUp(System.Windows.Forms.MouseEventArgs objArg)
+ {
+ if (MouseUp != null)
+ MouseUp(this, objArg);
+ }
+ ///
+ /// Occurs when the mouse pointer is over the item and a mouse button is released. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void InternalMouseUp(System.Windows.Forms.MouseEventArgs objArg)
+ {
+ if(m_HotSubItem!=null)
+ {
+ if(m_HotSubItem.DisplayRectangle.Contains(objArg.X,objArg.Y) || m_HotSubItem.MouseUpNotification)
+ m_HotSubItem.InternalMouseUp(objArg);
+ }
+ else if(!m_DesignMode)
+ {
+ if (m_TextMarkup != null)
+ m_TextMarkup.MouseUp(this.ContainerControl as System.Windows.Forms.Control, objArg);
+ RaiseMouseUp(objArg);
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeMouseUp(this,objArg);
+ if ((objArg.Button == System.Windows.Forms.MouseButtons.Left || objArg.Button == System.Windows.Forms.MouseButtons.Right && this.IsOnContextMenu) && this.DisplayRectangle.Contains(objArg.X, objArg.Y) && (this.DisplayRectangle.Contains(m_MouseDownPt) && this.GetEnabled() || this.IsOnMenu))
+ RaiseClick(eEventSource.Mouse);
+ }
+ else
+ {
+ BaseItem objNew=ItemAtLocation(objArg.X,objArg.Y);
+ if(objNew!=null && objNew!=this)
+ objNew.InternalMouseUp(objArg);
+ }
+
+ m_MouseDownPt=System.Drawing.Point.Empty;
+ }
+
+ ///
+ /// Gets whether item is on context menu created using ContextMenuBar
+ ///
+ [Browsable(false)]
+ public bool IsOnContextMenu
+ {
+ get { return this.GetOwner() is ContextMenuBar; }
+ }
+
+ ///
+ /// Occurs when a key is pressed down while the item has focus. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void InternalKeyDown(System.Windows.Forms.KeyEventArgs objArg)
+ {
+ if(m_DesignMode)
+ {
+ objArg.Handled=true;
+ return;
+ }
+
+ if(m_HotSubItem!=null)
+ {
+ m_HotSubItem.InternalKeyDown(objArg);
+ }
+
+ if(objArg.KeyCode==System.Windows.Forms.Keys.Enter || objArg.KeyCode==System.Windows.Forms.Keys.Return)
+ {
+ if (!(this.IsOnMenuBar || (this.IsOnMenu || this.ShowSubItems) && this.SubItems.Count > 0) && this.GetEnabled())
+ {
+ RaiseClick(eEventSource.Keyboard);
+ objArg.Handled=true;
+
+ if (this.GetOwner() is RibbonStrip || this.GetOwner() is RibbonBar)
+ {
+ ((ItemControl)this.GetOwner()).ReleaseFocus();
+ ((ItemControl)this.GetOwner()).MenuFocus = false;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Processes the MouseLeave for the current mouse over item.
+ ///
+ protected virtual void LeaveHotSubItem(BaseItem newMouseOverItem)
+ {
+ BaseItem hotSubItem = m_HotSubItem;
+ if (hotSubItem != null)
+ {
+ hotSubItem.InternalMouseLeave();
+ //if(objNew!=null && m_AutoExpand && m_HotSubItem.Expanded)
+ if (newMouseOverItem != null && hotSubItem.Expanded && (this.IsOnMenu || this.ContainerControl is Bar && ((Bar)this.ContainerControl).BarType == eBarType.MenuBar))
+ hotSubItem.Expanded = false;
+ HotSubItem = null;
+ }
+ }
+
+ ///
+ /// Occurs when the mouse pointer is moved over the item. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void InternalMouseMove(System.Windows.Forms.MouseEventArgs objArg)
+ {
+ if(m_DesignMode && objArg.Button==System.Windows.Forms.MouseButtons.Left && (Math.Abs(objArg.X-m_MouseDownPt.X)>=2 || Math.Abs(objArg.Y-m_MouseDownPt.Y)>=2))
+ {
+ BaseItem objFocus=this.FocusedItem();
+ if(objFocus!=null && objFocus.CanCustomize)
+ {
+ if(!objFocus.SystemItem)
+ {
+ IOwner owner=this.GetOwner() as IOwner;
+ if(owner!=null)
+ owner.StartItemDrag(objFocus);
+ }
+ }
+ else if(!m_IsContainer)
+ {
+ if(!this.SystemItem && m_CanCustomize)
+ {
+ IOwner owner=this.GetOwner() as IOwner;
+ if(owner!=null)
+ owner.StartItemDrag(this);
+ }
+ }
+ return;
+ }
+
+ // If item is container and not in design time...
+ if(m_IsContainer && !m_DesignMode)
+ {
+ BaseItem objNew=ItemAtLocation(objArg.X,objArg.Y);
+ if(objNew!=m_HotSubItem && (!(objArg.Button != MouseButtons.None && m_HotSubItem!=null) || m_CheckMouseMovePressed) &&
+ !(m_HotSubItem!=null && m_HotSubItem.MouseDownCapture && objArg.Button == MouseButtons.Left))
+ {
+ LeaveHotSubItem(objNew);
+
+ if(objNew!=null)
+ {
+ if(m_AutoExpand)
+ {
+ BaseItem objItem=ExpandedItem();
+ if(objItem!=null && objItem!=objNew)
+ objItem.Expanded=false;
+ }
+ if (objNew != this)
+ {
+ objNew.InternalMouseEnter();
+ objNew.InternalMouseMove(objArg);
+ if (objNew.GetEnabled())
+ {
+ if (m_AutoExpand && objNew.ShowSubItems)
+ {
+ if (objNew is PopupItem)
+ {
+ PopupItem pi = objNew as PopupItem;
+ ePopupAnimation oldAnim = pi.PopupAnimation;
+ pi.PopupAnimation = ePopupAnimation.None;
+ if (objNew.SubItems.Count > 0)
+ objNew.Expanded = true;
+ pi.PopupAnimation = oldAnim;
+ }
+ else
+ objNew.Expanded = true;
+ }
+ }
+ HotSubItem = objNew;
+ }
+ }
+ else
+ HotSubItem=null;
+ if(MouseMove!=null)
+ MouseMove(this, objArg);
+ }
+ else if(m_HotSubItem!=null)
+ {
+ m_HotSubItem.InternalMouseMove(objArg);
+ }
+ else
+ {
+ if(MouseMove!=null)
+ MouseMove(this,objArg);
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeMouseMove(this,objArg);
+ }
+
+ if (m_TextMarkup != null)
+ {
+ //m_TextMarkup.MouseMove(this.ContainerControl as Control, objArg);
+
+ Control control = GetParentControl();
+
+ if (control != null)
+ m_TextMarkup.MouseMove(control, objArg);
+ }
+ }
+ else
+ {
+ if (!m_DesignMode)
+ {
+ if (m_TextMarkup != null)
+ {
+ //m_TextMarkup.MouseMove(this.ContainerControl as Control, objArg);
+
+ Control control = GetParentControl();
+
+ if (control != null)
+ m_TextMarkup.MouseMove(control, objArg);
+ }
+
+ if (MouseMove!=null)
+ MouseMove(this,objArg);
+
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+
+ if (owner!=null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeMouseMove(this,objArg);
+ }
+ }
+ }
+
+ internal Control GetParentControl()
+ {
+ Control control = ContainerControl as Control;
+
+ if (control == null)
+ {
+ BaseItem item = ContainerControl as BaseItem;
+
+ while (item != null)
+ {
+ control = item.ContainerControl as Control;
+
+ if (control != null)
+ break;
+
+ item = item.Parent;
+ }
+ }
+
+ return (control);
+ }
+
+ ///
+ /// Occurs when the item is clicked. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void InternalClick(System.Windows.Forms.MouseButtons mb, System.Drawing.Point mpos)
+ {
+ if(m_HotSubItem!=null)
+ {
+ m_HotSubItem.InternalClick(mb,mpos);
+ return;
+ }
+
+ if (m_TextMarkup != null)
+ m_TextMarkup.Click(this.ContainerControl as System.Windows.Forms.Control);
+
+ //RaiseClick();
+ }
+
+ ///
+ /// Gets whether RaiseClick method will generate a click event give current item state.
+ ///
+ internal bool CanRaiseClick
+ {
+ get
+ {
+ if (this.DesignMode || !m_Visible && !this.SystemItem && !this.IsOnCustomizeMenu || _IgnoreClick || !GetEnabled())
+ return false;
+ if(this.ContainerControl is BaseItemControl && ((BaseItemControl)this.ContainerControl).IsValidationCancelled)
+ return false;
+#if TRIAL
+ if(NativeFunctions.ColorExpAlt())
+ return false;
+#endif
+
+ return true;
+ }
+ }
+
+ private bool _CollapseAllBeforeRaisingClick = true;
+ ///
+ /// Indicates whether RaiseClick method collapses parent popups before raising click event. Default value is true.
+ ///
+ internal bool CollapseAllBeforeRaisingClick
+ {
+ get { return _CollapseAllBeforeRaisingClick; }
+ set
+ {
+ _CollapseAllBeforeRaisingClick = value;
+ }
+ }
+
+ private void ClickCollapseAll()
+ {
+ if (m_AutoCollapseOnClick)
+ {
+ if ((!this.SystemItem || this.SystemItem && this.Name.StartsWith("mdi-")) && (IsOnPopup(this)) && !(m_Parent != null && m_Parent.SystemItem && !(m_Parent is DisplayMoreItem)))
+ {
+ if (!(this is PopupItem && ((PopupItem)this).ShowSubItems && (SubItems.Count > 0 || ((PopupItem)this).PopupType == ePopupType.Container)))
+ CollapseAll(this);
+ }
+
+ if (m_Parent != null && m_Parent.AutoExpand && this.SubItems.Count == 0)
+ m_Parent.AutoExpand = false;
+ }
+ }
+ ///
+ /// Raises the click event and provide the information about the source of the event.
+ ///
+ ///
+ public virtual void RaiseClick(eEventSource source)
+ {
+ //if (BaseItem.IsOnPopup(this))
+ // NativeFunctions.sndPlaySound("MenuCommand", NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT);
+ if (!CanRaiseClick)
+ return;
+
+ IOwnerItemEvents owner = this.GetIOwnerItemEvents();
+ BaseItem rootParent = this.RootParentItem;
+
+ if(_CollapseAllBeforeRaisingClick)
+ ClickCollapseAll();
+
+ if (m_InClickEvent) return;
+ m_InClickEvent = true;
+ try
+ {
+ this.OnClick();
+
+ if (Click != null)
+ Click(this, new DevComponents.DotNetBar.Events.EventSourceArgs(source));
+
+ if (rootParent != null && rootParent.ContainerControl is Bar)
+ {
+ Bar bar = rootParent.ContainerControl as Bar;
+ if (bar != null)
+ bar.InvokeItemClick(this, new DevComponents.DotNetBar.Events.EventSourceArgs(source));
+ }
+ else if (this.GetOwner() is Bar && owner == null)
+ ((Bar)this.GetOwner()).InvokeItemClick(this, new DevComponents.DotNetBar.Events.EventSourceArgs(source));
+
+ if (owner != null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeItemClick(this);
+ }
+ finally
+ {
+ m_InClickEvent = false;
+ }
+
+ if (!_CollapseAllBeforeRaisingClick)
+ ClickCollapseAll();
+ }
+
+ ///
+ /// Raises the Click event with default source as Code.
+ ///
+ private bool m_InClickEvent=false;
+ public virtual void RaiseClick()
+ {
+ RaiseClick(eEventSource.Code);
+ }
+
+ private BaseItem RootParentItem
+ {
+ get
+ {
+ BaseItem parent = Parent;
+ while (parent != null && parent.Parent != null)
+ parent = parent.Parent;
+ return parent;
+ }
+ }
+
+ internal void ClearClick()
+ {
+ Click=null;
+ }
+
+ ///
+ /// Occurs when the item is double clicked. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void InternalDoubleClick(System.Windows.Forms.MouseButtons mb, System.Drawing.Point mpos)
+ {
+ if (m_HotSubItem != null)
+ {
+ m_HotSubItem.InternalDoubleClick(mb, mpos);
+ }
+ else
+ {
+ InvokeDoubleClick();
+
+ IOwnerItemEvents owner = this.GetIOwnerItemEvents();
+ if (owner != null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeItemDoubleClick(this, new MouseEventArgs(mb, 2, mpos.X, mpos.Y, 0));
+ }
+ }
+
+ ///
+ /// Invokes DoubleClick event.
+ ///
+ protected virtual void InvokeDoubleClick()
+ {
+ if (DoubleClick != null)
+ DoubleClick(this, new EventArgs());
+ }
+
+ ///
+ /// Occurs when the item receives focus. If overridden base implementation must be called so default processing can occur.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void OnGotFocus()
+ {
+ m_Focused=true;
+
+ if(!m_DesignMode)
+ {
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeGotFocus(this,new EventArgs());
+ }
+
+ this.Refresh();
+
+ OnGotFocus(EventArgs.Empty);
+ }
+
+ protected virtual void OnGotFocus(EventArgs e)
+ {
+ if (GotFocus != null)
+ GotFocus(this, e);
+ }
+ ///
+ /// Occurs when the item has lost the focus. If overridden base implementation must be called so default processing can occur.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void OnLostFocus()
+ {
+ if (this.IsDisposed) return;
+
+ if (!m_DesignMode)
+ {
+ IOwnerItemEvents owner = this.GetIOwnerItemEvents();
+ if (owner != null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeLostFocus(this, new EventArgs());
+ }
+ else
+ InternalMouseLeave();
+ m_Focused=false;
+ this.Refresh();
+
+ OnLostFocus(EventArgs.Empty);
+ }
+
+ protected virtual void OnLostFocus(EventArgs e)
+ {
+ if (LostFocus != null)
+ LostFocus(this, e);
+ }
+ ///
+ /// Sets the input focus to the item. If overridden base implementation must be called so default processing can occur.
+ ///
+ public virtual void Focus()
+ {
+ if(BaseItem.IsOnPopup(this))
+ {
+ MenuPanel menu=this.ContainerControl as MenuPanel;
+ if(menu!=null && menu.ParentItem.Parent==null)
+ {
+ menu.SetFocusItem(this);
+ return;
+ }
+ }
+
+ IOwner owner=this.GetOwner() as IOwner;
+ if(owner!=null)
+ owner.SetFocusItem(this);
+ else
+ this.OnGotFocus();
+
+ if(this.Parent!=null)
+ this.Parent.OnSubItemGotFocus(this);
+ }
+
+ ///
+ /// Releases the input focus. If overridden base implementation must be called so default processing can occur.
+ ///
+ public virtual void ReleaseFocus()
+ {
+ if(m_Focused)
+ {
+ if(BaseItem.IsOnPopup(this))
+ {
+ MenuPanel menu=this.ContainerControl as MenuPanel;
+ if(menu!=null && menu.ParentItem.Parent==null)
+ {
+ menu.SetFocusItem(null);
+ return;
+ }
+ }
+
+ IOwner owner=this.GetOwner() as IOwner;
+ if(owner!=null)
+ owner.SetFocusItem(null);
+ else
+ this.OnLostFocus();
+
+ if(this.Parent!=null)
+ this.Parent.OnSubItemLostFocus(this);
+ }
+ }
+
+ ///
+ /// Gets whether item has input focus.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual bool Focused
+ {
+ get
+ {
+ return m_Focused;
+ }
+ }
+
+ ///
+ /// Occurs when item container has lost the input focus. If overridden base implementation must be called so default processing can occur.
+ ///
+ [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void ContainerLostFocus(bool appLostFocus)
+ {
+ if(m_SubItems!=null)
+ {
+ foreach(BaseItem objSub in m_SubItems)
+ {
+ objSub.ContainerLostFocus(appLostFocus);
+ }
+ }
+ if(m_HotSubItem!=null)
+ {
+ bool leave = true;
+ if (!appLostFocus)
+ {
+ System.Windows.Forms.Control c = this.ContainerControl as System.Windows.Forms.Control;
+ if (c != null)
+ {
+ Point p = c.PointToClient(System.Windows.Forms.Control.MousePosition);
+ if (m_HotSubItem.DisplayRectangle.Contains(p))
+ leave = false;
+ }
+ }
+ if (leave)
+ {
+ m_HotSubItem.InternalMouseLeave();
+ HotSubItem = null;
+ }
+ }
+ if(this.Focused)
+ {
+ IOwner owner=this.GetOwner() as IOwner;
+ if(owner!=null)
+ owner.SetFocusItem(null);
+ }
+ }
+
+ ///
+ /// Occurs when item container receives the input focus. If overridden base implementation must be called so default processing can occur.
+ ///
+ [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void ContainerGotFocus()
+ {
+ if(m_SubItems!=null)
+ {
+ foreach(BaseItem objSub in m_SubItems)
+ {
+ objSub.ContainerGotFocus();
+ }
+ }
+ }
+
+ ///
+ /// Indicates that item size has changed. It must be called by child item to let the parent know that its size
+ /// has been changed.
+ ///
+ [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual void SubItemSizeChanged(BaseItem objChildItem) {}
+
+ ///
+ /// Return Sub Item at specified location
+ ///
+ public virtual BaseItem ItemAtLocation(int x, int y)
+ {
+ if(!m_IsContainer)
+ {
+ return null;
+ }
+ if(m_SubItems!=null)
+ {
+ foreach (BaseItem objSub in m_SubItems)
+ {
+ //if(objSub.Visible && objSub.Displayed && x>=objSub.Left && x<=(objSub.Left+objSub.Width) && y>=objSub.Top && y<=(objSub.Top+objSub.Height))
+ if ((objSub.Visible || m_IsOnCustomizeMenu) && objSub.Displayed && objSub.DisplayRectangle.Contains(x, y))
+ {
+ if (m_ViewRectangle.IsEmpty || m_ViewRectangle.Contains(x, y))
+ return objSub;
+ }
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Gets the current expanded subitem.
+ ///
+ ///
+ protected internal virtual BaseItem ExpandedItem()
+ {
+ if(!m_IsContainer)
+ {
+ return null;
+ }
+ if(m_SubItems!=null)
+ {
+ foreach(BaseItem objSub in m_SubItems)
+ {
+ if (objSub is GalleryContainer && ((GalleryContainer)objSub).IsGalleryPopupOpen)
+ return objSub;
+ if (objSub is ItemContainer)
+ {
+ BaseItem exp = objSub.ExpandedItem();
+ if (exp != null)
+ return exp;
+ }
+ else if(objSub.Expanded)
+ {
+ return objSub;
+ }
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Gets the item that has input focus.
+ ///
+ /// Item that has focus or Null (Nothing) if none of the subitems have focus.
+ protected internal BaseItem FocusedItem()
+ {
+ if(!m_IsContainer)
+ return null;
+ if(m_SubItems!=null)
+ {
+ foreach(BaseItem objSub in m_SubItems)
+ {
+ if(objSub.Focused)
+ {
+ return objSub;
+ }
+ else if (objSub.IsContainer)
+ {
+ BaseItem focused = objSub.FocusedItem();
+ if (focused != null)
+ return focused;
+ }
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Gets the owner of the item.
+ ///
+ /// DotNetBarManager that owns the item.
+ public object GetOwner()
+ {
+ if(m_Owner!=null)
+ return m_Owner;
+
+ System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+
+ if (objCtrl is Bar)
+ return ((Bar)objCtrl).Owner;
+ else if(objCtrl is MenuPanel)
+ return ((MenuPanel)objCtrl).Owner;
+ else if(m_Parent!=null)
+ return m_Parent.GetOwner();
+
+ return null;
+ }
+
+ protected object OwnerDirect
+ {
+ get { return m_Owner; }
+ }
+
+ internal protected IOwnerItemEvents GetIOwnerItemEvents()
+ {
+ return this.GetOwner() as IOwnerItemEvents;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetOwner(object owner)
+ {
+ if(m_Owner!=owner)
+ {
+ m_Owner=owner;
+ this.OnOwnerChanged();
+ }
+ }
+
+ ///
+ /// Recalculate the size of the item. If overridden base implementation must be called so default processing can occur.
+ ///
+ public virtual void RecalcSize()
+ {
+ m_NeedRecalcSize=false;
+ }
+
+ ///
+ /// Indicates that item is recalculating its size.
+ ///
+ [System.ComponentModel.Browsable(false),DevCoBrowsable(false)]
+ public bool IsRecalculatingSize
+ {
+ get {return m_RecalculatingSize;}
+ }
+
+ ///
+ /// Must be overridden by class that is inheriting to provide the painting for the item.
+ ///
+ public abstract void Paint(ItemPaintArgs p);
+
+ ///
+ /// Must be overridden by class that is inheriting to provide the method to
+ /// return copy of an item.
+ ///
+ public abstract BaseItem Copy();
+
+ ///
+ /// Internal Copy implementation.
+ ///
+ /// Item to copy to.
+ protected virtual void CopyToItem(BaseItem objCopy)
+ {
+ objCopy.Visible=m_Visible;
+ objCopy.SetIsContainer(m_IsContainer);
+ objCopy.AutoExpand=m_AutoExpand;
+ objCopy.BeginGroup=m_BeginGroup;
+ objCopy.Enabled=m_Enabled;
+ objCopy.Description=m_Description;
+ objCopy.Tooltip=m_Tooltip;
+ objCopy.Category=m_Category;
+ objCopy.Orientation=m_Orientation;
+ objCopy.Text=m_Text;
+ objCopy.Name=m_Name;
+ objCopy.GlobalName = m_GlobalName;
+ objCopy.GlobalItem = m_GlobalItem;
+ objCopy.Style=m_Style;
+ objCopy.SetDesignMode(m_DesignMode);
+ objCopy.ShowSubItems=m_ShowSubItems;
+ objCopy.Stretch=m_Stretch;
+ if(m_Shortcuts!=null && m_Shortcuts.Count>0)
+ objCopy.Shortcuts.FromString(m_Shortcuts.ToString(","),",");
+
+ // Copy Events
+ objCopy.Click=this.Click;
+ objCopy.ExpandChange=this.ExpandChange;
+ objCopy.LostFocus=this.LostFocus;
+ objCopy.GotFocus=this.GotFocus;
+ objCopy.MouseDown=this.MouseDown;
+ objCopy.MouseEnter=this.MouseEnter;
+ objCopy.MouseHover=this.MouseHover;
+ objCopy.MouseLeave=this.MouseLeave;
+ objCopy.MouseMove=this.MouseMove;
+ objCopy.MouseUp=this.MouseUp;
+ objCopy.VisibleChanged=this.VisibleChanged;
+ objCopy.EnabledChanged=this.EnabledChanged;
+ objCopy.TextChanged=this.TextChanged;
+ objCopy.IsRightToLeft = this.IsRightToLeft;
+ objCopy.Cursor=m_Cursor;
+ objCopy.ThemeAware=m_ThemeAware;
+ objCopy.AutoCollapseOnClick = this.AutoCollapseOnClick;
+ objCopy.Tag=m_ItemData;
+ objCopy.CanCustomize = m_CanCustomize;
+ objCopy.Command = this.Command;
+ objCopy.CommandParameter = this.CommandParameter;
+ objCopy.KeyTips = this.KeyTips;
+ if(m_SubItems!=null)
+ {
+ foreach(BaseItem objItem in m_SubItems)
+ objCopy.SubItems.Add(objItem.Copy());
+ }
+
+ if(ItemCopied!=null)
+ ItemCopied(objCopy,new EventArgs());
+ }
+
+ ///
+ /// Returns copy of the item.
+ ///
+ /// Copy of the item.
+ public object Clone()
+ {
+ return this.Copy();
+ }
+
+ ///
+ /// Forces the repaint the item.
+ ///
+ public virtual void Refresh()
+ {
+ if(m_SuspendLayout)
+ return;
+
+ if((m_Visible || m_IsOnCustomizeMenu) && m_Displayed)
+ {
+ System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if (objCtrl != null && IsHandleValid(objCtrl) && !(objCtrl is ItemsListBox))
+ {
+ if (objCtrl.InvokeRequired)
+ {
+ objCtrl.BeginInvoke(new MethodInvoker(delegate { this.Refresh(); }));
+ return;
+ }
+
+ if (m_NeedRecalcSize)
+ {
+ if (m_Parent is ItemContainer)
+ {
+ m_Parent.RecalcSize();
+ }
+ else
+ {
+ RecalcSize();
+ if (m_Parent != null)
+ m_Parent.SubItemSizeChanged(this);
+ }
+ }
+ Invalidate(objCtrl);
+ }
+ }
+ }
+
+ protected virtual void Update()
+ {
+ Control cont = this.ContainerControl as Control;
+ if (cont != null)
+ Update(cont);
+ }
+ protected virtual void Update(Control containerControl)
+ {
+ if (containerControl.InvokeRequired)
+ containerControl.BeginInvoke(new MethodInvoker(delegate { containerControl.Update(); }));
+ else
+ containerControl.Update();
+ }
+ protected virtual void Invalidate()
+ {
+ Control cont = this.ContainerControl as Control;
+ if (cont != null)
+ Invalidate(cont);
+ }
+ private static void InvalidateFormCaption(Control containerControl)
+ {
+ int height = SystemInformation.Border3DSize.Height + SystemInformation.CaptionHeight;
+ WinApi.RECT r = new WinApi.RECT(0, -height, containerControl.Width, height);
+ WinApi.RedrawWindow(containerControl.Handle, ref r, IntPtr.Zero, WinApi.RedrawWindowFlags.RDW_INVALIDATE | WinApi.RedrawWindowFlags.RDW_FRAME | WinApi.RedrawWindowFlags.RDW_UPDATENOW);
+ }
+ protected virtual void Invalidate(Control containerControl)
+ {
+ if (this.DesignMode)
+ {
+ if (containerControl is Form && !(containerControl is RadialMenuPopup))
+ {
+ if (IsHandleValid(containerControl))
+ InvalidateFormCaption(containerControl);
+ containerControl.Refresh();
+ }
+ else
+ {
+ if (containerControl.InvokeRequired)
+ containerControl.BeginInvoke(new MethodInvoker(delegate { containerControl.Invalidate(); }));
+ else
+ containerControl.Invalidate();
+ }
+ }
+ else
+ {
+ if (containerControl is Form && !(containerControl is RadialMenuPopup))
+ {
+ if (IsHandleValid(containerControl))
+ InvalidateFormCaption(containerControl);
+ }
+ else
+ {
+ if (containerControl.InvokeRequired)
+ containerControl.BeginInvoke(new MethodInvoker(delegate { containerControl.Invalidate(GetInvalidateBounds(), true); }));
+ else
+ containerControl.Invalidate(GetInvalidateBounds(), true);
+ }
+ }
+ }
+ protected virtual Rectangle GetInvalidateBounds()
+ {
+ return m_Rect;
+ }
+
+ private bool m_Refreshing=false;
+ protected internal void OnAppearanceChanged()
+ {
+ if(m_Refreshing || !this.DesignMode)
+ return;
+
+ m_Refreshing=true;
+ try
+ {
+ System.Windows.Forms.Control c=this.ContainerControl as System.Windows.Forms.Control;
+ if(c!=null)
+ {
+ BarFunctions.InvokeRecalcLayout(c, true);
+ }
+ }
+ finally
+ {
+ m_Refreshing=false;
+ }
+ }
+
+ ///
+ /// Occurs when Expanded state changes. If overridden base implementation must be called so default processing can occur.
+ ///
+ protected internal virtual void OnExpandChange()
+ {
+ HideToolTip();
+ RaiseExpandChange(EventArgs.Empty);
+ }
+
+ ///
+ /// Raises ExpandChange event.
+ ///
+ /// Event arguments
+ protected virtual void RaiseExpandChange(EventArgs e)
+ {
+ if (ExpandChange != null)
+ ExpandChange(this, e);
+
+ IOwnerItemEvents owner = this.GetIOwnerItemEvents();
+ if (owner != null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ owner.InvokeExpandedChange(this, e);
+ }
+
+ ///
+ /// Occurs when sub item expanded state has changed.
+ ///
+ /// Sub item affected.
+ protected internal virtual void OnSubItemExpandChange(BaseItem item){}
+
+ ///
+ /// Suspends all layout for the item including painting. Use this property carefully and only to improve performace.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual bool SuspendLayout
+ {
+ get
+ {
+ return m_SuspendLayout;
+ }
+ set
+ {
+ m_SuspendLayout=value;
+ }
+ }
+
+ private bool _IsLayoutPass = false;
+
+ ///
+ /// Indicates whether item is performing layout pass.
+ ///
+ [Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public bool IsLayoutPass
+ {
+ get { return _IsLayoutPass; }
+ set { _IsLayoutPass = value; }
+ }
+
+ ///
+ /// Gets whether layout pass is in progress in the parent chain.
+ ///
+ [Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public bool IsLayoutPassInProgress
+ {
+ get
+ {
+ BaseItem parent = this.Parent;
+ while (parent != null)
+ {
+ if (parent.IsLayoutPass) return true;
+ parent = parent.Parent;
+ }
+ return false;
+ }
+ }
+
+ ///
+ /// Releases all resurces used in this control. After calling Dispose()
+ /// object is not in valid state and cannot be recovered to the valid state.
+ /// Recreation of the object is required.
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ if(m_Expanded && (this.Site!=null && !this.Site.DesignMode || this.Site==null))
+ this.Expanded=false;
+
+ HideToolTip();
+
+ if(m_Parent!=null)
+ {
+ m_Parent=null;
+ }
+ IOwner owner=this.GetOwner() as IOwner;
+ if(owner!=null)
+ owner.RemoveShortcutsFromItem(this);
+
+ if(this.Site==null || this.Site!=null && !this.Site.DesignMode)
+ {
+ if(m_SubItems!=null && m_SubItems.Count>0)
+ {
+ ArrayList subitems=new ArrayList(m_SubItems.Count);
+ m_SubItems.CopyTo(subitems);
+ foreach(BaseItem objSub in subitems)
+ {
+ if(objSub.Parent==this)
+ objSub.Dispose();
+ }
+ m_SubItems._Clear();
+ }
+ m_SubItems=null;
+ }
+
+ //if(Disposed != null)
+ // Disposed(this,EventArgs.Empty);
+
+ if(this.Site==null || this.Site!=null && !this.Site.DesignMode)
+ {
+ if(m_Shortcuts!=null)
+ m_Shortcuts=null;
+ //m_ItemData=null;
+ m_ContainerControl=null;
+ }
+
+ if (_Command != null)
+ this.Command = null;
+
+ if (m_TextMarkup != null)
+ {
+ m_TextMarkup.HyperLinkClick -= TextMarkupLinkClick;
+ m_TextMarkup = null;
+ }
+
+ m_IsDisposed = true;
+
+ base.Dispose(disposing);
+ }
+
+ ///
+ /// Gets whether item has been disposed through Dispose method call.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool IsDisposed
+ {
+ get
+ {
+ return m_IsDisposed;
+ }
+ }
+
+ ///
+ /// Returns the collection of sub items.
+ ///
+ [System.ComponentModel.Browsable(false),DevCoBrowsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)]
+ public virtual SubItemsCollection SubItems
+ {
+ get
+ {
+ if(m_SubItems==null)
+ m_SubItems=new SubItemsCollection(this);
+ return m_SubItems;
+ }
+ }
+
+ ///
+ /// Returns count of sub items in SubItems collection that have Visible property set to true.
+ ///
+ [Browsable(false)]
+ public int VisibleSubItems
+ {
+ get
+ {
+ int iCount = 0;
+ foreach (BaseItem item in this.SubItems)
+ if (item.Visible)
+ iCount++;
+ return iCount;
+ }
+ }
+
+
+ ///
+ /// Unique ID that indentifies the item.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.Category("Design"),System.ComponentModel.Description("Specifies unique ID of the item.")]
+ public long Id
+ {
+ get
+ {
+ return m_Id;
+ }
+ }
+
+// ///
+// /// Allows the user to associate custom user data with the item.
+// ///
+// [System.ComponentModel.Browsable(false), DevCoBrowsable(false),System.ComponentModel.Category("Data"),System.ComponentModel.DefaultValue(""),System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)),Obsolete("ItemData is being replaced by Tag property.")]
+// public virtual object ItemData
+// {
+// get
+// {
+// return m_ItemData;
+// }
+// set
+// {
+// m_ItemData=value;
+// }
+// }
+
+ ///
+ /// Allows the user to associate custom user data with the item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true),System.ComponentModel.Category("Data"),System.ComponentModel.DefaultValue(null),System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)),System.ComponentModel.Localizable(true)]
+ public virtual object Tag
+ {
+ get
+ {
+ return m_ItemData;
+ }
+ set
+ {
+ m_ItemData=value;
+ }
+ }
+
+ ///
+ /// Applies new visual style to this the item and all of its sub-items.
+ ///
+ [System.ComponentModel.Browsable(false),DevCoBrowsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden),System.ComponentModel.DefaultValue(eDotNetBarStyle.OfficeXP),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Determines the display of the item when shown.")]
+ public virtual eDotNetBarStyle Style
+ {
+ get
+ {
+ return m_Style;
+ }
+ set
+ {
+ m_Style=value;
+ if(m_SubItems!=null)
+ {
+ foreach(BaseItem objSub in m_SubItems)
+ {
+ objSub.Style=m_Style;
+ }
+ }
+ OnStyleChanged();
+ }
+ }
+ ///
+ /// Gets the effective item style.
+ ///
+ [Browsable(false)]
+ public virtual eDotNetBarStyle EffectiveStyle
+ {
+ get
+ {
+ if (Style == eDotNetBarStyle.StyleManagerControlled)
+ return StyleManager.GetEffectiveStyle();
+ return Style;
+ }
+ }
+
+ ///
+ /// Occurs after item visual style has changed.
+ ///
+ protected virtual void OnStyleChanged(){}
+
+ ///
+ /// Occurs after text has changed.
+ ///
+ protected virtual void OnTextChanged()
+ {
+ MarkupTextChanged();
+ if(TextChanged!=null)
+ TextChanged(this,new EventArgs());
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null)
+ owner.InvokeItemTextChanged(this,new EventArgs());
+ this.GenerateAccessibilityEvent(System.Windows.Forms.AccessibleEvents.NameChange);
+
+ this.OnAppearanceChanged();
+ }
+
+ ///
+ /// Gets or sets whether item will display sub items.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Determines whether sub-items are displayed.")]
+ public virtual bool ShowSubItems
+ {
+ get
+ {
+ return m_ShowSubItems;
+ }
+ set
+ {
+ if(m_ShowSubItems!=value)
+ {
+ NeedRecalcSize=true;
+ m_ShowSubItems=value;
+ if(this.Displayed)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets item alignment inside the container.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(eItemAlignment.Near),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Determines alignment of the item inside the container.")]
+ public virtual eItemAlignment ItemAlignment
+ {
+ get
+ {
+ return m_ItemAlignment;
+ }
+ set
+ {
+ if(m_ItemAlignment!=value)
+ {
+ m_ItemAlignment=value;
+ NeedRecalcSize=true;
+ if(this.Displayed && this.Parent!=null)
+ this.Parent.SubItemSizeChanged(this);
+ if (this.DesignMode)
+ {
+ OnAppearanceChanged();
+ Refresh();
+ }
+ }
+ }
+ }
+
+ ///
+ /// Returns if passed control is valid.
+ ///
+ /// Control to test.
+ ///
+ protected internal static bool IsHandleValid(System.Windows.Forms.Control objCtrl)
+ {
+ return (objCtrl!=null && !objCtrl.Disposing && !objCtrl.IsDisposed && objCtrl.IsHandleCreated);
+ }
+
+ ///
+ /// Resets Hoover timer.
+ ///
+ protected virtual void ResetHover()
+ {
+ System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(!IsHandleValid(objCtrl))
+ return;
+ // We need to reset hover thing since it is fired only first time mouse hovers inside the window and we need it for each of our items
+ NativeFunctions.TRACKMOUSEEVENT tme=new NativeFunctions.TRACKMOUSEEVENT();
+ tme.dwFlags=NativeFunctions.TME_QUERY;
+ tme.hwndTrack=objCtrl.Handle;
+ tme.cbSize=System.Runtime.InteropServices.Marshal.SizeOf(tme);
+ NativeFunctions.TrackMouseEvent(ref tme);
+ tme.dwFlags=tme.dwFlags | NativeFunctions.TME_HOVER;
+ NativeFunctions.TrackMouseEvent(ref tme);
+ objCtrl=null;
+ }
+
+ ///
+ /// Returns true if any subitem is contained on the control with a given handle.
+ ///
+ /// Container handle to test.
+ ///
+ protected internal virtual bool IsAnyOnHandle(IntPtr iHandle)
+ {
+ bool bRet=false;
+ if(m_SubItems==null || m_SubItems.Count==0)
+ return bRet;
+ BaseItem objTmp=m_SubItems[0] as BaseItem;
+ System.Windows.Forms.Control objCtrl=null;
+ // Since all items are always contained on same control check the first child only
+ if(objTmp!=null)
+ {
+ objCtrl=objTmp.ContainerControl as System.Windows.Forms.Control;
+ if(objCtrl is MenuPanel && ((MenuPanel)objCtrl).PopupMenu)
+ objCtrl=objCtrl.Parent;
+ if (objCtrl != null && objCtrl.Handle == iHandle)
+ return true;
+ objTmp=null;
+ }
+
+ foreach(BaseItem objItem in m_SubItems)
+ {
+ // Now go through each child and if it is expanded call this function to verify the handle
+ if(objItem.Expanded)
+ {
+ if(objItem.IsAnyOnHandle(iHandle))
+ {
+ bRet=true;
+ break;
+ }
+ }
+ }
+
+ return bRet;
+ }
+
+ ///
+ /// Gets or sets item description. This description is displayed in
+ /// Customize dialog to describe the item function in an application.
+ ///
+ [Browsable(true),DevCoBrowsable(true),DefaultValue(""),Category("Design"),Description("Indicates description of the item that is displayed during design."), Localizable(true)]
+ public virtual string Description
+ {
+ get
+ {
+
+ return m_Description;
+ }
+ set
+ {
+ if(m_Description==value)
+ return;
+ m_Description=value;
+
+ if(ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "Description");
+ }
+ }
+
+ ///
+ /// Gets or sets whether the item expands automatically to fill out the remaining space inside the container. Applies to Items on stretchable, no-wrap Bars only.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(false),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates whether item will stretch to consume empty space. Items on stretchable, no-wrap Bars only.")]
+ public virtual bool Stretch
+ {
+ get
+ {
+ return m_Stretch;
+ }
+ set
+ {
+ if(m_Stretch==value)
+ return;
+ m_Stretch=value;
+ if(ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "Stretch");
+ NeedRecalcSize=true;
+ if(this.Displayed && m_Parent!=null && !m_SuspendLayout)
+ {
+ m_Parent.SubItemSizeChanged(this);
+ }
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Occurs after Tooltip text has changed.
+ ///
+ protected virtual void OnTooltipChanged(){}
+ ///
+ /// Gets/Sets informational text (tooltip) for the item.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(""),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates the text that is displayed when mouse hovers over the item."),System.ComponentModel.Localizable(true)]
+ public virtual string Tooltip
+ {
+ get
+ {
+
+ return m_Tooltip;
+ }
+ set
+ {
+ if (m_Tooltip == value)
+ return;
+ if (value == null) value = "";
+ m_Tooltip = value;
+
+ if (this.ToolTipVisible)
+ {
+ if (string.IsNullOrEmpty(m_Tooltip))
+ this.HideToolTip();
+ else
+ {
+ ToolTip tooltipWindow = m_ToolTipWnd;
+ tooltipWindow.Text = m_Tooltip;
+ tooltipWindow.ShowToolTip();
+ tooltipWindow.Invalidate();
+ }
+ }
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "Tooltip");
+ OnTooltipChanged();
+ }
+ }
+
+ ///
+ /// Returns category for this item. If item cannot be customzied using the
+ /// customize dialog category is empty string.
+ ///
+ [Browsable(true),DevCoBrowsable(true),DefaultValue(""),Category("Design"),Description("Indicates item category used to group similar items at design-time."), Localizable(true)]
+ public virtual string Category
+ {
+ get
+ {
+
+ return m_Category;
+ }
+ set
+ {
+ m_Category=value;
+ }
+ }
+
+ ///
+ /// Returns name of the item that can be used to identify item from the code.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Design"),System.ComponentModel.Description("Indicates the name used to identify item.")]
+ public virtual string Name
+ {
+ get
+ {
+ if(this.Site!=null)
+ m_Name=this.Site.Name;
+ return m_Name;
+ }
+ set
+ {
+ if(this.Site!=null)
+ this.Site.Name=value;
+ if(value==null)
+ m_Name="";
+ else
+ m_Name=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the global name of the item that is used to synchronize the Global properties for the item across all instances with same
+ /// global name. Note that only instances that belong to the same control are synchronized. GlobalItem must be set to true to perform the synchronization.
+ /// You can find more information and list of
+ /// properties that are synchronized in help file.
+ ///
+ [Browsable(true), Category("Design"), Description("Indicates global name of the item that is used to synchronize the Global properties for the item across all instances with same global name."), DefaultValue("")]
+ public virtual string GlobalName
+ {
+ get { return m_GlobalName; }
+ set { m_GlobalName = value; }
+ }
+
+ ///
+ /// Gets whether global properties should synchronized.
+ ///
+ protected virtual bool ShouldSyncProperties
+ {
+ get { return this.GlobalItem && (this.GlobalName.Length > 0 || this.Name.Length > 0) && !m_IsOnCustomizeDialog; }
+ }
+
+ ///
+ /// Gets orientation within container that is supported by this item. If item does not support certain orientation the container automatically hides it when container switches into that orientation.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public eSupportedOrientation SupportedOrientation
+ {
+ get
+ {
+ return m_SupportedOrientation;
+ }
+ }
+
+ ///
+ /// Gets or sets whether item is global or not.
+ /// This flag is used to propagate property changes to all items with the same name.
+ /// Setting for example Visible property on the item that has GlobalItem set to true will
+ /// set visible property to the same value on all items with the same name.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates whether certain global properties are propagated to all items with the same name when changed.")]
+ public virtual bool GlobalItem
+ {
+ get
+ {
+ return m_GlobalItem;
+ }
+ set
+ {
+ m_GlobalItem=value;
+ }
+ }
+
+ ///
+ /// Gets or sets orientation inside the container. Do not change the value of this property. It is managed by system only.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual eOrientation Orientation
+ {
+ get
+ {
+ return m_Orientation;
+ }
+ set
+ {
+ if(m_Orientation!=value)
+ {
+ SetOrientation(value);
+ NeedRecalcSize=true;
+ }
+ }
+ }
+
+ ///
+ /// Sets orientation of the item but it does not cause the recalculate layout flag setting on the parent item.
+ ///
+ /// New orientation value.
+ internal void SetOrientation(eOrientation o)
+ {
+ if (m_Orientation != o)
+ {
+ m_Orientation = o;
+ if (m_SubItems != null)
+ {
+ foreach (BaseItem objItem in m_SubItems)
+ {
+ objItem.Orientation = m_Orientation;
+ }
+ }
+ m_NeedRecalcSize = true;
+ }
+ }
+
+ ///
+ /// Destroys tooltip window.
+ ///
+ internal protected void HideToolTip()
+ {
+ if(m_ToolTipWnd!=null)
+ {
+ System.Drawing.Rectangle tipRect=m_ToolTipWnd.Bounds;
+ tipRect.Width+=5;
+ tipRect.Height+=6;
+
+ OnTooltip(false);
+ OnToolTipVisibleChanged(new EventArgs());
+ try
+ {
+ if(m_ToolTipWnd!=null)
+ {
+ m_ToolTipWnd.Hide();
+ m_ToolTipWnd.Dispose();
+ m_ToolTipWnd=null;
+ }
+ }
+ catch{}
+
+ if(this.ContainerControl!=null)
+ {
+ System.Windows.Forms.Control ctrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(ctrl!=null)
+ ctrl.Invalidate(ctrl.RectangleToClient(tipRect),false);
+ }
+ }
+ }
+
+ private void OnToolTipVisibleChanged(EventArgs eventArgs)
+ {
+ EventHandler h = ToolTipVisibleChanged;
+ if (h != null)
+ ToolTipVisibleChanged(this, eventArgs);
+ }
+
+ internal BaseItem HotSubItem
+ {
+ get
+ {
+ return m_HotSubItem;
+ }
+ set
+ {
+ BaseItem oldValue = m_HotSubItem;
+ m_HotSubItem = value;
+ if (oldValue != value)
+ OnHotSubItemChanged(value, oldValue);
+ }
+ }
+ ///
+ /// Called when HotSubItem has changed.
+ ///
+ /// New value.
+ /// Old value.
+ protected virtual void OnHotSubItemChanged(BaseItem newValue, BaseItem oldValue)
+ {
+ }
+
+ ///
+ /// Shows tooltip for this item.
+ ///
+ public virtual void ShowToolTip()
+ {
+ if(m_DesignMode)
+ return;
+
+ if(m_Visible && m_Displayed && !m_Expanded)
+ {
+ IOwner owner=this.GetOwner() as IOwner;
+ if(owner!=null && !owner.ShowToolTips || !this.ShowToolTips)
+ return;
+ Control container = this.ContainerControl as Control;
+ if (container is Bar && !((Bar)container).ShowToolTips)
+ return;
+
+ if (container is MenuPanel && !((MenuPanel)container).ShowToolTips)
+ return;
+
+ OnTooltip(true);
+ if(m_Tooltip!="")
+ {
+ if(m_ToolTipWnd==null)
+ m_ToolTipWnd=new ToolTip();
+ m_ToolTipWnd.Style = EffectiveStyle;
+ m_ToolTipWnd.Text=m_Tooltip;
+ if(owner!=null && owner.ShowShortcutKeysInToolTips && m_Shortcuts!=null && m_Shortcuts.Count>0)
+ m_ToolTipWnd.Text+=(" ("+GetTooltipShortcutString()+")");
+ IOwnerItemEvents ownerEvents=this.GetIOwnerItemEvents();
+ if(ownerEvents!=null)
+ ownerEvents.InvokeToolTipShowing(this,new EventArgs());
+
+ m_ToolTipWnd.ReferenceRectangle = ScreenRectangle;
+
+ OnToolTipVisibleChanged(new EventArgs());
+ m_ToolTipWnd.ShowToolTip();
+ }
+ }
+ }
+ ///
+ /// Returns the shortcut string that is displayed on tooltip.
+ ///
+ ///
+ protected virtual string GetTooltipShortcutString()
+ {
+ return this.ShortcutString;
+ }
+
+ ///
+ /// Gets whether tooltip for the item is displayed.
+ ///
+ protected virtual bool ShowToolTips
+ {
+ get { return true; }
+ }
+
+ internal virtual Rectangle ScreenRectangle
+ {
+ get
+ {
+ System.Windows.Forms.Control c = this.ContainerControl as System.Windows.Forms.Control;
+ if (c == null) return Rectangle.Empty;
+ return new Rectangle(c.PointToScreen(this.DisplayRectangle.Location), this.DisplayRectangle.Size);
+ }
+ }
+
+ ///
+ /// Returns the point in screen coordinates.
+ ///
+ /// Client point
+ /// Point in screen coordinates if there is a parent Control otherwise clientPoint
+ public virtual Point PointToScreen(Point clientPoint)
+ {
+ Control c = this.ContainerControl as Control;
+ if (c == null) return clientPoint;
+ return c.PointToScreen(clientPoint);
+ }
+
+ ///
+ /// Gets whether tooltip is visible or not.
+ ///
+ internal protected bool ToolTipVisible
+ {
+ get
+ {
+ return (m_ToolTipWnd!=null);
+ }
+ }
+
+ ///
+ /// Gets or sets the name of the bar this item originated on. This is used to remember the
+ /// originating bar when user is moving the items from bar to bar.
+ ///
+ internal string OriginalBarName
+ {
+ get {return m_OriginalBarName;}
+ set {m_OriginalBarName=value;}
+ }
+
+ ///
+ /// Gets or sets item's original position (index) if item position has changed due to the user customization.
+ ///
+ internal int OriginalPosition
+ {
+ get {return m_OriginalPosition;}
+ set {m_OriginalPosition=value;}
+ }
+
+ ///
+ /// Gets or sets flag that indicates whether item was customize by the end-user.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool UserCustomized
+ {
+ get { return m_UserCustomized; }
+ set { m_UserCustomized = value; }
+ }
+
+ ///
+ /// Gets reference to the tooltip control if tooltip is displayed for this item.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public ToolTip ToolTipControl
+ {
+ get {return m_ToolTipWnd;}
+ }
+
+ ///
+ /// Gets or sets the Key Tips access key or keys for the item when on Ribbon Control or Ribbon Bar. Use KeyTips property
+ /// when you want to assign the one or more letters to be used to access an item. For example assigning the FN to KeyTips property
+ /// will require the user to press F then N keys to select an item. Pressing the F letter will show only keytips for the items that start with letter F.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(""), Description("Indicates the Key Tips access key or keys for the item when on Ribbon Control or Ribbon Bar.")]
+ public virtual string KeyTips
+ {
+ get { return m_KeyTips; }
+ set
+ {
+ if (value == null) value = "";
+ m_KeyTips = value.ToUpper();
+ }
+ }
+
+ ///
+ /// Gets or sets the text associated with this item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),Category("Appearance"),Description("The text contained in the item."),Localizable(true),DefaultValue(""), Bindable(true)]
+ public virtual string Text
+ {
+ get
+ {
+ return m_Text;
+ }
+ set
+ {
+ if(m_Text==value)
+ return;
+ if(value==null)
+ m_Text="";
+ else
+ m_Text=value;
+ m_AccessKey=NativeFunctions.GetAccessKey(m_Text);
+
+ if(ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "Text");
+
+ NeedRecalcSize=true;
+ if(this.Displayed && m_Parent!=null && !m_SuspendLayout)
+ {
+ RecalcSize();
+ m_Parent.SubItemSizeChanged(this);
+ }
+
+ this.OnTextChanged();
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets whether item can be customized by end user.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates whether item can be customized by user.")]
+ public virtual bool CanCustomize
+ {
+ get
+ {
+ return m_CanCustomize;
+ }
+ set
+ {
+ m_CanCustomize=value;
+ }
+ }
+
+ ///
+ /// Returns whether item is hosted on Customize menu.
+ ///
+ protected internal bool IsOnCustomizeMenu
+ {
+ get
+ {
+ return m_IsOnCustomizeMenu;
+ }
+ }
+
+ internal void SetIsOnCustomizeMenu(bool b)
+ {
+ if(m_IsOnCustomizeMenu!=b)
+ {
+ m_IsOnCustomizeMenu=b;
+ OnIsOnCustomizeMenuChanged();
+ }
+ }
+
+ public override string ToString()
+ {
+ return m_Text;
+ }
+
+ ///
+ /// Returns whether item is hosted on Customize Dialog.
+ ///
+ protected internal bool IsOnCustomizeDialog
+ {
+ get
+ {
+ return m_IsOnCustomizeDialog;
+ }
+ }
+
+ internal void SetIsOnCustomizeDialog(bool b)
+ {
+ if(m_IsOnCustomizeDialog!=b)
+ {
+ m_IsOnCustomizeDialog=b;
+ OnIsOnCustomizeDialogChanged();
+ }
+ }
+
+ ///
+ /// Returns whether item is hosted on menu or not.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public bool IsOnMenu
+ {
+ get
+ {
+ if(this.ContainerControl is MenuPanel || this.ContainerControl is ItemsListBox)
+ return true;
+ else
+ return false;
+ }
+ }
+
+ ///
+ /// Returns whether item is hosted on menu bar or not.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public virtual bool IsOnMenuBar
+ {
+ get
+ {
+ System.Windows.Forms.Control ctrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(ctrl!=null && ctrl is Bar)
+ return ((Bar)ctrl).MenuBar;
+ return false;
+ }
+ }
+
+ ///
+ /// Returns whether item is hosted on bar or not.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public bool IsOnBar
+ {
+ get
+ {
+ System.Windows.Forms.Control ctrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(ctrl!=null && ctrl is Bar)
+ return true;
+ return false;
+ }
+ }
+
+ ///
+ /// Returns whether item is in design mode or not.
+ ///
+ [System.ComponentModel.Browsable(false),DevCoBrowsable(false)]
+ public virtual bool DesignMode
+ {
+ get
+ {
+ return m_DesignMode;
+ }
+ }
+
+ [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public void SetDesignMode(bool b)
+ {
+ if(m_DesignMode!=b)
+ {
+ m_DesignMode=b;
+ if(m_SubItems!=null)
+ {
+ foreach(BaseItem objItem in m_SubItems)
+ objItem.SetDesignMode(m_DesignMode);
+ }
+ if(m_HotSubItem!=null)
+ {
+ m_HotSubItem.InternalMouseLeave();
+ HotSubItem = null;
+ }
+ OnDesignModeChanged();
+ }
+ }
+
+ ///
+ /// Get or sets whether item has been changed in a way that it needs its size recalculated. This is internal
+ /// property and it should not be used by your code.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual bool NeedRecalcSize
+ {
+ get
+ {
+ return m_NeedRecalcSize;
+ }
+ set
+ {
+ m_NeedRecalcSize=value;
+ if(value && this.Parent!=null && this.ContainerControl == this.Parent.ContainerControl)
+ {
+ this.Parent.NeedRecalcSize=true;
+ }
+ }
+ }
+
+
+ ///
+ /// Returns whether item is System item.
+ ///
+ [System.ComponentModel.Browsable(false)]
+ public bool SystemItem
+ {
+ get
+ {
+ return m_SystemItem;
+ }
+ }
+
+ internal void SetSystemItem(bool b)
+ {
+ m_SystemItem=b;
+ }
+
+ private bool _AccessKeyEnabled = true;
+ ///
+ /// Indicates whether access key processing set using ampersand key in Text is enabled. When enabled, and access key is pressed, item will raise Click event.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether access key processing set using ampersand key in Text is enabled. When enabled, and access key is pressed, item will raise Click event.")]
+ public bool AccessKeyEnabled
+ {
+ get { return _AccessKeyEnabled; }
+ set
+ {
+ _AccessKeyEnabled = value;
+ }
+ }
+
+
+ ///
+ /// Return Access key for the item.
+ ///
+ protected internal char AccessKey
+ {
+ get
+ {
+ return m_AccessKey;
+ }
+ }
+
+ ///
+ /// Gets or sets the collection of shortcut keys associated with the item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Design"), System.ComponentModel.Description("Indicates list of shortcut keys for this item."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ShortcutsDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter("DevComponents.DotNetBar.Design.ShortcutsConverter, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)]
+ public virtual ShortcutsCollection Shortcuts
+ {
+ get
+ {
+ if(m_Shortcuts==null)
+ m_Shortcuts=new ShortcutsCollection(this);
+ return m_Shortcuts;
+ }
+ set
+ {
+ IOwner owner=this.GetOwner() as IOwner;
+ if(m_Shortcuts!=null && owner!=null)
+ owner.RemoveShortcutsFromItem(this);
+ m_Shortcuts=value;
+ m_Shortcuts.Parent=this;
+ if(m_Shortcuts!=null && owner!=null)
+ owner.AddShortcutsFromItem(this);
+ }
+ }
+
+ ///
+ /// Returns text representation of shortcut for this item.
+ ///
+ protected internal string ShortcutString
+ {
+ get
+ {
+ return m_ShortcutString;
+ }
+ }
+
+ internal void RefreshShortcutString()
+ {
+ m_ShortcutString = "";
+ if (m_Shortcuts == null || m_Shortcuts.Count == 0)
+ return;
+ System.Windows.Forms.KeysConverter objConv = new System.Windows.Forms.KeysConverter();
+ m_ShortcutString = objConv.ConvertToString((System.Windows.Forms.Keys)m_Shortcuts[0]);
+ }
+
+ ///
+ /// Collapses all sub items by setting their Expanded property to false.
+ ///
+ /// Item to collapse.
+ public static void CollapseSubItems(BaseItem item)
+ {
+ if(item==null && item.SubItems.Count==0)
+ return;
+ BaseItem[] subItems = new BaseItem[item.SubItems.Count];
+ item.SubItems.CopyTo(subItems, 0);
+ foreach (BaseItem o in subItems)
+ if (o.Expanded)
+ o.Expanded = false;
+ }
+
+ ///
+ /// Collapses all sub items by setting their Expanded property to false. Enumerates all child items as well.
+ ///
+ /// Item to collapse.
+ public static void CollapseSubItemsTree(BaseItem item)
+ {
+ if (item == null && item.SubItems.Count == 0)
+ return;
+ BaseItem[] subItems = new BaseItem[item.SubItems.Count];
+ item.SubItems.CopyTo(subItems, 0);
+ foreach (BaseItem o in subItems)
+ {
+ CollapseSubItemsTree(o);
+ if (o.Expanded)
+ o.Expanded = false;
+ }
+ }
+
+ ///
+ /// Collapses whole tree for the item starting with its parent.
+ ///
+ /// Item to collapse.
+ public static void CollapseAll(BaseItem objItem)
+ {
+ if(objItem==null)
+ return;
+
+ do
+ {
+ System.Windows.Forms.Control objCtrl=objItem.ContainerControl as System.Windows.Forms.Control;
+ if (objCtrl is MenuPanel)
+ {
+ if (objItem.Parent != null)
+ objItem = objItem.Parent;
+ }
+ else if (objCtrl is Bar)
+ {
+ if (((Bar)objCtrl).ParentInternal == null)
+ break;
+ objItem = ((Bar)objCtrl).ParentItem;
+ }
+ else if (objItem is RadialMenuContainer && objItem.Parent != null)
+ {
+ break;
+ }
+ else if (objItem.Parent != null)
+ objItem = objItem.Parent;
+ } while (objItem!=null && objItem.Parent!=null);
+
+ if(objItem!=null)
+ {
+ objItem.Expanded=false;
+ objItem.AutoExpand=false;
+ if(objItem.Parent!=null)
+ objItem.Parent.AutoExpand=false;
+ }
+ }
+
+ ///
+ /// Returns whether item is hosted on popup menu or bar.
+ ///
+ /// Item to get information for.
+ ///
+ public static bool IsOnPopup(BaseItem item)
+ {
+ if(item==null)
+ return false;
+ object objCont=item.ContainerControl;
+ if(objCont==null)
+ return false;
+ if(objCont is MenuPanel)
+ return true;
+ if(objCont is Bar)
+ {
+ if(((Bar)objCont).BarState==eBarState.Popup)
+ return true;
+ }
+ if (objCont is RadialMenuPopup) return true;
+
+ return false;
+ }
+
+ ///
+ /// Gets or sets whether Click event will be auto repeated when mouse button is kept pressed over the item.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(false),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Gets or sets whether Click event will be auto repeated when mouse button is kept pressed over the item.")]
+ public virtual bool ClickAutoRepeat
+ {
+ get
+ {
+ return m_ClickAutoRepeat;
+ }
+ set
+ {
+ m_ClickAutoRepeat=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the auto-repeat interval for the click event when mouse button is kept pressed over the item.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(600),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Gets or sets the auto-repeat interval for the click event when mouse button is kept pressed over the item.")]
+ public virtual int ClickRepeatInterval
+ {
+ get
+ {
+ return m_ClickRepeatInterval;
+ }
+ set
+ {
+ m_ClickRepeatInterval=value;
+ }
+ }
+
+ ///
+ /// Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
+ ///
+ /// Hash code.
+ public override int GetHashCode()
+ {
+ return m_Id;
+ }
+
+ internal eDesignInsertPosition DesignInsertMarker
+ {
+ get {return m_DesignInsertMarker;}
+ set
+ {
+ if(m_DesignInsertMarker==value)
+ return;
+ m_DesignInsertMarker=value;
+ //if(this.DesignMode)
+ this.Refresh();
+ }
+ }
+
+ private eDesignMarkerOrientation _DesignMarkerOrientation = eDesignMarkerOrientation.NotSet;
+ ///
+ /// Gets or sets the design-marker orientation for the item.
+ ///
+ protected internal virtual eDesignMarkerOrientation DesignMarkerOrientation
+ {
+ get
+ {
+ return _DesignMarkerOrientation;
+ }
+ set
+ {
+ _DesignMarkerOrientation = value;
+ }
+ }
+
+ ///
+ /// Gets whether design-time item drag & drop marker is horizontal.
+ ///
+ internal bool IsDesignMarkHorizontal
+ {
+ get
+ {
+ if (_DesignMarkerOrientation != eDesignMarkerOrientation.NotSet)
+ return _DesignMarkerOrientation == eDesignMarkerOrientation.Horizontal;
+
+ if (this.Parent is ItemContainer)
+ {
+ if (((ItemContainer)this.Parent).LayoutOrientation == eOrientation.Horizontal)
+ return true;
+ else
+ return false;
+ }
+ else if (this.Parent is SimpleItemContainer)
+ {
+ if (((SimpleItemContainer)this.Parent).LayoutOrientation == eOrientation.Horizontal)
+ return true;
+ else
+ return false;
+ }
+
+ if(m_Orientation==eOrientation.Horizontal && !this.IsOnMenu && !(this.Parent is SideBarPanelItem) && !(this.Parent is ExplorerBarGroupItem))
+ return true;
+
+ return false;
+ }
+ }
+
+ protected virtual bool ShouldDrawInsertMarker()
+ {
+ IOwner owner = GetOwner() as IOwner;
+
+ return m_DesignInsertMarker != eDesignInsertPosition.None && this.Visible && this.Displayed &&
+ (owner != null && !owner.DragInProgress && !this.DesignMode);
+ }
+
+ protected internal void DrawInsertMarker(System.Drawing.Graphics g)
+ {
+ if (!ShouldDrawInsertMarker())
+ return;
+
+ Color lineColor = ColorScheme.GetColor("834DD5");
+ Color fillColor = ColorScheme.GetColor("CCCFF8");
+
+ int size = 4;
+ int lineThickness = 1;
+ int padding = 2;
+
+ if(IsDesignMarkHorizontal)
+ {
+ Point start = new Point(m_Rect.X, m_Rect.Y + padding), end = new Point(m_Rect.X, m_Rect.Bottom - (padding + 1));
+ if (m_DesignInsertMarker == eDesignInsertPosition.After)
+ {
+ start = new Point(m_Rect.Right - size * 2, m_Rect.Y + padding);
+ end = new Point(m_Rect.Right - size * 2, m_Rect.Bottom - (padding+1));
+ }
+
+ using (SolidBrush fillBrush = new SolidBrush(fillColor))
+ {
+ using (Pen pen = new Pen(lineColor, 1))
+ {
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddLine(start.X, start.Y + size, start.X + size, start.Y);
+ path.AddLine(start.X + size * 2, start.Y + size, start.X + (size * 2 - (size - lineThickness)), start.Y + size);
+ path.AddLine(end.X + (size * 2 - (size - lineThickness)), end.Y - size, end.X + size * 2, end.Y - size);
+ path.AddLine(end.X + size, end.Y, end.X, end.Y - size);
+ path.AddLine(end.X + (size - lineThickness), end.Y - size, start.X + (size - lineThickness), start.Y + size);
+ path.CloseAllFigures();
+
+ g.FillPath(fillBrush, path);
+ g.DrawPath(pen, path);
+ }
+ }
+ }
+ }
+ else
+ {
+ Point start = new Point(m_Rect.X + padding, m_Rect.Y), end = new Point(m_Rect.Right - (padding+1), m_Rect.Y);
+ if (m_DesignInsertMarker == eDesignInsertPosition.After)
+ {
+ start = new Point(m_Rect.X + padding, m_Rect.Bottom - (size * 2 + 1));
+ end = new Point(m_Rect.Right - (padding + 1), m_Rect.Bottom - (size * 2 + 1));
+ }
+
+ using (SolidBrush fillBrush = new SolidBrush(fillColor))
+ {
+ using (Pen pen = new Pen(lineColor, 1))
+ {
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddLine(start.X, start.Y + size, start.X + size, start.Y);
+ path.AddLine(start.X + size, start.Y + (size - lineThickness), end.X - size, end.Y + (size - lineThickness));
+ path.AddLine(end.X - size, end.Y, end.X, end.Y + size);
+ path.AddLine(end.X - size, end.Y + size * 2, end.X - size, end.Y + (size*2 - (size-padding)));
+ path.AddLine(start.X + size, start.Y + (size * 2 - (size - padding)), start.X + size, start.Y + size * 2);
+
+ path.CloseAllFigures();
+
+ g.FillPath(fillBrush, path);
+ g.DrawPath(pen, path);
+ }
+ }
+ }
+ //if(m_DesignInsertMarker==eDesignInsertPosition.Before)
+ //{
+ // p[0].X=m_Rect.Left+1;
+ // p[0].Y=m_Rect.Top;
+ // p[1].X=m_Rect.Left+1;
+ // p[1].Y=m_Rect.Top+4;
+ // g.DrawLines(pen,p);
+
+ // p[0].X=m_Rect.Left+1;
+ // p[0].Y=m_Rect.Top+2;
+ // p[1].X=m_Rect.Right-1;
+ // p[1].Y=m_Rect.Top+2;
+ // g.DrawLines(pen,p);
+
+ // p[0].X=m_Rect.Right-1;
+ // p[0].Y=m_Rect.Top;
+ // p[1].X=m_Rect.Right-1;
+ // p[1].Y=m_Rect.Top+4;
+ // g.DrawLines(pen,p);
+ //}
+ //else
+ //{
+ // p[0].X=m_Rect.Left+1;
+ // p[0].Y=m_Rect.Bottom-4;
+ // p[1].X=m_Rect.Left+1;
+ // p[1].Y=m_Rect.Bottom;
+ // g.DrawLines(pen,p);
+
+ // p[0].X=m_Rect.Left+1;
+ // p[0].Y=m_Rect.Bottom-2;
+ // p[1].X=m_Rect.Right-1;
+ // p[1].Y=m_Rect.Bottom-2;
+ // g.DrawLines(pen,p);
+
+ // p[0].X=m_Rect.Right-1;
+ // p[0].Y=m_Rect.Bottom-4;
+ // p[1].X=m_Rect.Right-1;
+ // p[1].Y=m_Rect.Bottom;
+ // g.DrawLines(pen,p);
+ //}
+ }
+ //g.SmoothingMode = sm;
+ }
+
+ ///
+ /// Specifes the mouse cursor displayed when mouse is over the item.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(null),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Specifies the mouse cursor displayed when mouse is over the item.")]
+ public virtual System.Windows.Forms.Cursor Cursor
+ {
+ get
+ {
+ return m_Cursor;
+ }
+ set
+ {
+ if(m_Cursor!=value)
+ {
+ m_Cursor=value;
+ if(m_Cursor!=null && m_Visible && m_Displayed)
+ {
+ System.Windows.Forms.Control cont=this.ContainerControl as System.Windows.Forms.Control;
+ if(cont!=null)
+ {
+ System.Drawing.Point p=cont.PointToClient(System.Windows.Forms.Control.MousePosition);
+ if(m_Rect.Contains(p))
+ cont.Cursor=m_Cursor;
+ }
+ }
+ }
+ }
+ }
+
+ [System.ComponentModel.Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override System.ComponentModel.ISite Site
+ {
+ get
+ {
+ return base.Site;
+ }
+ set
+ {
+ base.Site = value;
+ OnSiteChanged();
+ }
+ }
+
+ protected virtual void OnSiteChanged()
+ {
+
+ }
+
+ ///
+ /// Indicates whether item will be Serialized.
+ ///
+ [System.ComponentModel.Browsable(false),DevCoBrowsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public bool ShouldSerialize
+ {
+ get
+ {
+ return m_ShouldSerialize;
+ }
+ set
+ {
+ m_ShouldSerialize=value;
+ }
+ }
+
+ internal bool IsThemed
+ {
+ get
+ {
+ if(m_ThemeAware && BarFunctions.ThemedOS && Themes.ThemesActive && !BarFunctions.IsWindows8)
+ return true;
+ return false;
+ }
+ }
+
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public virtual bool IsWindowed
+ {
+ get {return false;}
+ }
+
+ ///
+ /// Specifies whether item is drawn using Themes when running on OS that supports themes like Windows XP.
+ ///
+ [Browsable(true),DevCoBrowsable(true),DefaultValue(false),Category("Appearance"),Description("Specifies whether item is drawn using Themes when running on OS that supports themes like Windows XP.")]
+ public virtual bool ThemeAware
+ {
+ get
+ {
+ return m_ThemeAware;
+ }
+ set
+ {
+ m_ThemeAware=value;
+ if(m_SubItems!=null)
+ {
+ foreach(BaseItem item in m_SubItems)
+ item.ThemeAware=value;
+ }
+ }
+ }
+
+ ///
+ /// Gets the AccessibleObject assigned to the item.
+ ///
+ [System.ComponentModel.Browsable(false),DevCoBrowsable(false)]
+ public virtual System.Windows.Forms.AccessibleObject AccessibleObject
+ {
+ get
+ {
+ return CreateAccessibilityInstance(); //m_Accessible;
+ }
+ }
+
+ private ItemAccessibleObject _ItemAccessibleObject = null;
+ protected virtual System.Windows.Forms.AccessibleObject CreateAccessibilityInstance()
+ {
+ if (_ItemAccessibleObject == null)
+ _ItemAccessibleObject = new ItemAccessibleObject(this);
+ return _ItemAccessibleObject;
+ }
+
+ ///
+ /// Gets or sets the default action description of the control for use by accessibility client applications.
+ ///
+ [DevCoBrowsable(true),System.ComponentModel.Browsable(true),System.ComponentModel.Category("Accessibility"),System.ComponentModel.DefaultValue(""),System.ComponentModel.Description("Gets or sets the default action description of the control for use by accessibility client applications.")]
+ public virtual string AccessibleDefaultActionDescription
+ {
+ get {return m_AccessibleDefaultActionDescription;}
+ set {m_AccessibleDefaultActionDescription=value;}
+ }
+
+ ///
+ /// Gets or sets the description of the control used by accessibility client applications.
+ ///
+ [DevCoBrowsable(true),System.ComponentModel.Browsable(true),System.ComponentModel.Category("Accessibility"),System.ComponentModel.DefaultValue(""),System.ComponentModel.Description("Gets or sets the description of the control used by accessibility client applications.")]
+ public virtual string AccessibleDescription
+ {
+ get {return m_AccessibleDescription;}
+ set
+ {
+ if(m_AccessibleDescription!=value)
+ {
+ m_AccessibleDescription=value;
+ GenerateAccessibilityEvent(System.Windows.Forms.AccessibleEvents.DescriptionChange);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the name of the control used by accessibility client applications.
+ ///
+ [DevCoBrowsable(true),System.ComponentModel.Browsable(true),System.ComponentModel.Category("Accessibility"),System.ComponentModel.Description("Gets or sets the name of the control used by accessibility client applications."),System.ComponentModel.DefaultValue("")]
+ public virtual string AccessibleName
+ {
+ get {return m_AccessibleName;}
+ set
+ {
+ if(m_AccessibleName!=value)
+ {
+ m_AccessibleName=value;
+ GenerateAccessibilityEvent(System.Windows.Forms.AccessibleEvents.NameChange);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the accessible role of the item.
+ ///
+ [DevCoBrowsable(true),System.ComponentModel.Browsable(true),System.ComponentModel.Category("Accessibility"),System.ComponentModel.Description("Gets or sets the accessible role of the item."),System.ComponentModel.DefaultValue(System.Windows.Forms.AccessibleRole.Default)]
+ public virtual System.Windows.Forms.AccessibleRole AccessibleRole
+ {
+ get {return m_AccessibleRole;}
+ set {m_AccessibleRole=value;}
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the item is visible to accessibility applications.
+ ///
+ [DevCoBrowsable(false),System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public virtual bool IsAccessible
+ {
+ get {return m_IsAccessible;}
+ set {m_IsAccessible=value;}
+ }
+
+ internal void GenerateAccessibilityEvent(System.Windows.Forms.AccessibleEvents e)
+ {
+ if(this.ContainerControl is Bar && ((Bar)this.ContainerControl).m_AccessibleObjectCreated)
+ {
+ Bar.BarAccessibleObject a=((Bar)this.ContainerControl).AccessibilityObject as Bar.BarAccessibleObject;
+ if(a!=null)
+ a.GenerateEvent(this,e);
+ }
+// else if(this.ContainerControl is PopupMenu && ((PopupMenu)this.ContainerControl).m_AccessibleObjectCreated)
+// {
+// PopupMenu.PopupMenuAccessibleObject a=((PopupMenu)this.ContainerControl).AccessibilityObject as PopupMenu.PopupMenuAccessibleObject;
+// if(a!=null)
+// a.GenerateEvent(this,e);
+// }
+ }
+ internal bool _AccessibleExpandAction = false;
+ internal virtual void DoAccesibleDefaultAction()
+ {
+ if(this.VisibleSubItems>0 && (this.IsOnMenu || this.IsOnMenuBar || _AccessibleExpandAction))
+ {
+ if(this.Expanded)
+ {
+ this.Expanded=false;
+ if(this.Parent!=null && this.IsOnMenuBar)
+ this.Parent.AutoExpand=false;
+ }
+ else
+ {
+ if(this.IsOnMenuBar && this.Parent!=null)
+ this.Parent.AutoExpand=true;
+ this.Expanded=true;
+ }
+ this.Refresh();
+ _AccessibleExpandAction = false;
+ }
+ else
+ this.RaiseClick(eEventSource.Keyboard);
+ }
+
+ private eContainerState _ContainerState = eContainerState.NotSet;
+ ///
+ /// Gets the item state inside of the parent container.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public eContainerState ContainerState
+ {
+ get { return _ContainerState; }
+ internal set { _ContainerState = value; }
+ }
+
+ private Point _DragStartPoint;
+ internal Point DragStartPoint
+ {
+ get { return _DragStartPoint; }
+ set
+ {
+ if (value != _DragStartPoint)
+ {
+ Point oldValue = _DragStartPoint;
+ _DragStartPoint = value;
+ OnDragStartPointChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when DragStartPoint property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnDragStartPointChanged(Point oldValue, Point newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("DragStartPoint"));
+ }
+ private bool _AllowDrop = true;
+ internal bool AllowDrop
+ {
+ get { return _AllowDrop; }
+ set
+ {
+ _AllowDrop = value;
+ }
+ }
+
+ protected void InvokeDelayed(MethodInvoker method)
+ {
+ InvokeDelayed(method, 10);
+ }
+ protected void InvokeDelayed(MethodInvoker method, int delayInterval)
+ {
+ Timer delayedInvokeTimer = new Timer();
+ delayedInvokeTimer = new Timer();
+ delayedInvokeTimer.Tag = method;
+ delayedInvokeTimer.Interval = delayInterval;
+ delayedInvokeTimer.Tick += new EventHandler(DelayedInvokeTimerTick);
+ delayedInvokeTimer.Start();
+ }
+ void DelayedInvokeTimerTick(object sender, EventArgs e)
+ {
+ Timer timer = (Timer)sender;
+ MethodInvoker method = (MethodInvoker)timer.Tag;
+ timer.Stop();
+ timer.Dispose();
+ if (!this.IsDisposed)
+ method.Invoke();
+ }
+
+ private DevComponents.DotNetBar.Padding _Margin = new DevComponents.DotNetBar.Padding(0);
+ ///
+ /// Gets or sets item margin only used by certain items in certain containers. Provided only for internal DotNetBar use.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public DevComponents.DotNetBar.Padding Margin
+ {
+ get { return _Margin; }
+ set { _Margin = value; }
+ }
+ #endregion
+
+ #region ICommandSource Members
+ protected virtual void ExecuteCommand()
+ {
+ if (_Command == null) return;
+ if (_Command is Command && ((Command)_Command).IsSyncingCommand) return;
+
+ CommandManager.ExecuteCommand(this);
+ }
+
+ internal void ExecuteCommandInternal()
+ {
+ ExecuteCommand();
+ }
+
+ ///
+ /// Gets or sets the command assigned to the item. Default value is null.
+ /// Note that for ButtonItem instances if this property is set to null and command was assigned previously, Enabled property will be set to false automatically to disable the item.
+ ///
+ [DefaultValue(null), Category("Commands"), Description("Indicates the command assigned to the item.")]
+ public virtual Command Command
+ {
+ get { return (Command)((ICommandSource)this).Command; }
+ set
+ {
+ ((ICommandSource)this).Command = value;
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "Command");
+ }
+ }
+
+ private ICommand _Command = null;
+ //[System.ComponentModel.Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ ICommand ICommandSource.Command
+ {
+ get
+ {
+ return _Command;
+ }
+ set
+ {
+ bool changed = false;
+ if (_Command != value)
+ changed = true;
+
+ if (_Command != null)
+ CommandManager.UnRegisterCommandSource(this, _Command);
+ _Command = value;
+ if (value != null)
+ CommandManager.RegisterCommand(this, value);
+ if (changed)
+ OnCommandChanged();
+ }
+ }
+ ///
+ /// Called when Command property value changes.
+ ///
+ protected virtual void OnCommandChanged()
+ {
+ }
+
+ private object _CommandParameter = null;
+ ///
+ /// Gets or sets user defined data value that can be passed to the command when it is executed.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Commands"), Description("Indicates user defined data value that can be passed to the command when it is executed."), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)), System.ComponentModel.Localizable(true)]
+ public virtual object CommandParameter
+ {
+ get
+ {
+ return _CommandParameter;
+ }
+ set
+ {
+ _CommandParameter = value;
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "CommandParameter");
+ }
+ }
+
+ #endregion
+
+ #region ItemAccessibleObject
+ public class ItemAccessibleObject: System.Windows.Forms.AccessibleObject
+ {
+ private BaseItem m_Owner=null;
+ private bool m_Hot=false;
+ public ItemAccessibleObject(BaseItem owner)
+ {
+ m_Owner = owner;
+ m_Owner.MouseEnter+=new EventHandler(OnMouseEnter);
+ m_Owner.MouseLeave+=new EventHandler(OnMouseLeave);
+ }
+
+ protected virtual void OnMouseEnter(object sender, System.EventArgs e)
+ {
+ m_Hot=true;
+ }
+
+ protected virtual void OnMouseLeave(object sender, System.EventArgs e)
+ {
+ m_Hot=false;
+ }
+
+ internal BaseItem Owner
+ {
+ get { return m_Owner; }
+ }
+
+ public override string Name
+ {
+ get
+ {
+ if(m_Owner==null)
+ return"";
+
+ if(m_Owner.AccessibleName!="")
+ return m_Owner.AccessibleName;
+
+ if(m_Owner.Text!=null)
+ return m_Owner.Text.Replace("&", "");
+
+ return m_Owner.Tooltip;
+ }
+ set
+ {
+ m_Owner.AccessibleName=value;
+ }
+ }
+
+ public override string Description
+ {
+ get
+ {
+ if(m_Owner==null)
+ return "";
+ if(m_Owner.AccessibleDescription!="")
+ return m_Owner.AccessibleDescription;
+ if (m_Owner.IsOnMenu)
+ return Name + " menu item";
+ else if(m_Owner.IsOnMenuBar)
+ return Name + " menu";
+ else
+ return Name + " button";
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleRole Role
+ {
+ get
+ {
+ if(m_Owner==null || !m_Owner.IsAccessible)
+ return System.Windows.Forms.AccessibleRole.None;
+
+ if(m_Owner.AccessibleRole!=System.Windows.Forms.AccessibleRole.Default)
+ return m_Owner.AccessibleRole;
+ BaseItem topParent=m_Owner;
+ while(topParent.Parent!=null)
+ topParent=topParent.Parent;
+ return (m_Owner.IsOnMenu || m_Owner.IsOnMenuBar || topParent.IsOnMenuBar ?
+ System.Windows.Forms.AccessibleRole.MenuItem :
+ System.Windows.Forms.AccessibleRole.PushButton);
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleStates State
+ {
+ get
+ {
+ if(m_Owner==null)
+ return System.Windows.Forms.AccessibleStates.Unavailable;
+ //System.Diagnostics.Trace.WriteLine("Getting state for "+m_Owner.Text);
+ System.Windows.Forms.AccessibleStates state=0;
+
+ if(!m_Owner.IsAccessible)
+ return System.Windows.Forms.AccessibleStates.Unavailable;
+
+ if(!m_Owner.Displayed || !m_Owner.Visible)
+ state |= System.Windows.Forms.AccessibleStates.Invisible;
+ else if (!m_Owner.GetEnabled())
+ {
+ state=System.Windows.Forms.AccessibleStates.Unavailable;
+ if(m_Owner.Expanded || m_Hot || m_Owner is ButtonItem && ((ButtonItem)m_Owner).IsMouseOver)
+ state|=(System.Windows.Forms.AccessibleStates.HotTracked | System.Windows.Forms.AccessibleStates.Focused);
+ return state;
+ }
+ else
+ {
+ if(m_Owner.Expanded || m_Hot || m_Owner is ButtonItem && ((ButtonItem)m_Owner).IsMouseOver)
+ state |= (System.Windows.Forms.AccessibleStates.Focused | System.Windows.Forms.AccessibleStates.HotTracked);
+ else
+ state |= System.Windows.Forms.AccessibleStates.Focusable;
+ if(m_Owner.ShowSubItems && m_Owner.SubItems.Count>0)
+ {
+ if(m_Owner.Expanded)
+ state|=System.Windows.Forms.AccessibleStates.Expanded;
+ else
+ state|=System.Windows.Forms.AccessibleStates.Collapsed;
+ }
+ }
+
+
+// if(m_Owner.SubItems.Count>0 && m_Owner.ShowSubItems)
+// state|=(System.Windows.Forms.AccessibleStates)0x40000000;
+
+ return state;
+ }
+ }
+
+ /*public override string Value
+ {
+ get { return m_owner.AccessibleRole; }
+ set { m_owner.AccessibleRole = value; }
+ }*/
+
+ public override System.Windows.Forms.AccessibleObject Parent
+ {
+ get
+ {
+ if(m_Owner==null)
+ return null;
+ if(m_Owner.Parent!=null)
+ {
+ if(!(m_Owner.Parent is GenericItemContainer && ((GenericItemContainer)m_Owner.Parent).SystemContainer))
+ return m_Owner.Parent.AccessibleObject;
+ }
+
+ System.Windows.Forms.Control control=m_Owner.ContainerControl as System.Windows.Forms.Control;
+ if(control!=null)
+ return control.AccessibilityObject;
+ return null;
+ }
+ }
+
+ public override System.Drawing.Rectangle Bounds
+ {
+ get
+ {
+ if(m_Owner==null)
+ return System.Drawing.Rectangle.Empty;
+
+ System.Windows.Forms.Control objCtrl=m_Owner.ContainerControl as System.Windows.Forms.Control;
+ if (objCtrl != null)
+ return objCtrl.RectangleToScreen(m_Owner.DisplayRectangle);
+ else
+ return m_Owner.m_Rect;
+ }
+ }
+
+ public override int GetChildCount()
+ {
+ if(m_Owner==null)
+ return 0;
+ return m_Owner.SubItems.Count;
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetChild(int iIndex)
+ {
+ if (m_Owner == null || iIndex < 0 || iIndex >= m_Owner.SubItems.Count)
+ return null;
+ return m_Owner.SubItems[iIndex].AccessibleObject;
+ }
+
+ public override string DefaultAction
+ {
+ get
+ {
+ if(m_Owner.AccessibleDefaultActionDescription!="")
+ return m_Owner.AccessibleDefaultActionDescription;
+ return "Press";
+ }
+ }
+
+ public override void DoDefaultAction()
+ {
+ if(m_Owner==null)
+ return;
+
+ System.Windows.Forms.Control cont=m_Owner.ContainerControl as System.Windows.Forms.Control;
+ if(cont is MenuPanel && !(cont is IAccessibilitySupport))
+ {
+ cont=((MenuPanel)cont).ParentItem.ContainerControl as System.Windows.Forms.Control;
+ }
+
+ IAccessibilitySupport ias = cont as IAccessibilitySupport;
+ if(ias!=null)
+ {
+ ias.DoDefaultActionItem=m_Owner;
+ NativeFunctions.PostMessage(cont.Handle,NativeFunctions.WM_USER+107,IntPtr.Zero,IntPtr.Zero);
+ }
+
+ base.DoDefaultAction();
+ }
+
+ public override string KeyboardShortcut
+ {
+ get
+ {
+ return m_Owner.ShortcutString;
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetSelected()
+ {
+ if (m_Owner == null)
+ return base.GetSelected();
+ foreach (BaseItem item in m_Owner.SubItems)
+ {
+ if ((item.AccessibleObject.State & System.Windows.Forms.AccessibleStates.HotTracked) == System.Windows.Forms.AccessibleStates.HotTracked)
+ return item.AccessibleObject;
+ }
+
+ return base.GetSelected();
+ }
+
+ public override System.Windows.Forms.AccessibleObject HitTest(int x, int y)
+ {
+ if (m_Owner == null)
+ return base.HitTest(x, y);
+
+ Point screen=new Point(x,y);
+ foreach (BaseItem item in m_Owner.SubItems)
+ {
+ System.Windows.Forms.Control cont = item.ContainerControl as System.Windows.Forms.Control;
+ if (cont != null)
+ {
+ Point p = cont.PointToClient(screen);
+ if (item.DisplayRectangle.Contains(p))
+ return item.AccessibleObject;
+ }
+ }
+
+ return base.HitTest(x, y);
+ }
+
+ public override System.Windows.Forms.AccessibleObject Navigate(System.Windows.Forms.AccessibleNavigation navdir)
+ {
+ if (m_Owner == null)
+ return base.Navigate(navdir);
+
+ BaseItem item = null;
+
+ if (navdir == System.Windows.Forms.AccessibleNavigation.Down || navdir == System.Windows.Forms.AccessibleNavigation.Right)
+ {
+ if (m_Owner.Parent != null)
+ {
+ BaseItem parent = m_Owner.Parent;
+ item = GetFirstVisible(parent.SubItems, parent.SubItems.IndexOf(m_Owner) + 1);
+ }
+ }
+ else if (navdir == System.Windows.Forms.AccessibleNavigation.Next)
+ {
+ if (m_Owner != null && m_Owner.Parent != null)
+ {
+ int index = m_Owner.Parent.SubItems.IndexOf(m_Owner);
+ if (index < m_Owner.Parent.SubItems.Count - 1)
+ item = m_Owner.Parent.SubItems[index + 1];
+ }
+ }
+ else if (navdir == System.Windows.Forms.AccessibleNavigation.Previous)
+ {
+ if (m_Owner != null && m_Owner.Parent != null)
+ {
+ int index = m_Owner.Parent.SubItems.IndexOf(m_Owner);
+ if (index > 0)
+ item = m_Owner.Parent.SubItems[index - 1];
+ }
+ }
+ else if (navdir == System.Windows.Forms.AccessibleNavigation.FirstChild)
+ {
+ item = GetFirstVisible(m_Owner.SubItems, 0);
+ }
+ else if (navdir == System.Windows.Forms.AccessibleNavigation.LastChild)
+ {
+ item = GetFirstVisibleReverse(m_Owner.SubItems, m_Owner.SubItems.Count - 1);
+ }
+ else if (navdir == System.Windows.Forms.AccessibleNavigation.Up)
+ {
+ if (m_Owner != null && m_Owner.Parent.IsContainer && m_Owner.Parent.SystemItem)
+ {
+ Control container = m_Owner.Parent.ContainerControl as Control;
+ if (container != null) return container.AccessibilityObject;
+ }
+ if (m_Owner.Parent != null) return m_Owner.Parent.AccessibleObject;
+ }
+ else if (navdir == System.Windows.Forms.AccessibleNavigation.Left)
+ {
+ BaseItem parent = m_Owner.Parent;
+ item = GetFirstVisibleReverse(m_Owner.SubItems, parent.SubItems.IndexOf(m_Owner) - 1);
+ }
+
+ if (item != null)
+ return item.AccessibleObject;
+
+ return base.Navigate(navdir);
+ }
+
+ private BaseItem GetFirstVisible(SubItemsCollection col, int startIndex)
+ {
+ int count = col.Count;
+ if (count == 0) return null;
+ if (startIndex >= col.Count) startIndex = col.Count - 1;
+ for (int i = startIndex; i < count; i++)
+ {
+ if (col[i].Visible)
+ return col[i];
+ }
+ return null;
+ }
+
+ private BaseItem GetFirstVisibleReverse(SubItemsCollection col, int startIndex)
+ {
+ if (col.Count == 0) return null;
+ if (startIndex >= col.Count) startIndex = col.Count - 1;
+ for (int i = startIndex; i >= 0; i--)
+ {
+ if (col[i].Visible)
+ return col[i];
+ }
+ return null;
+ }
+
+ }
+ #endregion
+
+ #region Markup Implementation
+ private TextMarkup.BodyElement m_TextMarkup = null;
+
+ private void MarkupTextChanged()
+ {
+ if (m_TextMarkup != null)
+ m_TextMarkup.HyperLinkClick -= TextMarkupLinkClick;
+
+ m_TextMarkup = null;
+
+ if (!IsMarkupSupported)
+ return;
+
+ if (!TextMarkup.MarkupParser.IsMarkup(ref m_Text))
+ return;
+
+ m_TextMarkup = TextMarkup.MarkupParser.Parse(m_Text);
+
+ if(m_TextMarkup!=null)
+ m_TextMarkup.HyperLinkClick += TextMarkupLinkClick;
+ }
+
+ ///
+ /// Occurs when text markup link is clicked.
+ ///
+ protected virtual void TextMarkupLinkClick(object sender, EventArgs e) {}
+
+ ///
+ /// Gets reference to parsed markup body element if text was markup otherwise returns null.
+ ///
+ internal TextMarkup.BodyElement TextMarkupBody
+ {
+ get { return m_TextMarkup; }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void TextMarkupBodyMeasure(Size size, DevComponents.DotNetBar.TextMarkup.MarkupDrawContext d)
+ {
+ TextMarkupBody.InvalidateElementsSize();
+ TextMarkupBody.Measure(size, d);
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void TextMarkupBodyArrange(Rectangle r, DevComponents.DotNetBar.TextMarkup.MarkupDrawContext d)
+ {
+ TextMarkupBody.Arrange(r, d);
+ }
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Rectangle TextMarkupBodyBounds
+ {
+ get
+ {
+ if (TextMarkupBody == null) return Rectangle.Empty;
+ return TextMarkupBody.Bounds;
+ }
+ set
+ {
+ TextMarkupBody.Bounds = value;
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void TextMarkupBodyRender(DevComponents.DotNetBar.TextMarkup.MarkupDrawContext d)
+ {
+ TextMarkupBody.Render(d);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
+ public bool IsUsingTextMarkup
+ {
+ get
+ {
+ return m_TextMarkup != null;
+ }
+ }
+
+ ///
+ /// Gets plain text without text-markup if text-markup is used in Text.
+ ///
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public string PlainText
+ {
+ get
+ {
+ return m_TextMarkup != null ? m_TextMarkup.PlainText : Text;
+ }
+ }
+
+ ///
+ /// Gets whether item supports text markup. Default is false.
+ ///
+ protected virtual bool IsMarkupSupported
+ {
+ get { return false; }
+ }
+ #endregion
+
+ #region IBindableComponent Members
+#if FRAMEWORK20
+ private BindingContext _BindingContext = null;
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Advanced), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public BindingContext BindingContext
+ {
+ get
+ {
+ if (_BindingContext != null) return _BindingContext;
+ Control container = this.ContainerControl as Control;
+ if (container != null)
+ {
+ if (container is MenuPanel)
+ {
+ object owner = this.GetOwner();
+ if (owner is DotNetBarManager && ((DotNetBarManager)owner).ParentForm != null)
+ return ((DotNetBarManager)owner).ParentForm.BindingContext;
+ else if (owner is Control)
+ return ((Control)owner).BindingContext;
+ }
+ else
+ return container.BindingContext;
+ }
+ else
+ {
+ object owner = this.GetOwner();
+ if (owner is DotNetBarManager && ((DotNetBarManager)owner).ParentForm != null)
+ return ((DotNetBarManager)owner).ParentForm.BindingContext;
+ else if (owner is Control)
+ {
+ return ((Control)owner).BindingContext;
+ }
+ }
+
+ return null;
+ }
+ set
+ {
+ _BindingContext = value;
+ UpdateBindings();
+ }
+ }
+
+ ///
+ /// Updates data bindings for item and its sub-items in response to binding context change on parent control.
+ ///
+ public void UpdateBindings()
+ {
+ if(_DataBindings!=null)
+ {
+ BindingContext context = this.BindingContext;
+ for (int i = 0; i < _DataBindings.Count; i++)
+ {
+ BindingContext.UpdateBinding(context, _DataBindings[i]);
+ }
+ }
+ if (m_SubItems != null)
+ {
+ foreach (BaseItem item in m_SubItems)
+ {
+ item.UpdateBindings();
+ }
+ }
+ }
+
+ private ControlBindingsCollection _DataBindings = null;
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Data"), ParenthesizePropertyName(true), RefreshProperties(RefreshProperties.All)]
+ public ControlBindingsCollection DataBindings
+ {
+ get
+ {
+ if (_DataBindings == null)
+ {
+ _DataBindings = new ControlBindingsCollection(this);
+ }
+ return _DataBindings;
+ }
+ }
+#endif
+ #endregion
+
+ #region Invoke Support
+ ///
+ /// Gets a value indicating whether the caller must call an invoke method when making method calls to the item because the caller is on a different thread than the one the item was created on.
+ /// This property calls directly the ContainerControl.InvokeRequired and is provided as shortcut convinience property only.
+ ///
+ [Browsable(false)]
+ public bool InvokeRequired
+ {
+ get
+ {
+ Control parent = this.ContainerControl as Control;
+ if (parent != null) return parent.InvokeRequired;
+ return false;
+ }
+ }
+
+ ///
+ /// Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.
+ /// This property calls directly the ContainerControl.Invoke and is provided as shortcut convenience property only.
+ ///
+ /// A delegate to a method that takes parameters of the same number and type that are contained in the args parameter.
+ /// An array of objects to pass as arguments to the specified method. This parameter can be null reference (Nothing in Visual Basic) if the method takes no arguments.
+ /// An Object that contains the return value from the delegate being invoked, or nullNothingnullptra null reference (Nothing in Visual Basic) if the delegate has no return value.
+ public Object Invoke(Delegate method,Object[] args)
+ {
+ Control parent = this.ContainerControl as Control;
+ if (parent == null || parent.IsDisposed) return null;
+ return parent.Invoke(method, args);
+ }
+
+ ///
+ /// Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.
+ /// This property calls directly the ContainerControl.Invoke and is provided as shortcut convenience property only.
+ ///
+ /// A delegate to a method that takes parameters of the same number and type that are contained in the args parameter.
+ /// An Object that contains the return value from the delegate being invoked, or nullNothingnullptra null reference (Nothing in Visual Basic) if the delegate has no return value.
+ public Object Invoke(Delegate method)
+ {
+ Control parent = this.ContainerControl as Control;
+ if (parent == null || parent.IsDisposed) return null;
+ return parent.Invoke(method);
+ }
+ ///
+ /// Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.
+ /// This property calls directly the ContainerControl.BeginInvoke and is provided as shortcut convenience property only.
+ ///
+ /// A delegate to a method that takes parameters of the same number and type that are contained in the args parameter.
+ /// An Object that contains the return value from the delegate being invoked, or nullNothingnullptra null reference (Nothing in Visual Basic) if the delegate has no return value.
+ public Object BeginInvoke(Delegate method)
+ {
+ Control parent = this.ContainerControl as Control;
+ if (parent == null || parent.IsDisposed) return null;
+ return parent.BeginInvoke(method);
+ }
+ #endregion
+
+ #region IComparable Members
+
+ int IComparable.CompareTo(object obj)
+ {
+ if (obj == null) return 1;
+
+ BaseItem targetItem = obj as BaseItem;
+ if (targetItem != null)
+ return string.Compare(this.Text, targetItem.Text);
+ else
+ throw new ArgumentException("Object is not a BaseItem");
+ }
+
+ #endregion
+ }
+
+ ///
+ /// Defines item parent container states.
+ ///
+ public enum eContainerState
+ {
+ ///
+ /// State is not set.
+ ///
+ NotSet,
+ ///
+ /// Item in on the NavigationPane in normal size.
+ ///
+ NavigationPane,
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BaseItemController.cs b/PROMS/DotNetBar Source Code/BaseItemController.cs
new file mode 100644
index 00000000..66b346b5
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BaseItemController.cs
@@ -0,0 +1,161 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the controller which allows single BaseItem to be hosted on the control.
+ ///
+ internal class BaseItemController : IDisposable
+ {
+ #region Constructor
+ private BaseItem _Item = null;
+ private Control _ParentControl = null;
+
+ ///
+ /// Initializes a new instance of the BaseItemController class.
+ ///
+ ///
+ ///
+ public BaseItemController(BaseItem item, Control parentControl)
+ {
+ _Item = item;
+ _ParentControl = parentControl;
+ _ParentControl.MouseDown += new MouseEventHandler(ParentControlMouseDown);
+ _ParentControl.MouseEnter += new EventHandler(ParentControlMouseEnter);
+ _ParentControl.MouseMove += new MouseEventHandler(ParentControlMouseMove);
+ _ParentControl.MouseUp += new MouseEventHandler(ParentControlMouseUp);
+ _ParentControl.MouseLeave += new EventHandler(ParentControlMouseLeave);
+ _ParentControl.Paint += new PaintEventHandler(ParentControlPaint);
+ _Item.ContainerControl = _ParentControl;
+ }
+
+ #endregion
+
+ #region Implementation
+ public BaseItem Item
+ {
+ get
+ {
+ return _Item;
+ }
+ }
+ void ParentControlPaint(object sender, PaintEventArgs e)
+ {
+ if (_Item.NeedRecalcSize)
+ {
+ _Item.RecalcSize();
+ }
+ _Item.Displayed = true;
+ Graphics g = e.Graphics;
+ SmoothingMode sm = g.SmoothingMode;
+ TextRenderingHint th = g.TextRenderingHint;
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ _Item.Paint(GetItemPaintArgs(g));
+ g.SmoothingMode = sm;
+ g.TextRenderingHint = th;
+ }
+
+ void ParentControlMouseLeave(object sender, EventArgs e)
+ {
+ if (_MouseOver)
+ {
+ _Item.InternalMouseLeave();
+ _MouseOver = false;
+ }
+ }
+
+ void ParentControlMouseUp(object sender, MouseEventArgs e)
+ {
+ _Item.InternalMouseUp(e);
+ }
+
+ void ParentControlMouseMove(object sender, MouseEventArgs e)
+ {
+ if (_Item.Bounds.Contains(e.Location))
+ {
+ if (!_MouseOver)
+ {
+ _Item.InternalMouseEnter();
+ _MouseOver = true;
+ }
+ _Item.InternalMouseMove(e);
+ }
+ else if (_MouseOver)
+ {
+ _Item.InternalMouseLeave();
+ _MouseOver = false;
+ }
+ }
+ private bool _MouseOver = false;
+ void ParentControlMouseEnter(object sender, EventArgs e)
+ {
+ Point p = _ParentControl.PointToClient(Control.MousePosition);
+
+ if (_Item.Bounds.Contains(p))
+ _Item.InternalMouseEnter();
+ }
+
+ void ParentControlMouseDown(object sender, MouseEventArgs e)
+ {
+ if (_Item.Bounds.Contains(e.Location))
+ _Item.InternalMouseDown(e);
+ }
+
+ private ItemPaintArgs GetItemPaintArgs(Graphics g)
+ {
+ ItemPaintArgs pa = new ItemPaintArgs(null, _ParentControl, g, GetColorScheme());
+ pa.Renderer = this.GetRenderer();
+ pa.ButtonStringFormat = pa.ButtonStringFormat & ~(pa.ButtonStringFormat & eTextFormat.SingleLine);
+ pa.ButtonStringFormat |= (eTextFormat.WordBreak | eTextFormat.EndEllipsis);
+ return pa;
+ }
+
+ private ColorScheme GetColorScheme()
+ {
+ BaseRenderer r = GetRenderer();
+ if (r is Office2007Renderer)
+ return ((Office2007Renderer)r).ColorTable.LegacyColors;
+ return new ColorScheme(eDotNetBarStyle.StyleManagerControlled);
+ }
+ private Rendering.BaseRenderer m_DefaultRenderer = null;
+ private Rendering.BaseRenderer m_Renderer = null;
+ private eRenderMode m_RenderMode = eRenderMode.Global;
+ ///
+ /// Returns the renderer control will be rendered with.
+ ///
+ /// The current renderer.
+ public virtual Rendering.BaseRenderer GetRenderer()
+ {
+ return Rendering.GlobalManager.Renderer;
+ }
+ #endregion
+
+ #region IDisposable Members
+
+ public void Dispose()
+ {
+ if (_ParentControl != null)
+ {
+ _ParentControl.MouseDown -= new MouseEventHandler(ParentControlMouseDown);
+ _ParentControl.MouseEnter -= new EventHandler(ParentControlMouseEnter);
+ _ParentControl.MouseMove -= new MouseEventHandler(ParentControlMouseMove);
+ _ParentControl.MouseUp -= new MouseEventHandler(ParentControlMouseUp);
+ _ParentControl.MouseLeave -= new EventHandler(ParentControlMouseLeave);
+ _ParentControl.Paint -= new PaintEventHandler(ParentControlPaint);
+ _Item.ContainerControl = null;
+ _Item = null;
+ _ParentControl = null;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BaseItemDesigner.cs b/PROMS/DotNetBar Source Code/BaseItemDesigner.cs
new file mode 100644
index 00000000..3a2cac92
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BaseItemDesigner.cs
@@ -0,0 +1,258 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents designer for BaseItem objects and derived classes.
+ ///
+ public class BaseItemDesigner:System.ComponentModel.Design.ComponentDesigner,IDesignerServices
+ {
+ #region Internal Implementation
+ ///
+ /// Creates new instance of the class.
+ ///
+ public BaseItemDesigner()
+ {
+ }
+
+ public override void Initialize(IComponent component)
+ {
+ base.Initialize(component);
+ if(!component.Site.DesignMode)
+ return;
+
+ ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null)
+ ss.SelectionChanged+=new EventHandler(OnSelectionChanged);
+
+ BaseItem c=component as BaseItem;
+ if(c!=null)
+ this.Visible=c.Visible;
+
+ // If our component is removed we need to clean-up
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ {
+ cc.ComponentRemoved+=new ComponentEventHandler(this.OnComponentRemoved);
+ }
+ }
+ protected override void Dispose(bool disposing)
+ {
+ ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null)
+ ss.SelectionChanged-=new EventHandler(OnSelectionChanged);
+
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ {
+ cc.ComponentRemoved-=new ComponentEventHandler(this.OnComponentRemoved);
+ }
+
+ base.Dispose(disposing);
+ }
+
+ private void OnComponentRemoved(object sender,ComponentEventArgs e)
+ {
+ if(e.Component is BaseItem)
+ {
+ BaseItem parent=this.Component as BaseItem;
+ BaseItem item=e.Component as BaseItem;
+ if(item!=null && parent!=null && parent.SubItems.Contains(item))
+ {
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ cc.OnComponentChanging(parent,TypeDescriptor.GetProperties(parent)["SubItems"]);
+ parent.SubItems.Remove(item);
+ if(cc!=null)
+ cc.OnComponentChanged(parent,TypeDescriptor.GetProperties(parent)["SubItems"],null,null);
+ this.RecalcLayout();
+ }
+ }
+ }
+
+ private void OnSelectionChanged(object sender, EventArgs e)
+ {
+ ISelectionService ss = (ISelectionService)sender;
+ if(ss!=null && ss.PrimarySelection!=this.Component && ss.PrimarySelection is BaseItem)
+ {
+ BaseItem item=this.Component as BaseItem;
+ if(item!=null)
+ {
+ BaseItem selected=ss.PrimarySelection as BaseItem;
+ IOwner owner=item.GetOwner() as IOwner;
+ if(owner!=null)
+ {
+ if(owner.GetItem(selected.Name)!=selected)
+ owner.SetFocusItem(null);
+ }
+ }
+ }
+ }
+
+ public override DesignerVerbCollection Verbs
+ {
+ get
+ {
+ DesignerVerb[] verbs = new DesignerVerb[]
+ {
+ new DesignerVerb("Create Button", new EventHandler(CreateButton)),
+ new DesignerVerb("Create Text Box", new EventHandler(CreateTextBox)),
+ new DesignerVerb("Create Combo Box", new EventHandler(CreateComboBox)),
+ new DesignerVerb("Create Label", new EventHandler(CreateLabel)),
+ };
+ return new DesignerVerbCollection(verbs);
+ }
+ }
+
+ protected virtual void CreateButton(object sender, EventArgs e)
+ {
+ CreateNewItem(typeof(ButtonItem));
+ }
+
+ protected virtual void CreateComboBox(object sender, EventArgs e)
+ {
+ CreateNewItem(typeof(ComboBoxItem));
+ }
+
+ protected virtual void CreateLabel(object sender, EventArgs e)
+ {
+ CreateNewItem(typeof(LabelItem));
+ }
+
+ protected virtual void CreateTextBox(object sender, EventArgs e)
+ {
+ CreateNewItem(typeof(TextBoxItem));
+ }
+
+ protected virtual void CreateNewItem(Type itemType)
+ {
+ BaseItem parent=this.Component as BaseItem;
+ System.ComponentModel.Design.IDesignerHost dh=(System.ComponentModel.Design.IDesignerHost)GetService(typeof(System.ComponentModel.Design.IDesignerHost));
+ System.ComponentModel.Design.IComponentChangeService change=this.GetService(typeof(System.ComponentModel.Design.IComponentChangeService)) as IComponentChangeService;
+ if(change!=null)
+ change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(parent).Find("SubItems",true));
+ BaseItem item=dh.CreateComponent(itemType) as BaseItem;
+ if(item==null)
+ return;
+ item.Text=item.Name;
+ BeforeNewItemAdded(item);
+ parent.SubItems.Add(item);
+ AfterNewItemAdded(item);
+ if(change!=null)
+ change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(parent).Find("SubItems",true),null,null);
+
+ this.RecalcLayout();
+ }
+
+ protected virtual void BeforeNewItemAdded(BaseItem item) {}
+
+ protected virtual void AfterNewItemAdded(BaseItem item) {}
+
+ protected virtual void RecalcLayout()
+ {
+ BaseItem item=this.Component as BaseItem;
+ System.Windows.Forms.Control control=item.ContainerControl as System.Windows.Forms.Control;
+
+ if(control is Bar)
+ ((Bar)control).RecalcLayout();
+ else if(control is ExplorerBar)
+ ((ExplorerBar)control).RecalcLayout();
+ else if(control is BarBaseControl)
+ ((BarBaseControl)control).RecalcLayout();
+ else if(control is SideBar)
+ ((SideBar)control).RecalcLayout();
+ }
+
+ public override System.Collections.ICollection AssociatedComponents
+ {
+ get
+ {
+ System.Collections.ArrayList components=new System.Collections.ArrayList();
+ BaseItem parent=this.Component as BaseItem;
+ if(parent==null)
+ return base.AssociatedComponents;
+ parent.SubItems.CopyTo(components);
+ return components;
+ }
+ }
+
+ protected override void PreFilterProperties(IDictionary properties)
+ {
+ base.PreFilterProperties(properties);
+ properties["Visible"] = TypeDescriptor.CreateProperty(typeof(BaseItemDesigner),(PropertyDescriptor)properties["Visible"], new Attribute[]
+ {
+ new DefaultValueAttribute(true),
+ new BrowsableAttribute(true),
+ new CategoryAttribute("Layout")});
+ properties["CanCustomize"] = TypeDescriptor.CreateProperty(typeof(BaseItemDesigner),(PropertyDescriptor)properties["CanCustomize"], new Attribute[]
+ {
+ new DefaultValueAttribute(true),
+ new BrowsableAttribute(true),
+ new CategoryAttribute("Behavior"),
+ new DescriptionAttribute("Indicates whether item can be customized by user.")});
+ }
+
+ ///
+ /// Gets or sets whether item can be customized by end user.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.DefaultValue(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates whether item can be customized by user.")]
+ public virtual bool CanCustomize
+ {
+ get
+ {
+ return (bool)ShadowProperties["CanCustomize"];
+ }
+ set
+ {
+ // this value is not passed to the actual control
+ this.ShadowProperties["CanCustomize"] = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether item is visible.
+ ///
+ [DefaultValue(true),Browsable(true),DevCoBrowsable(true),Category("Layout"),Description("Gets or sets whether item is visible.")]
+ public bool Visible
+ {
+ get
+ {
+ return (bool)ShadowProperties["Visible"];
+ }
+ set
+ {
+ // this value is not passed to the actual control
+ this.ShadowProperties["Visible"] = value;
+ }
+ }
+ #endregion
+
+ #region IDesignerServices Implementation
+ object IDesignerServices.CreateComponent(System.Type componentClass)
+ {
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh==null)
+ return null;
+ return dh.CreateComponent(componentClass);
+ }
+
+ void IDesignerServices.DestroyComponent(IComponent c)
+ {
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh==null)
+ return;
+ dh.DestroyComponent(c);
+ }
+
+ object IDesignerServices.GetService(Type serviceType)
+ {
+ return this.GetService(serviceType);
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BindingDef.cs b/PROMS/DotNetBar Source Code/BindingDef.cs
new file mode 100644
index 00000000..6ef3f779
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BindingDef.cs
@@ -0,0 +1,504 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Globalization;
+using System.Drawing;
+using System.Security;
+using System.Reflection;
+using System.Collections;
+using System.ComponentModel.Design.Serialization;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Defines class which described single binding.
+ ///
+ [TypeConverter(typeof(BindingDefConverer)), DesignTimeVisible(false), ToolboxItem(false)]
+ public class BindingDef : INotifyPropertyChanged
+ {
+ #region Dependency Properties & Events
+ public event DataConvertEventHandler Format;
+ ///
+ /// Raises Format event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnFormat(DataConvertEventArgs e)
+ {
+ DataConvertEventHandler handler = Format;
+ if (handler != null)
+ handler(this, e);
+ }
+ #endregion
+
+ #region Constructor
+ ///
+ /// Initializes a new instance of the BindingDef class.
+ ///
+ public BindingDef()
+ {
+
+ }
+ ///
+ /// Initializes a new instance of the BindingDef class.
+ ///
+ ///
+ ///
+ public BindingDef(string propertyName, string dataMember)
+ {
+ _PropertyName = propertyName;
+ _PropertyPath = propertyName.Split('.');
+ _DataMember = dataMember;
+ _BindingMemberInfo = new BindingMemberInfo(dataMember);
+ }
+ #endregion
+
+ #region Implementation
+ ///
+ /// Updates specified item PropertyName with the data from data object property specified by DataMember.
+ ///
+ /// Item to set PropertyName on.
+ /// Data to retrieve DataMember value from.
+ public void Update(object item, object data)
+ {
+ Update(null, item, data);
+ }
+
+ ///
+ /// Updates specified item PropertyName with the data from data object property specified by DataMember.
+ ///
+ /// CurrencyManager to use
+ /// Item to set PropertyName on.
+ /// Data to retrieve DataMember value from.
+ public void Update(ItemVisualGenerator generator, object item, object data)
+ {
+ string propertyName = _PropertyName;
+
+ if (item is BaseItem && _PropertyPath.Length > 1)
+ {
+ // Dig into child items
+ BaseItem parent = (BaseItem)item;
+ for (int i = 0; i < _PropertyPath.Length - 1; i++)
+ {
+ parent = parent.SubItems[_PropertyPath[i]];
+ }
+ item = parent;
+ propertyName = _PropertyPath[_PropertyPath.Length - 1];
+ }
+
+ PropertyInfo targetProp = item.GetType().GetProperty(propertyName);
+ if (targetProp.PropertyType == typeof(string))
+ targetProp.SetValue(item, GetDataText(generator, data, _DataMember), null);
+ else
+ targetProp.SetValue(item, GetDataValue(generator, data, _DataMember, GetPropertyValue(generator, data, _DataMember)), null);
+ }
+
+ private static TypeConverter stringTypeConverter;
+ private string GetDataText(ItemVisualGenerator generator, object data, string fieldName)
+ {
+ object propertyValue = GetPropertyValue(generator, data, fieldName);
+ return GetDataText(generator, data, fieldName, propertyValue);
+ }
+ private string GetDataText(ItemVisualGenerator generator, object data, string fieldName, object propertyValue)
+ {
+ if (!_FormattingEnabled)
+ {
+ if (data == null)
+ {
+ return string.Empty;
+ }
+ if (propertyValue == null)
+ {
+ return "";
+ }
+ return Convert.ToString(propertyValue, CultureInfo.CurrentCulture);
+ }
+
+ DataConvertEventArgs e = new DataConvertEventArgs(propertyValue, typeof(string), data, fieldName);
+ this.OnFormat(e);
+ if ((e.Value != data) && (e.Value is string))
+ {
+ return (string)e.Value;
+ }
+ if (stringTypeConverter == null)
+ {
+ stringTypeConverter = TypeDescriptor.GetConverter(typeof(string));
+ }
+ try
+ {
+ return (string)FormatHelper.FormatObject(propertyValue, typeof(string), generator.GetFieldConverter(fieldName), stringTypeConverter, _FormatString, _FormatInfo, null, DBNull.Value);
+ }
+ catch (Exception ex)
+ {
+ if (ex is SecurityException || IsCriticalException(ex))
+ {
+ throw;
+ }
+ return ((propertyValue != null) ? Convert.ToString(data, CultureInfo.CurrentCulture) : "");
+ }
+ }
+
+ private object GetDataValue(ItemVisualGenerator generator, object data, string fieldName, object propertyValue)
+ {
+ if (!_FormattingEnabled)
+ {
+ return propertyValue;
+ }
+
+ DataConvertEventArgs e = new DataConvertEventArgs(propertyValue, typeof(object), data, fieldName);
+ this.OnFormat(e);
+ return e.Value;
+ }
+
+ private static bool IsCriticalException(Exception ex)
+ {
+ return (((((ex is NullReferenceException) || (ex is StackOverflowException)) || ((ex is OutOfMemoryException) || (ex is System.Threading.ThreadAbortException))) || ((ex is ExecutionEngineException) || (ex is IndexOutOfRangeException))) || (ex is AccessViolationException));
+ }
+
+ private object GetPropertyValue(ItemVisualGenerator generator, object data, string fieldName)
+ {
+ if ((data != null) && (fieldName.Length > 0))
+ {
+ try
+ {
+ PropertyDescriptor descriptor = null;
+ if (generator.DataManager != null)
+ {
+ descriptor = generator.DataManager.GetItemProperties().Find(fieldName, true);
+ }
+ if(descriptor == null)
+ {
+ descriptor = TypeDescriptor.GetProperties(data).Find(fieldName, true);
+ }
+ if (descriptor != null)
+ {
+ data = descriptor.GetValue(data);
+ }
+ }
+ catch
+ {
+ }
+ }
+
+ if (data == DBNull.Value && _NullValue != null)
+ return _NullValue;
+
+ return data;
+ }
+ #endregion
+
+ #region Properties
+ private string[] _PropertyPath = new string[0];
+ private string _PropertyName = "";
+ ///
+ /// Gets or sets the property name binding is attached to.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates property name binding is attached to.")]
+ public string PropertyName
+ {
+ get { return _PropertyName; }
+ set
+ {
+ if (value != _PropertyName)
+ {
+ string oldValue = _PropertyName;
+ _PropertyName = value;
+ OnPropertyNameChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when PropertyName property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnPropertyNameChanged(string oldValue, string newValue)
+ {
+ _PropertyPath = newValue.Split('.');
+ OnPropertyChanged(new PropertyChangedEventArgs("PropertyName"));
+ }
+
+ ///
+ /// Gets the reference to BindingMemberInfo created based on DataMember.
+ ///
+ [Browsable(false)]
+ public BindingMemberInfo BindingMemberInfo
+ {
+ get
+ {
+ return _BindingMemberInfo;
+ }
+ }
+
+ private BindingMemberInfo _BindingMemberInfo;
+ private string _DataMember = "";
+ ///
+ /// Gets or sets the data member name which holds data that PropertyName is populated with.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates data member name which holds data that PropertyName is populated with.")]
+ public string DataMember
+ {
+ get { return _DataMember; }
+ set
+ {
+ if (value == null) value = "";
+ if (value != _DataMember)
+ {
+ string oldValue = _DataMember;
+ _DataMember = value;
+ OnDataMemberChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when DataMember property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnDataMemberChanged(string oldValue, string newValue)
+ {
+ if (!string.IsNullOrEmpty(newValue))
+ _BindingMemberInfo = new BindingMemberInfo(newValue);
+ else
+ _BindingMemberInfo = new BindingMemberInfo();
+ OnPropertyChanged(new PropertyChangedEventArgs("DataMember"));
+ }
+
+ private bool _FormattingEnabled = false;
+ ///
+ /// Gets or sets whether type conversion and formatting is applied to the property data.
+ ///
+ [DefaultValue(false), Category("Data"), Description("Indicates whether type conversion and formatting is applied to the property data.")]
+ public bool FormattingEnabled
+ {
+ get { return _FormattingEnabled; }
+ set
+ {
+ if (value != _FormattingEnabled)
+ {
+ bool oldValue = _FormattingEnabled;
+ _FormattingEnabled = value;
+ OnFormattingEnabledChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when FormattingEnabled property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnFormattingEnabledChanged(bool oldValue, bool newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("FormattingEnabled"));
+
+ }
+
+ private string _FormatString = "";
+ ///
+ /// Gets or sets format specifier characters that indicate how a value is to be displayed.
+ /// For more information, see Formatting Overview: http://msdn.microsoft.com/en-us/library/26etazsy%28v=vs.71%29.aspx
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates format specifier characters that indicate how a value is to be displayed.")]
+ public string FormatString
+ {
+ get { return _FormatString; }
+ set
+ {
+ if (value != _FormatString)
+ {
+ string oldValue = _FormatString;
+ _FormatString = value;
+ OnFormatStringChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when FormatString property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnFormatStringChanged(string oldValue, string newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("FormatString"));
+
+ }
+
+ private IFormatProvider _FormatInfo = null;
+ ///
+ /// Gets or sets the IFormatProvider that provides custom formatting behavior.
+ ///
+ [DefaultValue(null), Category("Data"), Description("Indicates IFormatProvider that provides custom formatting behavior.")]
+ public IFormatProvider FormatInfo
+ {
+ get { return _FormatInfo; }
+ set
+ {
+ if (value != _FormatInfo)
+ {
+ IFormatProvider oldValue = _FormatInfo;
+ _FormatInfo = value;
+ OnFormatInfoChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when FormatInfo property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnFormatInfoChanged(IFormatProvider oldValue, IFormatProvider newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("FormatInfo"));
+
+ }
+
+ private object _NullValue = null;
+ ///
+ /// Gets or sets the Object to be set as the target property when the data source contains a DBNull value.
+ /// The data source must contain DBNull for the NullValue property to be correctly applied.
+ /// If the data source type is a type such as a string or integer the value of the NullValue property will be ignored.
+ /// Also, the NullValue property is ignored if it is set to null.
+ ///
+ [DefaultValue(null), Category("Data"), Description("Indicates Object to be set as the control property when the data source contains a DBNull value. ")]
+ [System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter))]
+ public object NullValue
+ {
+ get { return _NullValue; }
+ set
+ {
+ if (value != _NullValue)
+ {
+ object oldValue = _NullValue;
+ _NullValue = value;
+ OnNullValueChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when NullValue property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnNullValueChanged(object oldValue, object newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("NullValue"));
+ }
+ #endregion
+
+ #region INotifyPropertyChanged Members
+ ///
+ /// Raises the PropertyChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null) handler(this, e);
+ }
+ ///
+ /// Occurs when property on BindingDef object has changed.
+ ///
+ [Description("Occurs when property on BindingDef object has changed.Occurs when property on BindingDef object has changed.")]
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ #endregion
+ }
+
+ ///
+ /// Represents the method that will handle converting for bindings.
+ ///
+ ///
+ ///
+ public delegate void DataConvertEventHandler(object sender, DataConvertEventArgs e);
+ public class DataConvertEventArgs : ConvertEventArgs
+ {
+ // Fields
+ private object _DataItem;
+
+ // Methods
+ public DataConvertEventArgs(object value, Type desiredType, object dataItem, string fieldName)
+ : base(value, desiredType)
+ {
+ _DataItem = dataItem;
+ _FieldName = fieldName;
+ }
+
+ ///
+ /// Gets the reference to the item being converted.
+ ///
+ public object DataItem
+ {
+ get
+ {
+ return _DataItem;
+ }
+ }
+
+ private string _FieldName = "";
+ ///
+ /// Get the reference to the name of the field or property on the item that needs conversion.
+ ///
+ public string FieldName
+ {
+ get { return _FieldName; }
+ }
+ }
+
+ ///
+ /// Represents BindingDefConverer converter.
+ ///
+ public class BindingDefConverer : TypeConverter
+ {
+ ///
+ /// Creates new instance of the class.
+ ///
+ public BindingDefConverer() { }
+
+ ///
+ /// Checks whether conversion can be made to specified type.
+ ///
+ /// Context Information.
+ /// Destination type.
+ ///
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
+ {
+ if (destinationType == typeof(InstanceDescriptor))
+ return true;
+ return base.CanConvertTo(context, destinationType);
+ }
+
+ ///
+ /// Converts object to specified type.
+ ///
+ /// Context information.
+ /// Culture information.
+ /// Object to convert.
+ /// Destination type.
+ /// Object converted to destination type.
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if ((destinationType == typeof(InstanceDescriptor)) && (value is BindingDef))
+ {
+ BindingDef info = (BindingDef)value;
+ Type[] constructorParams = null;
+ MemberInfo constructorMemberInfo = null;
+ object[] constructorValues = null;
+
+ constructorParams = new Type[] { typeof(string), typeof(string) };
+ constructorMemberInfo = typeof(BindingDef).GetConstructor(constructorParams);
+ constructorValues = new object[] { info.PropertyName, info.DataMember };
+
+ if (constructorMemberInfo != null)
+ {
+ return new InstanceDescriptor(constructorMemberInfo, constructorValues);
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleBar.bmp b/PROMS/DotNetBar Source Code/BubbleBar.bmp
new file mode 100644
index 00000000..e19d0ac5
Binary files /dev/null and b/PROMS/DotNetBar Source Code/BubbleBar.bmp differ
diff --git a/PROMS/DotNetBar Source Code/BubbleBar.cs b/PROMS/DotNetBar Source Code/BubbleBar.cs
new file mode 100644
index 00000000..8e9376af
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleBar.cs
@@ -0,0 +1,2088 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using DevComponents.UI.ContentManager;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the toolbar control with the magnifying (bubbling) buttons.
+ ///
+ [ToolboxItem(true), DefaultEvent("ButtonClick"), System.Runtime.InteropServices.ComVisible(false), Designer("DevComponents.DotNetBar.Design.BubbleBarDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class BubbleBar : Control, ISupportInitialize, IMessageHandlerClient
+ {
+ #region Private Variables
+ const float _falloffFactor = .3f;
+
+ private System.Windows.Forms.ImageList m_Images;
+ private System.Windows.Forms.ImageList m_ImagesLarge = null;
+ private bool m_ShowTooltips = true;
+ private eOrientation m_Orientation = eOrientation.Horizontal;
+ private System.Drawing.Size m_ImageSizeLarge = new System.Drawing.Size(48, 48);
+ private System.Drawing.Size m_ImageSizeNormal = new System.Drawing.Size(24, 24);
+ private BubbleContentManager m_ContentManager = new BubbleContentManager();
+ private BubbleButtonLayoutManager m_ButtonLayoutManager = new BubbleButtonLayoutManager();
+ private BubbleButton m_MouseOverButton = null;
+ private BubbleButton m_MouseDownButton = null;
+ private int m_AnimationTime = 100;
+ private BubbleButtonDisplayInfo m_BubbleButtonDisplayInfo = new BubbleButtonDisplayInfo();
+ private bool m_AntiAlias = true;
+ private BubbleBarOverlay m_Overlay = null;
+ private bool m_Animation = false;
+ private bool m_AnimationEnabled = true;
+ private bool m_IgnoreMouseMove = false;
+ private bool m_EnableOverlay = true;
+ private eBubbleButtonAlignment m_ButtonAlignment = eBubbleButtonAlignment.Bottom;
+ private int m_ButtonMargin = 6;
+ private Font m_TooltipFont = null;
+ private int m_MagTooltipIncrease = 0;
+ private Rectangle m_ButtonBounds = Rectangle.Empty;
+ private BubbleBarTab m_SelectedTab = null;
+ private BubbleBarTab m_MouseOverTab = null;
+ private TabColors m_SelectedTabColors = new TabColors();
+ private TabColors m_MouseOverTabColors = new TabColors();
+ private BubbleBarTabCollection m_Tabs = null;
+ private bool m_TabsVisible = true;
+ private Rectangle m_TabsBounds = Rectangle.Empty;
+ private SimpleTabLayoutManager m_TabLayoutManager = null;
+ private SimpleTabDisplay m_TabDisplay = null;
+ private SerialContentLayoutManager m_TabContentManager = null;
+ private Point m_LastMouseOverPosition = Point.Empty;
+ private BubbleButton m_IgnoreButtonMouseMove = null;
+ private ElementStyle m_ButtonBackAreaStyle = new ElementStyle();
+ private ElementStyle m_BackgroundStyle = new ElementStyle();
+ private bool m_ButtonBackgroundStretch = true;
+ private bool m_FilterInstalled = false;
+ private bool m_HasShortcuts = false;
+ private Color m_TooltipTextColor = Color.White;
+ private Color m_TooltipOutlineColor = Color.Black;
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs when active tab is about to change.
+ ///
+ public event BubbleBarTabChangingEventHadler TabChanging;
+ ///
+ /// Occurs when any of the buttons is clicked. Sender object should be casted to BubbleButton to get the button that was actually clicked.
+ ///
+ public event ClickEventHandler ButtonClick;
+ ///
+ /// Occurs when mouse first enters the control and bubble effect is employed to provide feedback.
+ ///
+ public event EventHandler BubbleStart;
+ ///
+ /// Occurs when mouse leaves the control and bubble effect is ended.
+ ///
+ public event EventHandler BubbleEnd;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Creates new instance of the control.
+ ///
+ public BubbleBar()
+ {
+ if (!ColorFunctions.ColorsLoaded)
+ {
+ NativeFunctions.RefreshSettings();
+ NativeFunctions.OnDisplayChange();
+ ColorFunctions.LoadColors();
+ }
+
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
+ this.SetStyle(ControlStyles.ContainerControl, false);
+ this.SetStyle(ControlStyles.Selectable, false);
+
+ m_Tabs = new BubbleBarTabCollection(this);
+
+ m_ButtonBackAreaStyle.StyleChanged += new EventHandler(ElementStyleChanged);
+ m_BackgroundStyle.StyleChanged += new EventHandler(ElementStyleChanged);
+
+ m_ContentManager.BlockSpacing = 0;
+ m_ContentManager.ContentVerticalAlignment = eContentVerticalAlignment.Bottom;
+ m_ContentManager.BlockLineAlignment = eContentVerticalAlignment.Bottom;
+ m_ContentManager.ContentOrientation = eContentOrientation.Horizontal;
+
+ m_TabLayoutManager = new SimpleTabLayoutManager();
+ m_TabDisplay = new SimpleTabDisplay();
+ m_TabContentManager = new SerialContentLayoutManager();
+
+ //m_Buttons=new BubbleButtonCollection(this);
+ m_BubbleButtonDisplayInfo.BubbleBar = this;
+ // Make sure this is JIT-ed
+ m_Overlay = new BubbleBarOverlay(this);
+ m_Overlay = null;
+
+ if (!OSFeature.Feature.IsPresent(OSFeature.LayeredWindows))
+ m_EnableOverlay = false;
+
+ ApplyButtonAlignment();
+
+ // m_SelectedTabColors.BorderColor=Color.Black;
+ // m_MouseOverTabColors.BorderColor=SystemColors.Highlight;
+ }
+ #endregion
+
+ #region Public Properties
+ ///
+ /// Gets or sets the bubble button tooltip text color. Default value is White color.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates bubble button tooltip text color.")]
+ public Color TooltipTextColor
+ {
+ get { return m_TooltipTextColor; }
+ set { m_TooltipTextColor = value; }
+ }
+ ///
+ /// Indicates whether property should be serialized. Used by the Windows Forms design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTooltipTextColor()
+ {
+ return m_TooltipTextColor != Color.White;
+ }
+ ///
+ /// Resets the property to default value. Used by the Windows Forms design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTooltipTextColor()
+ {
+ TypeDescriptor.GetProperties(this)["TooltipTextColor"].SetValue(this, Color.White);
+ }
+
+ ///
+ /// Gets or sets the bubble button tooltip text outline color. Default value is Black color.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates bubble button tooltip text outline color.")]
+ public Color TooltipOutlineColor
+ {
+ get { return m_TooltipOutlineColor; }
+ set { m_TooltipOutlineColor = value; }
+ }
+ ///
+ /// Indicates whether property should be serialized. Used by the Windows Forms design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTooltipOutlineColor()
+ {
+ return m_TooltipOutlineColor != Color.Black;
+ }
+ ///
+ /// Resets the property to default value. Used by the Windows Forms design-time support.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTooltipOutlineColor()
+ {
+ TypeDescriptor.GetProperties(this)["TooltipOutlineColor"].SetValue(this, Color.Black);
+ }
+
+ ///
+ /// Gets or sets the spacing in pixels between buttons. Default value is 0.
+ ///
+ [Browsable(true), DefaultValue(0), Description("Indicates spacing in pixels between buttons."), Category("Appearance")]
+ public int ButtonSpacing
+ {
+ get { return m_ContentManager.BlockSpacing; }
+ set
+ {
+ m_ContentManager.BlockSpacing = value;
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+ ///
+ /// Gets or sets whether background for the buttons is stretched to consume complete width of the control. Default value is true.
+ ///
+ [Browsable(true), Category("Button Background"), Description("Indicates whether background for the buttons is stretched to consume complete width of the control."), DefaultValue(true)]
+ public bool ButtonBackgroundStretch
+ {
+ get { return m_ButtonBackgroundStretch; }
+ set
+ {
+ if (m_ButtonBackgroundStretch != value)
+ {
+ m_ButtonBackgroundStretch = value;
+ if (this.DesignMode)
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets the style for the background of the control.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Gets the style for the background of the control."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return m_BackgroundStyle; }
+ }
+
+ ///
+ /// Gets the style for the background of the buttons.
+ ///
+ [Browsable(true), Category("Button Background"), Description("Gets the style for the background of the buttons."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle ButtonBackAreaStyle
+ {
+ get { return m_ButtonBackAreaStyle; }
+ }
+
+ ///
+ /// Gets the bounds of the buttons back area.
+ ///
+ [Browsable(false)]
+ public Rectangle ButtonBackAreaBounds
+ {
+ get { return m_ButtonBounds; }
+ }
+
+ ///
+ /// Gets the bounds of the tabs area.
+ ///
+ [Browsable(false)]
+ public Rectangle TabAreaBounds
+ {
+ get { return m_TabsBounds; }
+ }
+
+ ///
+ /// Gets or sets the duration of animation that is performed when mouse enters a button for the first time or when mouse has left the control.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates duration of animatio."), DefaultValue(100)]
+ public int AnimationTime
+ {
+ get { return m_AnimationTime; }
+ set { m_AnimationTime = value; }
+ }
+
+ ///
+ /// Gets or sets whether bubble animation is enabled. Default value is true.
+ ///
+ [Browsable(false), Description("Indicates whether animation is enabled."), DefaultValue(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool AnimationEnabled
+ {
+ get { return m_AnimationEnabled; }
+ set
+ {
+ m_AnimationEnabled = value;
+ if (!m_AnimationEnabled)
+ OverlayInactive();
+ }
+ }
+
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting.
+ ///
+ [DefaultValue(false), Browsable(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting.")]
+ public bool AntiAlias
+ {
+ get { return m_AntiAlias; }
+ set
+ {
+ if (m_AntiAlias != value)
+ {
+ m_AntiAlias = value;
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets ImageList for images used on buttons. These images will be used as images for the buttons that are not magnified.
+ /// Use ImagesLarge to specify the magnified images for the coresponding images based on the index in this list.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Button Images"), Description("ImageList for images used on buttons.")]
+ public System.Windows.Forms.ImageList Images
+ {
+ get
+ {
+ return m_Images;
+ }
+ set
+ {
+ if (m_Images != null)
+ m_Images.Disposed -= new EventHandler(this.ImageListDisposed);
+ m_Images = value;
+ if (m_Images != null)
+ m_Images.Disposed += new EventHandler(this.ImageListDisposed);
+ }
+ }
+
+ ///
+ /// Gets or sets ImageList for large-sized images used on buttons when button is magnified.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Button Images"), Description("ImageList for large-sized images used on buttons when button is magnified.")]
+ public System.Windows.Forms.ImageList ImagesLarge
+ {
+ get
+ {
+ return m_ImagesLarge;
+ }
+ set
+ {
+ if (m_ImagesLarge != null)
+ m_ImagesLarge.Disposed -= new EventHandler(this.ImageListDisposed);
+ m_ImagesLarge = value;
+ if (m_ImagesLarge != null)
+ m_ImagesLarge.Disposed += new EventHandler(this.ImageListDisposed);
+ }
+ }
+
+ ///
+ /// Gets or sets whether tooltips are displayed for the buttons.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(true), Description("Indicates whether tooltips are displayed for the buttons.")]
+ public bool ShowTooltips
+ {
+ get { return m_ShowTooltips; }
+ set { m_ShowTooltips = value; }
+ }
+
+ ///
+ /// Gets or sets size of the images when button is enlarged, default value is 48 by 48 pixels. Note that you should provide the
+ /// images in the same size for the buttons through the image properties on the buttons or through ImagesLarge property.
+ /// If the large images are not provided the regular button image will be automatically enlarged.
+ ///
+ [Browsable(true), Category("Button Images"), Description("Indicates size of the images when button is enlarged.")]
+ public System.Drawing.Size ImageSizeLarge
+ {
+ get { return m_ImageSizeLarge; }
+ set
+ {
+ if (m_ImageSizeLarge != value)
+ {
+ m_ImageSizeLarge = value;
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Returns whether property should be serialized by Windows Forms designer.
+ ///
+ /// True if property is different than default value otherwise false.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeImageSizeLarge()
+ {
+ if (m_ImageSizeLarge.Width != 48 || m_ImageSizeLarge.Height != 48)
+ return true;
+ return false;
+ }
+
+ ///
+ /// Gets or sets the normal image size for the buttons, default value is 24 by 24 pixels. This should be set to the default image size that you will use on the
+ /// buttons. If the images specified for the buttons are not of the same size as the size specified here then they will
+ /// be automatically resized. Normal size must always be smaller than the size specified by ImageSizeLarge property.
+ ///
+ [Browsable(true), Category("Button Images"), Description("Indicates size of the images when button is enlarged.")]
+ public System.Drawing.Size ImageSizeNormal
+ {
+ get { return m_ImageSizeNormal; }
+ set
+ {
+ if (m_ImageSizeNormal != value)
+ {
+ m_ImageSizeNormal = value;
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Returns whether property should be serialized by Windows Forms designer.
+ ///
+ /// True if property is different than default value otherwise false.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeImageSizeNormal()
+ {
+ if (m_ImageSizeLarge.Width != 24 || m_ImageSizeLarge.Height != 24)
+ return true;
+ return false;
+ }
+
+ ///
+ /// Gets or sets the font that is used to display tooltips.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(null)]
+ public Font TooltipFont
+ {
+ get { return m_TooltipFont; }
+ set { m_TooltipFont = value; }
+ }
+
+ ///
+ /// Gets or sets the selected tab.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public BubbleBarTab SelectedTab
+ {
+ get { return m_SelectedTab; }
+ set
+ {
+ if (m_SelectedTab != value)
+ {
+ m_SelectedTab = value;
+ OnSelectedTabChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets the reference to the colors that are used when tab is selected.
+ ///
+ [Browsable(true), Category("Tabs"), Description("Gets the reference to the colors that are used when tab is selected."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public TabColors SelectedTabColors
+ {
+ get { return m_SelectedTabColors; }
+ }
+
+ ///
+ /// Gets the reference to the colors that are used when mouse is over the tab.
+ ///
+ [Browsable(true), Category("Tabs"), Description("Gets the reference to the colors that are used when mouse is over the tab."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public TabColors MouseOverTabColors
+ {
+ get { return m_MouseOverTabColors; }
+ }
+
+ ///
+ /// Gets the collection of all tabs.
+ ///
+ [Editor("DevComponents.DotNetBar.Design.BubbleBarTabCollectionEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), System.ComponentModel.Category("Tabs"), Description("Returns the collection of Tabs.")]
+ public BubbleBarTabCollection Tabs
+ {
+ get { return m_Tabs; }
+ }
+
+ ///
+ /// Gets or sets the button alignment.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates button alignment.")]
+ public eBubbleButtonAlignment Alignment
+ {
+ get
+ {
+ return m_ButtonAlignment;
+ }
+ set
+ {
+ if (m_ButtonAlignment != value)
+ {
+ m_ButtonAlignment = value;
+ ApplyButtonAlignment();
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether tabs are visible. Default value is true.
+ ///
+ [Browsable(true), Category("Tabs"), Description("Indicates whether tabs are visible."), DefaultValue(true)]
+ public bool TabsVisible
+ {
+ get { return m_TabsVisible; }
+ set
+ {
+ if (m_TabsVisible != value)
+ {
+ m_TabsVisible = value;
+ this.LayoutButtons();
+ this.RepaintAll();
+ }
+ }
+ }
+
+ #endregion
+
+ #region Public Methods
+
+ ///
+ /// Recalculates the layout of the control. This method should be called after all changes to the tabs, buttons are completed so
+ /// layout of the control recalculated.
+ ///
+ public void RecalcLayout()
+ {
+ this.StopBubbleEffect();
+ this.LayoutButtons();
+ this.Invalidate();
+ OnItemLayoutUpdated(EventArgs.Empty);
+ }
+
+ ///
+ /// Occurs after internal item layout has been updated and items have valid bounds assigned.
+ ///
+ public event EventHandler ItemLayoutUpdated;
+ ///
+ /// Raises ItemLayoutUpdated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnItemLayoutUpdated(EventArgs e)
+ {
+ EventHandler handler = ItemLayoutUpdated;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Returns reference to the button at specified location
+ ///
+ /// x - coordinate
+ /// y - coordinate
+ /// Reference to the button or null if no button could be found at given coordinates.
+ public BubbleButton GetButtonAt(int x, int y)
+ {
+ if (m_SelectedTab == null)
+ return null;
+ BubbleButton ret = null;
+ foreach (BubbleButton button in m_SelectedTab.Buttons)
+ {
+ if (!button.Visible) continue;
+ if (m_MouseOverButton != null)
+ {
+ Rectangle r = button.MagnifiedDisplayRectangle;
+ if (r.Contains(x, y))
+ {
+ ret = button;
+ break;
+ }
+ }
+ else
+ {
+ Rectangle r = button.DisplayRectangle;
+ if (r.Contains(x, y))
+ {
+ ret = button;
+ break;
+ }
+ }
+ }
+ return ret;
+ }
+
+ ///
+ /// Returns reference to the button at specified location
+ ///
+ /// Location coordinates
+ /// Reference to the button or null if no button could be found at given coordinates.
+ public BubbleButton GetButtonAt(Point p)
+ {
+ return GetButtonAt(p.X, p.Y);
+ }
+
+ ///
+ /// Returns tab at specific location.
+ ///
+ /// Coordinates to get the tab from.
+ /// Reference to the tab object or null if tab cannot be found at specified location
+ public BubbleBarTab GetTabAt(Point p)
+ {
+ return GetTabAt(p.X, p.Y);
+ }
+
+ ///
+ /// Returns tab at specific location.
+ ///
+ /// x - coordinate
+ /// y - coordinate
+ /// Reference to the tab object or null if tab cannot be found at specified location
+ public BubbleBarTab GetTabAt(int x, int y)
+ {
+ foreach (BubbleBarTab tab in m_Tabs)
+ {
+ if (tab.DisplayRectangle.Contains(x, y))
+ return tab;
+ }
+ return null;
+ }
+
+ #endregion
+
+ #region Internal Implementation
+
+ protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
+ {
+ if (Dpi.RecordScalePerControl)
+ Dpi.SetScaling(factor);
+ base.ScaleControl(factor, specified);
+ }
+
+ protected override void OnCursorChanged(EventArgs e)
+ {
+ if (m_Overlay != null)
+ m_Overlay.Cursor = this.Cursor;
+ base.OnCursorChanged(e);
+ }
+ ///
+ /// Invokes BubbleStart event.
+ ///
+ protected virtual void OnBubbleStart(EventArgs e)
+ {
+ if (BubbleStart != null)
+ BubbleStart(this, e);
+ }
+
+ ///
+ /// Invokes BubbleEnd event.
+ ///
+ protected virtual void OnBubbleEnd(EventArgs e)
+ {
+ if (BubbleEnd != null)
+ BubbleEnd(this, e);
+ }
+ ///
+ /// Invokes ButtonClick event on the control.
+ ///
+ /// Reference to the button that was clicked.
+ internal void InvokeButtonClick(BubbleButton button, ClickEventArgs e)
+ {
+ if (ButtonClick != null)
+ ButtonClick(button, e);
+ }
+ protected override bool ProcessMnemonic(char charCode)
+ {
+ string s = "&" + charCode.ToString();
+ s = s.ToLower();
+ foreach (BubbleBarTab tab in this.Tabs)
+ {
+ string text = tab.Text.ToLower();
+ if (text.IndexOf(s) >= 0)
+ {
+ this.SelectedTab = tab;
+ return true;
+ }
+ }
+ return base.ProcessMnemonic(charCode);
+ }
+
+ protected override void OnSystemColorsChanged(EventArgs e)
+ {
+ base.OnSystemColorsChanged(e);
+ Application.DoEvents();
+ if (m_ButtonBackAreaStyle.GetColorScheme() != null)
+ m_ButtonBackAreaStyle.GetColorScheme().Refresh();
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+
+ if (this.Width == 0 || this.Height == 0)
+ return;
+
+ this.RecalcLayout();
+ this.Refresh();
+ }
+
+ private void RepaintAll()
+ {
+ if (m_Overlay != null)
+ {
+ m_Overlay.UpdateWindow();
+ // m_Overlay.Parent.Invalidate(m_Overlay.Bounds,true);
+ // m_Overlay.Parent.Update();
+ // m_Overlay.Update();
+ //m_Overlay.Refresh();
+ this.Refresh();
+ }
+ else
+ this.Refresh();
+ }
+
+ private void ElementStyleChanged(object sender, EventArgs e)
+ {
+ if (this.DesignMode)
+ {
+ this.LayoutButtons();
+ this.Refresh();
+ }
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ PaintBackground(e);
+ PaintControl(e);
+ }
+
+ protected virtual void PaintControl(PaintEventArgs e)
+ {
+ ElementStyleDisplayInfo info = new ElementStyleDisplayInfo();
+ info.Bounds = this.DisplayRectangle;
+ info.Graphics = e.Graphics;
+ info.Style = m_BackgroundStyle;
+ ElementStyleDisplay.Paint(info);
+
+ if (!m_ButtonBounds.IsEmpty && this.Tabs.Count > 0)
+ {
+ Rectangle r = GetButtonsBackground();
+ info.Bounds = r;
+ info.Graphics = e.Graphics;
+ info.Style = m_ButtonBackAreaStyle;
+ ElementStyleDisplay.Paint(info);
+ }
+
+ SmoothingMode sm = e.Graphics.SmoothingMode;
+ TextRenderingHint th = e.Graphics.TextRenderingHint;
+
+ if (m_AntiAlias)
+ {
+ e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ e.Graphics.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ if (!m_TabsBounds.IsEmpty)
+ {
+ Rectangle r = GetTabBounds();
+ e.Graphics.SetClip(r);
+ ISimpleTab[] tabs = new ISimpleTab[m_Tabs.Count];
+ m_Tabs.CopyTo(tabs);
+ m_TabDisplay.Paint(e.Graphics, tabs);
+ e.Graphics.ResetClip();
+ }
+
+ if (m_Overlay == null)
+ {
+ BubbleButtonDisplayInfo displayInfo = GetBubbleButtonDisplayInfo();
+ displayInfo.Graphics = e.Graphics;
+
+ if (m_SelectedTab != null)
+ {
+ foreach (BubbleButton button in m_SelectedTab.Buttons)
+ {
+ displayInfo.Button = button;
+ BubbleButtonDisplay.Paint(displayInfo);
+ }
+ }
+ }
+
+ if (this.DesignMode && this.Tabs.Count == 0)
+ {
+ Rectangle r = this.DisplayRectangle;
+ eTextFormat format = eTextFormat.Default | eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter |
+ eTextFormat.EndEllipsis | eTextFormat.WordBreak;
+ string INFO_TEXT = "Right-click and choose Create Tab or Button to add new items.";
+ TextDrawing.DrawString(e.Graphics, INFO_TEXT, this.Font, SystemColors.ControlDarkDark, r, format);
+ }
+
+#if !TRIAL
+ if (NativeFunctions.keyValidated2 != 266)
+ TextDrawing.DrawString(e.Graphics, "Invalid License", this.Font, Color.FromArgb(128, Color.Red), this.ClientRectangle, eTextFormat.Bottom | eTextFormat.HorizontalCenter);
+#endif
+ e.Graphics.TextRenderingHint = th;
+ e.Graphics.SmoothingMode = sm;
+ }
+
+ protected virtual void PaintBackground(PaintEventArgs e)
+ {
+ if (this.BackColor.A < 255)
+ {
+ base.OnPaintBackground(e);
+ }
+
+ if (!this.BackColor.IsEmpty)
+ {
+ using (SolidBrush brush = new SolidBrush(this.BackColor))
+ e.Graphics.FillRectangle(brush, this.DisplayRectangle);
+ }
+ }
+
+ internal void OnPaintOverlay(PaintEventArgs e)
+ {
+ BubbleButtonDisplayInfo displayInfo = GetBubbleButtonDisplayInfo();
+ displayInfo.Graphics = e.Graphics;
+
+ if (m_SelectedTab != null)
+ {
+ foreach (BubbleButton button in m_SelectedTab.Buttons)
+ {
+ displayInfo.Button = button;
+ BubbleButtonDisplay.Paint(displayInfo);
+ }
+ }
+ }
+
+ private bool IsParentFormActive()
+ {
+ Form form = this.FindForm();
+ if (form != null && form.MdiParent == null && form.Parent is Control)
+ {
+ form = form.Parent.FindForm();
+ }
+
+ if (form != null)
+ {
+ return (Form.ActiveForm == form && form.MdiParent == null ||
+ form.MdiParent != null && form.MdiParent.ActiveMdiChild == form);
+ }
+
+ bool ret = false;
+ IntPtr foregroundWindow = NativeFunctions.GetForegroundWindow();
+ try
+ {
+ Control c = Control.FromHandle(foregroundWindow);
+ if (c != null)
+ ret = true;
+ }
+ catch
+ {
+ ret = false;
+ }
+ return ret;
+ }
+
+ private void CreateOverlay()
+ {
+ if (m_Overlay == null)
+ {
+ OnBubbleStart(new EventArgs());
+ }
+
+ if (m_Overlay != null || this.Parent == null || !m_EnableOverlay || this.DesignMode || !m_AnimationEnabled)
+ return;
+
+ Rectangle overlayBounds = this.GetOverlayBounds();
+ m_Overlay = new BubbleBarOverlay(this);
+ m_Overlay.Bounds = overlayBounds;
+ m_Overlay.Visible = false;
+
+ // Layout buttons for overlay
+ m_ContentManager.MouseOverIndex = -1;
+ this.LayoutButtons();
+ if (m_MouseOverButton != null)
+ m_ContentManager.MouseOverIndex = m_MouseOverButton.Parent.Buttons.IndexOf(m_MouseOverButton);
+
+ m_Overlay.CreateControl();
+ Point p = this.Parent.PointToScreen(m_Overlay.Location);
+ m_Overlay.BeforeShow();
+ int hwndInsertAfter = NativeFunctions.HWND_NOTOPMOST;
+ if (this.FindForm() != null && this.FindForm().TopMost)
+ hwndInsertAfter = NativeFunctions.HWND_TOPMOST;
+ NativeFunctions.SetWindowPos(m_Overlay.Handle, new IntPtr(hwndInsertAfter), p.X, p.Y, m_Overlay.Width, m_Overlay.Height, NativeFunctions.SWP_SHOWWINDOW | NativeFunctions.SWP_NOACTIVATE);
+ m_Overlay.Visible = true;
+ m_Overlay.UpdateWindow();
+ this.Refresh();
+ }
+
+ private Rectangle GetOverlayBounds()
+ {
+ Rectangle r = new Rectangle(this.Location, this.Size);
+ if (m_ButtonAlignment == eBubbleButtonAlignment.Top || m_ButtonAlignment == eBubbleButtonAlignment.Bottom)
+ {
+ Size imageSizeLarge = Dpi.ImageSize(m_ImageSizeLarge);
+ Size imageSizeNormal = Dpi.ImageSize(m_ImageSizeNormal);
+ int increase = (imageSizeLarge.Height - imageSizeNormal.Height);
+ if (this.ShowTooltips)
+ {
+ if (this.TooltipFont != null)
+ m_MagTooltipIncrease = this.TooltipFont.Height + 6;
+ else
+ m_MagTooltipIncrease = this.Font.Height + 6;
+
+ increase += m_MagTooltipIncrease;
+ }
+ r.Height += increase;
+ if (m_ButtonAlignment == eBubbleButtonAlignment.Bottom)
+ r.Y -= increase;
+ }
+ else
+ {
+
+ }
+ return r;
+ }
+
+ ///
+ /// Called after overlay window became inactive.
+ ///
+ internal void OverlayInactive()
+ {
+ SetMouseDown(null);
+ // Mouse Over destroys overlay window as well
+ SetMouseOver(null);
+ this.RepaintAll();
+ }
+
+ ///
+ /// Stops the bubble animation effect is one is applied currently.
+ ///
+ public void StopBubbleEffect()
+ {
+ SetMouseDown(null);
+ SetMouseOver(null);
+ }
+
+ private void DestroyOverlay()
+ {
+ if (m_Overlay == null)
+ return;
+
+ OnBubbleEnd(new EventArgs());
+
+ m_Overlay.Hide();
+ m_Overlay.AfterClose();
+ m_Overlay.Dispose();
+ m_Overlay = null;
+
+ // Layout buttons without overlay
+ m_ContentManager.MouseOverIndex = -1;
+ this.LayoutButtons();
+ if (m_MouseOverButton != null)
+ m_ContentManager.MouseOverIndex = m_MouseOverButton.Parent.Buttons.IndexOf(m_MouseOverButton);
+ this.Invalidate();
+ }
+
+ private BubbleButtonDisplayInfo GetBubbleButtonDisplayInfo()
+ {
+ m_BubbleButtonDisplayInfo.Magnified = (m_MouseOverButton != null) && m_AnimationEnabled;
+ m_BubbleButtonDisplayInfo.Alignment = m_ButtonAlignment;
+ return m_BubbleButtonDisplayInfo;
+ }
+
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ if (!IsParentFormActive())
+ return;
+ if (m_Overlay != null && m_MagTooltipIncrease > 0)
+ {
+ Point p = this.PointToScreen(new Point(e.X, e.Y));
+ p = m_Overlay.PointToClient(p);
+ MouseEventArgs em = new MouseEventArgs(e.Button, e.Clicks, p.X, p.Y, e.Delta);
+ MouseMoveMessage(em);
+ }
+ else
+ MouseMoveMessage(e);
+ }
+
+ ///
+ /// Internal processing of MouseMove event.
+ ///
+ /// Move move event arguments.
+ internal void MouseMoveMessage(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if (m_IgnoreMouseMove)
+ {
+ m_IgnoreMouseMove = false;
+ return;
+ }
+
+ bool bRefresh = false;
+
+ Point mousePosition = new Point(e.X, e.Y);
+ BubbleButton mouseOver = GetButtonAt(mousePosition.X, mousePosition.Y);
+ if (mouseOver != null && mouseOver == m_IgnoreButtonMouseMove)
+ return;
+ else if (mouseOver == null)
+ m_IgnoreButtonMouseMove = null;
+
+ if (mouseOver != null)
+ {
+ if (m_MouseOverButton == null)
+ {
+ CreateOverlay();
+ // Set to enable painting of magnified buttons...
+ m_MouseOverButton = mouseOver;
+ AnimateButton(mouseOver, mousePosition, true);
+ m_MouseOverButton = null;
+ }
+
+ if (m_AnimationEnabled)
+ {
+ BubbleFactors factors = this.GetBubbleFactors(mouseOver.DisplayRectangle, mousePosition);
+ m_ContentManager.Factor1 = factors.Factor1;
+ m_ContentManager.Factor2 = factors.Factor2;
+ m_ContentManager.Factor3 = factors.Factor3;
+ m_ContentManager.Factor4 = factors.Factor4;
+ Size imageSizeLarge = Dpi.ImageSize(m_ImageSizeLarge);
+ m_ContentManager.BubbleSize = imageSizeLarge;
+ m_ContentManager.MouseOverPosition = factors.x;
+ m_ContentManager.MouseOverIndex = mouseOver.Parent.Buttons.IndexOf(mouseOver);
+ this.LayoutButtons();
+ bRefresh = true;
+ m_LastMouseOverPosition = mousePosition;
+ }
+ }
+
+ if (m_MouseOverTab != null || m_TabsBounds.Contains(mousePosition))
+ {
+ BubbleBarTab tab = GetTabAt(mousePosition);
+ SetMouseOverTab(tab);
+ }
+
+ if (m_MouseOverButton != mouseOver)
+ {
+ SetMouseOver(mouseOver);
+ bRefresh |= true;
+ }
+
+ if (m_MouseOverButton != mouseOver && e.Button == MouseButtons.Left)
+ {
+ SetMouseDown(mouseOver);
+ bRefresh |= true;
+ }
+
+ // Make sure that cursor did not escape while animation was going on...
+ if (m_MouseOverButton != null)
+ {
+ Point p = Control.MousePosition;
+ if (m_Overlay != null)
+ p = m_Overlay.PointToClient(p);
+ else
+ p = this.PointToClient(p);
+ mouseOver = GetButtonAt(p.X, p.Y);
+ if (mouseOver != m_MouseOverButton)
+ {
+ SetMouseOver(mouseOver);
+ bRefresh |= true;
+ }
+ }
+
+ if (bRefresh)
+ this.RepaintAll();
+ }
+
+ private void SetMouseOver(BubbleButton mouseOver)
+ {
+ if (m_MouseOverButton != null)
+ {
+ m_MouseOverButton.SetMouseOver(false);
+ if (mouseOver == null && !m_LastMouseOverPosition.IsEmpty)
+ {
+ AnimateButton(m_MouseOverButton, m_LastMouseOverPosition, false);
+ m_LastMouseOverPosition = Point.Empty;
+ }
+ }
+
+ m_MouseOverButton = mouseOver;
+ if (m_MouseOverButton != null)
+ {
+ m_MouseOverButton.SetMouseOver(true);
+ CreateOverlay();
+ }
+ else
+ {
+ SetMouseDown(null);
+ DestroyOverlay();
+ }
+ if (m_MouseOverButton != null)
+ m_ContentManager.MouseOverIndex = m_MouseOverButton.Parent.Buttons.IndexOf(m_MouseOverButton);
+ else
+ m_ContentManager.MouseOverIndex = -1;
+ }
+
+ private void SetMouseDown(BubbleButton mouseDown)
+ {
+ if (m_MouseDownButton != null)
+ m_MouseDownButton.SetMouseDown(false);
+
+ if (mouseDown != null && !mouseDown.Enabled)
+ {
+ m_MouseDownButton = null;
+ return;
+ }
+
+ m_MouseDownButton = mouseDown;
+ if (m_MouseDownButton != null)
+ m_MouseDownButton.SetMouseDown(true);
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ StopMouseLeaveTimer();
+ base.OnMouseEnter(e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ MouseLeaveMessage(e);
+ base.OnMouseLeave(e);
+ }
+
+ ///
+ /// Internal processing for MouseLeave event.
+ ///
+ /// Event arguments
+ internal void MouseLeaveMessage(EventArgs e)
+ {
+ Point p = Point.Empty;
+ if (m_MouseOverButton != null && m_Overlay != null)
+ p = m_Overlay.PointToClient(Control.MousePosition);
+ else
+ p = this.PointToClient(Control.MousePosition);
+
+ bool bRepaint = false;
+ BubbleButton buttonAt = GetButtonAt(p.X, p.Y);
+
+ if (m_MouseDownButton != null && buttonAt == null)
+ {
+ SetMouseDown(null);
+ bRepaint = true;
+ }
+
+ SetMouseOverTab(null);
+
+ if (bRepaint)
+ this.RepaintAll();
+ StartMouseLeaveTimer();
+ m_IgnoreButtonMouseMove = null;
+ }
+
+ private Timer m_MouseLeaveTimer = null;
+ private void StartMouseLeaveTimer()
+ {
+ if (m_Overlay == null || m_MouseOverButton == null || m_MouseLeaveTimer != null) return;
+
+ m_MouseLeaveTimer = new Timer();
+ m_MouseLeaveTimer.Interval = 500;
+ m_MouseLeaveTimer.Tick += new EventHandler(MouseLeaveTimerTick);
+ m_MouseLeaveTimer.Start();
+ }
+
+ private void MouseLeaveTimerTick(object sender, EventArgs e)
+ {
+ Point p = Point.Empty;
+ if (m_MouseOverButton != null && m_Overlay != null)
+ p = m_Overlay.PointToClient(Control.MousePosition);
+ else
+ p = this.PointToClient(Control.MousePosition);
+
+ bool bRepaint = false;
+ BubbleButton buttonAt = GetButtonAt(p.X, p.Y);
+
+ if (buttonAt == null)
+ {
+ StopBubbleEffect();
+ StopMouseLeaveTimer();
+ }
+ }
+
+ private void StopMouseLeaveTimer()
+ {
+ Timer t = m_MouseLeaveTimer;
+ m_MouseLeaveTimer = null;
+ if (t == null) return;
+ t.Stop();
+ t.Dispose();
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ MouseDownMessage(e);
+ base.OnMouseDown(e);
+ }
+
+ internal void OverlayMouseDownMessage(MouseEventArgs e)
+ {
+ OnMouseDown(e);
+ }
+
+ private void MouseDownMessage(MouseEventArgs e)
+ {
+ BubbleButton mouseOver = GetButtonAt(e.X, e.Y);
+ if (mouseOver != null)
+ {
+ SetMouseDown(mouseOver);
+ this.RepaintAll();
+ }
+ else if (m_TabsBounds.Contains(e.X, e.Y))
+ {
+ BubbleBarTab tab = GetTabAt(new Point(e.X, e.Y));
+ if (tab != null && tab != m_SelectedTab)
+ SetSelectedTab(tab, eEventSource.Mouse, true);
+ }
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ MouseUpMessage(e);
+ base.OnMouseUp(e);
+ }
+
+ internal void OverlayMouseUpMessage(MouseEventArgs e)
+ {
+ OnMouseUp(e);
+ }
+
+ private void MouseUpMessage(MouseEventArgs e)
+ {
+ if (m_MouseDownButton != null)
+ {
+ BubbleButton button = m_MouseDownButton;
+ Rectangle dispRect = button.DisplayRectangle;
+ Rectangle magRect = button.MagnifiedDisplayRectangle;
+ SetMouseDown(null);
+ SetMouseOver(null);
+ m_IgnoreMouseMove = true;
+ this.RepaintAll();
+ if (dispRect.Contains(e.X, e.Y) || magRect.Contains(e.X, e.Y))
+ button.InvokeClick(eEventSource.Mouse, e.Button);
+ m_IgnoreButtonMouseMove = button;
+ }
+ }
+
+ private void ImageListDisposed(object sender, EventArgs e)
+ {
+ if (sender == m_Images)
+ {
+ this.Images = null;
+ }
+ else if (sender == m_ImagesLarge)
+ {
+ this.ImagesLarge = null;
+ }
+ }
+
+ ///
+ /// Called after all buttons have been removed.
+ ///
+ /// Tab from which all buttons were removed.
+ internal void OnButtonsCollectionClear(BubbleBarTab tab)
+ {
+ StopBubbleEffect();
+ if (this.DesignMode)
+ {
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Called after specified button has been removed.
+ ///
+ /// Tab from which button was removed.
+ /// Button that was removed.
+ internal void OnButtonRemoved(BubbleBarTab tab, BubbleButton button)
+ {
+ StopBubbleEffect();
+ if (m_HasShortcuts && !this.IsDisposed)
+ RefreshHasShortcut();
+ if (this.DesignMode)
+ {
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+
+ internal void RefreshHasShortcut()
+ {
+ m_HasShortcuts = false;
+ foreach (BubbleBarTab t in this.Tabs)
+ {
+ foreach (BubbleButton b in t.Buttons)
+ {
+ if (b.Shortcut != eShortcut.None)
+ {
+ m_HasShortcuts = true;
+ break;
+ }
+ }
+ if (m_HasShortcuts)
+ break;
+ }
+ }
+
+ ///
+ /// Called after new button is added to the Buttons collection.
+ ///
+ /// Tab to which button was added.
+ /// Reference to the button added.
+ internal void OnButtonInserted(BubbleBarTab tab, BubbleButton button)
+ {
+ StopBubbleEffect();
+ LayoutButtons();
+ if (button.Shortcut != eShortcut.None)
+ {
+ m_HasShortcuts = true;
+ }
+ if (this.DesignMode)
+ {
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ base.OnHandleCreated(e);
+ this.RecalcLayout();
+ InstallIMessageHandlerClient();
+ }
+
+ protected override void OnHandleDestroyed(EventArgs e)
+ {
+ base.OnHandleDestroyed(e);
+ UninstallIMessageHandlerClient();
+ StopMouseLeaveTimer();
+ }
+
+ ///
+ /// Called when Visible property of Button has changed.
+ ///
+ /// Button affected.
+ internal void OnButtonVisibleChanged(BubbleButton button)
+ {
+ LayoutButtons();
+ }
+
+ private void LayoutButtons()
+ {
+ if (m_SelectedTab != null)
+ {
+ if (m_SelectedTab.Buttons.Count > 0)
+ {
+ IBlock[] buttons = new IBlock[m_SelectedTab.Buttons.Count];
+ m_SelectedTab.Buttons.CopyTo(buttons);
+ Rectangle r = m_ContentManager.Layout(GetButtonDisplayArea(), buttons, m_ButtonLayoutManager);
+ if (m_Overlay != null)
+ {
+ m_ButtonBounds.X = r.X;
+ m_ButtonBounds.Width = r.Width;
+ }
+ else
+ m_ButtonBounds = r;
+ }
+ else
+ {
+ m_ButtonBounds = GetButtonDisplayArea();
+ m_ButtonBounds.Inflate(-m_ButtonBounds.Width / 2, 0);
+ int b = m_ButtonBounds.Bottom;
+ Size imageSizeNormal = Dpi.ImageSize(m_ImageSizeNormal);
+ m_ButtonBounds.Height = imageSizeNormal.Height;
+ if (m_ButtonAlignment == eBubbleButtonAlignment.Bottom)
+ m_ButtonBounds.Y = b - m_ButtonBounds.Height;
+ }
+ }
+
+ LayoutTabs();
+ }
+
+ private void LayoutTabs()
+ {
+ if (!BarFunctions.IsHandleValid(this))
+ return;
+ // Layout tabs
+ if (m_TabsVisible && m_Tabs.Count > 0)
+ {
+ IBlock[] tabs = new IBlock[m_Tabs.Count];
+ m_Tabs.CopyTo(tabs);
+ Graphics g = null;
+ try
+ {
+ g = this.CreateGraphics();
+ m_TabLayoutManager.Graphics = g;
+ m_TabsBounds = m_TabContentManager.Layout(GetTabDisplayArea(), tabs, m_TabLayoutManager);
+ }
+ finally
+ {
+ m_TabLayoutManager.Graphics = null;
+ if (g != null)
+ g.Dispose();
+ }
+ }
+ else
+ m_TabsBounds = Rectangle.Empty;
+ }
+
+ private Rectangle GetButtonDisplayArea()
+ {
+ Rectangle r = this.DisplayRectangle;
+ if (m_Overlay != null)
+ r = m_Overlay.DisplayRectangle;
+ if (m_ButtonAlignment == eBubbleButtonAlignment.Bottom)
+ r.Height -= m_ButtonMargin;
+ else if (m_ButtonAlignment == eBubbleButtonAlignment.Top)
+ {
+ r.Height -= m_ButtonMargin;
+ r.Y += m_ButtonMargin;
+ }
+
+ return r;
+ }
+
+ ///
+ /// Returns the button background rectangle for display purposes. Applies setting for the ButtonBackgroundStretch property.
+ ///
+ /// Background rectangle.
+ private Rectangle GetButtonsBackground()
+ {
+ Rectangle r = m_ButtonBounds;
+ if (m_ButtonBackgroundStretch)
+ {
+ r.Width = this.Width;
+ r.X = 0;
+ }
+ else if (m_TabsBounds.Width + 16 > r.Width)
+ {
+ int diff = (m_TabsBounds.Width + 16) - r.Width;
+ r.Width += diff;
+ r.X -= diff / 2;
+ }
+
+ r.Height += (m_ButtonBackAreaStyle.PaddingTop + m_ButtonBackAreaStyle.PaddingBottom);
+ r.Y -= m_ButtonBackAreaStyle.PaddingTop;
+
+ if (!m_ButtonBackgroundStretch)
+ {
+ r.Width += (m_ButtonBackAreaStyle.PaddingLeft + m_ButtonBackAreaStyle.PaddingRight);
+ r.X -= m_ButtonBackAreaStyle.PaddingLeft;
+ }
+
+ return r;
+ }
+
+ private Rectangle GetTabDisplayArea()
+ {
+ Rectangle r;
+ Rectangle rButtonsBack = GetButtonsBackground();
+
+ if (m_ButtonAlignment == eBubbleButtonAlignment.Bottom)
+ {
+ r = new Rectangle(rButtonsBack.X, 0, rButtonsBack.Width, rButtonsBack.Y);
+ }
+ else
+ {
+ r = new Rectangle(rButtonsBack.X, rButtonsBack.Bottom, rButtonsBack.Width, this.Height - rButtonsBack.Bottom);
+ }
+ if (r.Height < 0)
+ r.Height = 0;
+
+ r.Width -= 16;
+ r.X += 8;
+ return r;
+ }
+
+ private Rectangle GetTabBounds()
+ {
+ Rectangle r = m_TabsBounds;
+ if (!r.IsEmpty)
+ {
+ r.Width += 16;
+ r.X -= 8;
+ }
+ return r;
+ }
+
+ private void AnimateButton(BubbleButton button, Point mousePosition, bool animateGrow)
+ {
+ if (m_AnimationTime <= 0 || m_Animation || m_SelectedTab == null || !m_AnimationEnabled)
+ return;
+
+ m_Animation = true;
+ try
+ {
+ m_ContentManager.MouseOverIndex = m_SelectedTab.Buttons.IndexOf(button);
+ bool animate = true;
+ Size imageSizeLarge = Dpi.ImageSize(m_ImageSizeLarge);
+ Size imageSizeNormal = Dpi.ImageSize(m_ImageSizeNormal);
+ int totalSteps = imageSizeLarge.Width - imageSizeNormal.Width;
+ int step = 1;
+ int current = imageSizeNormal.Width + step;
+ if (!animateGrow)
+ current = imageSizeLarge.Width - step;
+
+ Rectangle displayRectangle = GetButtonDisplayArea();
+
+ IBlock[] blocks = new IBlock[m_SelectedTab.Buttons.Count];
+ m_SelectedTab.Buttons.CopyTo(blocks);
+
+ DateTime start = DateTime.Now;
+ TimeSpan stepDuration = TimeSpan.MinValue;
+
+ while (animate)
+ {
+ DateTime stepStart = DateTime.Now;
+
+ float multi = (float)current / (float)imageSizeNormal.Width;
+ Size bubbleSize = new Size((int)((float)imageSizeNormal.Width * multi), (int)((float)imageSizeNormal.Height * multi));
+ BubbleFactors factors = this.GetBubbleFactors(button.DisplayRectangle, mousePosition, bubbleSize);
+ m_ContentManager.Factor1 = factors.Factor1;
+ m_ContentManager.Factor2 = factors.Factor2;
+ m_ContentManager.Factor3 = factors.Factor3;
+ m_ContentManager.Factor4 = factors.Factor4;
+ m_ContentManager.BubbleSize = bubbleSize;
+ m_ContentManager.MouseOverPosition = factors.x;
+ m_ContentManager.Layout(displayRectangle, blocks, m_ButtonLayoutManager);
+ this.RepaintAll();
+
+ stepDuration = DateTime.Now.Subtract(stepStart);
+ step = (int)((float)totalSteps * ((float)stepDuration.TotalMilliseconds / (float)m_AnimationTime));
+ if (step <= 0)
+ {
+ int diff = (int)(m_AnimationTime / Math.Max((float)stepDuration.TotalMilliseconds, (float)1) / totalSteps);
+ if (diff <= 0)
+ diff = (int)stepDuration.TotalMilliseconds;
+ try
+ {
+ using (
+ System.Threading.ManualResetEvent wait =
+ new System.Threading.ManualResetEvent(false))
+ wait.WaitOne(diff);
+ //System.Threading.Thread.Sleep(diff);
+ }
+ catch
+ {
+ break;
+ }
+ step = 1;
+ }
+ if (animateGrow)
+ current += step;
+ else
+ current -= step;
+ totalSteps -= step;
+ if (totalSteps <= 0 || DateTime.Now.Subtract(start).TotalMilliseconds >= m_AnimationTime)
+ break;
+ }
+ }
+ finally
+ {
+ m_Animation = false;
+ }
+ }
+
+ private BubbleFactors GetBubbleFactors(Rectangle buttonMouseOver, Point mousePosition)
+ {
+ return GetBubbleFactors(buttonMouseOver, mousePosition, Dpi.ImageSize(m_ImageSizeLarge));
+ }
+
+ private BubbleFactors GetBubbleFactors(Rectangle buttonMouseOver, Point mousePosition, Size finalSize)
+ {
+ BubbleFactors factors = new BubbleFactors();
+
+ float pp = 0;
+ int xa = 0, ya = 0;
+ int xDiff = Math.Max(mousePosition.X - buttonMouseOver.X, 0);
+ xDiff = Math.Min(xDiff, buttonMouseOver.Width);
+ int yDiff = Math.Max(mousePosition.Y - buttonMouseOver.Y, 0);
+ yDiff = Math.Min(yDiff, buttonMouseOver.Height);
+
+ if (m_Orientation == eOrientation.Horizontal)
+ {
+ pp = (float)(xDiff) / (float)buttonMouseOver.Width;
+ xa = mousePosition.X - (int)(pp * (float)finalSize.Width);
+ }
+ else
+ {
+ pp = (float)(yDiff) / (float)buttonMouseOver.Height;
+ ya = mousePosition.Y - (int)(pp * (float)finalSize.Height);
+ }
+
+ factors.x = xa;
+ factors.y = ya;
+
+ factors.Factor1 = (1 - pp) * _falloffFactor;
+ factors.Factor2 = Math.Max(1 - pp, _falloffFactor);
+ factors.Factor3 = Math.Max(pp, _falloffFactor);
+ factors.Factor4 = pp * _falloffFactor;
+
+ return factors;
+ }
+
+ private class BubbleFactors
+ {
+ public int x = 0;
+ public int y = 0;
+ public float Factor1 = 0;
+ public float Factor2 = 0;
+ public float Factor3 = 0;
+ public float Factor4 = 0;
+ }
+
+ private void ApplyButtonAlignment()
+ {
+ m_TabContentManager.BlockSpacing = 8;
+
+ if (m_ButtonAlignment == eBubbleButtonAlignment.Bottom)
+ {
+ m_ContentManager.ContentAlignment = eContentAlignment.Center;
+ m_ContentManager.ContentVerticalAlignment = eContentVerticalAlignment.Bottom;
+ m_ContentManager.BlockLineAlignment = eContentVerticalAlignment.Bottom;
+ m_ContentManager.ContentOrientation = eContentOrientation.Horizontal;
+
+ m_TabContentManager.ContentAlignment = eContentAlignment.Center;
+ m_TabContentManager.ContentVerticalAlignment = eContentVerticalAlignment.Bottom;
+ m_TabContentManager.BlockLineAlignment = eContentVerticalAlignment.Bottom;
+ m_TabContentManager.ContentOrientation = eContentOrientation.Horizontal;
+ }
+ else if (m_ButtonAlignment == eBubbleButtonAlignment.Top)
+ {
+ m_ContentManager.ContentAlignment = eContentAlignment.Center;
+ m_ContentManager.ContentVerticalAlignment = eContentVerticalAlignment.Top;
+ m_ContentManager.BlockLineAlignment = eContentVerticalAlignment.Top;
+ m_ContentManager.ContentOrientation = eContentOrientation.Horizontal;
+
+ m_TabContentManager.ContentAlignment = eContentAlignment.Center;
+ m_TabContentManager.ContentVerticalAlignment = eContentVerticalAlignment.Top;
+ m_TabContentManager.BlockLineAlignment = eContentVerticalAlignment.Top;
+ m_TabContentManager.ContentOrientation = eContentOrientation.Horizontal;
+ }
+ // else if(m_ButtonAlignment==eBubbleButtonAlignment.Left)
+ // {
+ // m_ContentManager.ContentAlignment=eContentAlignment.Center;
+ // m_ContentManager.ContentVerticalAlignment=eContentVerticalAlignment.Bottom;
+ // m_ContentManager.ContentOrientation=eContentOrientation.Horizontal;
+ // }
+ }
+ #endregion
+
+ #region Tabs Support
+ ///
+ /// Called after tab has been removed from the collection.
+ ///
+ /// Tab that was removed.
+ internal void OnTabRemoved(BubbleBarTab tab)
+ {
+ if (m_SelectedTab == tab)
+ {
+ SelectNextVisible(tab, eEventSource.Code, false);
+ }
+ if (this.DesignMode)
+ {
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Called after tab has been added to the collection.
+ ///
+ /// Newly added tab.
+ internal void OnTabAdded(BubbleBarTab tab)
+ {
+ if (m_SelectedTab == null)
+ m_SelectedTab = tab;
+ this.LayoutButtons();
+ if (this.DesignMode)
+ {
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Called after all tabs are removed from the collection.
+ ///
+ internal void OnTabsCleared()
+ {
+ m_SelectedTab = null;
+ this.LayoutButtons();
+ if (this.DesignMode)
+ {
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Called after text of a tab has changed.
+ ///
+ /// Tab which text has changed.
+ internal void OnTabTextChanged(BubbleBarTab tab)
+ {
+ this.RecalcLayout();
+ this.Refresh();
+ }
+
+ ///
+ /// Called after Visible property of the tab has changed.
+ ///
+ /// Tab affected.
+ internal void OnTabVisibleChanged(BubbleBarTab tab)
+ {
+ if (m_SelectedTab == tab)
+ {
+ SelectNextVisible(tab, eEventSource.Code, false);
+ }
+ this.LayoutButtons();
+ this.Refresh();
+ }
+
+ private void OnSelectedTabChanged()
+ {
+ StopBubbleEffect();
+ m_IgnoreButtonMouseMove = null;
+ LayoutButtons();
+ this.Refresh();
+ }
+
+ internal BubbleBarTab GetMouseOverTab()
+ {
+ return m_MouseOverTab;
+ }
+
+ private void SelectNextVisible(BubbleBarTab reference, eEventSource source, bool bCanCancel)
+ {
+ BubbleBarTab sel = m_Tabs.GetNextVisibleTab(reference);
+ if (sel == null)
+ sel = m_Tabs.GetPreviousVisibleTab(reference);
+ SetSelectedTab(sel, source, bCanCancel);
+ }
+
+ private void SetSelectedTab(BubbleBarTab tab, eEventSource source, bool bCanCancel)
+ {
+ if (TabChanging != null)
+ {
+ BubbleBarTabChangingEventArgs e = new BubbleBarTabChangingEventArgs();
+ e.CurrentTab = m_SelectedTab;
+ e.NewTab = tab;
+ e.Source = source;
+ TabChanging(this, e);
+ if (e.Cancel && bCanCancel) return;
+ }
+ m_SelectedTab = tab;
+ m_IgnoreButtonMouseMove = null;
+ this.LayoutButtons();
+ this.RepaintAll();
+ }
+
+ ///
+ /// Sets the tab mouse is placed over.
+ ///
+ /// Tab that mouse is currently over or null if mouse is not over any tab.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetMouseOverTab(BubbleBarTab tab)
+ {
+ if (m_MouseOverTab == tab)
+ return;
+
+ m_MouseOverTab = tab;
+
+ this.Invalidate(GetTabBounds());
+ this.Update();
+ }
+ #endregion
+
+ #region Drag & Drop support
+ private BubbleBarTab m_DragTab = null;
+ private int m_DragTabOriginalIndex = -1;
+ private int m_DragButtonOriginalIndex = -1;
+ private BubbleButton m_DragButton = null;
+ private bool m_DragInProgress = false;
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool DragInProgress
+ {
+ get { return m_DragInProgress; }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void StartDrag(BubbleBarTab tab)
+ {
+ if (m_DragInProgress)
+ return;
+
+ m_DragInProgress = true;
+ m_DragTab = tab;
+ Cursor.Current = Cursors.Hand;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void StartDrag(BubbleButton button)
+ {
+ if (m_DragInProgress)
+ return;
+
+ m_DragInProgress = true;
+ m_DragButton = button;
+ Cursor.Current = Cursors.Hand;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DragMouseMove(Point mousePosition)
+ {
+ if (m_DragTab != null)
+ {
+ BubbleBarTab tab = GetTabAt(mousePosition);
+ if (tab != null && tab != m_DragTab)
+ {
+ if (m_DragTabOriginalIndex == -1)
+ m_DragTabOriginalIndex = this.Tabs.IndexOf(m_DragTab);
+ int insertPos = this.Tabs.IndexOf(tab);
+ this.Tabs.Remove(m_DragTab);
+ this.Tabs.Insert(insertPos, m_DragTab);
+ this.SelectedTab = m_DragTab;
+ }
+ }
+ else if (m_DragButton != null)
+ {
+ BubbleBarTab tab = GetTabAt(mousePosition);
+ if (tab != null && tab != m_DragButton.Parent)
+ {
+ // Move button to the tab and select that tab
+ if (m_DragTabOriginalIndex == -1)
+ m_DragTabOriginalIndex = this.Tabs.IndexOf(m_DragButton.Parent);
+ if (m_DragButtonOriginalIndex == -1)
+ m_DragButtonOriginalIndex = m_DragButton.Parent.Buttons.IndexOf(m_DragButton);
+ this.SelectedTab = tab;
+ BubbleButton b = GetButtonAt(mousePosition);
+ if (m_DragButton.Parent != null)
+ m_DragButton.Parent.Buttons.Remove(m_DragButton);
+ if (b != null)
+ tab.Buttons.Insert(tab.Buttons.IndexOf(b), m_DragButton);
+ else
+ tab.Buttons.Add(m_DragButton);
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ else
+ {
+ BubbleButton button = GetButtonAt(mousePosition);
+ if (button != null && button != m_DragButton)
+ {
+ if (m_DragTabOriginalIndex == -1)
+ m_DragTabOriginalIndex = this.Tabs.IndexOf(m_DragButton.Parent);
+ if (m_DragButtonOriginalIndex == -1)
+ m_DragButtonOriginalIndex = m_DragButton.Parent.Buttons.IndexOf(m_DragButton);
+ BubbleBarTab parent = m_DragButton.Parent;
+ int insertIndex = parent.Buttons.IndexOf(button);
+ parent.Buttons.Remove(m_DragButton);
+ parent.Buttons.Insert(insertIndex, m_DragButton);
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void DragMouseUp(Point mousePosition)
+ {
+ if (m_DragTab != null)
+ {
+ BubbleBarTab tab = GetTabAt(mousePosition);
+ if (tab != m_DragTab)
+ {
+ DragCancel();
+ }
+ else
+ {
+ m_DragTab = null;
+ m_DragTabOriginalIndex = -1;
+ }
+ }
+ else if (m_DragButton != null)
+ {
+ BubbleButton button = GetButtonAt(mousePosition);
+ if (button != m_DragButton)
+ DragCancel();
+ else
+ {
+ m_DragButton = null;
+ m_DragTabOriginalIndex = -1;
+ m_DragButtonOriginalIndex = -1;
+ }
+ }
+
+ m_DragInProgress = false;
+ }
+
+ internal void DragCancel()
+ {
+ if (!m_DragInProgress)
+ return;
+
+ if (m_DragTab != null)
+ {
+ if (m_DragTabOriginalIndex >= 0)
+ {
+ this.Tabs.Remove(m_DragTab);
+ this.Tabs.Insert(m_DragTabOriginalIndex, m_DragTab);
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ m_DragTab = null;
+ m_DragTabOriginalIndex = -1;
+ }
+ else if (m_DragButton != null)
+ {
+ if (m_DragButtonOriginalIndex >= 0)
+ {
+ if (m_DragButton.Parent != null)
+ m_DragButton.Parent.Buttons.Remove(m_DragButton);
+ if (m_DragTabOriginalIndex >= 0 && m_DragTabOriginalIndex != this.Tabs.IndexOf(m_DragButton.Parent))
+ {
+ this.Tabs[m_DragTabOriginalIndex].Buttons.Insert(m_DragButtonOriginalIndex, m_DragButton);
+ }
+ else
+ this.Tabs[m_DragTabOriginalIndex].Buttons.Insert(m_DragButtonOriginalIndex, m_DragButton);
+ m_DragButtonOriginalIndex = -1;
+ m_DragTabOriginalIndex = -1;
+ m_DragButton = null;
+ this.RecalcLayout();
+ this.Refresh();
+ }
+ }
+
+ m_DragInProgress = false;
+ }
+ #endregion
+
+ #region ISupportInitialize
+ void ISupportInitialize.BeginInit()
+ {
+ }
+ void ISupportInitialize.EndInit()
+ {
+ //this.RecalcLayout();
+ }
+ #endregion
+
+ #region IMessageHandlerClient Implementation
+
+ bool IMessageHandlerClient.IsModal
+ {
+ get
+ {
+ Form form = this.FindForm();
+ if (form != null)
+ return form.Modal;
+ return false;
+ }
+ }
+ bool IMessageHandlerClient.OnMouseWheel(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+ bool IMessageHandlerClient.OnKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ // Check Shortcuts
+ int wParamInt = WinApi.ToInt(wParam);
+ if (System.Windows.Forms.Control.ModifierKeys != Keys.None || wParamInt >= (int)eShortcut.F1 && wParamInt <= (int)eShortcut.F12)
+ {
+ int i = (int)System.Windows.Forms.Control.ModifierKeys | wParamInt;
+ if (ProcessShortcut((eShortcut)i))
+ return true;
+ }
+ return false;
+ }
+ private bool ProcessShortcut(eShortcut key)
+ {
+ Form form = this.FindForm();
+ if (form == null || (form != Form.ActiveForm && form.MdiParent == null ||
+ form.MdiParent != null && form.MdiParent.ActiveMdiChild != form) && !form.IsMdiContainer || Form.ActiveForm != null && Form.ActiveForm.Modal && Form.ActiveForm != form)
+ return false;
+
+ if (m_HasShortcuts)
+ {
+ foreach (BubbleBarTab t in this.Tabs)
+ {
+ foreach (BubbleButton b in t.Buttons)
+ {
+ if (b.Shortcut == key && b.Enabled)
+ {
+ b.InvokeClick(eEventSource.Keyboard, MouseButtons.None);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+ bool IMessageHandlerClient.OnMouseDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+ bool IMessageHandlerClient.OnMouseMove(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+ bool IMessageHandlerClient.OnSysKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ if (!this.DesignMode)
+ {
+ // Check Shortcuts
+ int wParamInt = WinApi.ToInt(wParam);
+ if (System.Windows.Forms.Control.ModifierKeys != Keys.None || wParamInt >= (int)eShortcut.F1 && wParamInt <= (int)eShortcut.F12)
+ {
+ int i = (int)System.Windows.Forms.Control.ModifierKeys | wParamInt;
+ if (ProcessShortcut((eShortcut)i))
+ return true;
+ }
+ }
+ return false;
+ }
+ bool IMessageHandlerClient.OnSysKeyUp(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+ private void InstallIMessageHandlerClient()
+ {
+ if (!m_FilterInstalled && !this.DesignMode)
+ {
+ MessageHandler.RegisterMessageClient(this);
+ m_FilterInstalled = true;
+ }
+ }
+ private void UninstallIMessageHandlerClient()
+ {
+ if (m_FilterInstalled)
+ {
+ MessageHandler.UnregisterMessageClient(this);
+ m_FilterInstalled = false;
+ }
+ }
+ #endregion
+
+ #region Licensing
+#if !TRIAL
+ private string m_LicenseKey = "";
+ [Browsable(false), DefaultValue("")]
+ public string LicenseKey
+ {
+ get { return m_LicenseKey; }
+ set
+ {
+ if (NativeFunctions.ValidateLicenseKey(value))
+ return;
+ m_LicenseKey = (!NativeFunctions.CheckLicenseKey(value) ? "9dsjkhds7" : value);
+ }
+ }
+#endif
+ #endregion
+
+ }
+
+ #region Event handlers declaration
+ ///
+ /// Delegate for tab change events.
+ ///
+ public delegate void BubbleBarTabChangingEventHadler(object sender, BubbleBarTabChangingEventArgs e);
+ #endregion
+
+ #region Event Arguments
+ ///
+ /// Represents the event arguments tab changing events.
+ ///
+ public class BubbleBarTabChangingEventArgs : EventArgs
+ {
+ ///
+ /// Cancels the operation.
+ ///
+ public bool Cancel = false;
+ ///
+ /// Specifies the event source.
+ ///
+ public eEventSource Source = eEventSource.Code;
+ ///
+ /// Specifies newly selected tab.
+ ///
+ public BubbleBarTab NewTab = null;
+ ///
+ /// Specifies currently selected tab.
+ ///
+ public BubbleBarTab CurrentTab = null;
+ ///
+ /// Default Constructor.
+ ///
+ public BubbleBarTabChangingEventArgs() { }
+ }
+
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleBarDesigner.cs b/PROMS/DotNetBar Source Code/BubbleBarDesigner.cs
new file mode 100644
index 00000000..e2d750b9
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleBarDesigner.cs
@@ -0,0 +1,625 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Reflection;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents Windows Forms designer for BubbleBar control.
+ ///
+ public class BubbleBarDesigner:System.Windows.Forms.Design.ControlDesigner
+ {
+ #region Private Variables
+ private bool m_IgnoreMouseUp=false;
+ private Point m_MouseDownPosition=Point.Empty;
+ private bool m_Capture=false;
+
+ #endregion
+
+
+ public BubbleBarDesigner()
+ {
+ }
+
+ public override void Initialize(IComponent component)
+ {
+ base.Initialize(component);
+ if(!component.Site.DesignMode)
+ return;
+
+ ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null)
+ ss.SelectionChanged+=new EventHandler(OnSelectionChanged);
+
+ // If our component is removed we need to clean-up
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ cc.ComponentRemoving+=new ComponentEventHandler(this.OnComponentRemoving);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null)
+ ss.SelectionChanged-=new EventHandler(OnSelectionChanged);
+
+ // If our component is removed we need to clean-up
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ cc.ComponentRemoving-=new ComponentEventHandler(this.OnComponentRemoving);
+
+ base.Dispose(disposing);
+ }
+
+ public override DesignerVerbCollection Verbs
+ {
+ get
+ {
+ DesignerVerb[] verbs = new DesignerVerb[]
+ {
+ new DesignerVerb("Create Tab", new EventHandler(CreateTab)),
+ new DesignerVerb("Create Button", new EventHandler(CreateButton))};
+ return new DesignerVerbCollection(verbs);
+ }
+ }
+
+#if FRAMEWORK20
+ public override void InitializeNewComponent(IDictionary defaultValues)
+ {
+ base.InitializeNewComponent(defaultValues);
+ SetDesignTimeDefaults();
+ }
+#else
+ public override void OnSetComponentDefaults()
+ {
+ base.OnSetComponentDefaults();
+ SetDesignTimeDefaults();
+ }
+#endif
+
+ private void SetDesignTimeDefaults()
+ {
+ BubbleBar bar = this.Component as BubbleBar;
+ if (bar == null)
+ return;
+ // Setup default back style
+ bar.ButtonBackAreaStyle.SetColorScheme(new ColorScheme(eDotNetBarStyle.Office2003));
+ bar.ButtonBackAreaStyle.BackColor = Color.FromArgb(66, Color.DimGray);
+ bar.ButtonBackAreaStyle.BorderColor = Color.FromArgb(180, Color.WhiteSmoke);
+ bar.ButtonBackAreaStyle.BorderTop = eStyleBorderType.Solid;
+ bar.ButtonBackAreaStyle.BorderTopWidth = 1;
+ bar.ButtonBackAreaStyle.BorderBottom = eStyleBorderType.Solid;
+ bar.ButtonBackAreaStyle.BorderBottomWidth = 1;
+ bar.ButtonBackAreaStyle.BorderLeft = eStyleBorderType.Solid;
+ bar.ButtonBackAreaStyle.BorderLeftWidth = 1;
+ bar.ButtonBackAreaStyle.BorderRight = eStyleBorderType.Solid;
+ bar.ButtonBackAreaStyle.BorderRightWidth = 1;
+ bar.ButtonBackAreaStyle.PaddingBottom = 3;
+ bar.ButtonBackAreaStyle.PaddingTop = 3;
+ bar.ButtonBackAreaStyle.PaddingLeft = 3;
+ bar.ButtonBackAreaStyle.PaddingRight = 3;
+ bar.SelectedTabColors.BorderColor = Color.Black;
+ bar.MouseOverTabColors.BorderColor = SystemColors.Highlight;
+ }
+
+ private void OnSelectionChanged(object sender, EventArgs e)
+ {
+ ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss==null)
+ return;
+
+ bool refresh=ResetFocus();
+ if(ss.PrimarySelection is BubbleBarTab)
+ {
+ if(((BubbleBarTab)ss.PrimarySelection).Parent==this.Control)
+ {
+ ((BubbleBarTab)ss.PrimarySelection).Focus=true;
+ refresh=true;
+ }
+ }
+ else if(ss.PrimarySelection is BubbleButton)
+ {
+ if(((BubbleButton)ss.PrimarySelection).Parent.Parent==this.Control)
+ {
+ ((BubbleButton)ss.PrimarySelection).Focus=true;
+ refresh=true;
+ }
+ }
+
+ if(refresh)
+ this.Control.Refresh();
+ }
+
+ private bool ResetFocus()
+ {
+ bool refresh=false;
+ BubbleBar bar=this.Control as BubbleBar;
+ foreach(BubbleBarTab tab in bar.Tabs)
+ {
+ if(tab.Focus)
+ {
+ tab.Focus=false;
+ refresh=true;
+ }
+ foreach(BubbleButton button in tab.Buttons)
+ {
+ if(button.Focus)
+ {
+ button.Focus=false;
+ refresh=true;
+ }
+ }
+ }
+ return refresh;
+ }
+
+ private void OnComponentRemoving(object sender,ComponentEventArgs e)
+ {
+ if(e.Component==this.Component)
+ ThisComponentRemoving(sender,e);
+ else if(e.Component is BubbleBarTab)
+ {
+ BubbleBarTab tab=e.Component as BubbleBarTab;
+ if(tab.Parent==this.Control)
+ {
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ foreach(BubbleButton button in tab.Buttons)
+ dh.DestroyComponent(button);
+ BubbleBar bar=this.Component as BubbleBar;
+ bar.Tabs.Remove(tab);
+ bar.RecalcLayout();
+ bar.Refresh();
+ }
+ }
+ else if(e.Component is BubbleButton)
+ {
+ BubbleButton button=e.Component as BubbleButton;
+ if(button.GetBubbleBar()==this.Control)
+ {
+ button.Parent.Buttons.Remove(button);
+ BubbleBar bar=this.Component as BubbleBar;
+ bar.RecalcLayout();
+ bar.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Removes all tabs and buttons.
+ ///
+ protected virtual void ThisComponentRemoving(object sender, ComponentEventArgs e)
+ {
+ //m_InternalRemoving=true;
+// try
+// {
+ // Unhook events
+ IComponentChangeService cc=(IComponentChangeService)GetService(typeof(IComponentChangeService));
+ if(cc!=null)
+ cc.ComponentRemoving-=new ComponentEventHandler(this.OnComponentRemoving);
+
+ ISelectionService ss =(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null)
+ ss.SelectionChanged-=new EventHandler(OnSelectionChanged);
+
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ BubbleBar bar=this.Component as BubbleBar;
+ if(dh==null)
+ return;
+
+ foreach(BubbleBarTab tab in bar.Tabs)
+ {
+ foreach(BubbleButton button in tab.Buttons)
+ dh.DestroyComponent(button);
+ dh.DestroyComponent(tab);
+ }
+ //}
+// finally
+// {
+// m_InternalRemoving=false;
+// }
+ }
+
+ private void CreateButton(object sender,EventArgs e)
+ {
+ BubbleBar bar=this.Control as BubbleBar;
+ if(bar==null)
+ return;
+
+ if(bar.SelectedTab==null)
+ {
+ BubbleBarTab tab=CreateTab();
+ IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(change!=null)
+ change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true));
+ bar.SelectedTab=tab;
+ if(change!=null)
+ change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true),null,null);
+ }
+
+ if(bar.SelectedTab==null)
+ return;
+
+ BubbleButton button=CreateButton(bar.SelectedTab);
+
+ if(button==null)
+ return;
+
+ ISelectionService ss=(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null)
+ {
+ ArrayList list=new ArrayList();
+ list.Add(button);
+ ss.SetSelectedComponents(list);
+ }
+ }
+
+ private void CreateTab(object sender,EventArgs e)
+ {
+ BubbleBar bar=this.Control as BubbleBar;
+ if(bar==null)
+ return;
+
+ BubbleBarTab tab=CreateTab();
+ if(tab!=null)
+ {
+ if(bar.SelectedTab!=tab)
+ {
+ IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(change!=null)
+ change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true));
+ bar.SelectedTab=tab;
+ if(change!=null)
+ change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true),null,null);
+ }
+
+ ISelectionService ss=(ISelectionService)GetService(typeof(ISelectionService));
+ if(ss!=null)
+ {
+ ArrayList list=new ArrayList();
+ list.Add(tab);
+ ss.SetSelectedComponents(list);
+ }
+ }
+ }
+
+ private BubbleBarTab CreateTab()
+ {
+ BubbleBar bar=this.Control as BubbleBar;
+ if(bar==null)
+ return null;
+
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh==null)
+ return null;
+
+ IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(change!=null)
+ change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("Tabs",true));
+
+ BubbleBarTab tab=dh.CreateComponent(typeof(BubbleBarTab)) as BubbleBarTab;
+ if(tab==null)
+ return null;
+
+ tab.Text=tab.Name;
+ eTabItemColor color=eTabItemColor.Blue;
+ if(bar.Tabs.Count>0)
+ {
+ int tt=bar.Tabs.Count+1;
+ Type t=typeof(eTabItemColor);
+ FieldInfo[] fi=t.GetFields(BindingFlags.Public | BindingFlags.Static);
+ int count=fi.Length;
+ while(tt>count)
+ tt-=count;
+ if(tt==0) tt++;
+ color=(eTabItemColor)Enum.Parse(typeof(eTabItemColor),fi[tt].Name);
+ }
+ tab.PredefinedColor=color;
+
+ bar.Tabs.Add(tab);
+
+ if(change!=null)
+ change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("Tabs",true),null,null);
+
+ return tab;
+ }
+
+ private BubbleButton CreateButton(BubbleBarTab tab)
+ {
+ BubbleBar bar=this.Control as BubbleBar;
+ if(bar==null)
+ return null;
+
+ IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
+ if(dh==null)
+ return null;
+
+ IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(change!=null)
+ change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(tab).Find("Buttons",true));
+
+ BubbleButton button=dh.CreateComponent(typeof(BubbleButton)) as BubbleButton;
+ if(button==null)
+ return null;
+ button.Image=BarFunctions.LoadBitmap("SystemImages.Note24.png");
+ button.ImageLarge=BarFunctions.LoadBitmap("SystemImages.Note64.png");
+ tab.Buttons.Add(button);
+
+ if(change!=null)
+ change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(tab).Find("Buttons",true),null,null);
+
+ return button;
+ }
+
+ ///
+ /// Returns all components associated with this control
+ ///
+ public override System.Collections.ICollection AssociatedComponents
+ {
+ get
+ {
+ ArrayList c=new ArrayList(base.AssociatedComponents);
+ BubbleBar bar=this.Control as BubbleBar;
+ if(bar!=null)
+ {
+ foreach(BubbleBarTab tab in bar.Tabs)
+ {
+ c.Add(tab);
+ GetTabComponents(tab,c);
+ }
+ }
+ return c;
+ }
+ }
+
+ private void GetTabComponents(BubbleBarTab tab, ArrayList c)
+ {
+ foreach(BubbleButton b in tab.Buttons)
+ c.Add(b);
+ }
+
+ protected override void OnSetCursor()
+ {
+ BubbleBar bar=this.Control as BubbleBar;
+ Point pos=bar.PointToClient(System.Windows.Forms.Control.MousePosition);
+ BubbleButton button=bar.GetButtonAt(pos);
+ if(button!=null)
+ {
+ Cursor.Current=Cursors.Default;
+ return;
+ }
+ BubbleBarTab tab=bar.GetTabAt(pos);
+ if(tab!=null)
+ {
+ Cursor.Current=Cursors.Default;
+ return;
+ }
+ base.OnSetCursor();
+ }
+
+ ///
+ /// Selection support for items on container.
+ ///
+ protected override void WndProc(ref Message m)
+ {
+ switch(m.Msg)
+ {
+ case NativeFunctions.WM_LBUTTONDOWN:
+ case NativeFunctions.WM_RBUTTONDOWN:
+ {
+ if(OnMouseDown(ref m))
+ return;
+ break;
+ }
+ case NativeFunctions.WM_RBUTTONUP:
+ case NativeFunctions.WM_LBUTTONUP:
+ {
+ if(OnMouseUp(ref m))
+ return;
+ break;
+ }
+ case NativeFunctions.WM_MOUSEMOVE:
+ {
+ if(OnMouseMove(ref m))
+ return;
+ break;
+ }
+ case NativeFunctions.WM_LBUTTONDBLCLK:
+ {
+ if(OnMouseDoubleClick(m))
+ return;
+ break;
+ }
+ }
+
+ base.WndProc(ref m);
+ }
+
+ private bool OnMouseDoubleClick(Message m)
+ {
+ bool processed=false;
+
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(selection!=null && selection.PrimarySelection is BubbleButton && ((BubbleButton)selection.PrimarySelection).GetBubbleBar()==this.Control)
+ {
+ IDesignerHost host=(IDesignerHost) this.GetService(typeof(IDesignerHost));
+ if(host!=null)
+ {
+ IDesigner designer=host.GetDesigner(selection.PrimarySelection as IComponent);
+ if(designer!=null)
+ {
+ designer.DoDefaultAction();
+ processed=true;
+ }
+ }
+ }
+
+ return processed;
+ }
+
+ protected virtual bool OnMouseDown(ref Message m)
+ {
+ BubbleBar bar=this.Control as BubbleBar;
+
+ if(bar==null)
+ return false;
+
+ Point pos=bar.PointToClient(System.Windows.Forms.Control.MousePosition);
+ m_MouseDownPosition=pos;
+
+ BubbleButton button=bar.GetButtonAt(pos);
+ if(button!=null)
+ {
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(selection!=null)
+ {
+ ArrayList arr=new ArrayList(1);
+ arr.Add(button);
+#if FRAMEWORK20
+ selection.SetSelectedComponents(arr, SelectionTypes.Primary);
+#else
+ selection.SetSelectedComponents(arr,SelectionTypes.MouseDown);
+#endif
+ m_IgnoreMouseUp =true;
+
+ if(m.Msg==NativeFunctions.WM_RBUTTONDOWN)
+ {
+ this.OnContextMenu(System.Windows.Forms.Control.MousePosition.X,System.Windows.Forms.Control.MousePosition.Y);
+ }
+
+ return true;
+ }
+ }
+
+ BubbleBarTab tab=bar.GetTabAt(pos);
+ if(tab!=null)
+ {
+ ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
+ if(selection!=null && selection.PrimarySelection!=tab)
+ {
+ ArrayList arr=new ArrayList(1);
+ arr.Add(tab);
+#if FRAMEWORK20
+ selection.SetSelectedComponents(arr, SelectionTypes.Primary);
+#else
+ selection.SetSelectedComponents(arr,SelectionTypes.MouseDown);
+#endif
+
+ if (bar.SelectedTab!=tab)
+ {
+ IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(change!=null)
+ change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true));
+
+ bar.SelectedTab=tab;
+
+ if(change!=null)
+ change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(bar).Find("SelectedTab",true),null,null);
+ }
+ m_IgnoreMouseUp=true;
+ if(m.Msg!=NativeFunctions.WM_RBUTTONDOWN)
+ return true;
+ }
+
+ if(m.Msg==NativeFunctions.WM_RBUTTONDOWN)
+ {
+ this.OnContextMenu(System.Windows.Forms.Control.MousePosition.X,System.Windows.Forms.Control.MousePosition.Y);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected virtual bool OnMouseMove(ref Message m)
+ {
+ BubbleBar bar=this.Control as BubbleBar;
+ Point pos=bar.PointToClient(System.Windows.Forms.Control.MousePosition);
+
+ if(Control.MouseButtons==MouseButtons.Left)
+ {
+ if(bar.DragInProgress)
+ {
+ bar.DragMouseMove(pos);
+ return true;
+ }
+ else if(!m_MouseDownPosition.IsEmpty && Math.Abs(m_MouseDownPosition.X-pos.X)>=2 || Math.Abs(m_MouseDownPosition.Y-pos.Y)>=2)
+ {
+ BubbleBarTab tabDrag=bar.GetTabAt(pos);
+ if(tabDrag!=null)
+ {
+ bar.StartDrag(tabDrag);
+ System.Windows.Forms.Control c=System.Windows.Forms.Control.FromHandle(m.HWnd);
+ if(c!=null)
+ {
+ m_Capture=true;
+ c.Capture=true;
+ }
+ return true;
+ }
+ BubbleButton buttonDrag=bar.GetButtonAt(pos);
+ if(buttonDrag!=null)
+ {
+ bar.StartDrag(buttonDrag);
+ System.Windows.Forms.Control c=System.Windows.Forms.Control.FromHandle(m.HWnd);
+ if(c!=null)
+ {
+ m_Capture=true;
+ c.Capture=true;
+ }
+ return true;
+ }
+ m_MouseDownPosition=Point.Empty;
+ }
+ }
+
+ //BubbleButton button=bar.GetButtonAt(pos);
+ BubbleBarTab tab=bar.GetTabAt(pos);
+ if(tab!=null)
+ bar.SetMouseOverTab(tab);
+ else
+ bar.SetMouseOverTab(null);
+
+ return false;
+ }
+
+ private bool OnMouseUp(ref Message m)
+ {
+ if(m_Capture)
+ {
+ System.Windows.Forms.Control c=System.Windows.Forms.Control.FromHandle(m.HWnd);
+ if(c!=null)
+ c.Capture=false;
+ m_Capture=false;
+ }
+
+ BubbleBar bar=this.Control as BubbleBar;
+ if(bar!=null && bar.DragInProgress)
+ {
+ Point pos=bar.PointToClient(System.Windows.Forms.Control.MousePosition);
+ bar.DragMouseUp(pos);
+
+ BubbleBarTab tab=bar.SelectedTab;
+ if(tab!=null)
+ {
+ IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
+ if(change!=null)
+ change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(tab).Find("Buttons",true));
+ if(change!=null)
+ change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(tab).Find("Buttons",true),null,null);
+ }
+ }
+
+ if(m_IgnoreMouseUp)
+ {
+ m_IgnoreMouseUp=false;
+ return true;
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleBarOverlay.cs b/PROMS/DotNetBar Source Code/BubbleBarOverlay.cs
new file mode 100644
index 00000000..da016f52
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleBarOverlay.cs
@@ -0,0 +1,282 @@
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+using System.Windows.Forms;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents overlay class to support bubble effects on BubbleBar control.
+ ///
+ [ToolboxItem(false)]
+ internal class BubbleBarOverlay:Control
+ {
+ #region Private Variables
+ private BubbleBar m_BubbleBar=null;
+ private Timer m_VisibilityTimer=null;
+ #endregion
+
+ #region Internal Implementation
+ public BubbleBarOverlay(BubbleBar parent)
+ {
+ if(parent==null)
+ throw new InvalidOperationException("Parent BubbleBar object for BubbleBarOverlay cannot be null.");
+
+ m_BubbleBar=parent;
+ this.SetStyle(ControlStyles.UserPaint,true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);
+ this.SetStyle(ControlStyles.Opaque,true);
+ this.SetStyle(ControlStyles.ResizeRedraw,true);
+ //this.SetStyle(DisplayHelp.DoubleBufferFlag,true);
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor,true);
+ this.SetStyle(ControlStyles.ContainerControl,false);
+ this.SetStyle(ControlStyles.Selectable,false);
+ this.BackColor=Color.Transparent;
+ }
+
+ protected override void OnPaint(PaintEventArgs e){}
+
+ internal void UpdateWindow()
+ {
+ // Create bitmap for drawing onto
+ Bitmap memoryBitmap = new Bitmap(this.Width, this.Height, PixelFormat.Format32bppArgb);
+
+ using(Graphics g = Graphics.FromImage(memoryBitmap))
+ {
+ // Draw the background area
+ g.Clear(Color.Transparent);
+ g.CompositingMode=System.Drawing.Drawing2D.CompositingMode.SourceCopy;
+
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ g.SmoothingMode=System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+
+ PaintEventArgs p=new PaintEventArgs(g,this.DisplayRectangle);
+ m_BubbleBar.OnPaintOverlay(p);
+
+ // Get hold of the screen DC
+ IntPtr hDC = NativeFunctions.GetDC(IntPtr.Zero);
+
+ // Create a memory based DC compatible with the screen DC
+ IntPtr memoryDC = WinApi.CreateCompatibleDC(hDC);
+
+ // Get access to the bitmap handle contained in the Bitmap object
+ IntPtr hBitmap = memoryBitmap.GetHbitmap(Color.FromArgb(0));
+
+ // Select this bitmap for updating the window presentation
+ IntPtr oldBitmap = WinApi.SelectObject(memoryDC, hBitmap);
+
+ // New window size
+ NativeFunctions.SIZE ulwsize;
+ ulwsize.cx = this.Width;
+ ulwsize.cy = this.Height;
+
+ // New window position
+ NativeFunctions.POINT topPos;
+ topPos.x = this.Left;
+ topPos.y = this.Top;
+
+ // Offset into memory bitmap is always zero
+ NativeFunctions.POINT pointSource;
+ pointSource.x = 0;
+ pointSource.y = 0;
+
+ // We want to make the entire bitmap opaque
+ NativeFunctions.BLENDFUNCTION blend = new NativeFunctions.BLENDFUNCTION();
+ blend.BlendOp = (byte)NativeFunctions.Win23AlphaFlags.AC_SRC_OVER;
+ blend.BlendFlags = 0;
+ blend.SourceConstantAlpha = 255;
+ blend.AlphaFormat = (byte)NativeFunctions.Win23AlphaFlags.AC_SRC_ALPHA;
+
+ // Tell operating system to use our bitmap for painting
+ NativeFunctions.UpdateLayeredWindow(this.Handle, hDC, ref topPos, ref ulwsize,
+ memoryDC, ref pointSource, 0, ref blend,
+ (int)NativeFunctions.Win32UpdateLayeredWindowsFlags.ULW_ALPHA);
+ // Put back the old bitmap handle
+ WinApi.SelectObject(memoryDC, oldBitmap);
+
+ // Cleanup resources
+ WinApi.ReleaseDC(IntPtr.Zero, hDC);
+ WinApi.DeleteObject(hBitmap);
+ WinApi.DeleteDC(memoryDC);
+ }
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ this.Capture=true;
+ base.OnMouseEnter (e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ if(!this.DisplayRectangle.Contains(e.X,e.Y))
+ this.Capture=false;
+ m_BubbleBar.MouseMoveMessage(e);
+ base.OnMouseMove (e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ m_BubbleBar.MouseLeaveMessage(e);
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ m_BubbleBar.OverlayMouseDownMessage(e);
+ base.OnMouseDown (e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ m_BubbleBar.OverlayMouseUpMessage(e);
+ base.OnMouseUp(e);
+ }
+
+ protected override void WndProc(ref Message m)
+ {
+ const int WM_MOUSEACTIVATE = 0x21;
+ const int MA_NOACTIVATE = 3;
+ if(m.Msg==WM_MOUSEACTIVATE)
+ {
+ m.Result=new System.IntPtr(MA_NOACTIVATE);
+ return;
+ }
+ base.WndProc(ref m);
+ }
+
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ const uint WS_POPUP=0x80000000;
+ const uint WS_CLIPSIBLINGS=0x04000000;
+ const uint WS_CLIPCHILDREN=0x02000000;
+ const int WS_EX_LAYERED=0x00080000;
+ const int WS_EX_TOOLWINDOW=0x00000080;
+ CreateParams p=base.CreateParams;
+ p.ExStyle=(p.ExStyle | WS_EX_LAYERED | WS_EX_TOOLWINDOW);
+ p.Style=unchecked((int)(WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN));
+ p.Caption="";
+ return p;
+ }
+ }
+
+ private void CreateTimer()
+ {
+ if(m_VisibilityTimer!=null)
+ return;
+ m_VisibilityTimer=new Timer();
+ m_VisibilityTimer.Tick+=new EventHandler(this.CheckVisibility);
+ m_VisibilityTimer.Interval=500;
+ m_VisibilityTimer.Enabled=true;
+ m_VisibilityTimer.Start();
+ }
+
+ private void DestroyTimer()
+ {
+ if(m_VisibilityTimer==null)
+ return;
+ m_VisibilityTimer.Stop();
+ m_VisibilityTimer.Enabled=false;
+ m_VisibilityTimer.Dispose();
+ m_VisibilityTimer=null;
+ }
+
+ private void CheckVisibility(object sender,EventArgs e)
+ {
+ try
+ {
+ BubbleBar bar = m_BubbleBar;
+ if (bar == null || bar.IsDisposed)
+ {
+ DestroyTimer();
+ return;
+ }
+
+ Form form = bar.FindForm();
+ IntPtr foregroundWindow = NativeFunctions.GetForegroundWindow();
+ Control c = null;
+ if (foregroundWindow != IntPtr.Zero)
+ c = Control.FromHandle(foregroundWindow);
+ if (c == null)
+ {
+ OnOverlayInactive();
+ return;
+ }
+ if (form != null)
+ {
+ if (Form.ActiveForm == form)
+ return;
+ Form parentForm = form;
+ while (parentForm.ParentForm != null)
+ {
+ if (parentForm.ParentForm == Form.ActiveForm)
+ return;
+ parentForm = parentForm.ParentForm;
+ }
+
+ if (form.IsMdiChild && form.MdiParent != null)
+ {
+ if (form.MdiParent.ActiveMdiChild == form)
+ return;
+ }
+ }
+
+ NativeFunctions.POINT p = new NativeFunctions.POINT();
+ Point pm = Control.MousePosition;
+ p.x = pm.X;
+ p.x = pm.Y;
+ IntPtr window = IntPtr.Zero;
+ if (bar.Parent != null)
+ NativeFunctions.ChildWindowFromPoint(bar.Parent.Handle, p);
+ if (window == IntPtr.Zero)
+ {
+ window = NativeFunctions.WindowFromPoint(p);
+ }
+ if (window != IntPtr.Zero && window != this.Handle && window != bar.Handle && bar.Parent != null && bar.Parent.Handle != window)
+ {
+ OnOverlayInactive();
+ }
+ else
+ {
+ Point pc = this.PointToClient(pm);
+ if (!this.DisplayRectangle.Contains(pc))
+ {
+ bar.MouseLeaveMessage(e);
+ }
+ }
+ }
+ catch (NullReferenceException)
+ {
+ DestroyTimer();
+ }
+ }
+
+ private void OnOverlayInactive()
+ {
+ this.Capture=false;
+ DestroyTimer();
+ m_BubbleBar.OverlayInactive();
+ }
+
+ ///
+ /// Called just before window is shown.
+ ///
+ internal void BeforeShow()
+ {
+ CreateTimer();
+ }
+
+ ///
+ /// Called after window is closed.
+ ///
+ internal void AfterClose()
+ {
+ DestroyTimer();
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleBarTab.cs b/PROMS/DotNetBar Source Code/BubbleBarTab.cs
new file mode 100644
index 00000000..364e4c5b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleBarTab.cs
@@ -0,0 +1,495 @@
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Windows.Forms;
+using DevComponents.UI.ContentManager;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for BubbleBarGroup.
+ ///
+ [ToolboxItem(false), DesignTimeVisible(false), Designer("DevComponents.DotNetBar.Design.BubbleBarTabDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class BubbleBarTab:Component,ISimpleTab,IBlock
+ {
+ #region Private Properties
+ private string m_Text="";
+ private BubbleBar m_Parent=null;
+ private bool m_Visible=true;
+ private Rectangle m_DisplayRectangle=Rectangle.Empty;
+ private Color m_BackColor=Color.Empty;
+ private Color m_BackColor2=Color.Empty;
+ private int m_BackColorGradientAngle=90;
+ private Color m_LightBorderColor=Color.Empty;
+ private Color m_DarkBorderColor=Color.Empty;
+ private Color m_BorderColor=Color.Empty;
+ private Color m_TextColor=Color.Empty;
+ private string m_Name="";
+ private eTabItemColor m_PredefinedColor=eTabItemColor.Default;
+ private object m_Tag=null;
+ private BubbleButtonCollection m_Buttons=null;
+ private bool m_Focus=false;
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Default constructor.
+ ///
+ public BubbleBarTab():this(null){}
+
+ ///
+ /// Default constructor.
+ ///
+ /// Container object.
+ public BubbleBarTab(IContainer container)
+ {
+ if(container!=null)
+ container.Add(this);
+ m_Buttons=new BubbleButtonCollection(this);
+ }
+
+
+ ///
+ /// Gets the collection of the buttons associated with the tab.
+ ///
+ [Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Buttons"), Description("Returns collection of buttons on the tab."), Editor("DevComponents.DotNetBar.Design.BubbleButtonCollectionEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ public BubbleButtonCollection Buttons
+ {
+ get {return m_Buttons;}
+ }
+
+ ///
+ /// Gets or sets the text displayed on the tab.
+ ///
+ [Browsable(true),DevCoBrowsable(true),Category("Appearance"),Description("Indicates the text displayed on the tab."),Localizable(true)]
+ public string Text
+ {
+ get {return m_Text;}
+ set
+ {
+ if(m_Text==value)
+ return;
+ m_Text=value;
+ if(m_Parent!=null)
+ m_Parent.OnTabTextChanged(this);
+ Refresh();
+ }
+ }
+
+ ///
+ /// Gets or sets whether tab is visible.
+ ///
+ [Browsable(true),DevCoBrowsable(true),DefaultValue(true),Category("Behavior"),Description("Indicates whether the tab is visible.")]
+ public bool Visible
+ {
+ get{return m_Visible;}
+ set
+ {
+ if(m_Visible==value)
+ return;
+ m_Visible=value;
+ if(m_Parent!=null)
+ m_Parent.OnTabVisibleChanged(this);
+ Refresh();
+ }
+ }
+
+ ///
+ /// Gets the display bounds of the tab.
+ ///
+ [Browsable(false)]
+ public Rectangle DisplayRectangle
+ {
+ get {return m_DisplayRectangle;}
+ }
+
+ ///
+ /// Gets or sets the object that contains data about the tab. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ ///
+ [Browsable(false),DefaultValue(null),Category("Data"),Description("Indicates text that contains data about the cell.")]
+ public object Tag
+ {
+ get
+ {
+ return m_Tag;
+ }
+ set
+ {
+ m_Tag=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the object that contains data about the tab. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ ///
+ [Browsable(true),DefaultValue(""),Category("Data"),Description("Indicates text that contains data about the cell.")]
+ public string TagString
+ {
+ get
+ {
+ if(m_Tag==null)
+ return "";
+ return m_Tag.ToString();
+ }
+ set
+ {
+ m_Tag=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the background color of the tab when inactive.
+ ///
+ [Browsable(true),Description("Indicates the inactive tab background color."),Category("Style")]
+ public Color BackColor
+ {
+ get {return m_BackColor;}
+ set
+ {
+ m_BackColor=value;
+ this.Refresh();
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBackColor()
+ {
+ return !m_BackColor.IsEmpty;
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackColor()
+ {
+ BackColor=Color.Empty;
+ }
+
+ ///
+ /// Gets or sets the target gradient background color of the tab when inactive.
+ ///
+ [Browsable(true),Description("Indicates the inactive tab target gradient background color."),Category("Style")]
+ public Color BackColor2
+ {
+ get {return m_BackColor2;}
+ set
+ {
+ m_BackColor2=value;
+ this.Refresh();
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBackColor2()
+ {
+ return !m_BackColor2.IsEmpty;
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackColor2()
+ {
+ BackColor2=Color.Empty;
+ }
+
+ ///
+ /// Gets or sets the gradient angle.
+ ///
+ [Browsable(true),Description("Indicates the gradient angle."),Category("Style"),DefaultValue(90)]
+ public int BackColorGradientAngle
+ {
+ get {return m_BackColorGradientAngle;}
+ set {m_BackColorGradientAngle=value;this.Refresh();}
+ }
+
+ ///
+ /// Gets or sets the light border color when tab is inactive.
+ ///
+ [Browsable(true),Description("Indicates the inactive tab light border color."),Category("Style")]
+ public Color LightBorderColor
+ {
+ get {return m_LightBorderColor;}
+ set
+ {
+ m_LightBorderColor=value;
+ this.Refresh();
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeLightBorderColor()
+ {
+ return !m_LightBorderColor.IsEmpty;
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetLightBorderColor()
+ {
+ LightBorderColor=Color.Empty;
+ }
+
+ ///
+ /// Gets or sets the dark border color when tab is inactive.
+ ///
+ [Browsable(true),Description("Indicates the inactive tab dark border color."),Category("Style")]
+ public Color DarkBorderColor
+ {
+ get {return m_DarkBorderColor;}
+ set
+ {
+ m_DarkBorderColor=value;
+ this.Refresh();
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeDarkBorderColor()
+ {
+ return !m_DarkBorderColor.IsEmpty;
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetDarkBorderColor()
+ {
+ DarkBorderColor=Color.Empty;
+ }
+
+ ///
+ /// Gets or sets the border color when tab is inactive.
+ ///
+ [Browsable(true),Description("Indicates the inactive tab border color."),Category("Style")]
+ public Color BorderColor
+ {
+ get {return m_BorderColor;}
+ set
+ {
+ m_BorderColor=value;
+ this.Refresh();
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBorderColor()
+ {
+ return !m_BorderColor.IsEmpty;
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBorderColor()
+ {
+ BorderColor=Color.Empty;
+ }
+
+ ///
+ /// Gets or sets the text color when tab is inactive.
+ ///
+ [Browsable(true),Description("Indicates the inactive tab text color."),Category("Style")]
+ public Color TextColor
+ {
+ get {return m_TextColor;}
+ set
+ {
+ m_TextColor=value;
+ this.Refresh();
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTextColor()
+ {
+ return !m_TextColor.IsEmpty;
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTextColor()
+ {
+ TextColor=Color.Empty;
+ }
+
+ public override string ToString()
+ {
+ return m_Text;
+ }
+
+ ///
+ /// Gets or sets name of the tab item that can be used to identify item from the code.
+ ///
+ [Browsable(true),DevCoBrowsable(true),Category("Design"),Description("Indicates the name used to identify item.")]
+ public string Name
+ {
+ get
+ {
+ if(this.Site!=null)
+ m_Name=this.Site.Name;
+ return m_Name;
+ }
+ set
+ {
+ if(this.Site!=null)
+ this.Site.Name=value;
+ if(value==null)
+ m_Name="";
+ else
+ m_Name=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the predefined tab color.
+ ///
+ [Browsable(true), DefaultValue(eTabItemColor.Default),Category("Style"),Description("Applies predefined color to tab.")]
+ public eTabItemColor PredefinedColor
+ {
+ get {return m_PredefinedColor;}
+ set
+ {
+ m_PredefinedColor=value;
+ TabColorScheme.ApplyPredefinedColor(this,m_PredefinedColor);
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Returns the font for the tab text.
+ ///
+ /// Reference to the font object.
+ public Font GetTabFont()
+ {
+ if (m_Parent != null)
+ return m_Parent.Font;
+ else
+ return SystemFonts.DefaultFont;
+ }
+
+ ///
+ /// Returns true if tab is selected tab.
+ ///
+ [Browsable(false)]
+ public bool IsSelected
+ {
+ get
+ {
+ if(m_Parent!=null)
+ {
+ return (m_Parent.SelectedTab==this);
+ }
+ return false;
+ }
+ }
+
+ ///
+ /// Returns true if mouse is over the tab.
+ ///
+ [Browsable(false)]
+ public bool IsMouseOver
+ {
+ get
+ {
+ if(m_Parent!=null)
+ return (m_Parent.GetMouseOverTab()==this);
+ return false;
+ }
+ }
+
+ ///
+ /// Gets the tab alignment.
+ ///
+ eTabStripAlignment ISimpleTab.TabAlignment
+ {
+ get
+ {
+ if(m_Parent!=null)
+ {
+ if(m_Parent.Alignment==eBubbleButtonAlignment.Top)
+ return eTabStripAlignment.Bottom;
+ }
+ return eTabStripAlignment.Top;
+ }
+ }
+
+ ///
+ /// Returns reference to parent object or null if tab does not have parent.
+ ///
+ [Browsable(false)]
+ public BubbleBar Parent
+ {
+ get {return m_Parent;}
+ }
+
+ ///
+ /// Sets the parent of the tab.
+ ///
+ /// Reference to the tab parent object or null.
+ internal void SetParent(BubbleBar parent)
+ {
+ m_Parent=parent;
+ }
+
+ private void Refresh()
+ {
+ if(m_Parent!=null)
+ {
+ Rectangle r=this.DisplayRectangle;
+ r.Width+=16;
+ r.X-=8;
+ m_Parent.Invalidate(r);
+ m_Parent.Update();
+ }
+ }
+
+ ///
+ /// Called after new button is added to the Buttons collection.
+ ///
+ /// Reference to the added button.
+ internal void OnButtonInserted(BubbleButton button)
+ {
+ if(m_Parent!=null)
+ m_Parent.OnButtonInserted(this, button);
+ }
+
+ ///
+ /// Called after specified button has been removed.
+ ///
+ /// Button that was removed.
+ internal void OnButtonRemoved(BubbleButton button)
+ {
+ if(m_Parent!=null)
+ m_Parent.OnButtonRemoved(this,button);
+ }
+
+ ///
+ /// Called after all buttons have been removed.
+ ///
+ internal void OnButtonsCollectionClear()
+ {
+ if(m_Parent!=null)
+ m_Parent.OnButtonsCollectionClear(this);
+ }
+
+ ///
+ /// Gets or sets whether tab has design-time focus.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Focus
+ {
+ get {return m_Focus;}
+ set {m_Focus=value;}
+ }
+ #endregion
+
+ #region IBlock
+ ///
+ /// Gets or sets the bounds of the content block.
+ ///
+ Rectangle IBlock.Bounds
+ {
+ get
+ {
+ return m_DisplayRectangle;
+ }
+ set
+ {
+ m_DisplayRectangle=value;
+ }
+ }
+ private DevComponents.DotNetBar.Padding _Margin = new DevComponents.DotNetBar.Padding(0);
+ ///
+ /// Gets or sets item margin only used by certain items in certain containers. Provided only for internal DotNetBar use.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ DevComponents.DotNetBar.Padding DevComponents.UI.ContentManager.IBlock.Margin
+ {
+ get { return _Margin; }
+ set { _Margin = value; }
+ }
+ #endregion
+ }
+
+
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleBarTabCollection.cs b/PROMS/DotNetBar Source Code/BubbleBarTabCollection.cs
new file mode 100644
index 00000000..5b09af93
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleBarTabCollection.cs
@@ -0,0 +1,163 @@
+using System;
+using System.Collections;
+using DevComponents.UI.ContentManager;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents collection for BubbleBarTab objects.
+ ///
+ public class BubbleBarTabCollection:CollectionBase
+ {
+ #region Private Variables
+ private BubbleBar m_Owner=null;
+ #endregion
+
+ #region Internal Implementation
+ public BubbleBarTabCollection(BubbleBar owner)
+ {
+ m_Owner=owner;
+ }
+ ///
+ /// Adds new object to the collection.
+ ///
+ /// Object to add.
+ /// Index of newly added object.
+ public int Add(BubbleBarTab tab)
+ {
+ return List.Add(tab);
+ }
+ ///
+ /// Returns reference to the object in collection based on it's index.
+ ///
+ public BubbleBarTab this[int index]
+ {
+ get {return (BubbleBarTab)(List[index]);}
+ set {List[index] = value;}
+ }
+
+ ///
+ /// Inserts new object into the collection.
+ ///
+ /// Position of the object.
+ /// Object to insert.
+ public void Insert(int index, BubbleBarTab value)
+ {
+ List.Insert(index, value);
+ }
+
+ ///
+ /// Returns index of the object inside of the collection.
+ ///
+ /// Reference to the object.
+ /// Index of the object.
+ public int IndexOf(BubbleBarTab value)
+ {
+ return List.IndexOf(value);
+ }
+
+ ///
+ /// Returns whether collection contains specified object.
+ ///
+ /// Object to look for.
+ /// true if object is part of the collection, otherwise false.
+ public bool Contains(BubbleBarTab value)
+ {
+ return List.Contains(value);
+ }
+
+ ///
+ /// Removes specified object from the collection.
+ ///
+ ///
+ public void Remove(BubbleBarTab value)
+ {
+ List.Remove(value);
+ }
+
+ protected override void OnRemoveComplete(int index,object value)
+ {
+ base.OnRemoveComplete(index,value);
+ BubbleBarTab item=value as BubbleBarTab;
+ m_Owner.OnTabRemoved(item);
+ item.SetParent(null);
+ }
+ protected override void OnInsertComplete(int index,object value)
+ {
+ base.OnInsertComplete(index,value);
+ BubbleBarTab item=value as BubbleBarTab;
+ item.SetParent(m_Owner);
+ m_Owner.OnTabAdded(item);
+ }
+
+ ///
+ /// Copies collection into the specified array.
+ ///
+ /// Array to copy collection to.
+ /// Starting index.
+ public void CopyTo(BubbleBarTab[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ ///
+ /// Copies contained items to the IBlock array.
+ ///
+ /// Array to copy to.
+ internal void CopyTo(IBlock[] array)
+ {
+ List.CopyTo(array,0);
+ }
+
+ ///
+ /// Copies contained items to the ISimpleTab array.
+ ///
+ /// Array to copy to.
+ internal void CopyTo(ISimpleTab[] array)
+ {
+ List.CopyTo(array,0);
+ }
+
+ protected override void OnClear()
+ {
+ m_Owner.OnTabsCleared();
+ base.OnClear();
+ }
+
+ ///
+ /// Returns next visible tab from the reference tab.
+ ///
+ /// Reference tab.
+ /// Next visible tab or null if next visible tab cannot be determined.
+ internal BubbleBarTab GetNextVisibleTab(BubbleBarTab tabFrom)
+ {
+ int from=0;
+ if(tabFrom!=null)from=this.IndexOf(tabFrom)+1;
+ for(int i=from;i
+ /// Returns previous visible tab from the reference tab.
+ ///
+ /// Reference tab.
+ /// Previous visible tab or null if Previous visible tab cannot be determined.
+ internal BubbleBarTab GetPreviousVisibleTab(BubbleBarTab tabFrom)
+ {
+ int from=0;
+ if(tabFrom!=null) from=this.IndexOf(tabFrom)-1;
+
+ for(int i=from;i>=0;i--)
+ {
+ if(this[i].Visible)
+ return this[i];
+ }
+ return null;
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleButton.cs b/PROMS/DotNetBar Source Code/BubbleButton.cs
new file mode 100644
index 00000000..442e193d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleButton.cs
@@ -0,0 +1,594 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Diagnostics;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents a button used on BubbleBar control.
+ ///
+ [ToolboxItem(false),DesignTimeVisible(false),DefaultEvent("Click")]
+ public class BubbleButton:Component,DevComponents.UI.ContentManager.IBlock
+ {
+ #region Private Variables
+ private string m_TooltipText="";
+// private System.Drawing.Icon m_Icon=null;
+ private int m_ImageIndex=-1;
+ private int m_ImageIndexLarge=-1;
+ private bool m_Enabled=true;
+ private Image m_ImageCached=null;
+ private Image m_ImageLargeCached=null;
+ private Image m_Image=null;
+ private Image m_ImageLarge=null;
+ private Rectangle m_DisplayRectangle=Rectangle.Empty;
+ private Rectangle m_MagnifiedDisplayRectangle=Rectangle.Empty;
+ private bool m_MouseOver=false;
+ private bool m_MouseDown=false;
+ //private SubItemsCollection m_MenuItems;
+ private BubbleButtonCollection m_ParentCollection=null;
+ private string m_Name="";
+ private bool m_Visible=true;
+ private object m_Tag=null;
+ private bool m_Focus=false;
+ private eShortcut m_Shortcut=eShortcut.None;
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs when user clicks the button.
+ ///
+ public event ClickEventHandler Click;
+ ///
+ /// Occurs when mouse enters the button.
+ ///
+ public event EventHandler MouseEnter;
+ ///
+ /// Occurs when mouse leaves the button.
+ ///
+ public event EventHandler MouseLeave;
+ #endregion
+
+ ///
+ /// Creates new instance of button object.
+ ///
+ public BubbleButton()
+ {
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (BarUtilities.DisposeItemImages && !this.DesignMode)
+ {
+ BarUtilities.DisposeImage(ref m_Image);
+ BarUtilities.DisposeImage(ref m_ImageLarge);
+ BarUtilities.DisposeImage(ref m_ImageCached);
+ BarUtilities.DisposeImage(ref m_ImageLargeCached);
+ }
+ base.Dispose(disposing);
+ }
+ #region Public Properties
+ ///
+ /// Gets or sets the shortcut key to expand/collapse splitter.
+ ///
+ [Browsable(true),Category("Expand"),DefaultValue(eShortcut.None),Description("Indicates shortcut key to expand/collapse splitter."),]
+ public eShortcut Shortcut
+ {
+ get {return m_Shortcut;}
+ set
+ {
+ m_Shortcut=value;
+ if (m_Shortcut != eShortcut.None && this.GetBubbleBar()!=null)
+ {
+ this.GetBubbleBar().RefreshHasShortcut();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the tooltip for the button.
+ ///
+ [Category("Appearance"),DefaultValue(""),Description("Indicates tooltip for the button."), Localizable(true)]
+ public string TooltipText
+ {
+ get {return m_TooltipText;}
+ set {m_TooltipText=value;}
+ }
+
+// ///
+// /// Gets or sets the icon used on the button. The icon should at least have two sizes. Normal and enlarged size.
+// /// Proper size will be determined based on the settings for image size on BubbleBar object.
+// ///
+// [Browsable(true),Category("Images"),Description("Indicates icons used on the button."),DefaultValue(null)]
+// public Icon Icon
+// {
+// get {return m_Icon;}
+// set
+// {
+// m_Icon=value;
+// OnAppearanceChanged();
+// }
+// }
+
+ ///
+ /// Gets or sets the default image used on the button. Note that for improved appearance of the buttons when enlarged
+ /// you should set the ImageIndexLarge to the large version of the image specified here. The image size should be the same size
+ /// that is specified by the image size properties on BubbleBar object.
+ ///
+ [Browsable(true),Category("Images"),Description("Indicates default image used on the button."),Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)),System.ComponentModel.TypeConverter(typeof(ImageIndexConverter)),DefaultValue(-1)]
+ public int ImageIndex
+ {
+ get {return m_ImageIndex;}
+ set
+ {
+ m_ImageIndex=value;
+ m_ImageCached=null;
+ OnImageIndexChanged();
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Gets reference to the internal cached image loaded from the ImageIndex.
+ ///
+ internal Image ImageCached
+ {
+ get {return m_ImageCached;}
+ }
+
+ ///
+ /// Gets reference to the internal cached image loaded from the ImageIndex.
+ ///
+ internal Image ImageLargeCached
+ {
+ get {return m_ImageLargeCached;}
+ }
+
+ ///
+ /// Specifies the Button image.
+ ///
+ [Browsable(true),Category("Images"),Description("The image that will be displayed on the face of the button."),DefaultValue(null)]
+ public System.Drawing.Image Image
+ {
+ get {return m_Image;}
+ set
+ {
+ m_Image=value;
+ this.OnImageChanged();
+ }
+ }
+
+ ///
+ /// Specifies enlarged the Button image.
+ ///
+ [Browsable(true),Category("Images"),Description("Indicates enlarged image that will be displayed on the face of the button."),DefaultValue(null)]
+ public System.Drawing.Image ImageLarge
+ {
+ get {return m_ImageLarge;}
+ set
+ {
+ m_ImageLarge=value;
+ this.OnImageChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the image index of the enlarged image for the button. Note that if large image is not specified the
+ /// default image will be enlarged which might not result in perfect image appearance.
+ ///
+ [Browsable(true),Category("Images"),Description("Indicates image index of the enlarged image for the button."),Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)),TypeConverter(typeof(ImageIndexConverter)),DefaultValue(-1)]
+ public int ImageIndexLarge
+ {
+ get {return m_ImageIndexLarge;}
+ set
+ {
+ m_ImageIndexLarge=value;
+ m_ImageLargeCached=null;
+ OnImageIndexChanged();
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Property for Property Editor support for ImageIndex selection.
+ ///
+ [Browsable(false),EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public System.Windows.Forms.ImageList ImageList
+ {
+ get
+ {
+ BubbleBar bar=this.GetBubbleBar();
+ if(bar!=null)
+ return bar.Images;
+ return null;
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether button is enabled.
+ ///
+ [Browsable(true),DefaultValue(true),Category("Behavior"),Description("Indicates whether button is enabled.")]
+ public bool Enabled
+ {
+ get {return m_Enabled;}
+ set
+ {
+ if(m_Enabled!=value)
+ {
+ m_Enabled=value;
+ this.OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets the display rectangle occupied by the button.
+ ///
+ [Browsable(false)]
+ public Rectangle DisplayRectangle
+ {
+ get {return m_DisplayRectangle;}
+ }
+
+ ///
+ /// Sets the display rectangle of the button.
+ ///
+ /// New display rectangle of the button.
+ internal void SetDisplayRectangle(Rectangle r)
+ {
+ m_DisplayRectangle=r;
+ }
+
+ ///
+ /// Gets or sets the magnified display rectangle of the button.
+ ///
+ [Browsable(false)]
+ public Rectangle MagnifiedDisplayRectangle
+ {
+ get {return m_MagnifiedDisplayRectangle;}
+ }
+
+ ///
+ /// Sets the magnified display rectangle of the button.
+ ///
+ /// New magnified display rectangle.
+ internal void SetMagnifiedDisplayRectangle(Rectangle r)
+ {
+ m_MagnifiedDisplayRectangle=r;
+ }
+
+ ///
+ /// Gets whether mouse is over the button.
+ ///
+ [Browsable(false)]
+ public bool MouseOver
+ {
+ get {return m_MouseOver;}
+ }
+
+ ///
+ /// Sets whether mouse is over the button.
+ ///
+ /// True if mouse is over the button otherwise false.
+ internal void SetMouseOver(bool value)
+ {
+ bool changed=m_MouseOver!=value;
+ m_MouseOver=value;
+ UpdateCursor();
+ if (changed)
+ {
+ if (value)
+ OnMouseEnter();
+ else
+ OnMouseLeave();
+ }
+ }
+
+ ///
+ /// Raises the MouseEnter event.
+ ///
+ protected virtual void OnMouseEnter()
+ {
+ EventHandler eh = MouseEnter;
+ if (eh != null)
+ eh(this, new EventArgs());
+ }
+ ///
+ /// Raises the MouseLeave event.
+ ///
+ protected virtual void OnMouseLeave()
+ {
+ EventHandler eh = MouseLeave;
+ if (eh != null)
+ eh(this, new EventArgs());
+ }
+
+ private void UpdateCursor()
+ {
+ BubbleBar parent = GetBubbleBar();
+ if (parent == null || _Cursor == null) return;
+
+ if (m_MouseOver)
+ {
+ if (_OldCursor == null)
+ {
+ _OldCursor = Cursor.Current;
+ }
+ parent.Cursor = _Cursor;
+ }
+ else
+ {
+ if (_OldCursor != null)
+ {
+ parent.Cursor = _OldCursor;
+ _OldCursor = null;
+ }
+ }
+ }
+
+ ///
+ /// Gets whether left mouse button is pressed on the button.
+ ///
+ [Browsable(false)]
+ public bool MouseDown
+ {
+ get {return m_MouseDown;}
+ }
+
+ ///
+ /// Sets whether left mouse button is pressed over this button.
+ ///
+ /// True if left mouse button is pressed otherwise false.
+ internal void SetMouseDown(bool value)
+ {
+ m_MouseDown=value;
+ }
+
+ ///
+ /// Returns name of the button that can be used to identify it from the code.
+ ///
+ [Browsable(false),Category("Design"),Description("Indicates the name used to identify button.")]
+ public string Name
+ {
+ get
+ {
+ if(this.Site!=null)
+ m_Name=this.Site.Name;
+ return m_Name;
+ }
+ set
+ {
+ if(this.Site!=null)
+ this.Site.Name=value;
+ if(value==null)
+ m_Name="";
+ else
+ m_Name=value;
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether button is visible.
+ ///
+ [Browsable(true),DefaultValue(true),Category("Behavior"),Description("Determines whether the button is visible or hidden.")]
+ public virtual bool Visible
+ {
+ get
+ {
+ return m_Visible;
+ }
+ set
+ {
+ if(m_Visible==value)
+ return;
+
+ m_Visible=value;
+
+ OnVisibleChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the object that contains data about the tab. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ ///
+ [Browsable(false),DefaultValue(null),Category("Data"),Description("Indicates text that contains data about the cell.")]
+ public object Tag
+ {
+ get
+ {
+ return m_Tag;
+ }
+ set
+ {
+ m_Tag=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the object that contains data about the tab. Any Object derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned.
+ ///
+ [Browsable(true),DefaultValue(""),Category("Data"),Description("Indicates text that contains data about the cell.")]
+ public string TagString
+ {
+ get
+ {
+ if(m_Tag==null)
+ return "";
+ return m_Tag.ToString();
+ }
+ set
+ {
+ m_Tag=value;
+ }
+ }
+
+ ///
+ /// Returns the reference to parent tab.
+ ///
+ [Browsable(false)]
+ public BubbleBarTab Parent
+ {
+ get
+ {
+ if(m_ParentCollection!=null)
+ return m_ParentCollection.Parent;
+ return null;
+ }
+ }
+ #endregion
+
+ #region Public Methods
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Gets or sets whether button has design-time focus.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Focus
+ {
+ get {return m_Focus;}
+ set {m_Focus=value;}
+ }
+
+ ///
+ /// Sets the parent collection button belongs to.
+ ///
+ /// Parent collection of the item.
+ internal void SetParentCollection(BubbleButtonCollection value)
+ {
+ m_ParentCollection=value;
+ }
+
+ private void OnAppearanceChanged()
+ {
+ BubbleBar bar=this.GetBubbleBar();
+ if(bar==null)
+ return;
+ bar.Refresh();
+ }
+
+ private void OnImageIndexChanged()
+ {
+ BubbleBar bar=this.GetBubbleBar();
+ if(bar==null)
+ return;
+ if(m_ImageIndex>=0 && m_ImageCached==null)
+ {
+ if(bar.Images!=null && m_ImageIndex=0 && m_ImageLargeCached==null)
+ {
+ if(bar.ImagesLarge!=null && m_ImageIndexLarge
+ /// Returns the reference to the BubbleBar that contains this button.
+ ///
+ ///
+ public BubbleBar GetBubbleBar()
+ {
+ if(m_ParentCollection!=null && m_ParentCollection.Parent!=null && m_ParentCollection.Parent.Parent!=null)
+ return m_ParentCollection.Parent.Parent;
+ return null;
+ }
+
+ private void OnVisibleChanged()
+ {
+ BubbleBar bar=this.GetBubbleBar();
+ if(bar!=null)
+ bar.OnButtonVisibleChanged(this);
+ }
+
+ ///
+ /// Invokes button's Click event.
+ ///
+ /// Indicates source of the event.
+ public void InvokeClick(eEventSource source, MouseButtons mouseButton)
+ {
+ OnClick(new ClickEventArgs(source, mouseButton));
+ }
+
+ ///
+ /// Raises click event.
+ ///
+ /// Default event arguments.
+ protected virtual void OnClick(ClickEventArgs e)
+ {
+ if(Click!=null)
+ Click(this,e);
+
+ BubbleBar bar=this.GetBubbleBar();
+ if(bar!=null)
+ bar.InvokeButtonClick(this,e);
+ }
+
+ private Cursor _OldCursor = null;
+ private Cursor _Cursor = null;
+ ///
+ /// Gets or sets the mouse cursor that is displayed when mouse is over the button.
+ ///
+ [DefaultValue(null), Category("Appearance"), Description("Indciates mouse cursor that is displayed when mouse is over the button.")]
+ public Cursor Cursor
+ {
+ get { return _Cursor; }
+ set { _Cursor = value; }
+ }
+ #endregion
+
+ #region IBlock Interface
+ ///
+ /// Gets or sets the bounds of the content block.
+ ///
+ Rectangle DevComponents.UI.ContentManager.IBlock.Bounds
+ {
+ get {return m_DisplayRectangle;}
+ set {m_DisplayRectangle=value;}
+ }
+ private DevComponents.DotNetBar.Padding _Margin = new DevComponents.DotNetBar.Padding(0);
+ ///
+ /// Gets or sets item margin only used by certain items in certain containers. Provided only for internal DotNetBar use.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ DevComponents.DotNetBar.Padding DevComponents.UI.ContentManager.IBlock.Margin
+ {
+ get { return _Margin; }
+ set { _Margin = value; }
+ }
+ #endregion
+ }
+
+ #region Event Arguments and delegates
+ public delegate void ClickEventHandler(object sender, ClickEventArgs e);
+
+ ///
+ /// Represents event arguments for Click event.
+ ///
+ public class ClickEventArgs:EventArgs
+ {
+ ///
+ /// Gets the action that caused the event, event source.
+ ///
+ public readonly eEventSource EventSource=eEventSource.Code;
+ public readonly MouseButtons Button=MouseButtons.None;
+
+ public ClickEventArgs(eEventSource action, MouseButtons button)
+ {
+ this.EventSource=action;
+ this.Button=button;
+ }
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleButtonCollection.cs b/PROMS/DotNetBar Source Code/BubbleButtonCollection.cs
new file mode 100644
index 00000000..77841c0f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleButtonCollection.cs
@@ -0,0 +1,405 @@
+using System;
+using System.Collections;
+using System.Windows.Forms;
+using DevComponents.UI.ContentManager;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents typed collection of BubbleButton objects.
+ ///
+ public class BubbleButtonCollection:CollectionBase
+ {
+ #region Private Variables
+ private BubbleBarTab m_Parent=null;
+ private bool m_IgnoreEvents=false;
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Copies contained items to the IBlock array.
+ ///
+ /// Array to copy to.
+ internal void CopyTo(IBlock[] array)
+ {
+ List.CopyTo(array,0);
+ }
+
+ ///
+ /// Creates new instance of the collection.
+ ///
+ /// Parent of the collection.
+ internal BubbleButtonCollection(BubbleBarTab parent)
+ {
+ m_Parent=parent;
+ }
+
+ ///
+ /// Gets the parent of the collection.
+ ///
+ internal BubbleBarTab Parent
+ {
+ get {return m_Parent;}
+ }
+
+ ///
+ /// Adds new item to the collection but it does not raise internal events.
+ ///
+ /// New item to add.
+ /// Index of newly added item.
+ internal int _Add(BubbleButton item)
+ {
+ m_IgnoreEvents=true;
+ int i=0;
+ try
+ {
+ i=List.Add(item);
+ }
+ finally
+ {
+ m_IgnoreEvents=false;
+ }
+ return i;
+ }
+
+ ///
+ /// Adds new item to the collection at specified location but it does not raise internal events.
+ ///
+ /// New item to add.
+ /// Position to add item to.
+ internal void _Add(BubbleButton item, int Position)
+ {
+ m_IgnoreEvents=true;
+ try
+ {
+ List.Insert(Position,item);
+ }
+ finally
+ {
+ m_IgnoreEvents=false;
+ }
+ }
+
+ ///
+ /// Clears the collection but it does not raise internal events.
+ ///
+ internal void _Clear()
+ {
+ m_IgnoreEvents=true;
+ try
+ {
+ List.Clear();
+ }
+ finally
+ {
+ m_IgnoreEvents=false;
+ }
+ }
+
+ ///
+ /// Performs additional custom processes before setting a value in the CollectionBase instance.
+ ///
+ /// The zero-based index at which oldValue can be found.
+ /// The value to replace with newValue.
+ /// The new value of the element at index.
+ protected override void OnSet(int index,object oldValue,object newValue)
+ {
+ if(newValue==null)
+ throw new InvalidOperationException("Setting of null values to BubbleButtonCollection is not allowed.");
+
+ BubbleButton item=newValue as BubbleButton;
+ if(item.Parent!=null)
+ {
+ item.Parent.Buttons.Remove(item);
+ }
+
+ base.OnSet(index,oldValue,newValue);
+ }
+
+ ///
+ /// Performs additional custom processes after setting a value in the CollectionBase instance.
+ ///
+ /// The zero-based index at which oldValue can be found.
+ /// The value to replace with newValue.
+ /// The new value of the element at index.
+ protected override void OnSetComplete(int index,object oldValue,object newValue)
+ {
+ if(!m_IgnoreEvents)
+ {
+ BubbleButton item=newValue as BubbleButton;
+ item.SetParentCollection(this);
+ m_Parent.OnButtonInserted(item);
+ }
+ base.OnSetComplete(index,oldValue,newValue);
+ }
+
+ ///
+ /// Performs additional custom processes before inserting a new element into the CollectionBase instance.
+ ///
+ /// The zero-based index at which to insert value.
+ /// The new value of the element at index.
+ protected override void OnInsert(int index,object value)
+ {
+ BubbleButton item=value as BubbleButton;
+ if(item.Parent!=null && item.Parent!=this.Parent)
+ {
+ item.Parent.Buttons.Remove(item);
+ }
+ base.OnInsert(index,value);
+ }
+
+ ///
+ /// Performs additional custom processes after inserting a new element into the CollectionBase instance.
+ ///
+ /// The zero-based index at which to insert value.
+ /// The new value of the element at index.
+ protected override void OnInsertComplete(int index,object value)
+ {
+ if(!m_IgnoreEvents)
+ {
+ BubbleButton item=value as BubbleButton;
+ item.SetParentCollection(this);
+ m_Parent.OnButtonInserted(item);
+ }
+
+ base.OnInsertComplete(index,value);
+ }
+
+ ///
+ /// Performs additional custom processes when removing an element from the CollectionBase instance.
+ ///
+ /// The zero-based index at which value can be found.
+ /// The value of the element to remove from index.
+ protected override void OnRemove(int index,object value)
+ {
+// if(!m_IgnoreEvents)
+// {
+// BubbleButton item=value as BubbleButton;
+// }
+ base.OnRemove(index,value);
+ }
+
+ ///
+ /// Performs additional custom processes after removing an element from the CollectionBase instance.
+ ///
+ /// The zero-based index at which value can be found.
+ /// The value of the element to remove from index.
+ protected override void OnRemoveComplete(int index,object value)
+ {
+ if(!m_IgnoreEvents)
+ {
+ BubbleButton item=value as BubbleButton;
+ item.SetParentCollection(null);
+ m_Parent.OnButtonRemoved(item);
+ }
+
+ base.OnRemoveComplete(index,value);
+ }
+
+ ///
+ /// Removes an item without raising internal events.
+ ///
+ /// Item to remove.
+ internal void _Remove(BubbleButton item)
+ {
+ m_IgnoreEvents=true;
+ try{List.Remove(item);}
+ finally{m_IgnoreEvents=false;}
+ }
+
+ ///
+ /// Performs additional custom processes when clearing the contents of the CollectionBase instance.
+ ///
+ protected override void OnClear()
+ {
+ if(!m_IgnoreEvents)
+ {
+// if(List.Count>0)
+// {
+// foreach(BubbleButton objSub in this)
+// {
+// if(owner!=null)
+// owner.RemoveShortcutsFromItem(objSub);
+// }
+// }
+ if(m_Parent!=null)
+ {
+ m_Parent.OnButtonsCollectionClear();
+ }
+ }
+ base.OnClear();
+ }
+
+ ///
+ /// Copies the collection to the ArrayList object.
+ ///
+ /// Target ArrayList.
+ public void CopyTo(ArrayList list)
+ {
+ if(list==null)
+ return;
+ foreach(BubbleButton item in this)
+ list.Add(item);
+ }
+ #endregion
+
+ #region Public Interface
+ ///
+ /// Adds new item to the collection.
+ ///
+ /// New item to add.
+ /// Index of newly added item.
+ public virtual int Add(BubbleButton item)
+ {
+ return Add(item,-1);
+ }
+
+ ///
+ /// Adds new item to the collection at specified location.
+ ///
+ /// New item to add.
+ /// Position to insert item at. Position of -1 will append the item to the end of the collection.
+ /// Index of the newly added item.
+ public virtual int Add(BubbleButton item, int Position)
+ {
+ int iRet=Position;
+
+ if(Position>=0)
+ List.Insert(Position,item);
+ else
+ iRet=List.Add(item);
+
+ return iRet;
+ }
+
+ ///
+ /// Accesses items inside of the collection based on the index.
+ ///
+ public virtual BubbleButton this[int index]
+ {
+ get {return (BubbleButton)(List[index]);}
+ set {List[index] = value;}
+ }
+
+ ///
+ /// Accesses items inside of the collection based on the name.
+ ///
+ public virtual BubbleButton this[string name]
+ {
+ get {return (BubbleButton)(List[this.IndexOf(name)]);}
+ set {List[this.IndexOf(name)] = value;}
+ }
+
+ ///
+ /// Inserts new item at the specified position.
+ ///
+ /// Position to insert item at.
+ /// Item to insert.
+ public virtual void Insert(int index, BubbleButton item)
+ {
+ this.Add(item,index);
+ }
+
+ ///
+ /// Returns index of an item.
+ ///
+ /// Item to return index for.
+ /// Item at the specified position.
+ public virtual int IndexOf(BubbleButton value)
+ {
+ return List.IndexOf(value);
+ }
+
+ ///
+ /// Returns index of an item with given the item's name.
+ ///
+ /// Name of the item.
+ /// Index of the Item with the specified name or -1 if item is not found.
+ public virtual int IndexOf(string name)
+ {
+ int i=-1;
+ foreach(BubbleButton item in List)
+ {
+ i++;
+ if(item.Name==name)
+ return i;
+ }
+ return -1;
+ }
+
+ ///
+ /// Returns true if given item is contained by this collection.
+ ///
+ /// Item to test.
+ /// True if item is part of this collection otherwise false.
+ public virtual bool Contains(BubbleButton value)
+ {
+ return List.Contains(value);
+ }
+
+ ///
+ /// Returns true if item with given name is part of this collection.
+ ///
+ /// Item name.
+ /// True if item is part of this collection otherwise false.
+ public virtual bool Contains(string name)
+ {
+ foreach(BubbleButton item in List)
+ {
+ if(item.Name==name)
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Removes an item from the collection.
+ ///
+ /// Item to remove.
+ public virtual void Remove(BubbleButton item)
+ {
+ List.Remove(item);
+ }
+
+ ///
+ /// Removes an item from collection at specified index.
+ ///
+ /// Index of the item to remove.
+ public void Remove(int index)
+ {
+ this.Remove((BubbleButton)List[index]);
+ }
+
+ ///
+ /// Removes item from the collection with specified name.
+ ///
+ /// Name of the item to remove.
+ public virtual void Remove(string name)
+ {
+ this.Remove(this[name]);
+ }
+
+ ///
+ /// Adds array of the items to the collection.
+ ///
+ /// Array of items to add.
+ public virtual void AddRange(BubbleButton[] items)
+ {
+ foreach(BubbleButton item in items)
+ {
+ this.Add(item);
+ }
+ }
+
+ ///
+ /// Copy the collection to the array.
+ ///
+ /// Array to copy collection to.
+ /// The zero-based relative index in array at which copying begins.
+ public virtual void CopyTo(BubbleButton[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleButtonDisplay.cs b/PROMS/DotNetBar Source Code/BubbleButtonDisplay.cs
new file mode 100644
index 00000000..96ba9c39
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleButtonDisplay.cs
@@ -0,0 +1,231 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents class for displaying BubbleButton objects on canvas.
+ ///
+ internal class BubbleButtonDisplay
+ {
+ static int BUTTON_TOOLTIP_SPACING=3;
+ ///
+ /// Paints button on given canvas.
+ ///
+ /// Painting information.
+ public static void Paint(BubbleButtonDisplayInfo info)
+ {
+ if(!info.Button.Visible)
+ return;
+
+ CompositeImage image=null;
+ Rectangle buttonRectangle=Rectangle.Empty;
+ if(info.Magnified)
+ {
+ buttonRectangle=info.Button.MagnifiedDisplayRectangle;
+ image=GetButtonImage(info.Button,buttonRectangle.Size);
+ }
+ else
+ {
+ buttonRectangle=info.Button.DisplayRectangle;
+ image=GetButtonImage(info.Button,buttonRectangle.Size);
+ }
+
+ if (buttonRectangle.Width < 2 || buttonRectangle.Height < 2) return;
+
+ if(image!=null)
+ {
+ if(!info.Button.Enabled)
+ image.DrawImage(info.Graphics,buttonRectangle,0,0,image.ActualWidth,image.ActualHeight,GraphicsUnit.Pixel,GetDisabledAttributes());
+ else if(info.Button.MouseDown)
+ image.DrawImage(info.Graphics,buttonRectangle,0,0,image.ActualWidth,image.ActualHeight,GraphicsUnit.Pixel,GetDarkAttributes());
+ else
+ image.DrawImage(info.Graphics,buttonRectangle);
+ }
+ else
+ info.Graphics.DrawRectangle(SystemPens.Highlight,buttonRectangle);
+
+ if(info.Button.Focus)
+ {
+ buttonRectangle.Inflate(1,1);
+ DesignTime.DrawDesignTimeSelection(info.Graphics,buttonRectangle,Color.Navy);
+ }
+
+ DrawTooltip(info);
+ }
+
+ public static CompositeImage GetButtonImage(BubbleButton button, Size size)
+ {
+ CompositeImage image=null;
+ if(button.Image!=null)
+ {
+ if(button.Image.Size==size || button.ImageLarge==null)
+ image=new CompositeImage(button.Image,false,size);
+ else if(button.ImageLarge!=null && (button.ImageLarge.Size==size || button.ImageLarge.Size.Height/size.Height<2))
+ image=new CompositeImage(button.ImageLarge,false,size);
+ else
+ image=new CompositeImage(button.Image,false,size);
+ }
+ else if(button.ImageCached!=null)
+ {
+ if(button.ImageCached.Size==size || button.ImageLargeCached==null)
+ image=new CompositeImage(button.ImageCached,false,size);
+ else if(button.ImageLargeCached!=null && button.ImageLargeCached.Size.Height/size.Height<=2)
+ image=new CompositeImage(button.ImageLargeCached,false,size);
+ else
+ image=new CompositeImage(button.ImageCached,false,size);
+ }
+// else if(button.Icon!=null)
+// {
+//
+// }
+ return image;
+ }
+
+ private static void DrawTooltip(BubbleButtonDisplayInfo info)
+ {
+ //float emMulti=1.3285f;
+
+ if(info.Button.MouseOver && info.BubbleBar.ShowTooltips && info.Button.TooltipText!="")
+ {
+ Color textColor = info.BubbleBar.TooltipTextColor;
+ Color outlineColor = info.BubbleBar.TooltipOutlineColor;
+
+ StringFormat format = TextDrawing.GetStringFormat(eTextFormat.Default); // BarFunctions.CreateStringFormat();
+ System.Drawing.Drawing2D.CompositingMode cs=info.Graphics.CompositingMode=System.Drawing.Drawing2D.CompositingMode.SourceOver;
+ Font font=info.BubbleBar.TooltipFont;
+ if(font==null)
+ font=info.BubbleBar.Font;
+ Rectangle rText=info.Button.DisplayRectangle;
+
+ Size size = TextDrawing.MeasureString(info.Graphics, info.Button.TooltipText, font);
+
+ if(info.Magnified)
+ rText=info.Button.MagnifiedDisplayRectangle;
+ if(info.Alignment==eBubbleButtonAlignment.Bottom)
+ rText.Y-=(Math.Max(font.Height, size.Height)+BUTTON_TOOLTIP_SPACING);
+ else
+ rText.Y=rText.Bottom+BUTTON_TOOLTIP_SPACING;
+
+ rText.Offset(-(size.Width-rText.Width)/2,0);
+
+ Size tooltipSize = TextDrawing.MeasureString(info.Graphics, info.Button.TooltipText, font);
+ Rectangle outline = rText;
+ outline.Size = tooltipSize;
+ outline.Inflate(2, 2);
+ using (SolidBrush brush = new SolidBrush(Color.FromArgb(200, outlineColor)))
+ DisplayHelp.FillRoundedRectangle(info.Graphics, brush, outline, 3);
+ //Point pOutline=rText.Location;
+ //pOutline.Offset(-1,0);
+ //GraphicsPath path=new GraphicsPath();
+ //path.AddString(info.Button.TooltipText,font.FontFamily,(int)font.Style,font.SizeInPoints/*font.SizeInPoints*emMulti*/,new PointF((pOutline.X+1)*72/info.Graphics.DpiX,(pOutline.Y-1)*72/info.Graphics.DpiY),format);
+ //using(Pen pen=new Pen(outlineColor,(font.SizeInPoints>=10?1:1)))
+ // path.Widen(pen);
+ //using(SolidBrush brush=new SolidBrush(Color.FromArgb(200,outlineColor)))
+ //{
+ // GraphicsUnit pageUnit=info.Graphics.PageUnit;
+ // info.Graphics.PageUnit=GraphicsUnit.Point;
+ // info.Graphics.FillPath(brush,path);
+ // info.Graphics.PageUnit=pageUnit;
+ //}
+
+ //path.Dispose();
+ //path=new GraphicsPath();
+ //path.AddString(info.Button.TooltipText,font.FontFamily,(int)font.Style,font.SizeInPoints/*font.SizeInPoints*emMulti*/,new PointF(pOutline.X*72/info.Graphics.DpiX,pOutline.Y*72/info.Graphics.DpiY),format);
+ //path.Widen(SystemPens.ControlText);
+ //using(SolidBrush brush=new SolidBrush(Color.FromArgb(200,outlineColor)))
+ //{
+ // GraphicsUnit pageUnit=info.Graphics.PageUnit;
+ // info.Graphics.PageUnit=GraphicsUnit.Point;
+ // info.Graphics.FillPath(brush,path);
+ // info.Graphics.PageUnit=pageUnit;
+ //}
+ //path.Dispose();
+
+ TextDrawing.DrawString(info.Graphics,info.Button.TooltipText,font,textColor,rText.X,rText.Y,eTextFormat.Default);
+
+ info.Graphics.CompositingMode=cs;
+ format.Dispose();
+ }
+ }
+
+ private static ImageAttributes GetDarkAttributes()
+ {
+ float[][] array = new float[5][];
+// array[0] = new float[5] {1, 0, 0, 0, 0};
+// array[1] = new float[5] {0, 1, 0, 0, 0};
+// array[2] = new float[5] {0, 0, 1, 0, 0};
+// array[3] = new float[5] {0, 0, 1, 0, 0};
+// array[4] = new float[5] {.5f, .5f, .5f, 0, 1};
+ array[0] = new float[5] {.65f, 0, 0, 0, 0};
+ array[1] = new float[5] {0, .65f, 0, 0, 0};
+ array[2] = new float[5] {0, 0, .65f, 0, 0};
+ array[3] = new float[5] {0, 0, 0, 1, 0};
+ array[4] = new float[5] {0, 0, 0, 0, .65f};
+ ColorMatrix grayMatrix = new ColorMatrix(array);
+ ImageAttributes darkImageAttr = new ImageAttributes();
+ darkImageAttr.ClearColorKey();
+ darkImageAttr.SetColorMatrix(grayMatrix);
+ return darkImageAttr;
+ }
+
+ private static ImageAttributes GetDisabledAttributes()
+ {
+ float[][] array = new float[5][];
+ array[0] = new float[5] {0.5f, 0.5f, 0.5f, 0.0f, 0.0f};
+ array[1] = new float[5] {0.5f, 0.5f, 0.5f, 0.0f, 0.0f};
+ array[2] = new float[5] {0.5f, 0.5f, 0.5f, 0.0f, 0.0f};
+ array[3] = new float[5] {0.0f, 0.0f, 0.0f, 1.0f, 0.0f};
+ array[4] = new float[5] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
+ //ColorMatrix grayMatrix = new ColorMatrix(array);
+ ColorMatrix grayMatrix = new ColorMatrix();
+ grayMatrix.Matrix00 = 1/3f;
+ grayMatrix.Matrix01 = 1/3f;
+ grayMatrix.Matrix02 = 1/3f;
+ grayMatrix.Matrix10 = 1/3f;
+ grayMatrix.Matrix11 = 1/3f;
+ grayMatrix.Matrix12 = 1/3f;
+ grayMatrix.Matrix20 = 1/3f;
+ grayMatrix.Matrix21 = 1/3f;
+ grayMatrix.Matrix22 = 1/3f;
+ grayMatrix.Matrix33 = .5f; // Alpha-channel
+
+ ImageAttributes darkImageAttr = new ImageAttributes();
+ darkImageAttr.ClearColorKey();
+ darkImageAttr.SetColorMatrix(grayMatrix);
+ return darkImageAttr;
+ }
+ }
+
+ #region BubbleButtonDisplayInfo
+ ///
+ /// Represents class that holds information for BubbleButton painting.
+ ///
+ public class BubbleButtonDisplayInfo
+ {
+ ///
+ /// Graphics object.
+ ///
+ public Graphics Graphics=null;
+ ///
+ /// Button to paint.
+ ///
+ public BubbleButton Button=null;
+ ///
+ /// Reference to BubbleBar control.
+ ///
+ public BubbleBar BubbleBar=null;
+ ///
+ /// Gets or sets whether magnified version of the button is painted.
+ ///
+ public bool Magnified=false;
+ ///
+ /// Gets or sets the button alignment inside of the bar.
+ ///
+ public eBubbleButtonAlignment Alignment=eBubbleButtonAlignment.Bottom;
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleButtonLayoutManager.cs b/PROMS/DotNetBar Source Code/BubbleButtonLayoutManager.cs
new file mode 100644
index 00000000..d10041c0
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleButtonLayoutManager.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections;
+using System.Drawing;
+using DevComponents.UI.ContentManager;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents class for default layout of the BubbleButton objects.
+ ///
+ public class BubbleButtonLayoutManager:BlockLayoutManager
+ {
+ ///
+ /// Creates new instance of the class.
+ ///
+ public BubbleButtonLayoutManager()
+ {
+ }
+
+ ///
+ /// Resizes the content block and sets it's Bounds property to reflect new size.
+ ///
+ /// Content block to resize.
+ public override void Layout(IBlock block, Size availableSize)
+ {
+ BubbleButton button=block as BubbleButton;
+ BubbleBar bar=button.GetBubbleBar();
+ if(bar==null)
+ {
+ if(button.Site!=null && button.Site.DesignMode)
+ return;
+ throw new InvalidOperationException("BubbleBar object could not be found for button named: '"+button.Name+"' in BubbleButtonLayoutManager.Layout");
+ }
+ Size defaultSize=Dpi.ImageSize(bar.ImageSizeNormal);
+ button.SetDisplayRectangle(new Rectangle(button.DisplayRectangle.Location,defaultSize));
+ }
+
+ public override Rectangle FinalizeLayout(Rectangle containerBounds, Rectangle blocksBounds, ArrayList lines)
+ {
+ return (blocksBounds);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BubbleContentManager.cs b/PROMS/DotNetBar Source Code/BubbleContentManager.cs
new file mode 100644
index 00000000..e83edfee
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BubbleContentManager.cs
@@ -0,0 +1,302 @@
+using System;
+using System.Drawing;
+using DevComponents.UI.ContentManager;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents class that provides mangification for the BubbleMar control
+ ///
+ public class BubbleContentManager:SerialContentLayoutManager
+ {
+ #region Private Variables
+ private Size m_BubbleSize=Size.Empty;
+ private float m_Factor1=0,m_Factor2=0,m_Factor3=0,m_Factor4=0;
+ private int m_MouseOverIndex=-1;
+ private int m_MouseOverPosition=-1;
+ #endregion
+
+ public BubbleContentManager()
+ {
+ this.ContentAlignment=eContentAlignment.Center;
+ }
+
+ #region IContentLayout
+
+ ///
+ /// Performs layout of the content block.
+ ///
+ /// Container bounds to layout content blocks in.
+ /// Content blocks to layout.
+ /// Block layout manager that resizes the content blocks.
+ /// The bounds of the content blocks within the container bounds.
+ public override Rectangle Layout(Rectangle containerBounds,IBlock[] contentBlocks,BlockLayoutManager blockLayout)
+ {
+ if(contentBlocks.Length==0)
+ return Rectangle.Empty;
+
+ if(m_MouseOverIndex==-1)
+ {
+ return base.Layout(containerBounds,contentBlocks,blockLayout);
+ }
+
+ BubbleButton[] buttons=new BubbleButton[contentBlocks.Length];
+ contentBlocks.CopyTo(buttons,0);
+
+ int x=0,y=0;
+ if(this.ContentOrientation==eContentOrientation.Horizontal)
+ {
+ buttons[m_MouseOverIndex].SetMagnifiedDisplayRectangle(new Rectangle(m_MouseOverPosition,GetY(containerBounds,m_BubbleSize.Height),m_BubbleSize.Width,m_BubbleSize.Height));
+ x=m_MouseOverPosition;
+ }
+ else
+ {
+ buttons[m_MouseOverIndex].SetMagnifiedDisplayRectangle(new Rectangle(GetX(containerBounds,m_BubbleSize.Width),m_MouseOverPosition,m_BubbleSize.Width,m_BubbleSize.Height));
+ y=m_MouseOverPosition;
+ }
+
+ int growthWidth=m_BubbleSize.Width-contentBlocks[0].Bounds.Width;
+ int growthHeight=m_BubbleSize.Height-contentBlocks[0].Bounds.Height;
+
+ // Apply factor 2
+ int index=GetPreviousButtonIndex(buttons,m_MouseOverIndex);
+ if(index>=0)
+ SetFactorPrevious(containerBounds,buttons[index],growthWidth,growthHeight,m_Factor2,ref x, ref y);
+
+ // Apply factor 1
+ index=GetPreviousButtonIndex(buttons,index);
+ if(index>=0)
+ SetFactorPrevious(containerBounds,buttons[index],growthWidth,growthHeight,m_Factor1,ref x, ref y);
+
+ if(this.ContentOrientation==eContentOrientation.Horizontal)
+ {
+ while(index>=0)
+ {
+ index=GetPreviousButtonIndex(buttons,index);
+ if(index>=0)
+ {
+ x-=(buttons[index].DisplayRectangle.Width+this.BlockSpacing);
+ buttons[index].SetMagnifiedDisplayRectangle(new Rectangle(x,buttons[index].DisplayRectangle.Y,buttons[index].DisplayRectangle.Width,buttons[index].DisplayRectangle.Height));
+ }
+ }
+ x=m_MouseOverPosition+m_BubbleSize.Width+this.BlockSpacing;
+ }
+ else
+ {
+ while(index>=0)
+ {
+ index=GetPreviousButtonIndex(buttons,index);
+ if(index>=0)
+ {
+ y-=(buttons[index].DisplayRectangle.Height+this.BlockSpacing);
+ buttons[index].SetMagnifiedDisplayRectangle(new Rectangle(buttons[index].DisplayRectangle.X,y,buttons[index].DisplayRectangle.Width,buttons[index].DisplayRectangle.Height));
+ }
+ }
+
+ y=m_MouseOverPosition+m_BubbleSize.Height+this.BlockSpacing;
+ }
+
+ // Apply factor 3
+ index=GetNextButtonIndex(buttons,m_MouseOverIndex);
+ if(index>=0)
+ SetFactorNext(containerBounds,buttons[index],growthWidth,growthHeight,m_Factor3,ref x, ref y);
+
+ // Apply factor 4
+ if(index==-1) index=m_MouseOverIndex;
+ index=GetNextButtonIndex(buttons,index);
+ if(index>=0)
+ SetFactorNext(containerBounds,buttons[index],growthWidth,growthHeight,m_Factor4,ref x, ref y);
+
+ if(this.ContentOrientation==eContentOrientation.Horizontal)
+ {
+ while(index>=0)
+ {
+ index=GetNextButtonIndex(buttons,index);
+ if(index>=0)
+ {
+ buttons[index].SetMagnifiedDisplayRectangle(new Rectangle(x,buttons[index].DisplayRectangle.Y,buttons[index].DisplayRectangle.Width,buttons[index].DisplayRectangle.Height));
+ x+=(buttons[index].DisplayRectangle.Width+this.BlockSpacing);
+ }
+ }
+ }
+ else
+ {
+ while(index>=0)
+ {
+ index=GetNextButtonIndex(buttons,index);
+ if(index>=0)
+ {
+ buttons[index].SetMagnifiedDisplayRectangle(new Rectangle(buttons[index].DisplayRectangle.X,y,buttons[index].DisplayRectangle.Width,buttons[index].DisplayRectangle.Height));
+ y+=(buttons[index].DisplayRectangle.Height+this.BlockSpacing);
+ }
+ }
+ }
+
+ if(buttons.Length==1)
+ return buttons[0].MagnifiedDisplayRectangle;
+
+ return Rectangle.Union(buttons[0].MagnifiedDisplayRectangle,buttons[buttons.Length-1].MagnifiedDisplayRectangle);
+ }
+
+ private void SetFactorPrevious(Rectangle containerBounds, BubbleButton button, int growthWidth, int growthHeight, float factor, ref int x, ref int y)
+ {
+ int w=(int)(button.DisplayRectangle.Width+growthWidth*factor);
+ int h=(int)(button.DisplayRectangle.Height+growthHeight*factor);
+ if(this.ContentOrientation==eContentOrientation.Horizontal)
+ {
+ x-=(w+this.BlockSpacing);
+ button.SetMagnifiedDisplayRectangle(new Rectangle(x,GetY(containerBounds,h),w,h));
+ }
+ else
+ {
+ y-=(h+this.BlockSpacing);
+ button.SetMagnifiedDisplayRectangle(new Rectangle(GetX(containerBounds,w),y,w,h));
+ }
+ }
+
+ private void SetFactorNext(Rectangle containerBounds, BubbleButton button, int growthWidth, int growthHeight, float factor, ref int x, ref int y)
+ {
+ int w=(int)(button.DisplayRectangle.Width+growthWidth*factor);
+ int h=(int)(button.DisplayRectangle.Height+growthHeight*factor);
+ if(this.ContentOrientation==eContentOrientation.Horizontal)
+ {
+ button.SetMagnifiedDisplayRectangle(new Rectangle(x,GetY(containerBounds,h),w,h));
+ x+=(w+this.BlockSpacing);
+ }
+ else
+ {
+ button.SetMagnifiedDisplayRectangle(new Rectangle(GetX(containerBounds,w),y,w,h));
+ y+=(h+this.BlockSpacing);
+ }
+ }
+
+ private int GetNextButtonIndex(BubbleButton[] buttons, int index)
+ {
+ int next=-1;
+ for(int i=index+1;i=0;i--)
+ {
+ if(buttons[i].Visible)
+ {
+ next=i;
+ break;
+ }
+ }
+ return next;
+ }
+
+ private int GetX(Rectangle containerBounds, int width)
+ {
+ if(this.ContentOrientation==eContentOrientation.Vertical)
+ {
+ if(this.ContentVerticalAlignment==eContentVerticalAlignment.Top)
+ return containerBounds.Left;
+ else if(this.ContentVerticalAlignment==eContentVerticalAlignment.Middle)
+ return containerBounds.Left+(containerBounds.Width-width)/2;
+ else if(this.ContentVerticalAlignment==eContentVerticalAlignment.Bottom)
+ return containerBounds.Right-width;
+ }
+ else
+ throw new InvalidOperationException("Cannot use GetX method on eContentOrientation.Horizontal");
+ return -1;
+ }
+
+ private int GetY(Rectangle containerBounds, int height)
+ {
+ if(this.ContentOrientation==eContentOrientation.Horizontal)
+ {
+ if(this.ContentVerticalAlignment==eContentVerticalAlignment.Top)
+ return containerBounds.Top;
+ else if(this.ContentVerticalAlignment==eContentVerticalAlignment.Middle)
+ return containerBounds.Top+(containerBounds.Height-height)/2;
+ else if(this.ContentVerticalAlignment==eContentVerticalAlignment.Bottom)
+ return containerBounds.Bottom-height;
+ }
+ else
+ throw new InvalidOperationException("Cannot use GetX method on eContentOrientation.Vertical");
+ return -1;
+ }
+ #endregion
+
+ #region Public Properties
+
+ ///
+ /// Gets or sets the bubble size for the mouse over item.
+ ///
+ public Size BubbleSize
+ {
+ get {return m_BubbleSize;}
+ set {m_BubbleSize=value;}
+ }
+
+ ///
+ /// Gets or sets magnification factor for the item that is at the position MouseOverIndex-1
+ ///
+ public float Factor1
+ {
+ get {return m_Factor1;}
+ set {m_Factor1=value;}
+ }
+
+ ///
+ /// Gets or sets magnification factor for the item that is at the position MouseOverIndex-2
+ ///
+ public float Factor2
+ {
+ get {return m_Factor2;}
+ set {m_Factor2=value;}
+ }
+
+ ///
+ /// Gets or sets magnification factor for the item that is at the position MouseOverIndex+1
+ ///
+ public float Factor3
+ {
+ get {return m_Factor3;}
+ set {m_Factor3=value;}
+ }
+
+ ///
+ /// Gets or sets magnification factor for the item that is at the position MouseOverIndex+2
+ ///
+ public float Factor4
+ {
+ get {return m_Factor4;}
+ set {m_Factor4=value;}
+ }
+
+ ///
+ /// Gets or sets the index of the item mouse is over.
+ ///
+ public int MouseOverIndex
+ {
+ get {return m_MouseOverIndex;}
+ set {m_MouseOverIndex=value;}
+ }
+
+ ///
+ /// Gets or sets new X coordinate of the mouse over item when in horizontal layout or Y
+ /// coordinate when in vertical layout.
+ ///
+ public int MouseOverPosition
+ {
+ get {return m_MouseOverPosition;}
+ set {m_MouseOverPosition=value;}
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/BufferedBitmap.cs b/PROMS/DotNetBar Source Code/BufferedBitmap.cs
new file mode 100644
index 00000000..15c049a9
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/BufferedBitmap.cs
@@ -0,0 +1,123 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace DevComponents.DotNetBar
+{
+ public class BufferedBitmap : IDisposable
+ {
+ #region Private Variables
+ private Rectangle m_TargetRect = Rectangle.Empty;
+ private IntPtr m_MemDC = IntPtr.Zero;
+ private Graphics m_BitmapGraphics = null;
+ private IntPtr m_MemDib = IntPtr.Zero;
+ #endregion
+
+ #region Internal Implementation
+ public BufferedBitmap(Graphics source, Rectangle rect)
+ {
+ IntPtr hdc = source.GetHdc();
+ try
+ {
+ Initialize(hdc, rect);
+ }
+ finally
+ {
+ source.ReleaseHdc(hdc);
+ }
+ }
+
+ public Graphics Graphics
+ {
+ get
+ {
+ return m_BitmapGraphics;
+ }
+ }
+
+ public BufferedBitmap(IntPtr hdcSource, Rectangle rect)
+ {
+ Initialize(hdcSource, rect);
+ }
+ private void Initialize(IntPtr hdcSource, Rectangle r)
+ {
+ m_TargetRect = r;
+
+ m_MemDC = WinApi.CreateCompatibleDC(hdcSource);
+ WinApi.BITMAPINFO info = new WinApi.BITMAPINFO();
+ info.biWidth = r.Width;
+ info.biHeight = r.Height;
+ info.biPlanes = 1;
+ info.biBitCount = 32;
+ info.biSize = Marshal.SizeOf(info);
+ m_MemDib = WinApi.CreateDIBSection(hdcSource, info, 0, 0, IntPtr.Zero, 0);
+ WinApi.SelectObject(m_MemDC, m_MemDib);
+ m_BitmapGraphics = Graphics.FromHdc(m_MemDC);
+ }
+
+ public void Render(Graphics targetGraphics)
+ {
+ Render(targetGraphics, new Rectangle[] { });
+ }
+
+ public void Render(Graphics targetGraphics, Rectangle exclude)
+ {
+ Render(targetGraphics, new Rectangle[] { exclude });
+ }
+
+ public void Render(Graphics targetGraphics, Rectangle[] excludeArr)
+ {
+ const int SRCCOPY = 0x00CC0020;
+ IntPtr hdc = targetGraphics.GetHdc();
+ try
+ {
+ if (excludeArr!=null && excludeArr.Length > 0)
+ {
+ foreach (Rectangle r in excludeArr)
+ {
+ if (!r.IsEmpty)
+ WinApi.ExcludeClipRect(hdc, r.X, r.Y, r.Right, r.Bottom);
+ }
+ }
+ WinApi.BitBlt(hdc, m_TargetRect.Left, m_TargetRect.Top, m_TargetRect.Width, m_TargetRect.Height, m_MemDC, 0, 0, SRCCOPY);
+ }
+ finally
+ {
+ targetGraphics.ReleaseHdc(hdc);
+ }
+ }
+
+ public Rectangle TargetRect
+ {
+ get { return m_TargetRect; }
+ set { m_TargetRect = value; }
+ }
+ #endregion
+
+ #region IDisposable Members
+
+ public void Dispose()
+ {
+ if (m_BitmapGraphics != null)
+ {
+ m_BitmapGraphics.Dispose();
+ m_BitmapGraphics = null;
+ }
+
+ if (m_MemDib != IntPtr.Zero)
+ {
+ WinApi.DeleteObject(m_MemDib);
+ m_MemDib = IntPtr.Zero;
+ }
+
+ if (m_MemDC != IntPtr.Zero)
+ {
+ WinApi.DeleteDC(m_MemDC);
+ m_MemDC = IntPtr.Zero;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ButtonItem.cs b/PROMS/DotNetBar Source Code/ButtonItem.cs
new file mode 100644
index 00000000..85ac7eef
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ButtonItem.cs
@@ -0,0 +1,6512 @@
+using System.ComponentModel;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Controls;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for ButtonItem.
+ ///
+ [System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), DefaultEvent("Click"), Designer("DevComponents.DotNetBar.Design.BaseItemDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class ButtonItem : PopupItem, IPersonalizedMenuItem
+ {
+ #region Events
+ ///
+ /// Occurs when Checked property has changed.
+ ///
+ public event EventHandler CheckedChanged;
+ ///
+ /// Occurs before an item in option group is checked and provides opportunity to cancel that.
+ ///
+ [Description("Occurs before an item in option group is checked and provides opportunity to cancel that.")]
+ public event OptionGroupChangingEventHandler OptionGroupChanging;
+ #endregion
+
+ #region Private Variables
+ private const int STATEBUTTON_SPACING = 3;
+ private System.Drawing.Image m_Image;
+ private System.Drawing.Image m_ImageSmall;
+ private int m_ImageIndex; // Image index if image from ImageList is used
+ private System.Drawing.Image m_HoverImage;
+ private int m_HoverImageIndex; // Image index if image from ImageList is used
+ private System.Drawing.Image m_DisabledImage;
+ private bool m_DisabledImageCustom = false;
+ private int m_DisabledImageIndex; // Image index if image from ImageList is used
+ private System.Drawing.Icon m_DisabledIcon = null;
+ private System.Drawing.Image m_PressedImage;
+ private int m_PressedImageIndex; // Image index if image from ImageList is used
+ private eButtonStyle m_ButtonStyle;
+ private eImagePosition m_ImagePosition;
+ private Font m_Font;
+
+ private string m_AlternateShortcutText;
+
+ private bool m_MouseOver = false;
+ private bool m_MouseOverExpand = false;
+ private bool m_MouseDown;
+
+ private bool m_Checked;
+
+ private Rectangle m_ImageDrawRect;
+ private Rectangle m_TextDrawRect;
+ private Rectangle m_SubItemsRect;
+ private int m_VerticalPadding;
+ private int m_HorizontalPadding;
+
+ private Color m_ForeColor = System.Drawing.Color.Empty;
+ private Color m_HotForeColor = System.Drawing.Color.Empty;
+ private bool m_HotFontUnderline = false;
+ private bool m_HotFontBold = false;
+ private bool m_FontBold = false;
+ private bool m_FontItalic = false;
+ private bool m_FontUnderline = false;
+
+ // IPersonalizedMenuItem Implementation
+ private eMenuVisibility m_MenuVisibility = eMenuVisibility.VisibleAlways;
+ private bool m_RecentlyUsed = false;
+ private eHotTrackingStyle m_HotTrackingStyle = eHotTrackingStyle.Default;
+ private System.Drawing.Image m_ImageCachedIdx = null;
+ private ItemPaintArgs _ItemPaintArgs = null;
+ private int m_SubItemsExpandWidth = 12;
+ private string m_OptionGroup = "";
+ private Size m_ImageSizeOverride = Size.Empty;
+
+ internal bool _FitContainer = false;
+
+ System.Drawing.Icon m_Icon = null;
+ private bool m_AutoExpandOnClick = false;
+
+ private eButtonColor m_ColorTable = eButtonColor.Orange; private string m_CashedColorName = "Orange";
+
+ private int m_ImagePaddingHorizontal = 8;
+ private int m_ImagePaddingVertical = 6;
+ private string m_CustomColorName = "";
+ private Size m_FixedSize = Size.Empty;
+ private bool m_SplitButton = false;
+ private bool m_IgnoreAlpha = false;
+ private int m_MouseOverFadeAlphaIncrement = 65;
+ private int m_PulseFadeAlphaIncrement = 12;
+ private bool m_Pulse = false;
+ private int m_PulseBeats = 0, m_PulseCount = 0;
+ private bool m_StopPulseOnMouseOver = true;
+ private bool m_RibbonWordWrap = true;
+ private bool m_AutoCheckOnClick = false;
+ private bool m_UseSmallImage = false;
+ internal bool _FixedSizeCenterText = false;
+ #endregion
+
+ #region Constructor, Copy
+ ///
+ /// Creates new instance of ButtonItem.
+ ///
+ public ButtonItem() : this("", "") { }
+ ///
+ /// Creates new instance of ButtonItem and assigns the name to it.
+ ///
+ /// Item name.
+ public ButtonItem(string sItemName) : this(sItemName, "") { }
+ ///
+ /// Creates new instance of ButtonItem and assigns the name and text to it.
+ ///
+ /// Item name.
+ /// item text.
+ public ButtonItem(string sItemName, string ItemText)
+ : base(sItemName, ItemText)
+ {
+ m_IsContainer = false;
+ m_Image = null;
+ m_ImageIndex = -1;
+ m_HoverImage = null;
+ m_HoverImageIndex = -1;
+ m_DisabledImage = null;
+ m_DisabledImageIndex = -1;
+ m_PressedImage = null;
+ m_PressedImageIndex = -1;
+ m_MouseOver = false;
+ m_MouseDown = false;
+ m_ButtonStyle = eButtonStyle.Default;
+ m_ImagePosition = eImagePosition.Left;
+ m_Font = null;
+ m_ImageDrawRect = Rectangle.Empty;
+ m_TextDrawRect = Rectangle.Empty;
+ m_SubItemsRect = Rectangle.Empty;
+ m_VerticalPadding = 0;
+ m_HorizontalPadding = 0;
+ m_AlternateShortcutText = "";
+ }
+
+ ///
+ /// Returns copy of the item.
+ ///
+ public override BaseItem Copy()
+ {
+ ButtonItem objCopy = new ButtonItem(m_Name);
+ this.CopyToItem(objCopy);
+ return objCopy;
+ }
+
+ ///
+ /// Copies the ButtonItem specific properties to new instance of the item.
+ ///
+ /// New ButtonItem instance.
+ internal void InternalCopyToItem(ButtonItem copy)
+ {
+ CopyToItem((BaseItem)copy);
+ }
+
+ ///
+ /// Copies the ButtonItem specific properties to new instance of the item.
+ ///
+ /// New ButtonItem instance.
+ protected override void CopyToItem(BaseItem copy)
+ {
+ ButtonItem objCopy = copy as ButtonItem;
+ base.CopyToItem(objCopy);
+
+ if (m_Image != null)
+ objCopy.Image = (Image)m_Image.Clone();
+ if (m_ImageSmall != null)
+ objCopy.ImageSmall = (Image)m_ImageSmall.Clone();
+ if (m_HoverImage != null)
+ objCopy.HoverImage = (Image)m_HoverImage.Clone();
+ if (m_PressedImage != null)
+ objCopy.PressedImage = (Image)m_PressedImage.Clone();
+ if (m_DisabledImage != null && m_DisabledImageCustom)
+ objCopy.DisabledImage = (Image)m_DisabledImage.Clone();
+ if (m_Icon != null)
+ objCopy.Icon = m_Icon.Clone() as Icon;
+
+ objCopy.ButtonStyle = m_ButtonStyle;
+ //objCopy.ButtonType=m_ButtonType;
+ objCopy.ImagePosition = m_ImagePosition;
+ objCopy.OptionGroup = m_OptionGroup;
+ objCopy.Checked = m_Checked;
+ objCopy.PopupType = this.PopupType;
+ objCopy.AlternateShortCutText = this.AlternateShortCutText;
+
+ if (m_ImageIndex >= 0)
+ objCopy.SetImageIndex(m_ImageIndex);
+ if (m_PressedImageIndex >= 0)
+ objCopy.PressedImageIndex = m_PressedImageIndex;
+ if (m_HoverImageIndex >= 0)
+ objCopy.HoverImageIndex = m_HoverImageIndex;
+ if (m_DisabledImageIndex >= 0)
+ objCopy.DisabledImageIndex = m_DisabledImageIndex;
+
+ if (!m_ForeColor.IsEmpty)
+ objCopy.ForeColor = m_ForeColor;
+
+ objCopy.HotFontBold = m_HotFontBold;
+ objCopy.HotFontUnderline = m_HotFontUnderline;
+
+ if (!m_HotForeColor.IsEmpty)
+ objCopy.HotForeColor = m_HotForeColor;
+
+ objCopy.HotTrackingStyle = m_HotTrackingStyle;
+ objCopy.MenuVisibility = m_MenuVisibility;
+ objCopy.AutoExpandOnClick = this.AutoExpandOnClick;
+ objCopy.AlternateShortCutText = this.AlternateShortCutText;
+ objCopy.SubItemsExpandWidth = this.SubItemsExpandWidth;
+ objCopy.CheckedChanged = this.CheckedChanged;
+ objCopy.OptionGroupChanging = this.OptionGroupChanging;
+
+ if (!this.ImageFixedSize.IsEmpty)
+ objCopy.ImageFixedSize = this.ImageFixedSize;
+
+ objCopy.ImagePaddingHorizontal = m_ImagePaddingHorizontal;
+ objCopy.ImagePaddingVertical = m_ImagePaddingVertical;
+ objCopy.FixedSize = this.FixedSize;
+ objCopy.RibbonWordWrap = this.RibbonWordWrap;
+ objCopy.AutoCheckOnClick = this.AutoCheckOnClick;
+
+ if (this.Shape != null)
+ objCopy.Shape = this.Shape;
+
+ objCopy.ColorTable = this.ColorTable;
+ objCopy.CustomColorName = this.CustomColorName;
+ objCopy.AutoExpandMenuItem = this.AutoExpandMenuItem;
+
+ objCopy.EnableMarkup = this.EnableMarkup;
+ objCopy.SplitButton = this.SplitButton;
+
+ objCopy.NotificationMarkColor = this.NotificationMarkColor;
+ objCopy.NotificationMarkPosition = this.NotificationMarkPosition;
+ objCopy.NotificationMarkSize = this.NotificationMarkSize;
+ objCopy.NotificationMarkText = this.NotificationMarkText;
+
+ objCopy.Symbol = this.Symbol;
+ objCopy.SymbolSet = this.SymbolSet;
+ objCopy.SymbolColor = this.SymbolColor;
+ objCopy.SymbolSize = this.SymbolSize;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ StopFade();
+ StopPulse();
+ StopImageAnimation();
+ DisposeMouseOverFont();
+ DisposedCachedImageListImage();
+ if (BarUtilities.DisposeItemImages && !this.DesignMode || _AutoDisposeImages)
+ {
+ BarUtilities.DisposeImage(ref m_Image);
+ BarUtilities.DisposeImage(ref m_Icon);
+ BarUtilities.DisposeImage(ref m_ImageSmall);
+ BarUtilities.DisposeImage(ref m_HoverImage);
+ BarUtilities.DisposeImage(ref m_DisabledImage);
+ BarUtilities.DisposeImage(ref m_PressedImage);
+ BarUtilities.DisposeImage(ref m_DisabledIcon);
+ }
+ base.Dispose(disposing);
+ }
+
+ private void DisposedCachedImageListImage()
+ {
+ if (m_ImageCachedIdx != null) m_ImageCachedIdx.Dispose();
+ m_ImageCachedIdx = null;
+ }
+ private ButtonItemAccessibleObject _ButtonItemAccessibleObject = null;
+ protected override System.Windows.Forms.AccessibleObject CreateAccessibilityInstance()
+ {
+ if (_ButtonItemAccessibleObject == null)
+ _ButtonItemAccessibleObject = new ButtonItemAccessibleObject(this);
+ return _ButtonItemAccessibleObject;
+ }
+
+ private bool _AutoDisposeImages = false;
+ ///
+ /// Indicates whether images assigned to the button are disposed when button is disposed. Default value is false.
+ ///
+ [DefaultValue(false), Category("Behavior"), Description("Indicates whether images assigned to the button are disposed when button is disposed. Default value is false.")]
+ public bool AutoDisposeImages
+ {
+ get
+ {
+ return _AutoDisposeImages;
+ }
+ set
+ {
+ _AutoDisposeImages = value;
+ }
+ }
+
+ #endregion
+
+ #region Serialization
+ ///
+ /// Overloaded. Serializes the item and all sub-items into the XmlElement.
+ ///
+ /// XmlElement to serialize the item to.
+ protected internal override void Serialize(ItemSerializationContext context)
+ {
+ base.Serialize(context);
+ System.Xml.XmlElement ThisItem = context.ItemXmlElement;
+ ThisItem.SetAttribute("ImagePosition", System.Xml.XmlConvert.ToString(((int)m_ImagePosition)));
+ ThisItem.SetAttribute("ButtonStyle", System.Xml.XmlConvert.ToString(((int)m_ButtonStyle)));
+ ThisItem.SetAttribute("Checked", System.Xml.XmlConvert.ToString(m_Checked));
+ ThisItem.SetAttribute("VerticalPadding", System.Xml.XmlConvert.ToString(m_VerticalPadding));
+ ThisItem.SetAttribute("HorizontalPadding", System.Xml.XmlConvert.ToString(m_HorizontalPadding));
+
+ ThisItem.SetAttribute("MenuVisibility", System.Xml.XmlConvert.ToString((int)m_MenuVisibility));
+ ThisItem.SetAttribute("RecentlyUsed", System.Xml.XmlConvert.ToString(m_RecentlyUsed));
+
+ if (m_AlternateShortcutText != "")
+ ThisItem.SetAttribute("AlternateShortcutText", m_AlternateShortcutText);
+
+ if (!m_ForeColor.IsEmpty)
+ ThisItem.SetAttribute("forecolor", BarFunctions.ColorToString(m_ForeColor));
+
+ if (m_HotTrackingStyle != eHotTrackingStyle.Default)
+ ThisItem.SetAttribute("hottrack", System.Xml.XmlConvert.ToString((int)m_HotTrackingStyle));
+
+ if (m_HotFontBold)
+ ThisItem.SetAttribute("hotfb", System.Xml.XmlConvert.ToString(m_HotFontBold));
+ if (m_HotFontUnderline)
+ ThisItem.SetAttribute("hotfu", System.Xml.XmlConvert.ToString(m_HotFontUnderline));
+
+ if (!m_HotForeColor.IsEmpty)
+ ThisItem.SetAttribute("hotclr", BarFunctions.ColorToString(m_HotForeColor));
+
+ if (m_OptionGroup != "")
+ ThisItem.SetAttribute("optiongroup", m_OptionGroup);
+
+ if (m_FontBold)
+ ThisItem.SetAttribute("fontbold", System.Xml.XmlConvert.ToString(m_FontBold));
+ if (m_FontItalic)
+ ThisItem.SetAttribute("fontitalic", System.Xml.XmlConvert.ToString(m_FontItalic));
+ if (m_FontUnderline)
+ ThisItem.SetAttribute("fontunderline", System.Xml.XmlConvert.ToString(m_FontUnderline));
+
+ if (m_AutoExpandOnClick)
+ ThisItem.SetAttribute("autoexpandclick", System.Xml.XmlConvert.ToString(m_AutoExpandOnClick));
+
+ if (m_CustomColorName != "")
+ ThisItem.SetAttribute("CustomColorName", m_CustomColorName);
+ if (m_ColorTable != eButtonColor.Orange)
+ ThisItem.SetAttribute("ColorTable", Enum.GetName(m_ColorTable.GetType(), m_ColorTable));
+
+ System.Xml.XmlElement xmlElem = null, xmlElem2 = null;
+
+ // Serialize Images
+ if (m_Image != null || m_ImageIndex >= 0 || m_HoverImage != null || m_HoverImageIndex >= 0 || m_DisabledImage != null || m_DisabledImageIndex >= 0 || m_PressedImage != null || m_PressedImageIndex >= 0 || m_Icon != null || m_ImageSmall != null)
+ {
+ xmlElem = ThisItem.OwnerDocument.CreateElement("images");
+ ThisItem.AppendChild(xmlElem);
+
+ if (m_ImageIndex >= 0)
+ xmlElem.SetAttribute("imageindex", System.Xml.XmlConvert.ToString(m_ImageIndex));
+ if (m_HoverImageIndex >= 0)
+ xmlElem.SetAttribute("hoverimageindex", System.Xml.XmlConvert.ToString(m_HoverImageIndex));
+ if (m_DisabledImageIndex >= 0)
+ xmlElem.SetAttribute("disabledimageindex", System.Xml.XmlConvert.ToString(m_DisabledImageIndex));
+ if (m_PressedImageIndex >= 0)
+ xmlElem.SetAttribute("pressedimageindex", System.Xml.XmlConvert.ToString(m_PressedImageIndex));
+
+ if (m_Image != null)
+ {
+ xmlElem2 = ThisItem.OwnerDocument.CreateElement("image");
+ xmlElem2.SetAttribute("type", "default");
+ xmlElem.AppendChild(xmlElem2);
+ BarFunctions.SerializeImage(m_Image, xmlElem2);
+ }
+ if (m_ImageSmall != null)
+ {
+ xmlElem2 = ThisItem.OwnerDocument.CreateElement("imagesmall");
+ xmlElem2.SetAttribute("type", "small");
+ xmlElem.AppendChild(xmlElem2);
+ BarFunctions.SerializeImage(m_ImageSmall, xmlElem2);
+ }
+ if (m_HoverImage != null)
+ {
+ xmlElem2 = ThisItem.OwnerDocument.CreateElement("image");
+ xmlElem2.SetAttribute("type", "hover");
+ xmlElem.AppendChild(xmlElem2);
+ BarFunctions.SerializeImage(m_HoverImage, xmlElem2);
+ }
+ if (m_DisabledImage != null && m_DisabledImageCustom)
+ {
+ xmlElem2 = ThisItem.OwnerDocument.CreateElement("image");
+ xmlElem2.SetAttribute("type", "disabled");
+ xmlElem.AppendChild(xmlElem2);
+ BarFunctions.SerializeImage(m_DisabledImage, xmlElem2);
+ }
+ if (m_PressedImage != null)
+ {
+ xmlElem2 = ThisItem.OwnerDocument.CreateElement("image");
+ xmlElem2.SetAttribute("type", "pressed");
+ xmlElem.AppendChild(xmlElem2);
+ BarFunctions.SerializeImage(m_PressedImage, xmlElem2);
+ }
+ if (m_Icon != null)
+ {
+ xmlElem2 = ThisItem.OwnerDocument.CreateElement("image");
+ xmlElem2.SetAttribute("type", "icon");
+ xmlElem.AppendChild(xmlElem2);
+ BarFunctions.SerializeIcon(m_Icon, xmlElem2);
+ }
+ }
+ }
+
+ ///
+ /// Overloaded. Deserializes the Item from the XmlElement.
+ ///
+ /// Source XmlElement.
+ public override void Deserialize(ItemSerializationContext context)
+ {
+ base.Deserialize(context);
+
+ System.Xml.XmlElement ItemXmlSource = context.ItemXmlElement;
+ m_ImagePosition = (eImagePosition)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("ImagePosition"));
+ m_ButtonStyle = (eButtonStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("ButtonStyle"));
+ m_Checked = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("Checked"));
+ m_VerticalPadding = System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("VerticalPadding"));
+ m_HorizontalPadding = System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("HorizontalPadding"));
+
+ m_MenuVisibility = (eMenuVisibility)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("MenuVisibility"));
+ m_RecentlyUsed = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("RecentlyUsed"));
+
+ if (ItemXmlSource.HasAttribute("forecolor"))
+ m_ForeColor = BarFunctions.ColorFromString(ItemXmlSource.GetAttribute("forecolor"));
+ else
+ m_ForeColor = System.Drawing.Color.Empty;
+
+ if (ItemXmlSource.HasAttribute("hottrack"))
+ m_HotTrackingStyle = (eHotTrackingStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("hottrack"));
+ else
+ m_HotTrackingStyle = eHotTrackingStyle.Default;
+
+ if (ItemXmlSource.HasAttribute("hotclr"))
+ m_HotForeColor = BarFunctions.ColorFromString(ItemXmlSource.GetAttribute("hotclr"));
+ else
+ m_HotForeColor = System.Drawing.Color.Empty;
+
+ if (ItemXmlSource.HasAttribute("hotfb"))
+ m_HotFontBold = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("hotfb"));
+ else
+ m_HotFontBold = false;
+ if (ItemXmlSource.HasAttribute("hotfu"))
+ m_HotFontUnderline = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("hotfu"));
+ else
+ m_HotFontUnderline = false;
+
+ if (ItemXmlSource.HasAttribute("optiongroup"))
+ m_OptionGroup = ItemXmlSource.GetAttribute("optiongroup");
+ else
+ m_OptionGroup = "";
+
+ if (ItemXmlSource.HasAttribute("fontbold"))
+ m_FontBold = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("fontbold"));
+ else
+ m_FontBold = false;
+ if (ItemXmlSource.HasAttribute("fontitalic"))
+ m_FontItalic = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("fontitalic"));
+ else
+ m_FontItalic = false;
+ if (ItemXmlSource.HasAttribute("fontunderline"))
+ m_FontUnderline = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("fontunderline"));
+ else
+ m_FontUnderline = false;
+
+ if (ItemXmlSource.HasAttribute("AlternateShortcutText"))
+ m_AlternateShortcutText = ItemXmlSource.GetAttribute("AlternateShortcutText");
+ else
+ m_AlternateShortcutText = "";
+
+ if (ItemXmlSource.HasAttribute("autoexpandclick"))
+ m_AutoExpandOnClick = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("autoexpandclick"));
+ else
+ m_AutoExpandOnClick = false;
+
+ if (ItemXmlSource.HasAttribute("CustomColorName"))
+ m_CustomColorName = ItemXmlSource.GetAttribute("CustomColorName");
+ else
+ m_CustomColorName = "";
+
+ if (ItemXmlSource.HasAttribute("ColorTable"))
+ m_ColorTable = (eButtonColor)Enum.Parse(m_ColorTable.GetType(), ItemXmlSource.GetAttribute("ColorTable"));
+ else
+ m_ColorTable = eButtonColor.Orange;
+
+ m_ImageIndex = -1;
+ m_HoverImageIndex = -1;
+ m_DisabledImageIndex = -1;
+ m_PressedImageIndex = -1;
+ m_Icon = null;
+ m_Image = null;
+ m_ImageSmall = null;
+ m_HoverImage = null;
+ m_DisabledImage = null;
+ m_DisabledImageCustom = false;
+ m_PressedImage = null;
+
+ // Load Images
+ foreach (System.Xml.XmlElement xmlElem in ItemXmlSource.ChildNodes)
+ {
+ if (xmlElem.Name == "images")
+ {
+ if (xmlElem.HasAttribute("imageindex"))
+ m_ImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("imageindex"));
+ if (xmlElem.HasAttribute("hoverimageindex"))
+ m_HoverImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("hoverimageindex"));
+ if (xmlElem.HasAttribute("disabledimageindex"))
+ m_DisabledImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("disabledimageindex"));
+ if (xmlElem.HasAttribute("pressedimageindex"))
+ m_PressedImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("pressedimageindex"));
+
+ foreach (System.Xml.XmlElement xmlElem2 in xmlElem.ChildNodes)
+ {
+ switch (xmlElem2.GetAttribute("type"))
+ {
+ case "default":
+ {
+ m_Image = BarFunctions.DeserializeImage(xmlElem2);
+ m_ImageIndex = -1;
+ break;
+ }
+ case "icon":
+ {
+ m_Icon = BarFunctions.DeserializeIcon(xmlElem2);
+ m_ImageIndex = -1;
+ break;
+ }
+ case "hover":
+ {
+ m_HoverImage = BarFunctions.DeserializeImage(xmlElem2);
+ m_HoverImageIndex = -1;
+ break;
+ }
+ case "disabled":
+ {
+ m_DisabledImage = BarFunctions.DeserializeImage(xmlElem2);
+ m_DisabledImageIndex = -1;
+ m_DisabledImageCustom = true;
+ break;
+ }
+ case "pressed":
+ {
+ m_PressedImage = BarFunctions.DeserializeImage(xmlElem2);
+ m_PressedImageIndex = -1;
+ break;
+ }
+ case "small":
+ {
+ m_ImageSmall = BarFunctions.DeserializeImage(xmlElem2);
+ break;
+ }
+ }
+ }
+ break;
+ }
+ }
+ this.OnImageChanged();
+ }
+ #endregion
+
+ #region Internal Implementation
+ private string _NotificationMarkText = "";
+ ///
+ /// Specifies maximum of 2 character text displayed inside of the notification mark on top of the button.
+ ///
+ [DefaultValue(""), Category("Appearance"), Description("Specifies maximum of 2 character text displayed inside of the notification mark on top of the button.")]
+ public string NotificationMarkText
+ {
+ get { return _NotificationMarkText; }
+ set
+ {
+ if (value != _NotificationMarkText)
+ {
+ string oldValue = _NotificationMarkText;
+ _NotificationMarkText = value;
+ OnNotificationMarkTextChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when NotificationMarkText property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnNotificationMarkTextChanged(string oldValue, string newValue)
+ {
+ if (string.IsNullOrEmpty(newValue)) _NotificationMarkWasDisplayed = true; // Make sure button gets invalidated properly
+ this.Refresh();
+ }
+
+ private eNotificationMarkPosition _NotificationMarkPosition = eNotificationMarkPosition.TopRight;
+ ///
+ /// Indicates the position of the notification marker within the bounds of the button.
+ ///
+ [DefaultValue(eNotificationMarkPosition.TopRight), Category("Appearance"), Description("Indicates the position of the notification marker within the bounds of the button.")]
+ public eNotificationMarkPosition NotificationMarkPosition
+ {
+ get { return _NotificationMarkPosition; }
+ set
+ {
+ if (value != _NotificationMarkPosition)
+ {
+ eNotificationMarkPosition oldValue = _NotificationMarkPosition;
+ _NotificationMarkPosition = value;
+ OnNotificationMarkPositionChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when NotificationMarkPosition property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnNotificationMarkPositionChanged(eNotificationMarkPosition oldValue, eNotificationMarkPosition newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("NotificationMarkPosition"));
+ if(!string.IsNullOrEmpty(_NotificationMarkText))
+ this.Refresh();
+ }
+ private int _NotificationMarkSize = 0;
+ ///
+ /// Specifies diameter of notification mark. When set to 0 system default value is used.
+ ///
+ [DefaultValue(0), Category("Appearance"), Description("Specifies diameter of notification mark. When set to 0 system default value is used.")]
+ public int NotificationMarkSize
+ {
+ get { return _NotificationMarkSize; }
+ set
+ {
+ if (value != _NotificationMarkSize)
+ {
+ int oldValue = _NotificationMarkSize;
+ _NotificationMarkSize = value;
+ OnNotificationMarkSizeChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when NotificationMarkSize property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnNotificationMarkSizeChanged(int oldValue, int newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("NotificationMarkSize"));
+ this.Refresh();
+ }
+ private Color _NotificationMarkColor = Color.Empty;
+ ///
+ /// Gets or sets background color of the notification mark.
+ ///
+ [Category("Appearance"), Description("Indicates background color of the notification mark.")]
+ public Color NotificationMarkColor
+ {
+ get { return _NotificationMarkColor; }
+ set { _NotificationMarkColor = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeNotificationMarkColor()
+ {
+ return !_NotificationMarkColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetNotificationMarkColor()
+ {
+ this.NotificationMarkColor = Color.Empty;
+ }
+ private bool _NotificationMarkWasDisplayed = false;
+ protected override Rectangle GetInvalidateBounds()
+ {
+ if (_NotificationMarkWasDisplayed || !string.IsNullOrEmpty(_NotificationMarkText))
+ {
+ _NotificationMarkWasDisplayed = false;
+ Rectangle r = base.GetInvalidateBounds();
+ r.Inflate(6, 6);
+ return r;
+ }
+ return base.GetInvalidateBounds();
+ }
+
+ private static readonly Point DefaultNotificationMarkOffset = new Point(3, 3);
+ private Point _NotificationMarkOffset = DefaultNotificationMarkOffset;
+ ///
+ /// Specifies the offset for the notification mark relative to its position.
+ ///
+ [Category("Appearance"), Description("Specifies the offset for the notification mark relative to its position.")]
+ public Point NotificationMarkOffset
+ {
+ get { return _NotificationMarkOffset; }
+ set
+ {
+ if (value != _NotificationMarkOffset)
+ {
+ Point oldValue = _NotificationMarkOffset;
+ _NotificationMarkOffset = value;
+ OnNotificationMarkOffsetChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when NotificationMarkOffset property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnNotificationMarkOffsetChanged(Point oldValue, Point newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("NotificationMarkOffset"));
+ this.Invalidate();
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeNotificationMarkOffset()
+ {
+ return _NotificationMarkOffset != DefaultNotificationMarkOffset;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetNotificationMarkOffset()
+ {
+ this.NotificationMarkOffset = DefaultNotificationMarkOffset;
+ }
+
+ ///
+ /// Gets/Sets the image position inside the button.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The alignment of the image in relation to text displayed by this item."), System.ComponentModel.DefaultValue(eImagePosition.Left)]
+ public virtual eImagePosition ImagePosition
+ {
+ get
+ {
+ return m_ImagePosition;
+ }
+ set
+ {
+ if (m_ImagePosition != value)
+ {
+ m_ImagePosition = value;
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "ImagePosition");
+
+ NeedRecalcSize = true;
+ if (this.Parent != null)
+ this.Parent.NeedRecalcSize = true;
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the custom color name. Name specified here must be represented by the corresponding object with the same name that is part
+ /// of the Office2007ColorTable.RibbonTabItemColors collection. See documentation for Office2007ColorTable.RibbonTabItemColors for more information.
+ /// If color table with specified name cannot be found default color will be used. Valid settings for this property override any
+ /// setting to the Color property.
+ /// Applies to items with Office 2007 style only.
+ ///
+ [Browsable(true), DevCoBrowsable(false), DefaultValue(""), Category("Appearance"), Description("Indicates custom color table name for the button when Office 2007 style is used.")]
+ public virtual string CustomColorName
+ {
+ get { return m_CustomColorName; }
+ set
+ {
+ m_CustomColorName = value;
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Gets or sets the predefined color of the button. Color specified applies to buttons with Office 2007 style only. It does not have
+ /// any effect on other styles. Default value is eButtonColor.Default
+ ///
+ [Browsable(true), DevCoBrowsable(false), DefaultValue(eButtonColor.Orange), Category("Appearance"), Description("Indicates predefined color of button when Office 2007 style is used.")]
+ public virtual eButtonColor ColorTable
+ {
+ get { return m_ColorTable; }
+ set
+ {
+ if (m_ColorTable != value)
+ {
+ m_ColorTable = value;
+ m_CashedColorName = Enum.GetName(typeof(eButtonColor), m_ColorTable);
+ this.Refresh();
+ }
+ }
+ }
+
+ internal virtual string GetColorTableName()
+ {
+ return m_CashedColorName;
+ }
+
+ ///
+ /// Gets/Sets the button style which controls the appearance of the button elements. Changing the property can display image only, text only or image and text on the button at all times.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Determines the style of the button."), System.ComponentModel.DefaultValue(eButtonStyle.Default)]
+ public virtual eButtonStyle ButtonStyle
+ {
+ get
+ {
+ return m_ButtonStyle;
+ }
+ set
+ {
+ if (m_ButtonStyle != value)
+ {
+ m_ButtonStyle = value;
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "ButtonStyle");
+ NeedRecalcSize = true;
+ if (this.Displayed && m_Parent != null)
+ {
+ RecalcSize();
+ m_Parent.SubItemSizeChanged(this);
+ }
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Indicates whether the item will auto-expand when clicked.
+ /// When item is on top level bar and not on menu and contains sub-items, sub-items will be shown only if user
+ /// click the expand part of the button. Setting this property to true will expand the button and show sub-items when user
+ /// clicks anywhere inside of the button. Default value is false which indicates that button is expanded only
+ /// if its expand part is clicked.
+ ///
+ [DefaultValue(false), Browsable(true), DevCoBrowsable(true), Category("Behavior"), Description("Indicates whether the item will auto-expand (display pop-up menu or toolbar) when clicked.")]
+ public virtual bool AutoExpandOnClick
+ {
+ get
+ {
+ return m_AutoExpandOnClick;
+ }
+ set
+ {
+ m_AutoExpandOnClick = value;
+ }
+ }
+
+ private Color _SymbolColor = Color.Empty;
+ ///
+ /// Gets or sets the color of the Symbol.
+ ///
+ [Category("Appearance"), Description("Indicates color of the Symbol.")]
+ public Color SymbolColor
+ {
+ get { return _SymbolColor; }
+ set { _SymbolColor = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSymbolColor()
+ {
+ return !_SymbolColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSymbolColor()
+ {
+ this.SymbolColor = Color.Empty;
+ }
+
+ ///
+ /// Gets the realized symbol string.
+ ///
+ [Browsable(false)]
+ public string SymbolRealized
+ {
+ get { return _SymbolRealized; }
+ }
+ private string _Symbol = "", _SymbolRealized ="";
+ ///
+ /// Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the image setting.
+ ///
+ [DefaultValue(""), Category("Appearance"), Description("Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the 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 != _Symbol)
+ {
+ string oldValue = _Symbol;
+ _Symbol = value;
+ OnSymbolChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when Symbol property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnSymbolChanged(string oldValue, string newValue)
+ {
+ if (string.IsNullOrEmpty(newValue))
+ _SymbolRealized = "";
+ else
+ _SymbolRealized = Symbols.GetSymbol(newValue);
+ //OnPropertyChanged(new PropertyChangedEventArgs("Symbol"));
+ NeedRecalcSize = true;
+ OnAppearanceChanged();
+ this.Refresh();
+ }
+
+ private eSymbolSet _SymbolSet = eSymbolSet.Awesome;
+ ///
+ /// Gets or sets the symbol set used to represent the Symbol.
+ ///
+ [Browsable(false), DefaultValue(eSymbolSet.Awesome)]
+ public eSymbolSet SymbolSet
+ {
+ get { return _SymbolSet; }
+ set
+ {
+ if(_SymbolSet!=value)
+ {
+ eSymbolSet oldValue = _SymbolSet;
+ _SymbolSet = value;
+ OnSymbolSetChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when SymbolSet property value changes.
+ ///
+ /// Indciates old value
+ /// Indicates new value
+ protected virtual void OnSymbolSetChanged(eSymbolSet oldValue, eSymbolSet newValue)
+ {
+ NeedRecalcSize = true;
+ OnAppearanceChanged();
+ this.Refresh();
+ }
+
+
+ private float _SymbolSize = 0f;
+ ///
+ /// Indicates the size of the symbol in points.
+ ///
+ [DefaultValue(0f), Category("Appearance"), Description("Indicates the size of the symbol in points.")]
+ public float SymbolSize
+ {
+ get { return _SymbolSize; }
+ set
+ {
+ if (value != _SymbolSize)
+ {
+ float oldValue = _SymbolSize;
+ _SymbolSize = value;
+ OnSymbolSizeChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when SymbolSize property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnSymbolSizeChanged(float oldValue, float newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("SymbolSize"));
+ NeedRecalcSize = true;
+ OnAppearanceChanged();
+ this.Refresh();
+ }
+
+ ///
+ /// Specifies the Button icon. Icons support multiple image sizes and alpha blending.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("Specifies the Button icon. Icons support multiple image sizes and alpha blending."), DefaultValue(null)]
+ public virtual System.Drawing.Icon Icon
+ {
+ get
+ {
+ return m_Icon;
+ }
+ set
+ {
+ NeedRecalcSize = true;
+ m_Icon = value;
+ this.OnImageChanged();
+ OnAppearanceChanged();
+ this.Refresh();
+ }
+ }
+
+ private Image _ImageAlt = null;
+ ///
+ /// Specifies the Button image which is used when button background is black or very dark. Image is used when button text is white. This is provided for Metro style applications.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("Specifies the Button image which is used when button background is black or very dark. Image is used when button text is white. This is provided for Metro style applications."), DefaultValue(null)]
+ public System.Drawing.Image ImageAlt
+ {
+ get
+ {
+ return _ImageAlt;
+ }
+ set
+ {
+ _ImageAlt = value;
+ OnAppearanceChanged();
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Specifies the Button image.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("The image that will be displayed on the face of the item."), DefaultValue(null)]
+ public System.Drawing.Image Image
+ {
+ get
+ {
+ return m_Image;
+ }
+ set
+ {
+ NeedRecalcSize = true;
+ m_Image = value;
+ this.OnImageChanged();
+ OnAppearanceChanged();
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Specifies the small Button image used by Ribbon control when small image variant is needed because of the automatic button resizing or
+ /// because the button is on the Quick Access Toolbar.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("Specifies the small Button image used by Ribbon control when small image variant is needed"), DefaultValue(null)]
+ public virtual System.Drawing.Image ImageSmall
+ {
+ get
+ {
+ return m_ImageSmall;
+ }
+ set
+ {
+ m_ImageSmall = value;
+ if (!m_ImageSizeOverride.IsEmpty || UseSmallImageResolved)
+ {
+ NeedRecalcSize = true;
+ OnAppearanceChanged();
+ OnImageChanged();
+ this.Refresh();
+ }
+ }
+ }
+
+ private bool UseSmallImageResolved
+ {
+ get
+ {
+ return m_UseSmallImage;
+ }
+ }
+
+ private eButtonImageListSelection _ImageListSizeSelection = eButtonImageListSelection.NotSet;
+ ///
+ /// Gets or sets the image size that is used by the button when multiple ImageList controls are used as source for button image.
+ /// By default ImageList assigned to Images property of parent control is used. Using this property you can selection ImagesMedium or
+ /// ImagesLarge ImageList to be used as source for image for this button.
+ ///
+ [DefaultValue(eButtonImageListSelection.NotSet), Category("Image"), Description("Indicates image size that is used by the button when multiple ImageList controls are used as source for button image.")]
+ public virtual eButtonImageListSelection ImageListSizeSelection
+ {
+ get { return _ImageListSizeSelection; }
+ set
+ {
+ _ImageListSizeSelection = value;
+ NeedRecalcSize = true;
+ OnImageChanged();
+ this.OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets whether button uses the ImageSmall as source of the image displayed on the button if ImageSmall is set to valid image. Default value is false.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool UseSmallImage
+ {
+ get { return m_UseSmallImage; }
+ set
+ {
+ if (m_UseSmallImage != value)
+ {
+ m_UseSmallImage = value;
+ if (m_ImageSmall != null)
+ {
+ NeedRecalcSize = true;
+ OnImageChanged();
+ this.OnAppearanceChanged();
+ }
+ }
+ }
+ }
+
+
+ ///
+ /// Specifies the index of the image for the button if ImageList is used.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The image list image index of the image that will be displayed on the face of the item."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), System.ComponentModel.DefaultValue(-1)]
+ public int ImageIndex
+ {
+ get
+ {
+ return m_ImageIndex;
+ }
+ set
+ {
+ if (m_ImageCachedIdx != null) m_ImageCachedIdx.Dispose();
+ m_ImageCachedIdx = null;
+ if (m_ImageIndex != value)
+ {
+ //if(this.GetOwner()==null)
+ // throw(new System.InvalidOperationException("Owner DotNetBarManager is not set. Add containing bar do the bars collection first."));
+ m_ImageIndex = value;
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "ImageIndex");
+ if (m_Parent != null)
+ {
+ OnImageChanged();
+ NeedRecalcSize = true;
+ this.Refresh();
+ }
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ internal void SetImageIndex(int iImageIndex)
+ {
+ m_ImageIndex = iImageIndex;
+ }
+
+ protected override void ScaleItem(SizeF factor)
+ {
+ OnImageChanged(); // Force image size re-evaluation
+ base.ScaleItem(factor);
+ }
+
+ ///
+ /// Called when button image has changed.
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void OnImageChanged()
+ {
+ base.OnImageChanged();
+
+ StopPulse();
+ StopImageAnimation();
+
+ if (m_DisabledImage != null && !m_DisabledImageCustom)
+ {
+ m_DisabledImage.Dispose();
+ m_DisabledImage = null;
+ }
+ if (m_DisabledIcon != null)
+ {
+ m_DisabledIcon.Dispose();
+ m_DisabledIcon = null;
+ }
+
+ CompositeImage img = this.GetImage(ImageState.Default, Color.Black);
+ if (img != null)
+ {
+ if (m_Image != null)
+ {
+ IBarImageSize iImageSize = null;
+ if (_ItemPaintArgs != null)
+ iImageSize = _ItemPaintArgs.ContainerControl as IBarImageSize;
+ if (iImageSize == null) iImageSize = this.ContainerControl as IBarImageSize;
+ eBarImageSize imageListSize = GetImageListSize(iImageSize);
+
+ if (iImageSize != null && imageListSize != eBarImageSize.Default)
+ {
+ if (imageListSize == eBarImageSize.Medium)
+ {
+ this.ImageSize = new Size(32, 32);
+ }
+ else
+ {
+ this.ImageSize = new Size(48, 48);
+ }
+ }
+ else
+ this.ImageSize = new Size(img.Width, img.Height);
+ }
+ else
+ this.ImageSize = new Size(img.Width, img.Height);
+
+ if (img.Image == m_Image)
+ _CanAnimateImage = ImageAnimator.CanAnimate(m_Image);
+ else
+ _CanAnimateImage = false;
+
+ img.Dispose();
+ }
+ else
+ this.ImageSize = Dpi.Size(ImageItem._InitalImageSize); // This is ImageItem default size
+
+ if (m_Parent != null)
+ {
+ ImageItem objParentImageItem = m_Parent as ImageItem;
+ if (objParentImageItem != null)
+ {
+ //if(this.DesignMode)
+ objParentImageItem.RefreshSubItemImageSize();
+ //else
+ // objParentImageItem.OnSubItemImageSizeChanged(this);
+ }
+ }
+ }
+ private bool _CanAnimateImage = false;
+ internal bool CanAnimateImage
+ {
+ get
+ {
+ return _CanAnimateImage;
+ }
+ }
+ internal bool CurrentlyAnimatingImage
+ {
+ get
+ {
+ return _CurrentlyAnimatingImage;
+ }
+ }
+ private bool _CurrentlyAnimatingImage = false;
+ private Image _AnimateImage = null;
+ internal void StartImageAnimation(Image image)
+ {
+ if (!ImageAnimator.CanAnimate(image)) return;
+
+ _CurrentlyAnimatingImage = true;
+ _AnimateImage = image;
+
+ ImageAnimator.Animate(image, OnFrameChanged);
+ }
+ internal void StopImageAnimation()
+ {
+ if (_CurrentlyAnimatingImage == true)
+ {
+ _CurrentlyAnimatingImage = false;
+
+ Image animateImage = _AnimateImage;
+ _AnimateImage = null;
+
+ if (animateImage != null)
+ {
+ ImageAnimator.StopAnimate(animateImage, OnFrameChanged);
+
+ System.Drawing.Imaging.FrameDimension frameDimensions =
+ new System.Drawing.Imaging.FrameDimension(animateImage.FrameDimensionsList[0]);
+
+ animateImage.SelectActiveFrame(frameDimensions, 0);
+ }
+ }
+ }
+ private void OnFrameChanged(object o, EventArgs e)
+ {
+ if (_CurrentlyAnimatingImage && this.Visible)
+ {
+ this.Refresh();
+ this.Update();
+ }
+ else
+ {
+ StopImageAnimation();
+ }
+ }
+
+ ///
+ /// Called when container of the item has changed.
+ ///
+ /// Previous item container.
+ protected internal override void OnContainerChanged(object objOldContainer)
+ {
+ if (this.DesignMode || (m_ImageIndex >= 0 || m_Icon != null) && this.ImageSize.Width == ImageItem._InitalImageSize.Width && this.ImageSize.Height == ImageItem._InitalImageSize.Height)
+ OnImageChanged();
+ base.OnContainerChanged(objOldContainer);
+ }
+
+ ///
+ /// Specifies the image for the button when mouse is over the item.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("The image that will be displayed when mouse hovers over the item."), DefaultValue(null)]
+ public virtual System.Drawing.Image HoverImage
+ {
+ get
+ {
+ return m_HoverImage;
+ }
+ set
+ {
+ m_HoverImage = value;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Specifies the index of the image for the button when mouse is over the item when ImageList is used.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The image list image index of the image that will be displayed when mouse hovers over the item."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), System.ComponentModel.DefaultValue(-1)]
+ public virtual int HoverImageIndex
+ {
+ get
+ {
+ return m_HoverImageIndex;
+ }
+ set
+ {
+ if (m_HoverImageIndex != value)
+ {
+ //if(this.GetOwner()==null)
+ // throw(new System.InvalidOperationException("Owner DotNetBarManager is not set. Add containing bar do the bars collection first."));
+ m_HoverImageIndex = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "HoverImageIndex");
+
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Specifies the image for the button when mouse left button is pressed.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("The image that will be displayed when item is pressed."), DefaultValue(null)]
+ public virtual System.Drawing.Image PressedImage
+ {
+ get
+ {
+ return m_PressedImage;
+ }
+ set
+ {
+ m_PressedImage = value;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Specifies the index of the image for the button when mouse left button is pressed and ImageList is used.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The image list image index of the image that will be displayed when item is pressed."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), System.ComponentModel.DefaultValue(-1)]
+ public virtual int PressedImageIndex
+ {
+ get
+ {
+ return m_PressedImageIndex;
+ }
+ set
+ {
+ if (m_PressedImageIndex != value)
+ {
+ //if(this.GetOwner()==null)
+ // throw(new System.InvalidOperationException("Owner DotNetBarManager is not set. Add containing bar do the bars collection first."));
+ m_PressedImageIndex = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "PressedImageIndex");
+
+ OnAppearanceChanged();
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Specifies the image for the button when items Enabled property is set to false.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("The image that will be displayed when item is disabled."), DefaultValue(null)]
+ public System.Drawing.Image DisabledImage
+ {
+ get
+ {
+ if (!m_DisabledImageCustom)
+ return null;
+ return m_DisabledImage;
+ }
+ set
+ {
+ m_DisabledImage = value;
+ if (value == null)
+ m_DisabledImageCustom = false;
+ else
+ m_DisabledImageCustom = true;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Specifies the index of the image for the button when items Enabled property is set to false and ImageList is used.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The image list image index of the image that will be displayed when item is disabled."), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), System.ComponentModel.DefaultValue(-1)]
+ public int DisabledImageIndex
+ {
+ get
+ {
+ return m_DisabledImageIndex;
+ }
+ set
+ {
+ if (m_DisabledImageIndex != value)
+ {
+ if (m_DisabledImage != null)
+ m_DisabledImage.Dispose();
+ m_DisabledImage = null;
+ //if(this.GetOwner()==null)
+ // throw(new System.InvalidOperationException("Owner DotNetBarManager is not set. Add containing bar do the bars collection first."));
+ m_DisabledImageIndex = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "DisabledImageIndex");
+
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Overriden. Draws the item.
+ ///
+ /// Item paint arguments.
+ public override void Paint(ItemPaintArgs p)
+ {
+ if (this.SuspendLayout)
+ return;
+
+ bool oldMouseOver = m_MouseOver;
+
+ m_FadeImageLock.AcquireReaderLock(-1);
+ try
+ {
+ if (m_ImageState2 != null)
+ m_MouseOver = false;
+ try
+ {
+ _ItemPaintArgs = p;
+
+ if (EffectiveStyle == eDotNetBarStyle.Office2000 && !this.IsThemed)
+ PaintOffice(p);
+ else
+ {
+ RenderButton(p);
+
+ if (m_ImageState2 != null && !m_IgnoreAlpha)
+ {
+ Graphics g = p.Graphics;
+ Rectangle r = this.DisplayRectangle;
+ System.Drawing.Imaging.ColorMatrix matrix1 = new System.Drawing.Imaging.ColorMatrix();
+ matrix1[3, 3] = (float)((float)m_Alpha / 255);
+ using (System.Drawing.Imaging.ImageAttributes imageAtt = new System.Drawing.Imaging.ImageAttributes())
+ {
+ imageAtt.SetColorMatrix(matrix1);
+ g.DrawImage(m_ImageState2, r, 0, 0, r.Width, r.Height, GraphicsUnit.Pixel, imageAtt);
+ }
+ return;
+ }
+ }
+ }
+ finally
+ {
+ _ItemPaintArgs = null;
+ m_MouseOver = oldMouseOver;
+ }
+ }
+ finally
+ {
+ m_FadeImageLock.ReleaseReaderLock();
+ }
+
+ this.DrawInsertMarker(p.Graphics);
+ }
+
+ protected virtual void RenderButton(ItemPaintArgs p)
+ {
+ Rendering.BaseRenderer renderer = p.Renderer;
+ if (renderer != null)
+ {
+ p.ButtonItemRendererEventArgs.Graphics = p.Graphics;
+ p.ButtonItemRendererEventArgs.ButtonItem = this;
+ p.ButtonItemRendererEventArgs.ItemPaintArgs = p;
+ renderer.DrawButtonItem(p.ButtonItemRendererEventArgs);
+ }
+ else
+ {
+ ButtonItemPainter painter = PainterFactory.CreateButtonPainter(this);
+ if (painter != null)
+ {
+ painter.PaintButton(this, p);
+ }
+ else
+ {
+ if (EffectiveStyle == eDotNetBarStyle.Office2000)
+ PaintOffice(p);
+ else
+ PaintDotNet(p);
+ }
+ }
+ if (!string.IsNullOrEmpty(_NotificationMarkText))
+ DevComponents.DotNetBar.Rendering.NotificationMarkPainter.Paint(p.Graphics, this.Bounds, _NotificationMarkPosition,
+ _NotificationMarkText, new Size(_NotificationMarkSize, _NotificationMarkSize), _NotificationMarkOffset, _NotificationMarkColor);
+ }
+
+ private void PaintDotNet(ItemPaintArgs pa)
+ {
+ bool bIsOnMenu = pa.IsOnMenu;
+ bool bIsOnMenuBar = pa.IsOnMenuBar;
+ bool bThemed = this.IsThemed;
+
+ if (!bIsOnMenu && !bIsOnMenuBar && bThemed)
+ {
+ ThemedButtonItemPainter.PaintButton(this, pa);
+ return;
+ }
+
+ bool mouseOver = m_MouseOver;
+ if (bIsOnMenu && this.Expanded && pa.ContainerControl != null && pa.ContainerControl.Parent != null)
+ {
+ if (!pa.ContainerControl.Parent.Bounds.Contains(System.Windows.Forms.Control.MousePosition))
+ mouseOver = true;
+ }
+
+ System.Drawing.Graphics g = pa.Graphics;
+
+ Rectangle rect = Rectangle.Empty;
+ Rectangle itemRect = new Rectangle(m_Rect.X, m_Rect.Y, m_Rect.Width, m_Rect.Height);
+ Color textColor = System.Drawing.Color.Empty;
+
+ if (mouseOver && !m_HotForeColor.IsEmpty)
+ textColor = m_HotForeColor;
+ else if (!m_ForeColor.IsEmpty)
+ textColor = m_ForeColor;
+ else if (mouseOver /*&& m_Checked*/ && !m_Expanded && /*!bIsOnMenu &&*/ m_HotTrackingStyle != eHotTrackingStyle.Image)
+ textColor = pa.Colors.ItemHotText;
+ else if (m_Expanded)
+ textColor = pa.Colors.ItemExpandedText;
+ else
+ {
+ if (bThemed && bIsOnMenuBar && pa.Colors.ItemText == SystemColors.ControlText)
+ textColor = SystemColors.MenuText;
+ else
+ textColor = pa.Colors.ItemText;
+ }
+
+ Font objFont = null;
+
+ eTextFormat objStringFormat = pa.ButtonStringFormat;
+ CompositeImage objImage = GetImage();
+ System.Drawing.Size imageSize = System.Drawing.Size.Empty;
+
+ if (m_Font != null)
+ objFont = m_Font;
+ else
+ objFont = GetFont(pa, false);
+
+ // Calculate image position
+ if (objImage != null)
+ {
+ imageSize = this.ImageSize;// objImage.Size;
+ if (!bIsOnMenu && (m_ImagePosition == eImagePosition.Top || m_ImagePosition == eImagePosition.Bottom))
+ rect = new Rectangle(m_ImageDrawRect.X, m_ImageDrawRect.Y, itemRect.Width, m_ImageDrawRect.Height);
+ else
+ rect = new Rectangle(m_ImageDrawRect.X, m_ImageDrawRect.Y, m_ImageDrawRect.Width, m_ImageDrawRect.Height);
+
+ rect.Offset(itemRect.Left, itemRect.Top);
+ //if(m_ButtonType==eButtonType.StateButton)
+ // rect.Offset(STATEBUTTON_SPACING+(m_ImageSize.Width-STATEBUTTON_SPACING)/2+(rect.Width-m_Image.Width*2)/2,(rect.Height-m_Image.Height)/2);
+ //else
+ rect.Offset((rect.Width - imageSize.Width) / 2, (rect.Height - imageSize.Height) / 2);
+
+ rect.Width = imageSize.Width;
+ rect.Height = imageSize.Height;
+ }
+
+ if (bIsOnMenu)
+ {
+ // Draw side bar
+ if (this.MenuVisibility == eMenuVisibility.VisibleIfRecentlyUsed && !this.RecentlyUsed)
+ {
+ if (!pa.Colors.MenuUnusedSide2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(m_Rect.Left, m_Rect.Top, m_ImageDrawRect.Right, m_Rect.Height), pa.Colors.MenuUnusedSide, pa.Colors.MenuUnusedSide2, pa.Colors.MenuUnusedSideGradientAngle);
+ g.FillRectangle(gradient, m_Rect.Left, m_Rect.Top, m_ImageDrawRect.Right, m_Rect.Height);
+ gradient.Dispose();
+ }
+ else
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.MenuUnusedSide/*ColorFunctions.SideRecentlyBackColor(g)*/))
+ g.FillRectangle(mybrush, m_Rect.Left, m_Rect.Top, m_ImageDrawRect.Right, m_Rect.Height);
+ }
+ }
+ else
+ {
+ if (!pa.Colors.MenuSide2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(m_Rect.Left, m_Rect.Top, m_ImageDrawRect.Right, m_Rect.Height), pa.Colors.MenuSide, pa.Colors.MenuSide2, pa.Colors.MenuSideGradientAngle);
+ g.FillRectangle(gradient, m_Rect.Left, m_Rect.Top, m_ImageDrawRect.Right, m_Rect.Height);
+ gradient.Dispose();
+ }
+ else
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.MenuSide))
+ g.FillRectangle(mybrush, m_Rect.Left, m_Rect.Top, m_ImageDrawRect.Right, m_Rect.Height);
+ }
+ }
+ // Draw Background of the item
+ //using(SolidBrush mybrush=new SolidBrush(pa.Colors.MenuBackground))
+ // g.FillRectangle(mybrush,m_Rect.Left+m_ImageDrawRect.Right,m_Rect.Top,m_Rect.Width-m_ImageDrawRect.Right,m_Rect.Height);
+ }
+ else
+ {
+ // Draw button background
+ //if(bIsOnMenuBar)
+ // g.FillRectangle(SystemBrushes.Control,m_Rect);
+ //else
+ // g.FillRectangle(new SolidBrush(ColorFunctions.ToolMenuFocusBackColor(g)),m_Rect);
+ if (!pa.Colors.ItemBackground.IsEmpty)
+ {
+ if (pa.Colors.ItemBackground2.IsEmpty)
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemBackground))
+ g.FillRectangle(mybrush, m_Rect);
+ }
+ else
+ {
+ using (System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(this.DisplayRectangle, pa.Colors.ItemBackground, pa.Colors.ItemBackground2, pa.Colors.ItemBackgroundGradientAngle))
+ g.FillRectangle(gradient, this.DisplayRectangle);
+ }
+ }
+ else if (!GetEnabled(pa.ContainerControl) && !pa.Colors.ItemDisabledBackground.IsEmpty)
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemDisabledBackground))
+ g.FillRectangle(mybrush, m_Rect);
+ }
+ }
+
+ if (GetEnabled(pa.ContainerControl) || this.DesignMode)
+ {
+ if (m_Expanded && !bIsOnMenu)
+ {
+ // DotNet Style
+ if (pa.Colors.ItemExpandedBackground2.IsEmpty)
+ {
+ Rectangle rBack = new Rectangle(itemRect.Left, itemRect.Top, itemRect.Width, itemRect.Height);
+ if (pa.Colors.ItemExpandedShadow.IsEmpty)
+ rBack.Width -= 2;
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemExpandedBackground))
+ g.FillRectangle(mybrush, rBack);
+ }
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(itemRect.Left, itemRect.Top, itemRect.Width - 2, itemRect.Height), pa.Colors.ItemExpandedBackground, pa.Colors.ItemExpandedBackground2, pa.Colors.ItemExpandedBackgroundGradientAngle);
+ Rectangle rBack = new Rectangle(itemRect.Left, itemRect.Top, itemRect.Width, itemRect.Height);
+ if (pa.Colors.ItemExpandedShadow.IsEmpty)
+ rBack.Width -= 2;
+ g.FillRectangle(gradient, rBack);
+ gradient.Dispose();
+ }
+ Point[] p;
+ if (m_Orientation == eOrientation.Horizontal && this.PopupSide == ePopupSide.Default)
+ p = new Point[4];
+ else
+ p = new Point[5];
+ p[0].X = itemRect.Left;
+ p[0].Y = itemRect.Top + itemRect.Height - 1;
+ p[1].X = itemRect.Left;
+ p[1].Y = itemRect.Top;
+ if (m_Orientation == eOrientation.Horizontal /*&& !pa.Colors.ItemExpandedShadow.IsEmpty*/)
+ p[2].X = itemRect.Left + itemRect.Width - 3;
+ else
+ p[2].X = itemRect.Left + itemRect.Width - 1;
+ p[2].Y = itemRect.Top;
+ if (m_Orientation == eOrientation.Horizontal /*&& !pa.Colors.ItemExpandedShadow.IsEmpty*/)
+ p[3].X = itemRect.Left + itemRect.Width - 3;
+ else
+ p[3].X = itemRect.Left + itemRect.Width - 1;
+
+ p[3].Y = itemRect.Top + itemRect.Height - 1;
+ if (m_Orientation == eOrientation.Vertical || this.PopupSide != ePopupSide.Default)
+ {
+ p[4].X = itemRect.Left;
+ p[4].Y = itemRect.Top + itemRect.Height - 1;
+ }
+
+ if (!pa.Colors.ItemExpandedBorder.IsEmpty)
+ {
+ using (Pen mypen = new Pen(pa.Colors.ItemExpandedBorder, 1))
+ g.DrawLines(mypen, p);
+ }
+ // Draw the shadow
+ if (!pa.Colors.ItemExpandedShadow.IsEmpty && m_Orientation == eOrientation.Horizontal)
+ {
+ using (SolidBrush shadow = new SolidBrush(pa.Colors.ItemExpandedShadow))
+ g.FillRectangle(shadow, itemRect.Left + itemRect.Width - 2, itemRect.Top + 2, 2, itemRect.Height - 2); // TODO: ADD GRADIENT SHADOW
+ }
+ }
+
+ if ((mouseOver && m_HotTrackingStyle != eHotTrackingStyle.None) || m_Expanded && !bIsOnMenu)
+ {
+ // Draw Mouse over marker
+ if (!m_Expanded || bIsOnMenu)
+ {
+ Rectangle r = itemRect;
+ if (bIsOnMenu)
+ r = new Rectangle(itemRect.Left + 1, itemRect.Top, itemRect.Width - 2, itemRect.Height);
+ if (this.DesignMode && this.Focused)
+ {
+ //g.FillRectangle(new SolidBrush(ColorFunctions.MenuBackColor(g)),r);
+ r = m_Rect;
+ r.Inflate(-1, -1);
+ DesignTime.DrawDesignTimeSelection(g, r, pa.Colors.ItemDesignTimeBorder);
+ }
+ else
+ {
+ if (m_MouseDown)
+ {
+ if (m_HotTrackingStyle == eHotTrackingStyle.Image)
+ {
+ r = rect;
+ r.Inflate(2, 2);
+ }
+ if (pa.Colors.ItemPressedBackground2.IsEmpty)
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemPressedBackground/*ColorFunctions.PressedBackColor(g)*/))
+ g.FillRectangle(mybrush, r);
+ }
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemPressedBackground, pa.Colors.ItemPressedBackground2, pa.Colors.ItemPressedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ }
+ using (Pen mypen = new Pen(pa.Colors.ItemPressedBorder, 1))
+ NativeFunctions.DrawRectangle(g, mypen, r);
+ }
+ else if (m_HotTrackingStyle == eHotTrackingStyle.Image && !rect.IsEmpty)
+ {
+ Rectangle rImage = rect;
+ rImage.Inflate(2, 2);
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(rImage, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, rImage);
+ gradient.Dispose();
+ }
+ else
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemHotBackground/*ColorFunctions.HoverBackColor(g)*/))
+ g.FillRectangle(mybrush, rImage);
+ }
+ using (Pen mypen = new Pen(pa.Colors.ItemHotBorder, 1))
+ NativeFunctions.DrawRectangle(g, mypen, rImage);
+ }
+ else
+ {
+ if (!pa.Colors.ItemCheckedBackground2.IsEmpty && m_Checked)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemCheckedBackground2, pa.Colors.ItemCheckedBackground, pa.Colors.ItemCheckedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ }
+ else
+ {
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ }
+ else
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemHotBackground))
+ g.FillRectangle(mybrush, r);
+ }
+ }
+ using (Pen mypen = new Pen(pa.Colors.ItemHotBorder, 1))
+ NativeFunctions.DrawRectangle(g, mypen, r);
+ }
+ }
+ // TODO: Beta 2 Hack for DrawRectangle Possible bug, need to verify
+ //r.Width-=1;
+ //r.Height-=1;
+ //g.DrawRectangle(SystemPens.Highlight,r);
+ }
+
+ // Image needs shadow when it has focus
+ if (objImage != null && m_ButtonStyle != eButtonStyle.TextOnlyAlways)
+ {
+ // We needed the image to stay "up" when button is expanded too so we removed the checking here
+ //if(m_MouseDown || (m_Expanded && !bIsOnMenu) || m_Checked && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ if (m_MouseDown || m_Checked && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ {
+ objImage.DrawImage(g, rect);// g.DrawImage(objImage,rect);//,0,0,imageSize.Width,imageSize.Height,System.Drawing.GraphicsUnit.Pixel);
+ }
+ else
+ {
+ if (NativeFunctions.ColorDepth >= 16 && EffectiveStyle != eDotNetBarStyle.Office2003)
+ {
+ float[][] array = new float[5][];
+ array[0] = new float[5] { 0, 0, 0, 0, 0 };
+ array[1] = new float[5] { 0, 0, 0, 0, 0 };
+ array[2] = new float[5] { 0, 0, 0, 0, 0 };
+ array[3] = new float[5] { .5f, .5f, .5f, .5f, 0 };
+ array[4] = new float[5] { 0, 0, 0, 0, 0 };
+ System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array);
+ System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes();
+ disabledImageAttr.ClearColorKey();
+ disabledImageAttr.SetColorMatrix(grayMatrix);
+
+ rect.Offset(1, 1);
+ //g.DrawImage(objImage,rect,0,0,objImage.Width,objImage.Height,GraphicsUnit.Pixel,disabledImageAttr);
+ objImage.DrawImage(g, rect, 0, 0, objImage.Width, objImage.Height, GraphicsUnit.Pixel, disabledImageAttr);
+ rect.Offset(-2, -2);
+ //g.DrawImage(objImage,rect);
+ objImage.DrawImage(g, rect);
+ }
+ else
+ {
+ if (EffectiveStyle == eDotNetBarStyle.OfficeXP)
+ rect.Offset(-1, -1);
+ //g.DrawImage(objImage,rect);
+ objImage.DrawImage(g, rect);
+ }
+ }
+ }
+
+ if (bIsOnMenu && this.IsOnCustomizeMenu && m_Visible && !this.SystemItem)
+ {
+ // Draw check box if this item is visible
+ Rectangle r = new Rectangle(m_Rect.Left, m_Rect.Top, m_Rect.Height, m_Rect.Height);
+ r.Inflate(-1, -1);
+ //Color clr=g.GetNearestColor(Color.FromArgb(45,SystemColors.Highlight));
+ Color clr = pa.Colors.ItemCheckedBackground/*ColorFunctions.CheckBoxBackColor(g)*/;
+ if (mouseOver && !pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ }
+ else
+ {
+ if (mouseOver)
+ clr = pa.Colors.ItemHotBackground;
+
+ if (!pa.Colors.ItemCheckedBackground2.IsEmpty && !mouseOver)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemCheckedBackground, pa.Colors.ItemCheckedBackground2, pa.Colors.ItemCheckedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ }
+ else
+ {
+ SolidBrush objBrush = new SolidBrush(clr);
+ g.FillRectangle(objBrush, r);
+ objBrush.Dispose();
+ }
+ }
+ }
+ }
+ else
+ {
+ if (objImage != null && m_ButtonStyle != eButtonStyle.TextOnlyAlways)
+ {
+ if (!m_Checked || this.IsOnCustomizeMenu)
+ {
+ if (m_HotTrackingStyle != eHotTrackingStyle.Color)
+ {
+ objImage.DrawImage(g, rect);
+ }
+ else
+ {
+ // Draw gray-scale image for this hover style...
+ float[][] array = new float[5][];
+ array[0] = new float[5] { 0.2125f, 0.2125f, 0.2125f, 0, 0 };
+ array[1] = new float[5] { 0.5f, 0.5f, 0.5f, 0, 0 };
+ array[2] = new float[5] { 0.0361f, 0.0361f, 0.0361f, 0, 0 };
+ array[3] = new float[5] { 0, 0, 0, 1, 0 };
+ array[4] = new float[5] { 0.2f, 0.2f, 0.2f, 0, 1 };
+ System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array);
+ System.Drawing.Imaging.ImageAttributes att = new System.Drawing.Imaging.ImageAttributes();
+ att.SetColorMatrix(grayMatrix);
+ //g.DrawImage(objImage,rect,0,0,objImage.Width,objImage.Height,GraphicsUnit.Pixel,att);
+ objImage.DrawImage(g, rect, 0, 0, objImage.Width, objImage.Height, GraphicsUnit.Pixel, att);
+ }
+ }
+ else
+ {
+ if ((m_Checked && bIsOnMenu || !this.Expanded) && !this.IsOnCustomizeDialog)
+ {
+ Rectangle r;
+ if (bIsOnMenu)
+ r = new Rectangle(m_Rect.X + 1, m_Rect.Y, m_ImageDrawRect.Width - 2, m_Rect.Height);
+ else if (m_HotTrackingStyle == eHotTrackingStyle.Image)
+ {
+ r = rect;
+ r.Inflate(2, 2);
+ }
+ else
+ r = m_Rect;
+ if (bIsOnMenu)
+ r.Inflate(-1, -1);
+ Color clr;
+ if (mouseOver && m_HotTrackingStyle != eHotTrackingStyle.None)
+ {
+ if (m_Checked && !pa.Colors.ItemCheckedBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemCheckedBackground2, pa.Colors.ItemCheckedBackground, pa.Colors.ItemCheckedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ clr = System.Drawing.Color.Empty;
+ }
+ else
+ {
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ clr = System.Drawing.Color.Empty;
+ }
+ else
+ clr = System.Windows.Forms.ControlPaint.Dark(pa.Colors.ItemHotBackground);
+ }
+ }
+ else
+ {
+ if (!pa.Colors.ItemCheckedBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemCheckedBackground, pa.Colors.ItemCheckedBackground2, pa.Colors.ItemCheckedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ clr = System.Drawing.Color.Empty;
+ }
+ else
+ clr = pa.Colors.ItemCheckedBackground/*ColorFunctions.CheckBoxBackColor(g)*/;
+ }
+ if (!clr.IsEmpty)
+ {
+ SolidBrush objBrush = new SolidBrush(clr);
+ g.FillRectangle(objBrush, r);
+ objBrush.Dispose();
+ }
+ }
+ objImage.DrawImage(g, rect);
+ }
+ }
+ if (bIsOnMenu && this.IsOnCustomizeMenu && m_Visible && !this.SystemItem)
+ {
+ // Draw check box if this item is visible
+ Rectangle r = new Rectangle(m_Rect.Left, m_Rect.Top, m_Rect.Height, m_Rect.Height);
+ r.Inflate(-1, -1);
+ //Color clr=g.GetNearestColor(Color.FromArgb(96,ColorFunctions.HoverBackColor()));
+ if (pa.Colors.ItemCheckedBackground2.IsEmpty)
+ {
+ Color clr = pa.Colors.ItemCheckedBackground/*ColorFunctions.CheckBoxBackColor(g)*/;
+ SolidBrush objBrush = new SolidBrush(clr);
+ g.FillRectangle(objBrush, r);
+ objBrush.Dispose();
+ }
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemCheckedBackground, pa.Colors.ItemCheckedBackground2, pa.Colors.ItemCheckedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ }
+ }
+ else if (m_Checked && !bIsOnMenu && objImage == null)
+ {
+ Rectangle r = m_Rect;
+ // TODO: In 9188 GetNearestColor on the Graphics that were taken directly from Paint event did not work correctly. Check in future versions...
+ // Draw background
+ //Color clr=g.GetNearestColor(Color.FromArgb(96,ColorFunctions.HoverBackColor(g)));
+ Color clr;
+ if (mouseOver && m_HotTrackingStyle != eHotTrackingStyle.None)
+ {
+ if (!pa.Colors.ItemCheckedBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemCheckedBackground2, pa.Colors.ItemCheckedBackground, pa.Colors.ItemCheckedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ clr = System.Drawing.Color.Empty;
+ }
+ else
+ {
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ clr = System.Drawing.Color.Empty;
+ }
+ else
+ clr = pa.Colors.ItemHotBackground;
+ }
+ }
+ else
+ {
+ if (!pa.Colors.ItemCheckedBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemCheckedBackground, pa.Colors.ItemCheckedBackground2, pa.Colors.ItemCheckedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ clr = System.Drawing.Color.Empty;
+ }
+ else
+ clr = pa.Colors.ItemCheckedBackground;
+ }
+ if (!clr.IsEmpty)
+ {
+ SolidBrush objBrush = new SolidBrush(clr);
+ g.FillRectangle(objBrush, r);
+ objBrush.Dispose();
+ }
+ }
+ }
+
+ if (bIsOnMenu && this.IsOnCustomizeMenu && m_Visible && !this.SystemItem)
+ {
+ Rectangle r = new Rectangle(m_Rect.Left, m_Rect.Top, m_Rect.Height, m_Rect.Height);
+ r.Inflate(-1, -1);
+ //Color clr=g.GetNearestColor(Color.FromArgb(200,SystemColors.Highlight));
+ Color clr = pa.Colors.ItemCheckedBorder/*SystemColors.Highlight*/;
+ Pen objPen = new Pen(clr, 1);
+ // TODO: Beta 2 fix --> g.DrawRectangle(objPen,r);
+ NativeFunctions.DrawRectangle(g, objPen, r);
+
+ objPen.Dispose();
+ objPen = new Pen(pa.Colors.ItemCheckedText);
+ // Draw checker...
+ Point[] pt = new Point[3];
+ pt[0].X = r.Left + (r.Width - 5) / 2 - 1;
+ pt[0].Y = r.Top + (r.Height - 6) / 2 + 3;
+ pt[1].X = pt[0].X + 2;
+ pt[1].Y = pt[0].Y + 2;
+ pt[2].X = pt[1].X + 4;
+ pt[2].Y = pt[1].Y - 4;
+ g.DrawLines(objPen/*SystemPens.ControlText*/, pt);
+ pt[0].X++;
+ pt[1].X++;
+ pt[2].X++;
+ g.DrawLines(objPen/*SystemPens.ControlText*/, pt);
+ objPen.Dispose();
+ }
+
+ if (m_Checked && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ {
+ Rectangle r;
+
+ if (bIsOnMenu)
+ r = new Rectangle(m_Rect.X + 1, m_Rect.Y, m_ImageDrawRect.Width - 2, m_Rect.Height);
+ else if (m_HotTrackingStyle == eHotTrackingStyle.Image)
+ {
+ r = rect;
+ r.Inflate(2, 2);
+ }
+ else
+ r = new Rectangle(m_Rect.X, m_Rect.Y, m_Rect.Width, m_Rect.Height);
+ if (bIsOnMenu)
+ r.Inflate(-1, -1);
+
+ // Draw line around...
+ if (bIsOnMenu || !this.Expanded)
+ {
+ if (objImage == null || m_ButtonStyle == eButtonStyle.TextOnlyAlways)
+ {
+ if (mouseOver)
+ {
+ if (m_Checked && !pa.Colors.ItemCheckedBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemCheckedBackground2, pa.Colors.ItemCheckedBackground, pa.Colors.ItemCheckedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ }
+ else
+ {
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ }
+ else
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemHotBackground))
+ g.FillRectangle(mybrush, r);
+ }
+ }
+ }
+ else
+ {
+ if (pa.Colors.ItemCheckedBackground2.IsEmpty)
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemCheckedBackground))
+ g.FillRectangle(mybrush, r);
+ }
+ else
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(r, pa.Colors.ItemCheckedBackground, pa.Colors.ItemCheckedBackground2, pa.Colors.ItemCheckedBackgroundGradientAngle);
+ g.FillRectangle(gradient, r);
+ gradient.Dispose();
+ }
+ }
+ }
+
+ //Color clr=g.GetNearestColor(Color.FromArgb(200,SystemColors.Highlight));
+ Color clr = pa.Colors.ItemCheckedBorder/*SystemColors.Highlight*/;
+ Pen objPen = new Pen(clr, 1);
+ // TODO: Beta 2 fix ---> g.DrawRectangle(objPen,r);
+ NativeFunctions.DrawRectangle(g, objPen, r);
+
+ objPen.Dispose();
+ }
+
+ if ((objImage == null || m_ButtonStyle == eButtonStyle.TextOnlyAlways) && bIsOnMenu)
+ {
+ // Draw checker...
+ Pen pen = new Pen(pa.Colors.ItemCheckedText);
+ Point[] pt = new Point[3];
+ pt[0].X = r.Left + (r.Width - 5) / 2 - 1;
+ pt[0].Y = r.Top + (r.Height - 6) / 2 + 3;
+ pt[1].X = pt[0].X + 2;
+ pt[1].Y = pt[0].Y + 2;
+ pt[2].X = pt[1].X + 4;
+ pt[2].Y = pt[1].Y - 4;
+ g.DrawLines(pen/*SystemPens.ControlText*/, pt);
+ pt[0].X++;
+ //pt[0].Y
+ pt[1].X++;
+ //pt[1].Y;
+ pt[2].X++;
+ //pt[2].Y;
+ g.DrawLines(pen/*SystemPens.ControlText*/, pt);
+ pen.Dispose();
+ }
+ }
+ }
+ else
+ {
+ if (bIsOnMenu && mouseOver && m_HotTrackingStyle == eHotTrackingStyle.Default)
+ {
+ Rectangle r = new Rectangle(itemRect.Left + 1, itemRect.Top, itemRect.Width - 2, itemRect.Height);
+ using (Pen mypen = new Pen(pa.Colors.ItemHotBorder, 1))
+ NativeFunctions.DrawRectangle(g, mypen, r);
+ }
+
+ // Replicated code from above to draw the item checked box
+ if (m_Checked && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ {
+ Rectangle r;
+
+ if (bIsOnMenu)
+ r = new Rectangle(m_Rect.X + 1, m_Rect.Y, m_ImageDrawRect.Width - 2, m_Rect.Height);
+ else if (m_HotTrackingStyle == eHotTrackingStyle.Image)
+ {
+ r = rect;
+ r.Inflate(2, 2);
+ }
+ else
+ r = new Rectangle(m_Rect.X, m_Rect.Y, m_Rect.Width, m_Rect.Height);
+ if (bIsOnMenu)
+ r.Inflate(-1, -1);
+
+ // Draw line around...
+ if (bIsOnMenu || !this.Expanded)
+ {
+ Color clr = pa.Colors.ItemDisabledText;
+ Pen objPen = new Pen(clr, 1);
+ NativeFunctions.DrawRectangle(g, objPen, r);
+ objPen.Dispose();
+ }
+
+ if ((objImage == null || m_ButtonStyle == eButtonStyle.TextOnlyAlways) && bIsOnMenu)
+ {
+ // Draw checker...
+ Pen pen = new Pen(pa.Colors.ItemDisabledText);
+ Point[] pt = new Point[3];
+ pt[0].X = r.Left + (r.Width - 5) / 2 - 1;
+ pt[0].Y = r.Top + (r.Height - 6) / 2 + 3;
+ pt[1].X = pt[0].X + 2;
+ pt[1].Y = pt[0].Y + 2;
+ pt[2].X = pt[1].X + 4;
+ pt[2].Y = pt[1].Y - 4;
+ g.DrawLines(pen, pt);
+ pt[0].X++;
+ //pt[0].Y
+ pt[1].X++;
+ //pt[1].Y;
+ pt[2].X++;
+ //pt[2].Y;
+ g.DrawLines(pen, pt);
+ pen.Dispose();
+ }
+ }
+ textColor = pa.Colors.ItemDisabledText;
+ if (objImage != null && m_ButtonStyle != eButtonStyle.TextOnlyAlways)
+ {
+ // Draw disabled image
+ objImage.DrawImage(g, rect);
+ }
+ }
+
+ // Draw menu item text
+ if (bIsOnMenu || m_ButtonStyle != eButtonStyle.Default || objImage == null || (!bIsOnMenu && (m_ImagePosition == eImagePosition.Top || m_ImagePosition == eImagePosition.Bottom)) /*|| !this.IsOnBar*/) // Commented out becouse it caused text to be drawn if item is not on bar no matter what
+ {
+ if (bIsOnMenu)
+ rect = new Rectangle(m_TextDrawRect.X, m_TextDrawRect.Y, itemRect.Width - m_ImageDrawRect.Right - 26, m_TextDrawRect.Height);
+ else
+ {
+ rect = m_TextDrawRect;
+ if (m_ImagePosition == eImagePosition.Top || m_ImagePosition == eImagePosition.Bottom)
+ {
+ if (m_Orientation == eOrientation.Vertical)
+ {
+ rect = new Rectangle(m_TextDrawRect.X, m_TextDrawRect.Y, m_TextDrawRect.Width, m_TextDrawRect.Height);
+ }
+ else
+ {
+ rect = new Rectangle(m_TextDrawRect.X, m_TextDrawRect.Y, itemRect.Width, m_TextDrawRect.Height);
+ if ((this.SubItems.Count > 0 || this.PopupType == ePopupType.Container) && this.ShowSubItems)
+ rect.Width -= 10;
+ }
+
+ objStringFormat |= eTextFormat.HorizontalCenter;
+ }
+ else if (bIsOnMenuBar && objImage == null)
+ objStringFormat |= eTextFormat.HorizontalCenter;
+
+ if (m_MouseDown && m_HotTrackingStyle != eHotTrackingStyle.Image)
+ {
+ if (m_ForeColor.IsEmpty)
+ {
+ textColor = pa.Colors.ItemPressedText;
+ }
+ else
+ {
+ textColor = System.Windows.Forms.ControlPaint.Light(m_ForeColor);
+ }
+ }
+ }
+
+ rect.Offset(itemRect.Left, itemRect.Top);
+
+ if (m_Orientation == eOrientation.Vertical && !bIsOnMenu)
+ {
+ g.RotateTransform(90);
+ TextDrawing.DrawStringLegacy(g, m_Text, objFont, textColor, new Rectangle(rect.Top, -rect.Right, rect.Height, rect.Width), objStringFormat);
+ g.ResetTransform();
+ }
+ else
+ {
+ if (rect.Right > m_Rect.Right)
+ rect.Width = m_Rect.Right - rect.Left;
+ TextDrawing.DrawString(g, m_Text, objFont, textColor, rect, objStringFormat);
+ if (!this.DesignMode && this.Focused && !bIsOnMenu && !bIsOnMenuBar)
+ {
+ //SizeF szf=g.MeasureString(m_Text,objFont,rect.Width,objStringFormat);
+ Rectangle r = rect;
+ //r.Width=(int)Math.Ceiling(szf.Width);
+ //r.Height=(int)Math.Ceiling(szf.Height);
+ //r.Inflate(1,1);
+ System.Windows.Forms.ControlPaint.DrawFocusRectangle(g, r);
+ }
+ }
+
+ }
+
+ // Draw Shortcut text if needed
+ if (this.DrawShortcutText != "" && bIsOnMenu && !this.IsOnCustomizeDialog)
+ {
+ objStringFormat |= eTextFormat.HidePrefix | eTextFormat.Right;
+ TextDrawing.DrawString(g, this.DrawShortcutText, objFont, textColor, rect, objStringFormat);
+ }
+
+ // If it has subitems draw the triangle to indicate that
+ if ((this.SubItems.Count > 0 || this.PopupType == ePopupType.Container) && this.ShowSubItems)
+ {
+ if (bIsOnMenu)
+ {
+ Point[] p = new Point[3];
+ p[0].X = itemRect.Left + itemRect.Width - 12;
+ p[0].Y = itemRect.Top + (itemRect.Height - 8) / 2;
+ p[1].X = p[0].X;
+ p[1].Y = p[0].Y + 8;
+ p[2].X = p[0].X + 4;
+ p[2].Y = p[0].Y + 4;
+ using (SolidBrush brush = new SolidBrush(textColor))
+ g.FillPolygon(brush, p);
+ }
+ else if (!m_SubItemsRect.IsEmpty)
+ {
+ if (GetEnabled(pa.ContainerControl) && ((mouseOver || m_Checked) && !m_Expanded && m_HotTrackingStyle != eHotTrackingStyle.None && m_HotTrackingStyle != eHotTrackingStyle.Image))
+ {
+ if (m_Orientation == eOrientation.Horizontal)
+ {
+ using (Pen mypen = new Pen(pa.Colors.ItemHotBorder))
+ g.DrawLine(mypen/*SystemPens.Highlight*/, itemRect.Left + m_SubItemsRect.Left, itemRect.Top, itemRect.Left + m_SubItemsRect.Left, itemRect.Bottom - 1);
+ }
+ else
+ {
+ using (Pen mypen = new Pen(pa.Colors.ItemHotBorder))
+ g.DrawLine(mypen/*SystemPens.Highlight*/, itemRect.Left, itemRect.Top + m_SubItemsRect.Top, itemRect.Right - 2, itemRect.Top + m_SubItemsRect.Top);
+ }
+ }
+ Point[] p = new Point[3];
+ if (this.PopupSide == ePopupSide.Default)
+ {
+ if (m_Orientation == eOrientation.Horizontal)
+ {
+ p[0].X = itemRect.Left + m_SubItemsRect.Left + (m_SubItemsRect.Width - 5) / 2;
+ p[0].Y = itemRect.Top + (m_SubItemsRect.Height - 3) / 2 + 1;
+ p[1].X = p[0].X + 5;
+ p[1].Y = p[0].Y;
+ p[2].X = p[0].X + 2;
+ p[2].Y = p[0].Y + 3;
+ }
+ else
+ {
+ p[0].X = itemRect.Left + (m_SubItemsRect.Width - 3) / 2 + 1;
+ p[0].Y = itemRect.Top + m_SubItemsRect.Top + (m_SubItemsRect.Height - 5) / 2;
+ p[1].X = p[0].X;
+ p[1].Y = p[0].Y + 6;
+ p[2].X = p[0].X - 3;
+ p[2].Y = p[0].Y + 3;
+ }
+ }
+ else
+ {
+ switch (this.PopupSide)
+ {
+ case ePopupSide.Left:
+ {
+ p[0].X = itemRect.Left + m_SubItemsRect.Left + m_SubItemsRect.Width / 2;
+ p[0].Y = itemRect.Top + m_SubItemsRect.Height / 2 - 3;
+ p[1].X = p[0].X;
+ p[1].Y = p[0].Y + 6;
+ p[2].X = p[0].X + 3;
+ p[2].Y = p[0].Y + 3;
+ break;
+ }
+ case ePopupSide.Right:
+ {
+ p[0].X = itemRect.Left + m_SubItemsRect.Left + m_SubItemsRect.Width / 2 + 3;
+ p[0].Y = itemRect.Top + m_SubItemsRect.Height / 2 - 3;
+ p[1].X = p[0].X;
+ p[1].Y = p[0].Y + 6;
+ p[2].X = p[0].X - 3;
+ p[2].Y = p[0].Y + 3;
+ break;
+ }
+ case ePopupSide.Top:
+ {
+ p[0].X = itemRect.Left + m_SubItemsRect.Left + (m_SubItemsRect.Width - 5) / 2;
+ p[0].Y = itemRect.Top + (m_SubItemsRect.Height - 3) / 2 + 4;
+ p[1].X = p[0].X + 6;
+ p[1].Y = p[0].Y;
+ p[2].X = p[0].X + 3;
+ p[2].Y = p[0].Y - 4;
+ break;
+ }
+ case ePopupSide.Bottom:
+ {
+ p[0].X = itemRect.Left + m_SubItemsRect.Left + (m_SubItemsRect.Width - 5) / 2 + 1;
+ p[0].Y = itemRect.Top + (m_SubItemsRect.Height - 3) / 2 + 1;
+ p[1].X = p[0].X + 5;
+ p[1].Y = p[0].Y;
+ p[2].X = p[0].X + 2;
+ p[2].Y = p[0].Y + 3;
+ break;
+ }
+ }
+ }
+ if (GetEnabled(pa.ContainerControl))
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemText))
+ g.FillPolygon(mybrush/*SystemBrushes.ControlText*/, p);
+ }
+ else
+ {
+ using (SolidBrush mybrush = new SolidBrush(pa.Colors.ItemDisabledText))
+ g.FillPolygon(mybrush/*SystemBrushes.ControlDark*/, p);
+ }
+ }
+ }
+
+ if (this.Focused && this.DesignMode)
+ {
+ Rectangle r = itemRect;
+ r.Inflate(-1, -1);
+ DesignTime.DrawDesignTimeSelection(g, r, pa.Colors.ItemDesignTimeBorder);
+ }
+
+ if (objImage != null)
+ objImage.Dispose();
+ }
+
+ internal bool IgnoreAlpha
+ {
+ get { return m_IgnoreAlpha; }
+ set { m_IgnoreAlpha = value; }
+ }
+
+ private void PaintThemed(ItemPaintArgs pa)
+ {
+ System.Drawing.Graphics g = pa.Graphics;
+ ThemeToolbar theme = pa.ThemeToolbar;
+ ThemeToolbarParts part = ThemeToolbarParts.Button;
+ ThemeToolbarStates state = ThemeToolbarStates.Normal;
+ eTextFormat format = pa.ButtonStringFormat; //GetStringFormat();
+ Color textColor = SystemColors.ControlText;
+
+ Rectangle rectImage = Rectangle.Empty;
+ Rectangle itemRect = m_Rect;
+
+ Font font = null;
+ CompositeImage image = GetImage();
+
+ if (m_Font != null)
+ font = m_Font;
+ else
+ font = GetFont(pa, false);
+
+ bool bSplitButton = (this.SubItems.Count > 0 || this.PopupType == ePopupType.Container) && this.ShowSubItems && !m_SubItemsRect.IsEmpty;
+
+ if (bSplitButton)
+ part = ThemeToolbarParts.SplitButton;
+
+ // Calculate image position
+ if (image != null)
+ {
+ if (m_ImagePosition == eImagePosition.Top || m_ImagePosition == eImagePosition.Bottom)
+ rectImage = new Rectangle(m_ImageDrawRect.X, m_ImageDrawRect.Y, itemRect.Width, m_ImageDrawRect.Height);
+ else
+ rectImage = new Rectangle(m_ImageDrawRect.X, m_ImageDrawRect.Y, m_ImageDrawRect.Width, m_ImageDrawRect.Height);
+
+ rectImage.Offset(itemRect.Left, itemRect.Top);
+ rectImage.Offset((rectImage.Width - this.ImageSize.Width) / 2, (rectImage.Height - this.ImageSize.Height) / 2);
+ rectImage.Width = this.ImageSize.Width;
+ rectImage.Height = this.ImageSize.Height;
+ }
+
+ // Set the state and text brush
+ if (!GetEnabled(pa.ContainerControl))
+ {
+ state = ThemeToolbarStates.Disabled;
+ textColor = pa.Colors.ItemDisabledText;
+ }
+ else if (m_MouseDown)
+ {
+ state = ThemeToolbarStates.Pressed;
+ textColor = pa.Colors.ItemPressedText;
+ }
+ else if (m_MouseOver && m_Checked)
+ {
+ state = ThemeToolbarStates.HotChecked;
+ textColor = pa.Colors.ItemHotText;
+ }
+ else if (m_MouseOver || m_Expanded)
+ {
+ state = ThemeToolbarStates.Hot;
+ textColor = pa.Colors.ItemHotText;
+ }
+ else if (m_Checked)
+ {
+ state = ThemeToolbarStates.Checked;
+ textColor = pa.Colors.ItemCheckedText;
+ }
+ else
+ textColor = pa.Colors.ItemText;
+
+ Rectangle backRect = m_Rect;
+ if (m_HotTrackingStyle == eHotTrackingStyle.Image && image != null)
+ {
+ backRect = rectImage;
+ backRect.Inflate(3, 3);
+ }
+ else if (bSplitButton)
+ {
+ backRect.Width = backRect.Width - m_SubItemsRect.Width;
+ }
+
+ // Draw Button Background
+ if (m_HotTrackingStyle != eHotTrackingStyle.None)
+ {
+ theme.DrawBackground(g, part, state, backRect);
+ }
+
+ // Draw Image
+ if (image != null && m_ButtonStyle != eButtonStyle.TextOnlyAlways)
+ {
+ if (state == ThemeToolbarStates.Normal && m_HotTrackingStyle == eHotTrackingStyle.Color)
+ {
+ // Draw gray-scale image for this hover style...
+ float[][] array = new float[5][];
+ array[0] = new float[5] { 0.2125f, 0.2125f, 0.2125f, 0, 0 };
+ array[1] = new float[5] { 0.5f, 0.5f, 0.5f, 0, 0 };
+ array[2] = new float[5] { 0.0361f, 0.0361f, 0.0361f, 0, 0 };
+ array[3] = new float[5] { 0, 0, 0, 1, 0 };
+ array[4] = new float[5] { 0.2f, 0.2f, 0.2f, 0, 1 };
+ System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array);
+ System.Drawing.Imaging.ImageAttributes att = new System.Drawing.Imaging.ImageAttributes();
+ att.SetColorMatrix(grayMatrix);
+ //g.DrawImage(image,rectImage,0,0,image.Width,image.Height,GraphicsUnit.Pixel,att);
+ image.DrawImage(g, rectImage, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, att);
+ }
+ else if (state == ThemeToolbarStates.Normal && !image.IsIcon)
+ {
+ // Draw image little bit lighter, I decied to use gamma it is easy
+ System.Drawing.Imaging.ImageAttributes lightImageAttr = new System.Drawing.Imaging.ImageAttributes();
+ lightImageAttr.SetGamma(.7f, System.Drawing.Imaging.ColorAdjustType.Bitmap);
+ //g.DrawImage(image,rectImage,0,0,image.Width,image.Height,GraphicsUnit.Pixel,lightImageAttr);
+ image.DrawImage(g, rectImage, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, lightImageAttr);
+ }
+ else
+ {
+ image.DrawImage(g, rectImage);
+ }
+ }
+
+ // Draw Text
+ if (m_ButtonStyle == eButtonStyle.ImageAndText || m_ButtonStyle == eButtonStyle.TextOnlyAlways || image == null /*|| !this.IsOnBar*/) // Commented out becouse it caused text to be drawn if item is not on bar no matter what
+ {
+ Rectangle rectText = m_TextDrawRect;
+ if (m_ImagePosition == eImagePosition.Top || m_ImagePosition == eImagePosition.Bottom)
+ {
+ if (m_Orientation == eOrientation.Vertical)
+ {
+ rectText = new Rectangle(m_TextDrawRect.X, m_TextDrawRect.Y, m_TextDrawRect.Width, m_TextDrawRect.Height);
+ }
+ else
+ {
+ rectText = new Rectangle(m_TextDrawRect.X, m_TextDrawRect.Y, itemRect.Width, m_TextDrawRect.Height);
+ if ((this.SubItems.Count > 0 || this.PopupType == ePopupType.Container) && this.ShowSubItems)
+ rectText.Width -= 10;
+ }
+ format |= eTextFormat.HorizontalCenter;
+ }
+
+ rectText.Offset(itemRect.Left, itemRect.Top);
+
+ if (m_Orientation == eOrientation.Vertical)
+ {
+ g.RotateTransform(90);
+ TextDrawing.DrawStringLegacy(g, m_Text, font, textColor, new Rectangle(rectText.Top, -rectText.Right, rectText.Height, rectText.Width), format);
+ g.ResetTransform();
+ }
+ else
+ {
+ if (rectText.Right > m_Rect.Right)
+ rectText.Width = m_Rect.Right - rectText.Left;
+ TextDrawing.DrawString(g, m_Text, font, textColor, rectText, format);
+ if (!this.DesignMode && this.Focused && !pa.IsOnMenu && !pa.IsOnMenuBar)
+ {
+ //SizeF szf=g.MeasureString(m_Text,font,rectText.Width,format);
+ Rectangle r = rectText;
+ //r.Width=(int)Math.Ceiling(szf.Width);
+ //r.Height=(int)Math.Ceiling(szf.Height);
+ //r.Inflate(1,1);
+ System.Windows.Forms.ControlPaint.DrawFocusRectangle(g, r);
+ }
+ }
+ }
+
+ // If it has subitems draw the triangle to indicate that
+ if (bSplitButton)
+ {
+ part = ThemeToolbarParts.SplitButtonDropDown;
+
+ if (!GetEnabled(pa.ContainerControl))
+ state = ThemeToolbarStates.Disabled;
+ else
+ state = ThemeToolbarStates.Normal;
+
+ if (m_HotTrackingStyle != eHotTrackingStyle.None && m_HotTrackingStyle != eHotTrackingStyle.Image && GetEnabled(pa.ContainerControl))
+ {
+ if (m_Expanded || m_MouseDown)
+ state = ThemeToolbarStates.Pressed;
+ else if (m_MouseOver && m_Checked)
+ state = ThemeToolbarStates.HotChecked;
+ else if (m_Checked)
+ state = ThemeToolbarStates.Checked;
+ else if (m_MouseOver)
+ state = ThemeToolbarStates.Hot;
+ }
+
+ if (m_Orientation == eOrientation.Horizontal)
+ {
+ Rectangle r = m_SubItemsRect;
+ r.Offset(itemRect.X, itemRect.Y);
+ theme.DrawBackground(g, part, state, r);
+ }
+ else
+ {
+ Rectangle r = m_SubItemsRect;
+ r.Offset(itemRect.X, itemRect.Y);
+ theme.DrawBackground(g, part, state, r);
+ }
+ //g.DrawLine(new Pen(pa.Colors.ItemHotBorder)/*SystemPens.Highlight*/,itemRect.Left,itemRect.Top+m_SubItemsRect.Top,itemRect.Right-2,itemRect.Top+m_SubItemsRect.Top);
+ }
+
+ if (this.Focused && this.DesignMode)
+ {
+ Rectangle r = itemRect;
+ r.Inflate(-1, -1);
+ DesignTime.DrawDesignTimeSelection(g, r, pa.Colors.ItemDesignTimeBorder);
+ }
+
+ if (image != null)
+ image.Dispose();
+ }
+
+ private void PaintOffice(ItemPaintArgs pa)
+ {
+ System.Drawing.Graphics g = pa.Graphics;
+ Rectangle rect = Rectangle.Empty;
+ Rectangle itemRect = m_Rect;
+ Rectangle rTmp = Rectangle.Empty;
+ Color textColor = SystemColors.ControlText;
+ Color color3d = SystemColors.Control;
+
+ if (m_Parent is GenericItemContainer && !((GenericItemContainer)m_Parent).BackColor.IsEmpty)
+ color3d = ((GenericItemContainer)m_Parent).BackColor;
+ else if (m_Parent is SideBarPanelItem && !((SideBarPanelItem)m_Parent).BackgroundStyle.BackColor1.IsEmpty)
+ color3d = ((SideBarPanelItem)m_Parent).BackgroundStyle.BackColor1.GetCompositeColor();
+
+ if (m_MouseOver && !m_HotForeColor.IsEmpty)
+ textColor = m_HotForeColor;
+ else if (!m_ForeColor.IsEmpty)
+ textColor = m_ForeColor;
+
+ Font objFont = null;
+ bool bIsOnMenu = pa.IsOnMenu;
+ bool buttonX = pa.ContainerControl is ButtonX;
+ //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
+ //g.TextRenderingHint=System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
+ eTextFormat objStringFormat = pa.ButtonStringFormat;
+ CompositeImage objImage = GetImage();
+
+ if (m_Font != null)
+ objFont = m_Font;
+ else
+ objFont = GetFont(pa, false);
+
+ // Calculate image position
+ if (objImage != null)
+ {
+
+ if (!bIsOnMenu && (m_ImagePosition == eImagePosition.Top || m_ImagePosition == eImagePosition.Bottom))
+ rect = new Rectangle(m_ImageDrawRect.X, m_ImageDrawRect.Y + 1, itemRect.Width, m_ImageDrawRect.Height);
+ else
+ rect = m_ImageDrawRect; //new Rectangle(m_ImageDrawRect.X,m_ImageDrawRect.Y,m_ImageDrawRect.Width,m_ImageDrawRect.Height);
+
+ rect.Offset(itemRect.Left, itemRect.Top);
+ //if(m_ButtonType==eButtonType.StateButton)
+ // rect.Offset(STATEBUTTON_SPACING+(m_ImageSize.Width-STATEBUTTON_SPACING)/2+(rect.Width-m_Image.Width*2)/2,(rect.Height-m_Image.Height)/2);
+ //else
+ rect.Offset((rect.Width - this.ImageSize.Width) / 2, (rect.Height - this.ImageSize.Height) / 2);
+
+ rect.Width = this.ImageSize.Width;
+ rect.Height = this.ImageSize.Height;
+ }
+
+ // Draw background
+ if (bIsOnMenu && !this.DesignMode && this.MenuVisibility == eMenuVisibility.VisibleIfRecentlyUsed && !this.RecentlyUsed)
+ g.FillRectangle(new SolidBrush(ColorFunctions.RecentlyUsedOfficeBackColor()), m_Rect);
+ else if (buttonX)
+ {
+ ButtonState state = ButtonState.Normal;
+ if (m_MouseDown)
+ state = ButtonState.Pushed;
+ else if (m_Checked || m_Expanded)
+ state = ButtonState.Checked;
+ ControlPaint.DrawButton(g, itemRect, state);
+ }
+ //else
+ // g.FillRectangle(SystemBrushes.Control,m_Rect);
+
+ if (GetEnabled(pa.ContainerControl) || this.DesignMode)
+ {
+ if (m_Expanded && !bIsOnMenu)
+ {
+ // Office 2000 Style
+ g.FillRectangle(SystemBrushes.Control, itemRect);
+ //System.Windows.Forms.ControlPaint.DrawBorder3D(g,itemRect,System.Windows.Forms.Border3DStyle.SunkenOuter,System.Windows.Forms.Border3DSide.All);
+ BarFunctions.DrawBorder3D(g, itemRect, System.Windows.Forms.Border3DStyle.SunkenOuter, System.Windows.Forms.Border3DSide.All, color3d);
+ }
+
+ if ((m_MouseOver && m_HotTrackingStyle != eHotTrackingStyle.None) || m_Expanded || m_Checked && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ {
+ //if(m_ButtonType!=eButtonType.Label)
+ {
+ // Draw Mouse over marker
+ if (bIsOnMenu || this.IsOnCustomizeDialog)
+ {
+ if ((m_MouseOver && m_HotTrackingStyle != eHotTrackingStyle.None) || m_Expanded)
+ {
+ if (!(m_MouseOver && this.DesignMode) || this.IsOnCustomizeDialog)
+ g.FillRectangle(SystemBrushes.Highlight, itemRect);
+ }
+ }
+ else
+ {
+ if (m_MouseDown || (m_Checked && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog) || this.Expanded && (!this.ShowSubItems || this.IsOnMenuBar))
+ {
+ if (m_SubItemsRect.IsEmpty)
+ {
+ if (!buttonX)
+ {
+ BarFunctions.DrawBorder3D(g, itemRect, System.Windows.Forms.Border3DStyle.SunkenOuter, System.Windows.Forms.Border3DSide.All, color3d);
+ if (m_Checked && !m_MouseOver && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ {
+ Rectangle r = itemRect; // Rectangle(itemRect.X,itemRect.Y,itemRect.Width,itemRect.Height);
+ r.Inflate(-1, -1);
+ g.FillRectangle(ColorFunctions.GetPushedBrush(this), r);
+ }
+ }
+ }
+ else
+ {
+ if (!buttonX)
+ {
+ Rectangle r;
+ if (m_Orientation == eOrientation.Horizontal)
+ r = new Rectangle(itemRect.X, itemRect.Y, itemRect.Width - m_SubItemsRect.Width, itemRect.Height);
+ else
+ r = new Rectangle(itemRect.X, itemRect.Y, itemRect.Width, itemRect.Height - m_SubItemsRect.Height);
+ //System.Windows.Forms.ControlPaint.DrawBorder3D(g,r,System.Windows.Forms.Border3DStyle.SunkenOuter,System.Windows.Forms.Border3DSide.All);
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.SunkenOuter, System.Windows.Forms.Border3DSide.All, color3d);
+ if (!m_MouseOver)
+ {
+ r.Inflate(-1, -1);
+ g.FillRectangle(ColorFunctions.GetPushedBrush(this), r);
+ }
+ }
+ }
+ }
+ else if (!this.DesignMode)
+ {
+ if (m_SubItemsRect.IsEmpty)
+ {
+ if (!buttonX)
+ BarFunctions.DrawBorder3D(g, itemRect, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, color3d);
+ }
+ else
+ {
+ Rectangle r;
+ if (m_Orientation == eOrientation.Horizontal)
+ r = new Rectangle(itemRect.X, itemRect.Y, itemRect.Width - m_SubItemsRect.Width, itemRect.Height);
+ else
+ r = new Rectangle(itemRect.X, itemRect.Y, itemRect.Width, itemRect.Height - m_SubItemsRect.Height);
+ //System.Windows.Forms.ControlPaint.DrawBorder3D(g,r,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.All);
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, color3d);
+ }
+ }
+
+ }
+
+ // TODO: Add support for Checked buttons etc...
+ if (objImage != null && m_ButtonStyle != eButtonStyle.TextOnlyAlways)
+ {
+ //if(m_ButtonType==eButtonType.StateButton)
+ // rTmp=new Rectangle(m_ImageDrawRect.X,m_ImageDrawRect.Y,itemRect.Height,itemRect.Height);
+ //else
+ rTmp = new Rectangle(m_ImageDrawRect.X, m_ImageDrawRect.Y, m_ImageDrawRect.Width, itemRect.Height);
+ //if(m_ImagePosition==eImagePosition.Right)
+ // rTmp.X=itemRect.Width-21-m_ImageDrawRect.Width;
+
+ rTmp.Offset(itemRect.Left, itemRect.Top);
+ if (bIsOnMenu)
+ {
+ if (m_Checked && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog)
+ {
+ //System.Windows.Forms.ControlPaint.DrawBorder3D(g,rTmp,System.Windows.Forms.Border3DStyle.SunkenOuter,System.Windows.Forms.Border3DSide.All);
+ BarFunctions.DrawBorder3D(g, rTmp, System.Windows.Forms.Border3DStyle.SunkenOuter, System.Windows.Forms.Border3DSide.All, color3d);
+ if (!m_MouseOver)
+ {
+ rTmp.Inflate(-1, -1);
+ g.FillRectangle(ColorFunctions.GetPushedBrush(this), rTmp);
+ }
+ /*if(m_ButtonType==eButtonType.StateButton)
+ {
+ // Draw checker...
+ Point[] pt=new Point[3];
+ pt[0].X=rTmp.Left+(rTmp.Width-5)/2;
+ pt[0].Y=rTmp.Top+(rTmp.Height-6)/2+3;
+ pt[1].X=pt[0].X+2;
+ pt[1].Y=pt[0].Y+2;
+ pt[2].X=pt[1].X+4;
+ pt[2].Y=pt[1].Y-4;
+ g.DrawLines(SystemPens.ControlText,pt);
+ pt[0].X++;
+ //pt[0].Y
+ pt[1].X++;
+ //pt[1].Y;
+ pt[2].X++;
+ //pt[2].Y;
+ g.DrawLines(SystemPens.ControlText,pt);
+ }*/
+ }
+ else
+ {
+ //System.Windows.Forms.ControlPaint.DrawBorder3D(g,rTmp,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.All);
+ BarFunctions.DrawBorder3D(g, rTmp, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, color3d);
+ }
+ /*if(m_ButtonType==eButtonType.StateButton && m_MouseOver)
+ {
+ rTmp=new Rectangle(rTmp.Right+STATEBUTTON_SPACING,rTmp.Top,m_ImageDrawRect.Width-rTmp.Width-STATEBUTTON_SPACING,itemRect.Height);
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g,rTmp,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.All);
+ }*/
+ }
+ else
+ {
+ if (m_MouseDown)
+ rect.Offset(1, 1);
+ }
+ //g.DrawImage(objImage,rect,0,0,objImage.Width,objImage.Height,System.Drawing.GraphicsUnit.Pixel);
+ objImage.DrawImage(g, rect);
+ }
+ else if ((objImage == null || m_ButtonStyle == eButtonStyle.TextOnlyAlways) && m_Checked && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog && bIsOnMenu)
+ {
+ // Draw checked box
+ rTmp = new Rectangle(m_ImageDrawRect.X, m_ImageDrawRect.Y, m_ImageDrawRect.Width, itemRect.Height);
+ rTmp.Offset(itemRect.Left, itemRect.Top);
+ DrawOfficeCheckBox(g, rTmp);
+ }
+ }
+ //else
+ // g.FillRectangle(SystemBrushes.Highlight,itemRect);
+ }
+ else
+ {
+ if (objImage != null && m_ButtonStyle != eButtonStyle.TextOnlyAlways)
+ {
+ if (m_HotTrackingStyle != eHotTrackingStyle.Color)
+ {
+ //g.DrawImage(objImage,rect,0,0,objImage.Width,objImage.Height,System.Drawing.GraphicsUnit.Pixel);
+ objImage.DrawImage(g, rect);
+ }
+ else if (m_HotTrackingStyle == eHotTrackingStyle.Color)
+ {
+ // Draw gray-scale image for this hover style...
+ float[][] array = new float[5][];
+ array[0] = new float[5] { 0.2125f, 0.2125f, 0.2125f, 0, 0 };
+ array[1] = new float[5] { 0.5f, 0.5f, 0.5f, 0, 0 };
+ array[2] = new float[5] { 0.0361f, 0.0361f, 0.0361f, 0, 0 };
+ array[3] = new float[5] { 0, 0, 0, 1, 0 };
+ array[4] = new float[5] { 0.2f, 0.2f, 0.2f, 0, 1 };
+ System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array);
+ System.Drawing.Imaging.ImageAttributes att = new System.Drawing.Imaging.ImageAttributes();
+ att.SetColorMatrix(grayMatrix);
+ //g.DrawImage(objImage,rect,0,0,objImage.Width,objImage.Height,GraphicsUnit.Pixel,att);
+ objImage.DrawImage(g, rect, 0, 0, objImage.Width, objImage.Height, GraphicsUnit.Pixel, att);
+ }
+ //g.CompositingMode=System.Drawing.Drawing2D.CompositingMode.SourceCopy;
+ }
+ }
+
+ if (bIsOnMenu && this.IsOnCustomizeMenu && m_Visible && !this.SystemItem)
+ {
+ Rectangle r = new Rectangle(m_Rect.Left, m_Rect.Top, m_Rect.Height, m_Rect.Height);
+ //r.Inflate(-1,-1);
+ DrawOfficeCheckBox(g, r);
+ }
+ }
+ else
+ {
+ textColor = SystemColors.ControlDark;
+ if (objImage != null && m_ButtonStyle != eButtonStyle.TextOnlyAlways)
+ {
+ // Draw disabled image
+ //g.DrawImage(objImage,rect);
+ objImage.DrawImage(g, rect);
+ }
+ }
+
+ // Draw menu item text
+ if (bIsOnMenu || m_ButtonStyle != eButtonStyle.Default || objImage == null || (!bIsOnMenu && (m_ImagePosition == eImagePosition.Top || m_ImagePosition == eImagePosition.Bottom)))
+ {
+ if (bIsOnMenu)
+ rect = new Rectangle(m_TextDrawRect.X, m_TextDrawRect.Y, itemRect.Width - m_ImageDrawRect.Right - 24, m_TextDrawRect.Height);
+ else
+ {
+ rect = m_TextDrawRect;
+ if (m_ImagePosition == eImagePosition.Top || m_ImagePosition == eImagePosition.Bottom)
+ {
+ if (m_Orientation == eOrientation.Horizontal)
+ rect = new Rectangle(m_TextDrawRect.X, m_TextDrawRect.Y, itemRect.Width, m_TextDrawRect.Height);
+ if ((this.SubItems.Count > 0 || this.PopupType == ePopupType.Container) && m_Orientation == eOrientation.Horizontal && this.ShowSubItems)
+ rect.Width -= 12;
+
+ objStringFormat |= eTextFormat.HorizontalCenter;
+ }
+ //else
+ //rect=new Rectangle(m_TextDrawRect.X,m_TextDrawRect.Y,itemRect.Width-m_ImageDrawRect.Width,m_TextDrawRect.Height);
+ }
+
+ if (((m_MouseOver && m_HotTrackingStyle != eHotTrackingStyle.None) || m_Expanded) && bIsOnMenu && !this.DesignMode)
+ textColor = SystemColors.HighlightText;
+
+ rect.Offset(itemRect.Left, itemRect.Top);
+
+ if (!bIsOnMenu && (m_MouseDown || (this.Expanded && this.IsOnMenuBar)))
+ rect.Offset(1, 1);
+
+ if (buttonX)
+ {
+ objStringFormat |= eTextFormat.HorizontalCenter;
+ rect.Height--;
+ }
+ if (GetEnabled(pa.ContainerControl) || this.DesignMode)
+ {
+ if (m_Orientation == eOrientation.Vertical && !bIsOnMenu)
+ {
+ g.RotateTransform(90);
+ TextDrawing.DrawStringLegacy(g, m_Text, objFont, textColor, new Rectangle(rect.Top, -rect.Right, rect.Height, rect.Width), objStringFormat);
+ g.ResetTransform();
+ }
+ else
+ {
+ TextDrawing.DrawString(g, m_Text, objFont, textColor, rect, objStringFormat);
+ if (!this.DesignMode && this.Focused && !bIsOnMenu && !pa.IsOnMenuBar)
+ {
+ //SizeF szf=g.MeasureString(m_Text,objFont,rect.Width,objStringFormat);
+ Rectangle r = rect;
+ //r.Width=(int)Math.Ceiling(szf.Width);
+ //r.Height=(int)Math.Ceiling(szf.Height);
+ //r.Inflate(1,1);
+ System.Windows.Forms.ControlPaint.DrawFocusRectangle(g, r);
+ }
+ }
+ }
+ else
+ {
+ if (m_Orientation == eOrientation.Vertical && !bIsOnMenu)
+ {
+ g.RotateTransform(90);
+ System.Windows.Forms.ControlPaint.DrawStringDisabled(g, m_Text, objFont, SystemColors.Control, new Rectangle(rect.Top, -rect.Right, rect.Height, rect.Width), TextDrawing.GetStringFormat(objStringFormat));
+ g.ResetTransform();
+ }
+ else
+ System.Windows.Forms.ControlPaint.DrawStringDisabled(g, m_Text, objFont, SystemColors.Control, rect, TextDrawing.GetStringFormat(objStringFormat));
+ }
+ }
+
+ // Draw Shortcut text if needed
+ if (this.DrawShortcutText != "" && bIsOnMenu)
+ {
+ objStringFormat |= eTextFormat.HidePrefix | eTextFormat.Right;
+ if (GetEnabled(pa.ContainerControl) || this.DesignMode)
+ TextDrawing.DrawString(g, this.DrawShortcutText, objFont, textColor, rect, objStringFormat);
+ else
+ System.Windows.Forms.ControlPaint.DrawStringDisabled(g, this.DrawShortcutText, objFont, SystemColors.Control, rect, TextDrawing.GetStringFormat(objStringFormat));
+ }
+
+ // If it has subitems draw the triangle to indicate that
+ if ((this.SubItems.Count > 0 || this.PopupType == ePopupType.Container) && this.ShowSubItems)
+ {
+ if (bIsOnMenu)
+ {
+ Point[] p = new Point[3];
+ p[0].X = itemRect.Left + itemRect.Width - 12;
+ p[0].Y = itemRect.Top + (itemRect.Height - 8) / 2;
+ p[1].X = p[0].X;
+ p[1].Y = p[0].Y + 8;
+ p[2].X = p[0].X + 4;
+ p[2].Y = p[0].Y + 4;
+ using (SolidBrush brush = new SolidBrush(textColor))
+ g.FillPolygon(brush, p);
+ }
+ else if (!m_SubItemsRect.IsEmpty)
+ {
+ if (m_MouseOver && !m_Expanded && m_HotTrackingStyle != eHotTrackingStyle.None)
+ {
+ Rectangle r = new Rectangle(m_SubItemsRect.X, m_SubItemsRect.Y, m_SubItemsRect.Width, m_SubItemsRect.Height);
+ r.Offset(itemRect.X, itemRect.Y);
+ //System.Windows.Forms.ControlPaint.DrawBorder3D(g,r,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.All);
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, color3d);
+ }
+ else if (m_Expanded)
+ {
+ Rectangle r = new Rectangle(m_SubItemsRect.X, m_SubItemsRect.Y, m_SubItemsRect.Width, m_SubItemsRect.Height);
+ r.Offset(itemRect.X, itemRect.Y);
+ //System.Windows.Forms.ControlPaint.DrawBorder3D(g,r,System.Windows.Forms.Border3DStyle.SunkenOuter,System.Windows.Forms.Border3DSide.All);
+ BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.SunkenOuter, System.Windows.Forms.Border3DSide.All, color3d);
+ }
+ Point[] p = new Point[3];
+ if (m_Orientation == eOrientation.Horizontal)
+ {
+ p[0].X = itemRect.Left + m_SubItemsRect.Left + (m_SubItemsRect.Width - 5) / 2;
+ p[0].Y = itemRect.Top + (m_SubItemsRect.Height - 3) / 2 + 1;
+ p[1].X = p[0].X + 5;
+ p[1].Y = p[0].Y;
+ p[2].X = p[0].X + 2;
+ p[2].Y = p[0].Y + 3;
+ }
+ else
+ {
+ p[0].X = itemRect.Left + (m_SubItemsRect.Width - 3) / 2 + 1;
+ p[0].Y = itemRect.Top + m_SubItemsRect.Top + (m_SubItemsRect.Height - 5) / 2;
+ p[1].X = p[0].X;
+ p[1].Y = p[0].Y + 6;
+ p[2].X = p[0].X - 3;
+ p[2].Y = p[0].Y + 3;
+ }
+ g.FillPolygon(SystemBrushes.ControlText, p);
+ }
+ }
+
+ if (this.Focused && this.DesignMode)
+ {
+ Rectangle r = itemRect;
+ r.Inflate(-1, -1);
+ g.DrawRectangle(new Pen(SystemColors.ControlText, 2), r);
+ }
+
+ if (objImage != null)
+ objImage.Dispose();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Image GetItemImage()
+ {
+ CompositeImage image = GetImage();
+ if (image != null)
+ return image.Image;
+ return null;
+ }
+
+ internal CompositeImage GetImage(Color textColor)
+ {
+ if (!GetEnabled() && !this.IsOnCustomizeDialog) // Issue: B1002
+ return GetImage(ImageState.Disabled, textColor);
+ else if (m_MouseDown || this.Checked || this.Expanded && m_HotTrackingStyle == eHotTrackingStyle.Image)
+ return GetImage(ImageState.Pressed, textColor);
+ else if (m_MouseOver && !m_MouseOverExpand && !(StyleManager.IsMetro(this.EffectiveStyle) && this.Expanded))
+ return GetImage(ImageState.Hover, textColor);
+ return GetImage(ImageState.Default, textColor);
+ }
+ internal CompositeImage GetImage()
+ {
+ return GetImage(Color.Black);
+ }
+ internal CompositeImage GetImage(ImageState state, Color textColor)
+ {
+ Image image = null;
+ if (state == ImageState.Disabled && (m_DisabledImage != null || m_DisabledImageIndex >= 0 || m_DisabledIcon != null || m_Image != null || m_ImageIndex >= 0 || m_Icon != null))
+ {
+ if (m_DisabledImage != null)
+ return new CompositeImage(m_DisabledImage, false, m_ImageSizeOverride);
+ else if (m_DisabledIcon != null)
+ return new CompositeImage(m_DisabledIcon, false, m_ImageSizeOverride);
+ if (m_DisabledImageIndex >= 0)
+ {
+ DisposedCachedImageListImage();
+ image = GetImageFromImageList(m_DisabledImageIndex);
+ if (image != null)
+ return new CompositeImage(image, (image != m_ImageCachedIdx), m_ImageSizeOverride);
+ return null;
+ }
+
+ CreateDisabledImage();
+
+ if (m_DisabledImage != null)
+ return new CompositeImage(m_DisabledImage, false, m_ImageSizeOverride);
+ else if (m_DisabledIcon != null)
+ return new CompositeImage(m_DisabledIcon, false, m_ImageSizeOverride);
+ else
+ return null;
+ }
+
+ if (m_Icon != null)
+ {
+ System.Drawing.Size iconSize = this.IconSize;
+ System.Drawing.Icon icon = null;
+ try
+ {
+ icon = new System.Drawing.Icon(m_Icon, iconSize);
+ }
+ catch { icon = null; }
+ if (icon == null)
+ return new CompositeImage(m_Icon, false, m_ImageSizeOverride);
+ else
+ return new CompositeImage(icon, true, m_ImageSizeOverride);
+ }
+
+ if (state == ImageState.Hover && (m_HoverImage != null || m_HoverImageIndex >= 0))
+ {
+ if (m_HoverImage != null)
+ return new CompositeImage(m_HoverImage, false, m_ImageSizeOverride);
+ if (m_HoverImageIndex >= 0)
+ {
+ DisposedCachedImageListImage();
+ image = GetImageFromImageList(m_HoverImageIndex);
+ if (image != null)
+ return new CompositeImage(image, (image != m_ImageCachedIdx), m_ImageSizeOverride);
+ return null;
+ }
+ }
+
+ if (state == ImageState.Pressed && (m_PressedImage != null || m_PressedImageIndex >= 0))
+ {
+ if (m_PressedImage != null)
+ return new CompositeImage(m_PressedImage, false, m_ImageSizeOverride);
+ if (m_PressedImageIndex >= 0)
+ {
+ DisposedCachedImageListImage();
+ image = GetImageFromImageList(m_PressedImageIndex);
+ if (image != null)
+ return new CompositeImage(image, (image != m_ImageCachedIdx), m_ImageSizeOverride);
+ return null;
+ }
+ }
+
+ if (m_ImageSmall != null && (UseSmallImageResolved || m_ImageSizeOverride.Width == m_ImageSmall.Width && m_ImageSizeOverride.Height == m_ImageSmall.Height))
+ return new CompositeImage(m_ImageSmall, false);
+ if (m_Image != null)
+ {
+ if (_ImageAlt != null && textColor == Color.White)
+ return new CompositeImage(_ImageAlt, false, m_ImageSizeOverride);
+ return new CompositeImage(m_Image, false, m_ImageSizeOverride);
+ }
+ if (m_ImageIndex >= 0)
+ {
+ if (m_DisabledImageIndex >= 0 || m_HoverImageIndex >= 0 || m_PressedImageIndex >= 0)
+ DisposedCachedImageListImage();
+ image = GetImageFromImageList(m_ImageIndex);
+ if (image != null)
+ return new CompositeImage(image, (image != m_ImageCachedIdx), m_ImageSizeOverride);
+ }
+
+ return null;
+ }
+
+ //private ImageList GetImageList()
+ //{
+ // IOwner owner = null;
+ // IBarImageSize iImageSize = null;
+ // if (_ItemPaintArgs != null)
+ // {
+ // owner = _ItemPaintArgs.Owner;
+ // iImageSize = _ItemPaintArgs.ContainerControl as IBarImageSize;
+ // }
+ // if (owner == null) owner = this.GetOwner() as IOwner;
+ // if (iImageSize == null) iImageSize = this.ContainerControl as IBarImageSize;
+
+ // if (owner != null)
+ // {
+ // try
+ // {
+ // if (iImageSize != null && iImageSize.ImageSize != eBarImageSize.Default)
+ // {
+ // if (iImageSize.ImageSize == eBarImageSize.Medium && owner.ImagesMedium != null)
+ // return owner.ImagesMedium;
+ // else if (iImageSize.ImageSize == eBarImageSize.Large && owner.ImagesLarge != null)
+ // return owner.ImagesLarge;
+ // else if (owner.Images != null)
+ // return owner.Images;
+ // }
+ // else if (m_Parent is SideBarPanelItem && ((SideBarPanelItem)m_Parent).ItemImageSize != eBarImageSize.Default)
+ // {
+ // eBarImageSize imgSize = ((SideBarPanelItem)m_Parent).ItemImageSize;
+ // if (imgSize == eBarImageSize.Medium && owner.ImagesMedium != null)
+ // return owner.ImagesMedium;
+ // else if (imgSize == eBarImageSize.Large && owner.ImagesLarge != null)
+ // return owner.ImagesLarge;
+ // else if (owner.Images != null)
+ // return owner.Images;
+ // }
+ // else if (owner.Images != null)
+ // return owner.Images;
+ // }
+ // catch (Exception)
+ // {
+ // return null;
+ // }
+ // }
+
+ // return null;
+ //}
+
+ private eBarImageSize GetImageListSize(IBarImageSize barImageSize)
+ {
+ eBarImageSize imageListSize = eBarImageSize.Default;
+ if (barImageSize != null) imageListSize = barImageSize.ImageSize;
+ if (_ImageListSizeSelection != eButtonImageListSelection.NotSet)
+ imageListSize = (eBarImageSize)_ImageListSizeSelection;
+ return imageListSize;
+ }
+
+ private Image GetImageFromImageList(int ImageIndex)
+ {
+ if (ImageIndex >= 0)
+ {
+ IOwner owner = null;
+ IBarImageSize iImageSize = null;
+ if (_ItemPaintArgs != null)
+ {
+ owner = _ItemPaintArgs.Owner;
+ iImageSize = _ItemPaintArgs.ContainerControl as IBarImageSize;
+ }
+ if (owner == null) owner = this.GetOwner() as IOwner;
+ if (iImageSize == null)
+ {
+ iImageSize = this.ContainerControl as IBarImageSize;
+ }
+
+ if (owner != null)
+ {
+ try
+ {
+ eBarImageSize imageListSize = GetImageListSize(iImageSize);
+
+ if (imageListSize != eBarImageSize.Default)
+ {
+ if (imageListSize == eBarImageSize.Medium && owner.ImagesMedium != null && !UseSmallImageResolved) // && owner.ImagesMedium.Images.Count>0 && ImageIndex0 && ImageIndex0 && ImageIndex0 && ImageIndex0 && ImageIndex0 && ImageIndex0 && ImageIndex
+ /// Sets fixed size of the image. Image will be scaled and painted it size specified.
+ ///
+ [Browsable(true), DevCoBrowsable(false)]
+ public System.Drawing.Size ImageFixedSize
+ {
+ get { return m_ImageSizeOverride; }
+ set
+ {
+ m_ImageSizeOverride = value;
+ this.OnImageChanged();
+ if (m_Parent != null && m_Parent is ImageItem)
+ {
+ ((ImageItem)m_Parent).RefreshImageSize();
+ }
+ }
+ }
+ ///
+ /// Resets ImageFixedSize property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetImageFixedSize()
+ {
+ this.ImageFixedSize = new Size();
+ }
+ ///
+ /// Gets whether ImageFixedSize property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeImageFixedSize()
+ {
+ return !m_ImageSizeOverride.IsEmpty;
+ }
+
+ ///
+ /// Gets or sets the fixed size of the button. Both width and height must be set to value greater than 0 in order for button to use fixed size.
+ /// Setting both width and height to 0 (default value) indicates that button will be sized based on content.
+ ///
+ [Browsable(true), DevCoBrowsable(false), Description("Indicates fixed size of the button."), Category("Layout")]
+ public virtual System.Drawing.Size FixedSize
+ {
+ get { return m_FixedSize; }
+ set
+ {
+ if (value.Width < 0) value.Width = 0;
+ if (value.Height < 0) value.Height = 0;
+ m_FixedSize = value;
+ this.NeedRecalcSize = true;
+ this.OnAppearanceChanged();
+ }
+ }
+ ///
+ /// Gets whether FixedSize property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeFixedSize()
+ {
+ return !m_FixedSize.IsEmpty;
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetFixedSize()
+ {
+ TypeDescriptor.GetProperties(this)["FixedSize"].SetValue(this, Size.Empty);
+ }
+
+ private System.Drawing.Size IconSize
+ {
+ get
+ {
+ // Default Icon Size
+ System.Drawing.Size size = new Size(16, 16);
+ IBarImageSize iImageSize = null;
+ if (_ItemPaintArgs != null)
+ {
+ iImageSize = _ItemPaintArgs.ContainerControl as IBarImageSize;
+ }
+ if (iImageSize == null) iImageSize = this.ContainerControl as IBarImageSize;
+
+ try
+ {
+ eBarImageSize imageListSize = GetImageListSize(iImageSize);
+ if (iImageSize != null && imageListSize != eBarImageSize.Default)
+ {
+ if (imageListSize == eBarImageSize.Medium)
+ size = new Size(24, 24);
+ else if (imageListSize == eBarImageSize.Large)
+ size = new Size(32, 32);
+ }
+ else if (m_Parent is SideBarPanelItem && ((SideBarPanelItem)m_Parent).ItemImageSize != eBarImageSize.Default)
+ {
+ eBarImageSize imgSize = ((SideBarPanelItem)m_Parent).ItemImageSize;
+ if (imgSize == eBarImageSize.Medium)
+ size = new Size(24, 24);
+ else if (imgSize == eBarImageSize.Large)
+ size = new Size(32, 32);
+ }
+ }
+ catch (Exception)
+ {
+ }
+
+ return size;
+ }
+ }
+
+ ///
+ /// Overridden. Recalculates the size of the item.
+ ///
+ public override void RecalcSize()
+ {
+ if (this.SuspendLayout)
+ return;
+ bool pulse = false;
+ int pulseBeats = m_PulseBeats;
+ if (m_FadeAnimation)
+ {
+ StopFade();
+ pulse = m_Pulse;
+ m_Pulse = false;
+ }
+
+ if (Dpi.Factor.Width > 1)
+ {
+ CompositeImage img = GetImage();
+ if (img != null && this.ImageSize.Width != img.Width)
+ this.OnImageChanged();
+ }
+
+ if (EffectiveStyle == eDotNetBarStyle.Office2000 && !this.IsThemed)
+ RecalcSizeOffice();
+ else
+ RecalcSizeDotNet();
+ base.RecalcSize();
+
+ if (pulse)
+ InvokeDelayed(new MethodInvoker(delegate { Pulse(pulseBeats); }), 500);
+ }
+
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual bool UseParentSubItemsImageSize
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ private void RecalcSizeDotNet()
+ {
+ ButtonItemLayout.LayoutButton(this);
+
+ // System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ // if(!IsHandleValid(objCtrl))
+ // return;
+ // //Graphics g=Graphics.FromHwnd(objCtrl.Handle);
+ // Graphics g = BarFunctions.CreateGraphics(objCtrl);
+ // bool bHasImage=false;
+ // if(GetImage(ImageState.Default)!=null)
+ // bHasImage=true;
+ //
+ // m_TextDrawRect=Rectangle.Empty;
+ // m_ImageDrawRect=Rectangle.Empty;
+ // m_SubItemsRect=Rectangle.Empty;
+ // int measureStringWidth=0;
+ // if(_FitContainer)
+ // measureStringWidth=m_Rect.Width-4;
+ // m_Rect.Width=0;
+ // m_Rect.Height=0;
+ //
+ // // Get the right image size that we will use for calculation
+ // Size objImageSize=Size.Empty;
+ // if(m_Parent!=null && m_ImageSizeOverride.IsEmpty)
+ // {
+ // ImageItem objParentImageItem=m_Parent as ImageItem;
+ // if(objParentImageItem!=null && !objParentImageItem.SubItemsImageSize.IsEmpty)
+ // {
+ // if(!bHasImage || this.IsOnMenu)
+ // objImageSize=new Size(objParentImageItem.SubItemsImageSize.Width,objParentImageItem.SubItemsImageSize.Height);
+ // else
+ // {
+ // if(this.Orientation==eOrientation.Horizontal)
+ // objImageSize=new Size(this.ImageSize.Width,objParentImageItem.SubItemsImageSize.Height);
+ // else
+ // objImageSize=new Size(objParentImageItem.SubItemsImageSize.Width,this.ImageSize.Height);
+ // }
+ // }
+ // else
+ // objImageSize=this.ImageSize;
+ // }
+ // else if(!m_ImageSizeOverride.IsEmpty)
+ // objImageSize=m_ImageSizeOverride;
+ // else
+ // objImageSize=this.ImageSize;
+ // if(_FitContainer && bHasImage && (m_ImagePosition==eImagePosition.Left || m_ImagePosition==eImagePosition.Right))
+ // {
+ // measureStringWidth-=(objImageSize.Width+10);
+ // }
+ //
+ // // Measure string
+ // Font objCurrentFont=null;
+ // if(m_Font!=null)
+ // objCurrentFont=m_Font;
+ // else
+ // {
+ // objCurrentFont=GetFont(null);
+ // if(m_HotFontBold)
+ // objCurrentFont=new Font(objCurrentFont,FontStyle.Bold);
+ // }
+ //
+ // Size objStringSize=Size.Empty;
+ // eTextFormat objStringFormat=GetStringFormat();
+ //
+ // if(m_Text!="")
+ // {
+ // if (m_Orientation == eOrientation.Vertical && !this.IsOnMenu)
+ // objStringSize = TextDrawing.MeasureStringLegacy(g, m_Text, objCurrentFont, new Size(measureStringWidth,0), objStringFormat);
+ // else
+ // objStringSize=TextDrawing.MeasureString(g,m_Text,objCurrentFont,measureStringWidth,objStringFormat);
+ // }
+ //
+ // // See if this button is on menu, and do appropriate calculations
+ // if(this.IsOnMenu)
+ // {
+ // if(objImageSize.IsEmpty)
+ // objImageSize=new Size(16,16);
+ // // Add 4 pixel padding to the image size, 2 pixels on each side
+ // objImageSize.Height+=2;
+ // objImageSize.Width+=7;
+ //
+ // // Calculate item height
+ // if(objStringSize.Height>objImageSize.Height)
+ // m_Rect.Height=(int)objStringSize.Height+4;
+ // else
+ // m_Rect.Height=objImageSize.Height+4;
+ //
+ // // Add Vertical Padding to it
+ // m_Rect.Height+=m_VerticalPadding;
+ //
+ // // We know the image position now, we will center it into this area
+ // if(this.IsOnCustomizeMenu)
+ // m_ImageDrawRect=new Rectangle(m_Rect.Height+2,(m_Rect.Height-objImageSize.Height)/2,objImageSize.Width,objImageSize.Height);
+ // else
+ // m_ImageDrawRect=new Rectangle(0,(m_Rect.Height-objImageSize.Height)/2,objImageSize.Width,objImageSize.Height);
+ //
+ // m_Rect.Width=(int)objStringSize.Width;
+ // // Add short-cut size if we have short-cut
+ // if( this.DrawShortcutText != "" )
+ // {
+ // Size objSizeShortcut=TextDrawing.MeasureString(g,this.DrawShortcutText,objCurrentFont,0,objStringFormat);
+ // m_Rect.Width+=(objSizeShortcut.Width+14); // 14 distance between text and shortcut
+ // }
+ //
+ // m_TextDrawRect=new Rectangle(m_ImageDrawRect.Right+8,3,m_Rect.Width,m_Rect.Height-6);
+ //
+ // // 8 pixels distance between image and text, 22 pixels if this item has sub items
+ // m_Rect.Width+=(m_ImageDrawRect.Right+8+26);
+ // m_Rect.Width+=m_HorizontalPadding;
+ // }
+ // else
+ // {
+ // bool bThemed=this.IsThemed;
+ // if(m_Orientation==eOrientation.Horizontal && (m_ImagePosition==eImagePosition.Left || m_ImagePosition==eImagePosition.Right))
+ // {
+ // // Recalc size for the Bar button
+ // // Add 8 pixel padding to the image size, 4 pixels on each side
+ // //objImageSize.Height+=4;
+ // objImageSize.Width+=10;
+ //
+ // // Calculate item height
+ // if(objStringSize.Height>objImageSize.Height)
+ // m_Rect.Height=(int)objStringSize.Height+6;
+ // else
+ // m_Rect.Height=objImageSize.Height+6;
+ //
+ // // Add Vertical Padding
+ // m_Rect.Height+=m_VerticalPadding;
+ //
+ // if(bThemed && !this.IsOnMenuBar)
+ // m_Rect.Height+=4;
+ //
+ // m_ImageDrawRect=Rectangle.Empty;
+ // if(m_ButtonStyle!=eButtonStyle.TextOnlyAlways && bHasImage)
+ // {
+ // // We know the image position now, we will center it into this area
+ // m_ImageDrawRect=new Rectangle(0,(m_Rect.Height-objImageSize.Height)/2,objImageSize.Width,objImageSize.Height);
+ // }
+ //
+ // // Draw Text only if needed
+ // m_TextDrawRect=Rectangle.Empty;
+ // if(m_ButtonStyle!=eButtonStyle.Default || !bHasImage)
+ // {
+ // if(m_ImageDrawRect.Right>0)
+ // {
+ // m_Rect.Width=(int)objStringSize.Width+1;
+ // m_TextDrawRect=new Rectangle(m_ImageDrawRect.Right-2,2,m_Rect.Width,m_Rect.Height-4);
+ // }
+ // else
+ // {
+ // m_Rect.Width=(int)objStringSize.Width+6;
+ // if(!bHasImage && this.IsOnMenuBar)
+ // {
+ // m_Rect.Width+=6;
+ // m_TextDrawRect=new Rectangle(0,2,m_Rect.Width,m_Rect.Height-4);
+ // }
+ // else
+ // m_TextDrawRect=new Rectangle(3,2,m_Rect.Width,m_Rect.Height-4);
+ // }
+ // }
+ // // No need for the code below since it causes text to be drawn if item is not on Bar no matter what
+ //// else if(!this.IsOnBar)
+ //// {
+ //// if(m_ImageDrawRect.Right>0)
+ //// {
+ //// m_Rect.Width=(int)objStringSize.Width+4;
+ //// m_TextDrawRect=new Rectangle(m_ImageDrawRect.Right-2,2,m_Rect.Width,m_Rect.Height-4);
+ //// }
+ //// else
+ //// {
+ //// m_Rect.Width=(int)objStringSize.Width+6;
+ //// m_TextDrawRect=new Rectangle(3,2,m_Rect.Width,m_Rect.Height-4);
+ //// }
+ //// }
+ // m_Rect.Width+=m_ImageDrawRect.Right;
+ //
+ // if(m_ImagePosition==eImagePosition.Right && m_ImageDrawRect.Right>0)
+ // {
+ // m_TextDrawRect.X=3;
+ // m_ImageDrawRect.X=m_Rect.Width-m_ImageDrawRect.Width;
+ // }
+ //
+ // // Add Horizontal padding
+ // m_Rect.Width+=m_HorizontalPadding;
+ // }
+ // else
+ // {
+ // // Image is on top or bottom
+ // // Calculate width, that is easy
+ // if(m_Orientation==eOrientation.Horizontal)
+ // {
+ // if(objStringSize.Width>objImageSize.Width)
+ // m_Rect.Width=(int)objStringSize.Width+6;
+ // else
+ // m_Rect.Width=objImageSize.Width+6;
+ //
+ // // Calculate item height 3 padding on top and bottom and 2 pixels distance between the image and text
+ // m_Rect.Height=(int)(objImageSize.Height+objStringSize.Height+10);
+ //
+ // // Add Horizontal/Vertical padding
+ // m_Rect.Width+=m_HorizontalPadding;
+ // m_Rect.Height+=m_VerticalPadding;
+ //
+ // if(m_ImagePosition==eImagePosition.Top)
+ // {
+ // m_ImageDrawRect=new Rectangle(0,m_VerticalPadding/2+2,m_Rect.Width,objImageSize.Height+2);
+ // m_TextDrawRect=new Rectangle((int)(m_Rect.Width-objStringSize.Width)/2,m_ImageDrawRect.Bottom,(int)objStringSize.Width,(int)objStringSize.Height+5);
+ // }
+ // else
+ // {
+ // m_TextDrawRect=new Rectangle((int)(m_Rect.Width-objStringSize.Width)/2,m_VerticalPadding/2,(int)objStringSize.Width,(int)objStringSize.Height+2);
+ // m_ImageDrawRect=new Rectangle(0,m_TextDrawRect.Bottom,m_Rect.Width,objImageSize.Height+5);
+ // }
+ // }
+ // else
+ // {
+ // if(objStringSize.Height>objImageSize.Width && m_ButtonStyle!=eButtonStyle.Default)
+ // m_Rect.Width=(int)objStringSize.Height+6;
+ // else
+ // m_Rect.Width=objImageSize.Width+10;
+ //
+ // // Add Horizontal Padding
+ // m_Rect.Width+=m_HorizontalPadding;
+ //
+ // // Calculate item height 3 padding on top and bottom and 2 pixels distance between the image and text
+ // if(m_ButtonStyle!=eButtonStyle.Default || !bHasImage)
+ // {
+ // if(bHasImage)
+ // m_Rect.Height=(int)(objImageSize.Height+objStringSize.Width+12);
+ // else
+ // m_Rect.Height=(int)(objStringSize.Width+6);
+ // }
+ // else
+ // m_Rect.Height=objImageSize.Height+6;
+ //
+ // if(m_ImagePosition==eImagePosition.Top || m_ImagePosition==eImagePosition.Left)
+ // {
+ // if(bHasImage)
+ // m_ImageDrawRect=new Rectangle(0,0,m_Rect.Width,objImageSize.Height+6);
+ // m_TextDrawRect=new Rectangle((int)(m_Rect.Width-objStringSize.Height)/2,m_ImageDrawRect.Bottom+2,(int)objStringSize.Height,(int)objStringSize.Width+5);
+ // }
+ // else
+ // {
+ // m_TextDrawRect=new Rectangle((int)(m_Rect.Width-objStringSize.Width)/2,0,(int)objStringSize.Height,(int)objStringSize.Width+5);
+ // if(bHasImage)
+ // m_ImageDrawRect=new Rectangle(0,m_TextDrawRect.Bottom+2,m_Rect.Width,objImageSize.Height+5);
+ // }
+ //
+ // // Add Vertical Padding
+ // m_Rect.Height+=m_VerticalPadding;
+ // }
+ // }
+ //
+ // //if(SubItemsCount>0 && this.ShowSubItems && (!this.IsOnMenuBar || this.GetImage()!=null))
+ // if((SubItems.Count>0 || this.PopupType==ePopupType.Container) && this.ShowSubItems && !this.IsOnMenuBar)
+ // {
+ // // Add small button to expand the item
+ // if(m_Orientation==eOrientation.Horizontal)
+ // {
+ // if(bThemed)
+ // m_SubItemsRect=new Rectangle(m_Rect.Width,0,m_SubItemsExpandWidth,m_Rect.Height);
+ // else
+ // m_SubItemsRect=new Rectangle(m_Rect.Width-2,0/*m_Rect.Top*/,m_SubItemsExpandWidth,m_Rect.Height);
+ // m_Rect.Width+=m_SubItemsExpandWidth;
+ // }
+ // else
+ // {
+ // m_SubItemsRect=new Rectangle(/*m_Rect.Left+2*/2,m_Rect.Height-2,m_Rect.Width,m_SubItemsExpandWidth);
+ // m_Rect.Height+=m_SubItemsExpandWidth;
+ // }
+ // }
+ // }
+ // // This button is on Bar
+ // //objCurrentFont.Dispose();
+ // g.Dispose();
+ // objCtrl=null;
+ }
+
+ private void RecalcSizeOffice()
+ {
+ System.Windows.Forms.Control objCtrl = this.ContainerControl as System.Windows.Forms.Control;
+ if (!IsHandleValid(objCtrl))
+ return;
+ Graphics g = Graphics.FromHwnd(objCtrl.Handle);
+ g.PageUnit = System.Drawing.GraphicsUnit.Pixel;
+
+ m_TextDrawRect = Rectangle.Empty;
+ m_ImageDrawRect = Rectangle.Empty;
+ m_Rect = Rectangle.Empty;
+ m_SubItemsRect = Rectangle.Empty;
+
+ bool bHasImage = false;
+ if (GetImage(ImageState.Default, Color.Black) != null)
+ bHasImage = true;
+
+ // Get the right image size that we will use for calculation
+ Size objImageSize;
+ if (m_Parent != null)
+ {
+ ImageItem objImageItem = m_Parent as ImageItem;
+ if (objImageItem != null)
+ {
+ if (!bHasImage || this.IsOnMenu)
+ objImageSize = new Size(objImageItem.SubItemsImageSize.Width, objImageItem.SubItemsImageSize.Height);
+ else
+ {
+ if (this.Orientation == eOrientation.Horizontal)
+ objImageSize = new Size(this.ImageSize.Width, objImageItem.SubItemsImageSize.Height);
+ else
+ objImageSize = new Size(objImageItem.SubItemsImageSize.Width, this.ImageSize.Height);
+ }
+ }
+ else
+ objImageSize = this.ImageSize;
+ }
+ else
+ objImageSize = this.ImageSize;
+
+ // Measure string
+ Font objCurrentFont = null;
+ if (m_Font != null)
+ objCurrentFont = m_Font;
+ else
+ objCurrentFont = GetFont(null, true);
+
+ Size objStringSize;
+ eTextFormat objStringFormat = GetStringFormat();
+
+ if (m_Orientation == eOrientation.Vertical && !this.IsOnMenu)
+ objStringSize = TextDrawing.MeasureStringLegacy(g, m_Text, objCurrentFont, Size.Empty, objStringFormat);
+ else
+ objStringSize = TextDrawing.MeasureString(g, m_Text, objCurrentFont, 0, objStringFormat);
+
+ // See if this button is on menu, and do appropriate calculations
+ if (this.IsOnMenu)
+ {
+ // Add 4 pixel padding to the image size, 2 pixels on each side
+ //objImageSize.Height+=1;
+ objImageSize.Width += 4;
+
+ // Calculate item height
+ if (objStringSize.Height > objImageSize.Height)
+ m_Rect.Height = (int)objStringSize.Height + 4;
+ else
+ m_Rect.Height = objImageSize.Height + 4;
+
+ // Add Padding
+ m_Rect.Height += m_VerticalPadding;
+
+ // We know the image position now, we will center it into this area
+ if (this.IsOnCustomizeMenu)
+ m_ImageDrawRect = new Rectangle(m_Rect.Height, 0, m_Rect.Height, m_Rect.Height);
+ else
+ m_ImageDrawRect = new Rectangle(0, 0, objImageSize.Width, m_Rect.Height);
+
+ m_Rect.Width = (int)objStringSize.Width;
+ // Add short-cut size if we have short-cut
+ if (this.DrawShortcutText != "")
+ {
+ Size objSizeShortcut = TextDrawing.MeasureString(g, this.DrawShortcutText, objCurrentFont, 0, objStringFormat);
+ m_Rect.Width += (objSizeShortcut.Width + 14); // 14 distance between text and shortcut
+ }
+
+ //m_TextDrawRect=new Rectangle(m_ImageDrawRect.Right+2,3,m_Rect.Width,m_Rect.Height-6);
+ m_TextDrawRect = new Rectangle(m_ImageDrawRect.Right + 2, (int)(m_Rect.Height - objStringSize.Height) / 2, m_Rect.Width, (int)objStringSize.Height);
+
+ // 8 pixels distance between image and text, 22 pixels if this item has sub items
+ m_Rect.Width += (m_ImageDrawRect.Right + 2 + 24);
+
+ // Add Horizontal Padding
+ m_Rect.Width += m_HorizontalPadding;
+
+ // Don't support the image alignment in menus yet
+ /*if(m_ImagePosition==eImagePosition.Right)
+ {
+ int i=m_TextDrawRect.Right-m_ImageDrawRect.Right;
+ m_TextDrawRect.X=m_ImageDrawRect.X;
+ m_ImageDrawRect.X=i;
+ }*/
+
+ //if(m_BeginGroup)
+ // m_Rect.Height+=9;
+ }
+ else
+ {
+ // Recalc size for the Bar button
+ if (m_Orientation == eOrientation.Horizontal && (m_ImagePosition == eImagePosition.Left || m_ImagePosition == eImagePosition.Right))
+ {
+ // Add 8 pixel padding to the image size, 4 pixels on each side
+ //objImageSize.Height+=4;
+ objImageSize.Width += 10;
+
+ // Calculate item height
+ if (objStringSize.Height > objImageSize.Height)
+ m_Rect.Height = (int)objStringSize.Height + 6;
+ else
+ m_Rect.Height = objImageSize.Height + 6;
+
+ // Add Vertical Padding
+ m_Rect.Height += m_VerticalPadding;
+
+ m_ImageDrawRect = Rectangle.Empty;
+ if (m_ButtonStyle != eButtonStyle.TextOnlyAlways && bHasImage)
+ {
+ // We know the image position now, we will center it into this area
+ m_ImageDrawRect = new Rectangle(0, (m_Rect.Height - objImageSize.Height) / 2, objImageSize.Width, objImageSize.Height);
+ }
+
+ // Draw Text only if needed
+ m_TextDrawRect = Rectangle.Empty;
+ if (m_ButtonStyle != eButtonStyle.Default || !bHasImage)
+ {
+ if (m_ImageDrawRect.Right > 0)
+ {
+ m_Rect.Width = (int)objStringSize.Width + 1;
+ m_TextDrawRect = new Rectangle(m_ImageDrawRect.Right - 2, 2, m_Rect.Width, m_Rect.Height - 4);
+ }
+ else
+ {
+ m_Rect.Width = (int)objStringSize.Width + 6;
+ m_TextDrawRect = new Rectangle(3, 2, m_Rect.Width, m_Rect.Height - 4);
+ }
+ }
+ m_Rect.Width += m_ImageDrawRect.Right;
+
+ // Add Horizontal Padding
+ m_Rect.Width += m_HorizontalPadding;
+ }
+ else
+ {
+ // Image is on top or bottom
+ if (m_Orientation == eOrientation.Horizontal)
+ {
+ // Calculate width, that is easy
+ if (objStringSize.Width > objImageSize.Width)
+ m_Rect.Width = (int)objStringSize.Width + 6;
+ else
+ m_Rect.Width = objImageSize.Width + 6;
+
+ // Calculate item height 3 padding on top and bottom and 2 pixels distance between the image and text
+ m_Rect.Height = (int)(objImageSize.Height + objStringSize.Height + 10);
+
+ // Add Padding
+ m_Rect.Width += m_HorizontalPadding;
+ m_Rect.Height += m_VerticalPadding;
+
+ if (m_ImagePosition == eImagePosition.Top)
+ {
+ m_ImageDrawRect = new Rectangle(0, m_VerticalPadding / 2, m_Rect.Width, objImageSize.Height + 2);
+ m_TextDrawRect = new Rectangle((int)(m_Rect.Width - objStringSize.Width) / 2, m_ImageDrawRect.Bottom + 2, (int)objStringSize.Width, (int)objStringSize.Height + 5);
+ }
+ else
+ {
+ m_TextDrawRect = new Rectangle((int)(m_Rect.Width - objStringSize.Width) / 2, m_VerticalPadding / 2, (int)objStringSize.Width, (int)objStringSize.Height + 2);
+ m_ImageDrawRect = new Rectangle(0, m_TextDrawRect.Bottom + 2, m_Rect.Width, objImageSize.Height + 5);
+ }
+ }
+ else
+ {
+ // Calculate width, that is easy
+ if (objStringSize.Height > objImageSize.Height && m_ButtonStyle != eButtonStyle.Default)
+ m_Rect.Width = (int)objStringSize.Height + 6;
+ else
+ m_Rect.Width = objImageSize.Width + 6;
+
+ m_Rect.Width += m_HorizontalPadding;
+
+ // Calculate item height 3 padding on top and bottom and 2 pixels distance between the image and text
+ if (m_ButtonStyle != eButtonStyle.Default || !bHasImage)
+ {
+ if (bHasImage)
+ m_Rect.Height = (int)(objImageSize.Height + objStringSize.Width + 12);
+ else
+ m_Rect.Height = (int)(objStringSize.Width + 6);
+ }
+ else
+ m_Rect.Height = objImageSize.Height + 6;
+
+ if (m_ImagePosition == eImagePosition.Top || m_ImagePosition == eImagePosition.Left)
+ {
+ if (bHasImage)
+ m_ImageDrawRect = new Rectangle(0, 0, m_Rect.Width, objImageSize.Height + 5);
+ m_TextDrawRect = new Rectangle((int)(m_Rect.Width - objStringSize.Height) / 2, m_ImageDrawRect.Bottom + 2, (int)objStringSize.Height, (int)objStringSize.Width + 5);
+ }
+ else
+ {
+ m_TextDrawRect = new Rectangle((int)(m_Rect.Width - objStringSize.Height) / 2, 0, (int)objStringSize.Height, (int)objStringSize.Width + 5);
+ if (bHasImage)
+ m_ImageDrawRect = new Rectangle(0, m_TextDrawRect.Bottom + 2, m_Rect.Width, objImageSize.Height + 5);
+ }
+ m_Rect.Height += m_VerticalPadding;
+ }
+ }
+
+ if ((this.SubItems.Count > 0 || this.PopupType == ePopupType.Container) && this.ShowSubItems && (!this.IsOnMenuBar || this.GetImage() != null))
+ {
+ // Add small button to expand the item
+ if (m_Orientation == eOrientation.Horizontal)
+ {
+ m_SubItemsRect = new Rectangle(m_Rect.Right, 0/*m_Rect.Top*/, 12, m_Rect.Height);
+ m_Rect.Width += m_SubItemsRect.Width;
+ }
+ else
+ {
+ m_SubItemsRect = new Rectangle(0/*m_Rect.Left*/, m_Rect.Bottom, m_Rect.Width, 12);
+ m_Rect.Height += m_SubItemsRect.Height;
+ }
+ }
+ }
+
+ // This button is on Bar
+ //objCurrentFont.Dispose();
+ g.Dispose();
+ objCtrl = null;
+ }
+
+ private void DrawOfficeCheckBox(Graphics g, Rectangle r)
+ {
+ // Draw checked box
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.SunkenOuter, System.Windows.Forms.Border3DSide.All);
+ if (!m_MouseOver)
+ {
+ r.Inflate(-1, -1);
+ g.FillRectangle(ColorFunctions.GetPushedBrush(), r);
+ }
+ // Draw checker...
+ Point[] pt = new Point[3];
+ pt[0].X = r.Left + (r.Width - 6) / 2;
+ pt[0].Y = r.Top + (r.Height - 6) / 2 + 3;
+ pt[1].X = pt[0].X + 2;
+ pt[1].Y = pt[0].Y + 2;
+ pt[2].X = pt[1].X + 4;
+ pt[2].Y = pt[1].Y - 4;
+ g.DrawLines(SystemPens.ControlText, pt);
+ pt[0].X++;
+ pt[1].X++;
+ pt[2].X++;
+ g.DrawLines(SystemPens.ControlText, pt);
+ }
+
+ protected internal override void OnItemAdded(BaseItem item)
+ {
+ base.OnItemAdded(item);
+ OnAppearanceChanged();
+ }
+
+ ///
+ /// Overloaded. Called when size of the item is changed externally.
+ ///
+ protected override void OnExternalSizeChange()
+ {
+ base.OnExternalSizeChange();
+ if (!m_FixedSize.IsEmpty)
+ {
+ if (m_FixedSize.Width > 0) m_Rect.Width = Dpi.Width(m_FixedSize.Width);
+ if (m_FixedSize.Height > 0) m_Rect.Height = Dpi.Height(m_FixedSize.Height);
+ }
+ ButtonItemLayout.Arrange(this);
+ return;
+ }
+
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void ContainerLostFocus(bool appLostFocus)
+ {
+ base.ContainerLostFocus(appLostFocus);
+ if (m_Expanded)
+ {
+ this.Expanded = false;
+ if (m_Parent != null)
+ m_Parent.AutoExpand = false;
+ }
+ }
+
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalKeyDown(System.Windows.Forms.KeyEventArgs objArg)
+ {
+ base.InternalKeyDown(objArg);
+ if (this.Expanded || objArg.Handled)
+ return;
+
+ if (objArg.KeyCode == System.Windows.Forms.Keys.Enter || objArg.KeyCode == System.Windows.Forms.Keys.Return || objArg.KeyCode == System.Windows.Forms.Keys.Right && this.IsOnMenu)
+ {
+ if (SubItems.Count > 0 && this.GetEnabled())
+ {
+ if (this.Expanded)
+ {
+ if (m_Parent != null)
+ m_Parent.AutoExpand = false;
+ this.Expanded = false;
+ }
+ else
+ {
+ if (m_Parent != null)
+ m_Parent.AutoExpand = true;
+ this.Expanded = true;
+ // Select first item on that popup
+ if (this.PopupType == ePopupType.Menu && this.PopupControl is MenuPanel)
+ {
+ ((MenuPanel)this.PopupControl).SelectFirstItem();
+ }
+ }
+ objArg.Handled = true;
+ return;
+ }
+ }
+ else if (objArg.KeyCode == System.Windows.Forms.Keys.Escape)
+ {
+ if (SubItems.Count > 0 && this.Expanded)
+ {
+ this.Expanded = false;
+ if (m_Parent != null)
+ m_Parent.AutoExpand = false;
+ objArg.Handled = true;
+ return;
+ }
+ }
+
+ base.InternalKeyDown(objArg);
+ }
+
+ #region Fade Effect Support
+ private Bitmap m_ImageState2 = null;
+ private int m_Direction = 1;
+ private int m_Alpha = 0;
+ private bool m_FadeAnimation = false;
+ private System.Threading.ReaderWriterLock m_FadeImageLock = new System.Threading.ReaderWriterLock();
+ private void SetMouseOver(bool value)
+ {
+ if (value != m_MouseOver)
+ {
+ if (m_Pulse)
+ {
+ if (m_StopPulseOnMouseOver)
+ m_Pulse = false;
+ StopFade();
+ }
+
+ bool fadeEnabled = (IsFadeEnabled || m_Pulse) && this.GetEnabled() && this.Displayed && this.Visible && this.WidthInternal > 0 && this.HeightInternal > 0;
+ if (fadeEnabled)
+ {
+ int direction = value ? 1 : -1;
+ int initialAlpha = value ? 10 : 255;
+
+ m_MouseOver = value;
+ StartFade(direction, initialAlpha);
+ }
+ else
+ m_MouseOver = value;
+ }
+ }
+
+ private void StartFade(int direction, int initialAlpha)
+ {
+ bool createImage = false;
+ m_FadeImageLock.AcquireReaderLock(-1);
+ try
+ {
+ createImage = (m_ImageState2 == null);
+ }
+ finally
+ {
+ m_FadeImageLock.ReleaseReaderLock();
+ }
+
+ if (createImage)
+ {
+ bool oldMouseOver = m_MouseOver;
+ m_MouseOver = true;
+ try
+ {
+ bool readerLockHeld = m_FadeImageLock.IsReaderLockHeld;
+ System.Threading.LockCookie cookie1 = new System.Threading.LockCookie();
+ if (readerLockHeld)
+ {
+ cookie1 = m_FadeImageLock.UpgradeToWriterLock(-1);
+ }
+ else
+ {
+ m_FadeImageLock.AcquireWriterLock(-1);
+ }
+
+ try
+ {
+ m_ImageState2 = GetCurrentStateImage();
+ }
+ finally
+ {
+ if (readerLockHeld)
+ {
+ m_FadeImageLock.DowngradeFromWriterLock(ref cookie1);
+ }
+ else
+ {
+ m_FadeImageLock.ReleaseWriterLock();
+ }
+ }
+ }
+ finally
+ {
+ m_MouseOver = oldMouseOver;
+ }
+ }
+
+ m_Direction = direction;
+ m_Alpha = initialAlpha;
+
+ FadeAnimator.Fade(this, new EventHandler(this.OnFadeChanged));
+ m_FadeAnimation = true;
+ }
+
+ internal void StopFade()
+ {
+ if (!m_FadeAnimation)
+ return;
+
+ m_FadeAnimation = false;
+ FadeAnimator.StopFade(this, new EventHandler(OnFadeChanged));
+
+ bool disposeImage = false;
+ m_FadeImageLock.AcquireReaderLock(-1);
+ try
+ {
+ disposeImage = (m_ImageState2 != null);
+ }
+ finally
+ {
+ m_FadeImageLock.ReleaseReaderLock();
+ }
+ if (disposeImage)
+ DisposeFadeImage();
+
+ if (m_Alpha > 230)
+ m_Alpha = 255;
+ else if (m_Alpha < 0)
+ m_Alpha = 0;
+ this.Invalidate();
+ }
+
+ private void DisposeFadeImage()
+ {
+ bool readerLockHeld = m_FadeImageLock.IsReaderLockHeld;
+ System.Threading.LockCookie cookie1 = new System.Threading.LockCookie();
+
+ if (readerLockHeld)
+ {
+ cookie1 = m_FadeImageLock.UpgradeToWriterLock(-1);
+ }
+ else
+ {
+ m_FadeImageLock.AcquireWriterLock(-1);
+ }
+
+ try
+ {
+ m_ImageState2.Dispose();
+ m_ImageState2 = null;
+ }
+ finally
+ {
+ if (readerLockHeld)
+ {
+ m_FadeImageLock.DowngradeFromWriterLock(ref cookie1);
+ }
+ else
+ {
+ m_FadeImageLock.ReleaseWriterLock();
+ }
+ }
+ }
+
+ private void OnFadeChanged(object sender, EventArgs e)
+ {
+ m_Alpha += (m_Direction * (m_Pulse ? m_PulseFadeAlphaIncrement : m_MouseOverFadeAlphaIncrement));
+
+ if (m_Direction < 0 && m_Alpha <= 0 || m_Direction > 0 && m_Alpha >= 255)
+ {
+ if (m_Pulse)
+ {
+ m_Direction *= -1;
+ if (m_Alpha >= 255) m_Alpha = 255; else m_Alpha = 0;
+ m_PulseCount++;
+ if (m_PulseBeats > 0 && m_PulseCount > m_PulseBeats)
+ {
+ StopFade();
+ StopPulse();
+ }
+ }
+ else
+ StopFade();
+ }
+
+ System.Windows.Forms.Control cc = this.ContainerControl as System.Windows.Forms.Control;
+ if (cc != null && BarFunctions.IsHandleValid(cc))
+ {
+ try
+ {
+ cc.Invalidate(this.DisplayRectangle);
+ }
+ catch (ObjectDisposedException) { }
+ catch (System.ComponentModel.Win32Exception) { }
+ }
+ }
+
+ private Bitmap GetCurrentStateImage()
+ {
+ Bitmap bitmap = new Bitmap(this.WidthInternal, this.HeightInternal, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); // Format32bppArgb);
+ bitmap.MakeTransparent();
+ Graphics g = Graphics.FromImage(bitmap);
+
+ try
+ {
+ System.Windows.Forms.Control cc = this.ContainerControl as System.Windows.Forms.Control;
+ bool antiAlias = false;
+ ItemPaintArgs pa = null;
+ if (cc is ItemControl)
+ {
+ antiAlias = ((ItemControl)cc).AntiAlias;
+ pa = ((ItemControl)cc).GetItemPaintArgs(g);
+ }
+ else if (cc is Bar)
+ {
+ antiAlias = ((Bar)cc).AntiAlias;
+ pa = ((Bar)cc).GetItemPaintArgs(g);
+ }
+ else if (cc is ButtonX)
+ {
+ antiAlias = ((ButtonX)cc).AntiAlias;
+ pa = ((ButtonX)cc).GetItemPaintArgs(g);
+ }
+
+ System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix();
+ myMatrix.Translate(-this.DisplayRectangle.X, -this.DisplayRectangle.Y, System.Drawing.Drawing2D.MatrixOrder.Append);
+ g.Transform = myMatrix;
+ myMatrix.Dispose();
+ myMatrix = null;
+ if (antiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ if (pa == null)
+ {
+ bitmap.Dispose();
+ return null;
+ }
+
+ this.Paint(pa);
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ return bitmap;
+ }
+
+ internal bool _FadeEnabled = true;
+ ///
+ /// Gets whether fade effect is enabled.
+ ///
+ protected virtual bool IsFadeEnabled
+ {
+ get
+ {
+ eDotNetBarStyle effectiveStyle = EffectiveStyle;
+
+ if (this.DesignMode || m_HotTrackingStyle == eHotTrackingStyle.None || !_FadeEnabled || TextDrawing.UseTextRenderer
+ || effectiveStyle == eDotNetBarStyle.Office2010 || effectiveStyle == eDotNetBarStyle.Windows7 || StyleManager.IsMetro(effectiveStyle) || !BarUtilities.FadeAnimatorEnabled)
+ return false;
+ if (WinApi.IsGlassEnabled && (this.Parent is CaptionItemContainer || this.Parent is RibbonTabItemContainer && effectiveStyle == eDotNetBarStyle.Office2010))
+ return false;
+
+ System.Windows.Forms.Control cc = this.ContainerControl as System.Windows.Forms.Control;
+ if (cc != null)
+ {
+ if (cc is ItemControl)
+ return ((ItemControl)cc).IsFadeEnabled;
+ else if (cc is Bar)
+ return ((Bar)cc).IsFadeEnabled;
+ else if (cc is ButtonX)
+ return ((ButtonX)cc).IsFadeEnabled;
+ }
+ return false;
+ }
+ }
+
+ ///
+ /// Starts the button pulse effect which alternates slowly between the mouse over and the default state. The pulse effect
+ /// continues indefinitely until it is stopped by call to StopPulse method.
+ ///
+ public void Pulse()
+ {
+ Pulse(0);
+ }
+ ///
+ /// Gets whether Pulse function is enabled.
+ ///
+ protected virtual bool IsPulseEnabed
+ {
+ get
+ {
+ return true;
+ }
+ }
+ ///
+ /// Starts the button pulse effect which alternates slowly between the mouse over and the default state. Pulse effect
+ /// will alternate between the pulse state for the number of times specified by the pulseBeatCount parameter.
+ ///
+ /// Specifies the number of times button alternates between pulse states. 0 indicates indefinite pulse
+ public void Pulse(int pulseBeatCount)
+ {
+ if (this.DesignMode || m_HotTrackingStyle == eHotTrackingStyle.None || !IsPulseEnabed)
+ return;
+
+ m_PulseBeats = pulseBeatCount;
+ m_PulseCount = 0;
+ if (m_Pulse) return;
+
+ m_Pulse = true;
+ if (m_MouseOver) return;
+
+ StartFade(1, 0);
+ }
+
+ ///
+ /// Stops the button Pulse effect.
+ ///
+ public void StopPulse()
+ {
+ if (m_Pulse)
+ {
+ m_Pulse = false;
+ if (m_MouseOver) SetMouseOver(false);
+ StopFade();
+ }
+ }
+
+ ///
+ /// Gets whether the button is currently pulsing, alternating slowly between the mouse over and default state.
+ ///
+ [Browsable(false)]
+ public bool IsPulsing
+ {
+ get { return m_Pulse; }
+ }
+
+ ///
+ /// Gets or sets whether pulse effect started with StartPulse method stops automatically when mouse moves over the button. Default value is true.
+ ///
+ [DefaultValue(true), Browsable(true), Category("Behavior"), Description("Indicates whether pulse effect started with Pulse method stops automatically when mouse moves over the button.")]
+ public virtual bool StopPulseOnMouseOver
+ {
+ get { return m_StopPulseOnMouseOver; }
+ set { m_StopPulseOnMouseOver = value; }
+ }
+
+ ///
+ /// Gets or sets the pulse speed. The value must be greater than 0 and less than 128. Higher values indicate faster pulse. Default value is 12.
+ ///
+ [Browsable(true), DefaultValue(12), Category("Behavior"), Description("Indicates pulse speed. The value must be greater than 0 and less than 128.")]
+ public virtual int PulseSpeed
+ {
+ get { return m_PulseFadeAlphaIncrement; }
+ set
+ {
+ if (value <= 0 || value >= 128)
+ throw new ArgumentOutOfRangeException("PulseSpeed value must be greater than 0 and less than 128");
+ m_PulseFadeAlphaIncrement = value;
+ }
+ }
+ #endregion
+
+ ///
+ /// Indicates whether the item enabled property has changed.
+ ///
+ protected override void OnEnabledChanged()
+ {
+ if (!this.GetEnabled())
+ {
+ SetMouseOver(false);
+ SetMouseDown(false);
+ }
+ base.OnEnabledChanged();
+ }
+
+ //[System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ //public override void InternalMouseEnter()
+ //{
+ // base.InternalMouseEnter();
+
+ //}
+
+ public override void InternalMouseMove(System.Windows.Forms.MouseEventArgs objArg)
+ {
+ base.InternalMouseMove(objArg);
+
+ if (!this.DisplayRectangle.Contains(objArg.X, objArg.Y))
+ return;
+
+ bool refresh = false;
+
+ Rectangle r = GetTotalSubItemsRect(); // m_SubItemsRect;
+ if (!r.IsEmpty && this.GetEnabled())
+ {
+ r.Offset(this.DisplayRectangle.Location);
+ if (r.Contains(objArg.X, objArg.Y))
+ {
+ if (!m_MouseOverExpand)
+ {
+ m_MouseOverExpand = true;
+ refresh = true;
+ }
+ }
+ else if (m_MouseOverExpand)
+ {
+ m_MouseOverExpand = false;
+ refresh = true;
+ }
+ }
+
+ if (!m_MouseOver)
+ {
+ SetMouseOver(true);
+ if (this.GetEnabled() || this.IsOnMenu)
+ refresh = true;
+ }
+
+ if (refresh)
+ this.Refresh();
+ }
+
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseLeave()
+ {
+ base.InternalMouseLeave();
+
+ m_MouseOverExpand = false;
+ SetMouseOver(false);
+ m_MouseDown = false;
+
+ if (this.GetEnabled() || this.IsOnMenu)
+ this.Refresh();
+ }
+
+ internal bool MouseIsOver
+ {
+ get { return (m_MouseOver); }
+ set { m_MouseOver = value; }
+ }
+
+ internal bool MouseIsOverExpand
+ {
+ get { return (m_MouseOverExpand); }
+ set { m_MouseOverExpand = value; }
+ }
+
+ internal bool MouseIsDown
+ {
+ get { return (m_MouseDown); }
+ set { m_MouseDown = value; }
+ }
+
+ internal bool ButtonIsExpanded
+ {
+ get { return (m_Expanded); }
+ set { m_Expanded = value; }
+ }
+
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseHover()
+ {
+ base.InternalMouseHover();
+
+ if ((this.SubItems.Count > 0 || (this.PopupType == ePopupType.Container && !this.IsOnCustomizeMenu)) && this.IsOnMenu && this.ShowSubItems && this.AutoExpandMenuItem)
+ {
+ if (!this.Expanded && GetEnabled())
+ this.Expanded = true;
+ }
+ }
+
+ private bool _AutoExpandMenuItem = true;
+ ///
+ /// Gets or sets whether button auto-expands on mouse hover when button is used as menu-item and displayed on menu. Default value is true.
+ ///
+ [DefaultValue(true), Browsable(false), Description("Indicates whether button auto-expands on mouse hover when button is used as menu-item and displayed on menu."), Category("Behavior")]
+ public bool AutoExpandMenuItem
+ {
+ get { return _AutoExpandMenuItem; }
+ set
+ {
+ _AutoExpandMenuItem = value;
+ }
+ }
+
+
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseDown(System.Windows.Forms.MouseEventArgs objArg)
+ {
+ base.InternalMouseDown(objArg);
+ ButtonMouseDown(objArg);
+ }
+
+ protected virtual bool CanShowPopup
+ {
+ get
+ {
+ return (this.ShowSubItems || ShouldAutoExpandOnClick) && (this.SubItems.Count > 0 || this.PopupType == ePopupType.Container);
+ }
+ }
+ ///
+ /// Provides internal implementation for ButtonItem mouse down events.
+ ///
+ /// Mouse event arguments.
+ protected virtual void ButtonMouseDown(System.Windows.Forms.MouseEventArgs objArg)
+ {
+ // If this is a label don't do anything
+ //if(m_ButtonType==eButtonType.Label)
+ // return;
+
+ if (objArg.Button != System.Windows.Forms.MouseButtons.Left || !GetEnabled())
+ return;
+
+ m_MouseDown = true;
+
+ if ((this.IsOnMenuBar || ShouldAutoExpandOnClick) && !this.DesignMode)
+ {
+ if (objArg.Clicks != 2) // Ignore Double Click
+ {
+ if (CanShowPopup)
+ {
+ if (this.Expanded)
+ {
+ // Order of those two commands is very important since setting autoexpand to false will collapse all other items
+ this.Expanded = false;
+ if (m_Parent != null)
+ m_Parent.AutoExpand = false;
+ }
+ else
+ {
+ if (this.IsOnMenuBar && m_Parent != null)
+ m_Parent.AutoExpand = true;
+ this.Expanded = true;
+ }
+ }
+ else
+ this.Refresh();
+ }
+ }
+ else if ((this.IsOnMenuBar || ShouldAutoExpandOnClick) && this.DesignMode)
+ this.Expanded = !this.Expanded;
+ else if (!this.IsOnMenu)
+ {
+ // If user clicks on expand sub items part of this button expand the item
+ if ((this.SubItems.Count > 0 || (this.PopupType == ePopupType.Container && !this.IsOnCustomizeMenu)) && this.ShowSubItems)
+ {
+ if (!m_Expanded)
+ {
+ Rectangle r = GetTotalSubItemsRect();
+ r.Width += 2;
+ r.Height += 2;
+ //Rectangle r = new Rectangle(m_SubItemsRect.X, m_SubItemsRect.Y, m_SubItemsRect.Width + 2, m_SubItemsRect.Height + 2);
+ r.Offset(m_Rect.X, m_Rect.Y); // This was a bug since m_SubItemsRect already has the right position see RecalcSize...
+ if (r.Contains(objArg.X, objArg.Y))
+ {
+ if (EffectiveStyle == eDotNetBarStyle.Office2000)
+ m_MouseDown = false;
+ this.Expanded = true;
+ }
+
+ }
+ else
+ this.Expanded = false;
+ }
+
+ this.Refresh();
+ }
+ else
+ {
+ if ((this.SubItems.Count > 0 || this.PopupType == ePopupType.Container && !this.IsOnCustomizeMenu) && this.ShowSubItems)
+ {
+ if (!(this.IsOnMenu && this.Expanded))
+ this.Expanded = !m_Expanded;
+ }
+ else
+ this.Refresh();
+ }
+ }
+
+ internal override void DoAccesibleDefaultAction()
+ {
+ if (this.VisibleSubItems > 0 && (this.IsOnMenu || this.IsOnMenuBar || _AccessibleExpandAction || ShouldAutoExpandOnClick))
+ {
+ if (this.Expanded)
+ {
+ this.Expanded = false;
+ if (this.Parent != null && this.IsOnMenuBar)
+ this.Parent.AutoExpand = false;
+ }
+ else
+ {
+ if (this.IsOnMenuBar && this.Parent != null)
+ this.Parent.AutoExpand = true;
+ this.Expanded = true;
+ }
+ this.Refresh();
+ _AccessibleExpandAction = false;
+ }
+ else
+ this.RaiseClick(eEventSource.Keyboard);
+ }
+
+ ///
+ /// Indicates whether button should popup when clicked automatically.
+ ///
+ protected virtual bool ShouldAutoExpandOnClick
+ {
+ get { return m_AutoExpandOnClick; }
+ }
+
+ internal bool GetShouldAutoExpandOnClick()
+ {
+ return this.ShouldAutoExpandOnClick;
+ }
+
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseUp(System.Windows.Forms.MouseEventArgs objArg)
+ {
+ bool bCallBase = true;
+
+ Rectangle rsub = GetTotalSubItemsRect();
+ rsub.Width += 2;
+ rsub.Height += 2;
+ rsub.Offset(m_Rect.X, m_Rect.Y);
+
+ if (objArg.Button == System.Windows.Forms.MouseButtons.Left)
+ {
+ if (GetEnabled() && !this.DesignMode)
+ {
+ if (m_MenuVisibility == eMenuVisibility.VisibleIfRecentlyUsed && !m_RecentlyUsed && this.IsOnMenu)
+ {
+ // Propagate to the top
+ m_RecentlyUsed = true;
+ BaseItem objItem = this.Parent;
+ while (objItem != null)
+ {
+ IPersonalizedMenuItem ipm = objItem as IPersonalizedMenuItem;
+ if (ipm != null)
+ ipm.RecentlyUsed = true;
+ objItem = objItem.Parent;
+ }
+ }
+ }
+
+ // Since base item does not auto-collapse when clicked if it has subitems and it is on
+ // pop-up we need to handle that here and check did user click on expand part of this button
+ // and if they did not we need to raise click event and collapse the item.
+ if (!this.IsOnMenu && (this.SubItems.Count > 0 || this.PopupType == ePopupType.Container) && this.ShowSubItems && m_HotSubItem == null && !this.DesignMode && !this.IsOnMenuBar && !ShouldAutoExpandOnClick)
+ {
+ System.Windows.Forms.Control objCtrl = this.ContainerControl as System.Windows.Forms.Control;
+ if (objCtrl == null)
+ return;
+
+ //Point p=objCtrl.PointToClient(new Point(objArg.X,objArg.Y));
+ objCtrl = null;
+ if (!rsub.Contains(objArg.X, objArg.Y))
+ {
+ bool bCollapse = true;
+ if (this.PopupType == ePopupType.ToolBar || this.PopupType == ePopupType.Menu)
+ {
+ bool bExpanded = this.Expanded;
+ base.InternalMouseUp(objArg);
+ // Do not collapse if user has expanded it in Click event
+ if (!bExpanded && this.Expanded)
+ bCollapse = false;
+ bCallBase = false;
+ }
+ if (bCollapse)
+ CollapseAll(this);
+ }
+ }
+ }
+
+ if (!this.IsOnMenu || this.Parent is ItemContainer)
+ {
+ // If user clicks on expand sub items part of this button do not raise the click event, do not call base MouseUp
+ if ((this.SubItems.Count > 0 || (this.PopupType == ePopupType.Container && !this.IsOnCustomizeMenu)) && this.ShowSubItems)
+ {
+ if (rsub.Contains(objArg.X, objArg.Y))
+ bCallBase = false;
+ }
+ }
+
+ if (bCallBase)
+ base.InternalMouseUp(objArg);
+
+ if (!m_MouseDown)
+ return;
+
+ m_MouseDown = false;
+
+ if (!this.IsOnMenu || !(this.Parent is ButtonItem))
+ {
+ this.Refresh();
+ }
+ }
+
+ internal void SetMouseDown(bool mouseDown)
+ {
+ m_MouseDown = mouseDown;
+ }
+
+ ///
+ /// Occurs when the item is double clicked. This is used by internal implementation only.
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalDoubleClick(System.Windows.Forms.MouseButtons mb, System.Drawing.Point mpos)
+ {
+ base.InternalDoubleClick(mb, mpos);
+
+ if (this.Expanded && this.IsOnMenuBar
+ && m_Parent != null && !this.DesignMode && this.PopupType == ePopupType.Menu &&
+ (this.PersonalizedMenus == ePersonalizedMenus.Both || this.PersonalizedMenus == ePersonalizedMenus.DisplayOnClick))
+ {
+ if (this.PopupControl is MenuPanel)
+ ((MenuPanel)this.PopupControl).ExpandRecentlyUsed();
+ }
+ }
+
+ /*public override void InternalClick(System.Windows.Forms.MouseButtons mb, System.Drawing.Point mpos)
+ {
+ if(m_Enabled && !this.DesignMode)
+ {
+ if(m_MenuVisibility==eMenuVisibility.VisibleIfRecentlyUsed && !m_RecentlyUsed && this.IsOnMenu)
+ {
+ // Propagate to the top
+ m_RecentlyUsed=true;
+ BaseItem objItem=this.Parent;
+ while(objItem!=null)
+ {
+ IPersonalizedMenuItem ipm=objItem as IPersonalizedMenuItem;
+ if(ipm!=null)
+ ipm.RecentlyUsed=true;
+ objItem=objItem.Parent;
+ }
+ }
+ }
+
+ // Since base item does not auto-collapse when clicked if it has subitems and it is on
+ // pop-up we need to handle that here and check did user click on expand part of this button
+ // and if they did not we need to raise click event and collapse the item.
+ if(!this.IsOnMenu && (this.SubItemsCount>0 || this.PopupType==ePopupType.Container) && this.ShowSubItems && m_HotSubItem==null && !this.DesignMode && !this.IsOnMenuBar)
+ {
+ Rectangle r=new Rectangle(m_SubItemsRect.X,m_SubItemsRect.Y,m_SubItemsRect.Width,m_SubItemsRect.Height);
+ r.Offset(m_Rect.X,m_Rect.Y);
+ System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(objCtrl==null)
+ {
+ base.InternalClick(mb,mpos);
+ return;
+ }
+ Point p=objCtrl.PointToClient(mpos);
+ objCtrl=null;
+ if(!r.Contains(p))
+ {
+ CollapseAll(this);
+ RaiseClick();
+ }
+ }
+ else
+ base.InternalClick(mb,mpos);
+ }*/
+
+ // private void CreateDisabledImage()
+ // {
+ // if(m_Image==null && m_ImageIndex<0 && m_Icon==null)
+ // return;
+ // if(m_DisabledImage!=null)
+ // m_DisabledImage.Dispose();
+ // m_DisabledImage=null;
+ //
+ // CompositeImage defaultImage=GetImage(ImageState.Default);
+ //
+ // if(defaultImage==null)
+ // return;
+ // if(!defaultImage.IsIcon && defaultImage.Image!=null && defaultImage.Image is Bitmap)
+ // {
+ // m_DisabledImage=BarFunctions.CreateDisabledBitmap((Bitmap)defaultImage.Image);
+ // }
+ // }
+ private void CreateDisabledImage()
+ {
+ if (m_Image == null && m_ImageIndex < 0 && m_Icon == null)
+ return;
+ if (m_DisabledImage != null)
+ m_DisabledImage.Dispose();
+ m_DisabledImage = null;
+ if (m_DisabledIcon != null)
+ m_DisabledIcon.Dispose();
+ m_DisabledIcon = null;
+
+ CompositeImage defaultImage = GetImage(ImageState.Default, Color.Black);
+
+ if (defaultImage == null)
+ return;
+
+ if (this.GetOwner() is IOwner && ((IOwner)this.GetOwner()).DisabledImagesGrayScale)
+ {
+ if (defaultImage.IsIcon)
+ {
+ m_DisabledIcon = BarFunctions.CreateDisabledIcon(defaultImage.Icon);
+ }
+ else
+ {
+ m_DisabledImage = ImageHelper.CreateGrayScaleImage(defaultImage.Image as Bitmap);
+ }
+ }
+ if (m_DisabledIcon != null || m_DisabledImage != null)
+ return;
+
+ // Use old algorithm if first one failed...
+ System.Drawing.Imaging.PixelFormat pixelFormat = System.Drawing.Imaging.PixelFormat.Format32bppArgb;
+ if (!defaultImage.IsIcon && defaultImage.Image != null)
+ pixelFormat = defaultImage.Image.PixelFormat;
+
+ if (pixelFormat == System.Drawing.Imaging.PixelFormat.Format1bppIndexed || pixelFormat == System.Drawing.Imaging.PixelFormat.Format4bppIndexed || pixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
+ pixelFormat = System.Drawing.Imaging.PixelFormat.Format32bppArgb;
+
+ Bitmap bmp = new Bitmap(defaultImage.Width, defaultImage.Height, pixelFormat);
+ m_DisabledImage = new Bitmap(defaultImage.Width, defaultImage.Height, pixelFormat);
+
+ Graphics g2 = Graphics.FromImage(bmp);
+ using (SolidBrush brush = new SolidBrush(System.Drawing.Color.White))
+ g2.FillRectangle(brush, 0, 0, defaultImage.Width, defaultImage.Height);
+ //g2.DrawImage(defaultImage,0,0,defaultImage.Width,defaultImage.Height);
+ defaultImage.DrawImage(g2, new Rectangle(0, 0, defaultImage.Width, defaultImage.Height));
+ g2.Dispose();
+ g2 = Graphics.FromImage(m_DisabledImage);
+
+ bmp.MakeTransparent(System.Drawing.Color.White);
+ eDotNetBarStyle effectiveStyle = EffectiveStyle;
+ if ((effectiveStyle == eDotNetBarStyle.OfficeXP || effectiveStyle == eDotNetBarStyle.Office2003 || effectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(effectiveStyle)) && NativeFunctions.ColorDepth >= 8)
+ {
+ float[][] array = new float[5][];
+ array[0] = new float[5] { 0, 0, 0, 0, 0 };
+ array[1] = new float[5] { 0, 0, 0, 0, 0 };
+ array[2] = new float[5] { 0, 0, 0, 0, 0 };
+ array[3] = new float[5] { .5f, .5f, .5f, .5f, 0 };
+ array[4] = new float[5] { 0, 0, 0, 0, 0 };
+ System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array);
+ System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes();
+ disabledImageAttr.ClearColorKey();
+ disabledImageAttr.SetColorMatrix(grayMatrix);
+ g2.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, disabledImageAttr);
+ }
+ else
+ System.Windows.Forms.ControlPaint.DrawImageDisabled(g2, bmp, 0, 0, ColorFunctions.MenuBackColor(g2));
+
+ // Clean up
+ g2.Dispose();
+ g2 = null;
+ bmp.Dispose();
+ bmp = null;
+
+ defaultImage.Dispose();
+ }
+
+ private eTextFormat GetStringFormat()
+ {
+ eTextFormat format = eTextFormat.Default;
+ if (!_FitContainer)
+ {
+ format |= eTextFormat.SingleLine;
+ }
+ else
+ format |= eTextFormat.WordBreak;
+
+ format |= eTextFormat.VerticalCenter;
+ return format;
+
+ // //bool bMenuBar=this.IsOnMenuBar;
+ // StringFormat sfmt=BarFunctions.CreateStringFormat(); //new StringFormat(StringFormat.GenericDefault);
+ // if(NativeFunctions.ShowKeyboardCues /*&& bMenuBar*/ || this.IsOnMenu)
+ // sfmt.HotkeyPrefix=System.Drawing.Text.HotkeyPrefix.Show;
+ // else/* if(bMenuBar)*/
+ // {
+ // System.Windows.Forms.Control ctrl=this.ContainerControl as System.Windows.Forms.Control;
+ // if(ctrl!=null && (ctrl.Focused || ctrl is Bar && ((Bar)ctrl).MenuFocus) || ctrl is NavigationBar)
+ // sfmt.HotkeyPrefix=System.Drawing.Text.HotkeyPrefix.Show;
+ // else
+ // sfmt.HotkeyPrefix=System.Drawing.Text.HotkeyPrefix.Hide;
+ // }
+ //// else
+ //// sfmt.HotkeyPrefix=System.Drawing.Text.HotkeyPrefix.Hide;
+
+ // //sfmt.FormatFlags=sfmt.FormatFlags & ~(sfmt.FormatFlags & StringFormatFlags.DisableKerning);
+ // if(_FitContainer)
+ // {
+ // sfmt.FormatFlags=sfmt.FormatFlags & ~(sfmt.FormatFlags & StringFormatFlags.NoWrap);
+ // }
+ // else
+ // {
+ // sfmt.FormatFlags=sfmt.FormatFlags | StringFormatFlags.NoWrap;
+ // }
+ // sfmt.Trimming=StringTrimming.EllipsisCharacter;
+ // sfmt.Alignment=System.Drawing.StringAlignment.Near;
+ // sfmt.LineAlignment=System.Drawing.StringAlignment.Center;
+
+ // return sfmt;
+ }
+
+ private ThemeTextFormat GetThemeTextFormat()
+ {
+ ThemeTextFormat format = ThemeTextFormat.Left | ThemeTextFormat.HidePrefix |
+ ThemeTextFormat.WordEllipsis |
+ ThemeTextFormat.VCenter;
+ return format;
+ }
+
+ private Font _MouseOverFont = null;
+ ///
+ /// Returns the Font object to be used for drawing the item text.
+ ///
+ /// Font object.
+ internal virtual Font GetFont(ItemPaintArgs pa, bool isLayout)
+ {
+ System.Drawing.Font objFont = null;
+
+ if (pa != null)
+ objFont = pa.Font;
+
+ if (objFont == null)
+ {
+ System.Windows.Forms.Control objCtrl = null;
+ if (pa != null)
+ objCtrl = pa.ContainerControl;
+ if (objCtrl == null)
+ objCtrl = this.ContainerControl as System.Windows.Forms.Control;
+ if (objCtrl != null)
+ {
+ if (objCtrl.Font != null)
+ objFont = (Font)objCtrl.Font;
+ }
+ else
+ objFont = (Font)SystemFonts.DefaultFont;
+ }
+
+ if (m_MouseOver || isLayout && (m_HotFontBold || m_HotFontUnderline))
+ {
+ if (_MouseOverFont != null && objFont != null && objFont.FontFamily.Name == _MouseOverFont.FontFamily.Name && objFont.SizeInPoints == _MouseOverFont.SizeInPoints)
+ return _MouseOverFont;
+ try
+ {
+ Font mouseOverFont = null;
+ FontStyle fontStyle = objFont.Style;
+ if (m_HotFontBold) fontStyle |= FontStyle.Bold;
+ if (m_HotFontUnderline) fontStyle |= FontStyle.Underline;
+ mouseOverFont = new Font(objFont, fontStyle);
+ DisposeMouseOverFont();
+ _MouseOverFont = mouseOverFont;
+ return _MouseOverFont;
+ }
+ catch
+ {
+
+ }
+ }
+
+ if (m_FontBold || m_FontItalic || m_FontUnderline)
+ {
+ FontStyle style = objFont.Style;
+ if (m_FontBold)
+ style = style | System.Drawing.FontStyle.Bold;
+ if (m_FontItalic)
+ style = style | System.Drawing.FontStyle.Italic;
+ if (m_FontUnderline)
+ style = style | System.Drawing.FontStyle.Underline;
+ Font font = null;
+ try
+ {
+ font = new Font(objFont, style);
+ }
+ catch { }
+ if (font != null)
+ objFont = font;
+ }
+
+ return objFont;
+ }
+
+ private void DisposeMouseOverFont()
+ {
+ if (_MouseOverFont != null)
+ {
+ _MouseOverFont.Dispose();
+ _MouseOverFont = null;
+ }
+ }
+
+ ///
+ /// Gets or sets whether Checked property is automatically inverted, button checked/unchecked, when button is clicked. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Behavior"), Description("Indicates whether Checked property is automatically inverted when button is clicked.")]
+ public virtual bool AutoCheckOnClick
+ {
+ get { return m_AutoCheckOnClick; }
+ set { m_AutoCheckOnClick = value; }
+ }
+
+ ///
+ /// Gets or set a value indicating whether the button is in the checked state.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("Indicates whether item is checked or not."), DefaultValue(false), Bindable(true)]
+ public virtual bool Checked
+ {
+ get
+ {
+ return m_Checked;
+ }
+ set
+ {
+ if (m_Checked != value)
+ {
+ // Allow user to cancel the checking
+ if (value && m_OptionGroup.Length > 0 && this.Parent != null)
+ {
+ ButtonItem b = null;
+ foreach (BaseItem item in this.Parent.SubItems)
+ {
+ if (item == this)
+ continue;
+ b = item as ButtonItem;
+ if (b != null && b.OptionGroup == m_OptionGroup && b.Checked)
+ {
+ break;
+ }
+ }
+ OptionGroupChangingEventArgs e = new OptionGroupChangingEventArgs(b, this);
+ InvokeOptionGroupChanging(e);
+ if (e.Cancel)
+ return;
+ }
+
+ m_Checked = value;
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "Checked");
+ this.OnCheckedChanged();
+ if (this.Displayed)
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Called after Checked property has changed.
+ ///
+ protected virtual void OnCheckedChanged()
+ {
+ if (m_OptionGroup != "" && m_Checked && this.Parent != null)
+ {
+ foreach (BaseItem item in this.Parent.SubItems)
+ {
+ if (item == this)
+ continue;
+ ButtonItem b = item as ButtonItem;
+ if (b != null && b.OptionGroup == m_OptionGroup && b.Checked)
+ b.Checked = false;
+ }
+ }
+ InvokeCheckedChanged();
+ }
+
+ ///
+ /// Called when Visibility of the items has changed.
+ ///
+ /// New Visible state.
+ protected internal override void OnVisibleChanged(bool bVisible)
+ {
+ base.OnVisibleChanged(bVisible);
+
+ if (!bVisible)
+ {
+ StopFade();
+ StopImageAnimation();
+ }
+
+ if (!bVisible && this.Checked && m_OptionGroup != "")
+ {
+ this.Checked = false;
+ // Try to check first item in the group
+ if (this.Parent != null)
+ {
+ foreach (BaseItem item in this.Parent.SubItems)
+ {
+ if (item == this || !item.GetEnabled() || !item.Visible)
+ continue;
+ ButtonItem b = item as ButtonItem;
+ if (b != null && b.OptionGroup == m_OptionGroup)
+ {
+ b.Checked = true;
+ break;
+ }
+ }
+ }
+ }
+ else if (bVisible && m_OptionGroup != "" && this.VisibleSubItems <= 1)
+ {
+ bool checkIt = true;
+ // Try to check first item in the group
+ if (this.Parent != null)
+ {
+ foreach (BaseItem item in this.Parent.SubItems)
+ {
+ if (item == this || !item.GetEnabled() || !item.Visible)
+ continue;
+ ButtonItem b = item as ButtonItem;
+ if (b != null && b.OptionGroup == m_OptionGroup && b.Checked)
+ {
+ checkIt = false;
+ break;
+ }
+ }
+ }
+ if (checkIt)
+ this.Checked = true;
+ }
+ }
+
+ ///
+ /// Sets Checked property without firing any events or performing any built-in logic.
+ ///
+ internal void SetChecked(bool b)
+ {
+ m_Checked = b;
+ }
+
+ ///
+ /// Fires CheckedChanged event.
+ ///
+ protected virtual void InvokeCheckedChanged()
+ {
+ if (CheckedChanged != null)
+ CheckedChanged(this, new EventArgs());
+ IOwnerItemEvents owner = this.GetIOwnerItemEvents();
+ if (owner != null)
+ owner.InvokeCheckedChanged(this, new EventArgs());
+ }
+
+ ///
+ /// Fires OptionGroupChanging event.
+ ///
+ protected virtual void InvokeOptionGroupChanging(OptionGroupChangingEventArgs e)
+ {
+ if (OptionGroupChanging != null)
+ OptionGroupChanging(this, e);
+ if (!e.Cancel)
+ {
+ IOwnerItemEvents owner = this.GetIOwnerItemEvents();
+ if (owner != null)
+ owner.InvokeOptionGroupChanging(this, e);
+ }
+ }
+
+ ///
+ /// Occurs just before Click event is fired.
+ ///
+ protected override void OnClick()
+ {
+ if (m_AutoCheckOnClick && m_OptionGroup == "")
+ this.Checked = !this.Checked;
+ base.OnClick();
+ if (m_OptionGroup != "" && !m_Checked)
+ this.Checked = true;
+ ExecuteCommand();
+ }
+
+ protected override void OnCommandChanged()
+ {
+ if (!this.DesignMode && this.Command == null)
+ this.Enabled = false;
+ base.OnCommandChanged();
+ }
+
+ ///
+ /// Gets or set the alternative shortcut text.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Design"), System.ComponentModel.Description("Gets or set the alternative Shortcut Text. This text appears next to the Text instead of any shortcuts"), System.ComponentModel.DefaultValue(""), Localizable(true)]
+ public virtual string AlternateShortCutText
+ {
+ get
+ {
+ return m_AlternateShortcutText;
+ }
+ set
+ {
+ m_AlternateShortcutText = value;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Returns shortcut text if any that needs to be displayed.
+ ///
+ internal string DrawShortcutText
+ {
+ get
+ {
+ if (this.AlternateShortCutText != "")
+ return this.AlternateShortCutText;
+ else
+ return this.ShortcutString;
+ }
+ }
+
+ ///
+ /// Returns the shortcut string that is displayed on tooltip.
+ ///
+ ///
+ protected override string GetTooltipShortcutString()
+ {
+ return this.DrawShortcutText;
+ }
+
+ ///
+ /// Gets or sets the image bounds.
+ ///
+ internal Rectangle ImageDrawRect
+ {
+ get { return m_ImageDrawRect; }
+ set { m_ImageDrawRect = value; }
+ }
+
+ ///
+ /// Gets or sets sub items bounds.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Rectangle SubItemsRect
+ {
+ get { return m_SubItemsRect; }
+ set { m_SubItemsRect = value; }
+ }
+
+ ///
+ /// Gets or sets text bounds.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Rectangle TextDrawRect
+ {
+ get { return m_TextDrawRect; }
+ set { m_TextDrawRect = value; }
+ }
+
+
+ ///
+ /// Gets or set the Group item belongs to. The groups allows a user to choose from mutually exclusive options within the group. The choice is reflected by Checked property.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Gets or set the Group item belongs to. The groups allows a user to choose from mutually exclusive options within the group."), System.ComponentModel.DefaultValue("")]
+ public virtual string OptionGroup
+ {
+ get
+ {
+ return m_OptionGroup;
+ }
+ set
+ {
+ if (m_OptionGroup != value)
+ {
+ m_OptionGroup = value;
+ if (m_OptionGroup != "" && m_Checked && this.Parent != null)
+ {
+ foreach (BaseItem item in this.Parent.SubItems)
+ {
+ if (item == this)
+ continue;
+ ButtonItem b = item as ButtonItem;
+ if (b != null && b.OptionGroup == m_OptionGroup && b.Checked)
+ this.Checked = false;
+ }
+ }
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ private eColorSchemePart _ForeColorColorSchemePart = eColorSchemePart.None;
+ internal eColorSchemePart ForeColorColorSchemePart
+ {
+ get
+ {
+ return _ForeColorColorSchemePart;
+ }
+ set
+ {
+ _ForeColorColorSchemePart = value;
+ }
+ }
+ ///
+ /// Gets or sets the text color of the button.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The foreground color used to display text.")]
+ public virtual Color ForeColor
+ {
+ get
+ {
+ return m_ForeColor;
+ }
+ set
+ {
+ if (m_ForeColor != value)
+ {
+ m_ForeColor = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "ForeColor");
+
+ if (this.Displayed)
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+ [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public bool ShouldSerializeForeColor()
+ {
+ if (m_ForeColor.IsEmpty)
+ return false;
+ return true;
+ }
+
+ ///
+ /// Gets or sets the text color of the button when mouse is over the item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The foreground color used to display text when mouse is over the item.")]
+ public virtual Color HotForeColor
+ {
+ get
+ {
+ return m_HotForeColor;
+ }
+ set
+ {
+ if (m_HotForeColor != value)
+ {
+ m_HotForeColor = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "HotForeColor");
+
+ if (this.Displayed && m_MouseOver)
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+ [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public bool ShouldSerializeHotForeColor()
+ {
+ if (m_HotForeColor.IsEmpty)
+ return false;
+ return true;
+ }
+
+ ///
+ /// Gets or sets whether the font used to draw the item text is underlined when mouse is over the item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Specifies that text font is underlined when mouse is over the item."), System.ComponentModel.DefaultValue(false)]
+ public virtual bool HotFontUnderline
+ {
+ get
+ {
+ return m_HotFontUnderline;
+ }
+ set
+ {
+ if (m_HotFontUnderline != value)
+ {
+ DisposeMouseOverFont();
+ m_HotFontUnderline = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "HotFontUnderline");
+
+ if (this.Displayed && m_MouseOver)
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether the font used to draw the item text is bold when mouse is over the item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Specifies that text font is bold when mouse is over the item."), System.ComponentModel.DefaultValue(false)]
+ public virtual bool HotFontBold
+ {
+ get
+ {
+ return m_HotFontBold;
+ }
+ set
+ {
+ if (m_HotFontBold != value)
+ {
+ DisposeMouseOverFont();
+ m_HotFontBold = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "HotFontBold");
+
+ if (this.Displayed && m_MouseOver)
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether the font used to draw the item text is bold.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Specifies whether the font used to draw the item text is bold."), System.ComponentModel.DefaultValue(false)]
+ public virtual bool FontBold
+ {
+ get
+ {
+ return m_FontBold;
+ }
+ set
+ {
+ if (m_FontBold != value)
+ {
+ m_FontBold = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "FontBold");
+
+ if (this.Displayed)
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether the font used to draw the item text is italic.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Specifies whether the font used to draw the item text is italic."), System.ComponentModel.DefaultValue(false)]
+ public virtual bool FontItalic
+ {
+ get
+ {
+ return m_FontItalic;
+ }
+ set
+ {
+ if (m_FontItalic != value)
+ {
+ m_FontItalic = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "FontItalic");
+
+ if (this.Displayed)
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether the font used to draw the item text is underlined.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Specifies whether the font used to draw the item text is underlined."), System.ComponentModel.DefaultValue(false)]
+ public virtual bool FontUnderline
+ {
+ get
+ {
+ return m_FontUnderline;
+ }
+ set
+ {
+ if (m_FontUnderline != value)
+ {
+ m_FontUnderline = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "FontUnderline");
+
+ if (this.Displayed)
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+
+ ///
+ /// Gets or sets the width of the expand part of the button item.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Behavior"), Description("Indicates the width of the expand part of the button item."), DefaultValue(12)]
+ public virtual int SubItemsExpandWidth
+ {
+ get { return m_SubItemsExpandWidth; }
+ set
+ {
+ m_SubItemsExpandWidth = value;
+ NeedRecalcSize = true;
+ if (this.DesignMode)
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Returns the collection of sub items.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(false), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ButtonItemEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.Category("Data"), System.ComponentModel.Description("Collection of sub items."), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)]
+ public override SubItemsCollection SubItems
+ {
+ get
+ {
+ return base.SubItems;
+ }
+ }
+
+ ///
+ /// Gets or sets whether button appears as split button. Split button appearance divides button into two parts. Image which raises the click event
+ /// when clicked and text and expand sign which shows button sub items on popup menu when clicked. Button must have both text and image visible (ButtonStyle property) in order to appear as a full split button.
+ /// Use AutoExpandOnClick=true if you want to make complete surface of the button display popup when clicked.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance"), Description("Indicates whether button appears as split button. Use AutoExpandOnClick=true if you want to make complete surface of the button display popup when clicked.")]
+ public virtual bool SplitButton
+ {
+ get { return m_SplitButton; }
+ set
+ {
+ m_SplitButton = value;
+ OnAppearanceChanged();
+ }
+ }
+
+ internal Rectangle GetTotalSubItemsRect()
+ {
+ Rectangle r = this.SubItemsRect;
+ if (this.SplitButton && (this.ButtonStyle == eButtonStyle.ImageAndText || this.ImagePosition == eImagePosition.Top || this.ImagePosition == eImagePosition.Bottom)
+ && (this.Image != null || this.ImageIndex >= 0 || !string.IsNullOrEmpty(this.SymbolRealized)) && this.Text.Length > 0)
+ {
+ Rectangle rText = this.TextDrawRect;
+ rText.Inflate(0, -2);
+ if (this.ImagePosition == eImagePosition.Left)
+ {
+ if (this.Orientation == eOrientation.Horizontal)
+ rText.X -= 3;
+ else
+ rText.Y -= 6;
+ }
+ if (r.IsEmpty)
+ {
+ r = rText;
+ if (m_ImagePosition == eImagePosition.Top)
+ {
+ r.X = 0;// m_Rect.X - 1;
+ r.Width = m_Rect.Width;
+ r.Height = this.DisplayRectangle.Bottom - r.Y;
+ }
+ else if (m_ImagePosition == eImagePosition.Bottom)
+ {
+ r.X = 0;// m_Rect.X - 1;
+ r.Width = m_Rect.Width;
+ }
+ }
+ else
+ r = Rectangle.Union(r, rText);
+ return r;
+ }
+ return r;
+ }
+
+ ///
+ /// Gets or sets the text associated with this item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The text contained in the item."), System.ComponentModel.Localizable(true), System.ComponentModel.DefaultValue("")]
+ public override string Text
+ {
+ get
+ {
+ return base.Text;
+ }
+ set
+ {
+ base.Text = value;
+ }
+ }
+
+ internal int VerticalPadding
+ {
+ get { return m_VerticalPadding; }
+ set { m_VerticalPadding = value; }
+ }
+
+ internal int HorizontalPadding
+ {
+ get { return m_HorizontalPadding; }
+ set { m_HorizontalPadding = value; }
+ }
+
+ ///
+ /// Gets or sets the amount of padding added horizontally to the button images when not on menus. Default value is 10 pixels.
+ ///
+ [Browsable(true), DefaultValue(8), Category("Layout"), Description("Indicates amount of padding added horizontally to the button images when not on menus")]
+ public virtual int ImagePaddingHorizontal
+ {
+ get { return m_ImagePaddingHorizontal; }
+ set
+ {
+ m_ImagePaddingHorizontal = value;
+ this.OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the amount of padding added vertically to the button images when not on menus. Default value is 6 pixels.
+ ///
+ [Browsable(true), DefaultValue(6), Category("Layout"), Description("Indicates amount of padding added vertically to the button images when not on menus")]
+ public virtual int ImagePaddingVertical
+ {
+ get { return m_ImagePaddingVertical; }
+ set
+ {
+ m_ImagePaddingVertical = value;
+ this.OnAppearanceChanged();
+ }
+ }
+ ///
+ /// Gets or sets the current font for the button.
+ ///
+ // public System.Drawing.Font Font
+ // {
+ // get
+ // {
+ // return m_Font;
+ // }
+ // set
+ // {
+ // if(m_Font!=value)
+ // {
+ // m_Font=value;
+ // if(this.Displayed)
+ // this.Refresh();
+ // }
+ // }
+ // }
+
+ private ShapeDescriptor _Shape = null;
+ ///
+ /// Gets or sets an shape descriptor for the button which describes the shape of the button. Default value is null
+ /// which indicates that system default shape is used.
+ ///
+ [DefaultValue(null), Editor("DevComponents.DotNetBar.Design.ShapeTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), TypeConverter("DevComponents.DotNetBar.Design.ShapeStringConverter, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), MergableProperty(false)]
+ public virtual ShapeDescriptor Shape
+ {
+ get { return _Shape; }
+ set
+ {
+ if (_Shape != value)
+ {
+ _Shape = value;
+ this.OnAppearanceChanged();
+ }
+ }
+ }
+
+ protected override void OnDisplayedChanged()
+ {
+ // Reset all internal states upon display changed
+ m_MouseDown = false;
+ m_MouseOver = false;
+ if (!this.Displayed && _CurrentlyAnimatingImage)
+ StopImageAnimation();
+ }
+
+ // IPersonalizedMenuItem Impementation
+ ///
+ /// Indicates item's visibility when on pop-up menu.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Indicates item's visiblity when on pop-up menu."), System.ComponentModel.DefaultValue(eMenuVisibility.VisibleAlways)]
+ public virtual eMenuVisibility MenuVisibility
+ {
+ get
+ {
+ return m_MenuVisibility;
+ }
+ set
+ {
+ if (m_MenuVisibility != value)
+ {
+ m_MenuVisibility = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "MenuVisibility");
+ }
+ }
+ }
+
+ ///
+ /// Indicates whether item was recently used.
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public bool RecentlyUsed
+ {
+ get
+ {
+ return m_RecentlyUsed;
+ }
+ set
+ {
+ if (m_RecentlyUsed != value)
+ {
+ m_RecentlyUsed = value;
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "RecentlyUsed");
+
+ OnAppearanceChanged();
+ }
+ }
+ }
+
+ ///
+ /// Indicates whether mouse is over the item.
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public bool IsMouseOver
+ {
+ get { return m_MouseOver; }
+ }
+
+ ///
+ /// Indicates whether mouse is over the expand part of the button.
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public bool IsMouseOverExpand
+ {
+ get { return m_MouseOverExpand; }
+ }
+
+ ///
+ /// Indicates whether mouse is pressed.
+ ///
+ [System.ComponentModel.Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public bool IsMouseDown
+ {
+ get { return m_MouseDown; }
+ }
+
+ ///
+ /// Indicates the way item is painting the picture when mouse is over it. Setting the value to Color will render the image in gray-scale when mouse is not over the item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Indicates the way item is painting the picture when mouse is over it. Setting the value to Color will render the image in gray-scale when mouse is not over the item."), System.ComponentModel.DefaultValue(eHotTrackingStyle.Default)]
+ public virtual eHotTrackingStyle HotTrackingStyle
+ {
+ get { return m_HotTrackingStyle; }
+ set
+ {
+ if (m_HotTrackingStyle == value)
+ return;
+ m_HotTrackingStyle = value;
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "HotTrackingStyle");
+ this.Refresh();
+ OnAppearanceChanged();
+ }
+ }
+
+ // Property Editor support for ImageIndex selection
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public System.Windows.Forms.ImageList ImageList
+ {
+ get
+ {
+ IOwner owner = this.GetOwner() as IOwner;
+ if (owner != null)
+ return owner.Images;
+ return null;
+ }
+ }
+
+ ///
+ /// Gets or sets whether the button text is automatically wrapped over multiple lines when button is used on RibbonBar control. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Localizable(true), Category("Ribbon"), Description("Indicates whether the button text is automatically wrapped over multiple lines when button is used on RibbonBar control.")]
+ public virtual bool RibbonWordWrap
+ {
+ get { return m_RibbonWordWrap; }
+ set
+ {
+ if (m_RibbonWordWrap != value)
+ {
+ m_RibbonWordWrap = value;
+ this.OnAppearanceChanged();
+ }
+ }
+ }
+
+ private bool _EnableImageAnimation = false;
+ ///
+ /// Gets or sets whether image animation is enabled
+ ///
+ [Browsable(true), DevCoBrowsable(true)]
+ [DefaultValue(false), Category("Appearance")]
+ [Description("Indicates whether image animation is enabled.")]
+ public bool EnableImageAnimation
+ {
+ get { return (_EnableImageAnimation); }
+
+ set
+ {
+ if (_EnableImageAnimation != value)
+ {
+ _EnableImageAnimation = value;
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Creates new ButtonItem with text set to corresponding item from string array and adds it to SubItems collection.
+ ///
+ ///
+ public void AddSubItems(string[] itemTexts)
+ {
+ AddSubItems(itemTexts, null);
+ }
+
+ ///
+ /// Creates new ButtonItem with text set to corresponding item from string array and adds it to SubItems collection.
+ ///
+ /// Click event handler assigned to each item
+ public void AddSubItems(string[] itemTexts, EventHandler clickHandler)
+ {
+ if (itemTexts == null || itemTexts.Length == 0) return;
+ for (int i = 0; i < itemTexts.Length; i++)
+ {
+ ButtonItem item = new ButtonItem();
+ item.Text = itemTexts[i];
+ if (clickHandler != null)
+ item.Click += clickHandler;
+ this.SubItems.Add(item);
+ }
+ }
+
+ #endregion
+
+ #region Markup Implementation
+ ///
+ /// Gets whether item supports text markup. Default is false.
+ ///
+ protected override bool IsMarkupSupported
+ {
+ get { return _EnableMarkup; }
+ }
+
+ private bool _EnableMarkup = true;
+ ///
+ /// Gets or sets whether text-markup support is enabled for items Text property. Default value is true.
+ /// Set this property to false to display HTML or other markup in the item instead of it being parsed as text-markup.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether text-markup support is enabled for items Text property.")]
+ public bool EnableMarkup
+ {
+ get { return _EnableMarkup; }
+ set
+ {
+ if (_EnableMarkup != value)
+ {
+ _EnableMarkup = value;
+ NeedRecalcSize = true;
+ OnTextChanged();
+ }
+ }
+ }
+
+ ///
+ /// Occurs when text markup link is clicked. Markup links can be created using "a" tag, for example:
+ /// Markup link
+ ///
+ [Description("Occurs when text markup link is clicked. Markup links can be created using a tag.")]
+ public event MarkupLinkClickEventHandler MarkupLinkClick;
+ protected override void TextMarkupLinkClick(object sender, EventArgs e)
+ {
+ TextMarkup.HyperLink link = sender as TextMarkup.HyperLink;
+ if (link != null)
+ OnMarkupLinkClick(new MarkupLinkClickEventArgs(link.Name, link.HRef));
+ base.TextMarkupLinkClick(sender, e);
+ }
+ protected virtual void OnMarkupLinkClick(MarkupLinkClickEventArgs e)
+ {
+ if (this.MarkupLinkClick != null)
+ MarkupLinkClick(this, e);
+ }
+ #endregion
+
+ #region ButtonItemAccessibleObject
+ ///
+ /// Represents accessible interface for ButtonItem object.
+ ///
+ public class ButtonItemAccessibleObject : BaseItem.ItemAccessibleObject
+ {
+ private ButtonItemPartAccessibleObject m_PushButtonPart = null;
+ private ButtonItemPartAccessibleObject m_ExpandPart = null;
+
+ public ButtonItemAccessibleObject(BaseItem owner) : base(owner) { }
+
+ internal ButtonItem ButtonItem
+ {
+ get { return this.Owner as ButtonItem; }
+ }
+
+ private ButtonItemPartAccessibleObject AccessiblePushButtonPart
+ {
+ get
+ {
+ if (m_PushButtonPart == null)
+ {
+ m_PushButtonPart = new ButtonItemPartAccessibleObject(this.ButtonItem, true);
+ }
+ return m_PushButtonPart;
+ }
+ }
+
+ private ButtonItemPartAccessibleObject AccessibleExpandPart
+ {
+ get
+ {
+ if (m_ExpandPart == null)
+ {
+ m_ExpandPart = new ButtonItemPartAccessibleObject(this.ButtonItem, false);
+ }
+ return m_ExpandPart;
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleRole Role
+ {
+ get
+ {
+ if (IsSplitButton)
+ return System.Windows.Forms.AccessibleRole.Grouping;
+ return base.Role;
+ }
+ }
+
+ private bool IsSplitButton
+ {
+ get
+ {
+ ButtonItem b = this.ButtonItem;
+ if (b.VisibleSubItems > 0 && !b.AutoExpandOnClick && !b.IsOnMenu && !b.IsOnMenuBar)
+ return true;
+ return false;
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleStates State
+ {
+ get
+ {
+ if (this.IsSplitButton)
+ {
+ if (this.Owner == null || !this.Owner.IsAccessible)
+ return System.Windows.Forms.AccessibleStates.Unavailable;
+
+ System.Windows.Forms.AccessibleStates state = 0;
+
+ if (!this.Owner.Displayed || !this.Owner.Visible)
+ state |= System.Windows.Forms.AccessibleStates.Invisible;
+ else if (!this.Owner.GetEnabled())
+ {
+ return System.Windows.Forms.AccessibleStates.Unavailable;
+ }
+
+ return System.Windows.Forms.AccessibleStates.Default;
+ }
+
+ System.Windows.Forms.AccessibleStates st = base.State;
+
+ if (this.ButtonItem.GetEnabled())
+ {
+ if (this.ButtonItem.Checked || this.ButtonItem.IsMouseDown)
+ st |= System.Windows.Forms.AccessibleStates.Pressed;
+ }
+ return st;
+ }
+ }
+
+ public override int GetChildCount()
+ {
+ if (IsSplitButton)
+ return 2;
+ return base.GetChildCount();
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetChild(int iIndex)
+ {
+ if (IsSplitButton)
+ {
+ if (iIndex == 0)
+ return this.AccessiblePushButtonPart;
+ else if (iIndex == 1)
+ return this.AccessibleExpandPart;
+ }
+
+ return base.GetChild(iIndex);
+ }
+
+ public override AccessibleObject Navigate(AccessibleNavigation navdir)
+ {
+ if (IsSplitButton)
+ {
+ //if (navdir == AccessibleNavigation.FirstChild)
+ // return this.AccessiblePushButtonPart;
+ //else if (navdir == AccessibleNavigation.LastChild)
+ // return this.AccessibleExpandPart;
+ return null;
+ }
+ return base.Navigate(navdir);
+ }
+
+ public override string DefaultAction
+ {
+ get
+ {
+ if (this.IsSplitButton)
+ return "";
+ else
+ return base.DefaultAction;
+ }
+ }
+
+ public override void DoDefaultAction()
+ {
+ if (!this.IsSplitButton)
+ base.DoDefaultAction();
+ }
+
+ public override string KeyboardShortcut
+ {
+ get
+ {
+ return "";
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetSelected()
+ {
+ if (this.IsSplitButton)
+ {
+ if (this.ButtonItem.IsMouseOverExpand)
+ return this.AccessibleExpandPart;
+ else if (this.ButtonItem.IsMouseOver)
+ return this.AccessiblePushButtonPart;
+ return null;
+ }
+ else
+ return base.GetSelected();
+ }
+
+ public override System.Windows.Forms.AccessibleObject HitTest(int x, int y)
+ {
+ if (this.IsSplitButton)
+ {
+ Rectangle r = this.AccessiblePushButtonPart.Bounds;
+ if (r.Contains(x, y))
+ return this.AccessiblePushButtonPart;
+ r = this.AccessibleExpandPart.Bounds;
+ if (r.Contains(x, y))
+ return this.AccessibleExpandPart;
+
+ return null;
+ }
+ return base.HitTest(x, y);
+ }
+ }
+
+ ///
+ /// Represents accessible interface for ButtonItem object.
+ ///
+ public class ButtonItemPartAccessibleObject : System.Windows.Forms.AccessibleObject
+ {
+ private ButtonItem m_Button = null;
+ //private bool m_Hot = false;
+ private bool m_PushButtonPart = true;
+
+ public ButtonItemPartAccessibleObject(ButtonItem owner, bool pushButtonPart)
+ {
+ m_Button = owner;
+ m_PushButtonPart = pushButtonPart;
+ }
+
+ public override string Name
+ {
+ get
+ {
+ if (!m_PushButtonPart) return "Open";
+
+ if (m_Button == null)
+ return "";
+
+ if (m_Button.AccessibleName != "")
+ return m_Button.AccessibleName;
+
+ if (m_Button.Text != null)
+ return m_Button.Text.Replace("&", "");
+
+ return m_Button.Tooltip;
+ }
+ set
+ {
+ m_Button.AccessibleName = value;
+ }
+ }
+
+ public override string Description
+ {
+ get
+ {
+ if (m_Button == null)
+ return "";
+ if (m_Button.AccessibleDescription != "")
+ return m_Button.AccessibleDescription;
+ return Name + " button";
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleRole Role
+ {
+ get
+ {
+ if (m_PushButtonPart)
+ {
+#if FRAMEWORK20
+ return System.Windows.Forms.AccessibleRole.SplitButton;
+#else
+ return System.Windows.Forms.AccessibleRole.PushButton;
+#endif
+ }
+
+ return System.Windows.Forms.AccessibleRole.ButtonDropDown;
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleStates State
+ {
+ get
+ {
+ if (m_Button == null)
+ return System.Windows.Forms.AccessibleStates.Unavailable;
+
+ System.Windows.Forms.AccessibleStates state = 0;
+
+ if (!m_Button.IsAccessible)
+ return System.Windows.Forms.AccessibleStates.Unavailable;
+
+ if (!m_Button.Displayed || !m_Button.Visible)
+ state |= System.Windows.Forms.AccessibleStates.Invisible;
+ else if (!m_Button.GetEnabled())
+ {
+ state = System.Windows.Forms.AccessibleStates.Unavailable;
+ }
+ else
+ {
+ if (m_PushButtonPart)
+ {
+ if (m_Button.IsMouseOver && !m_Button.IsMouseOverExpand)
+ state |= System.Windows.Forms.AccessibleStates.HotTracked | System.Windows.Forms.AccessibleStates.Focused;
+ else
+ state |= System.Windows.Forms.AccessibleStates.Focusable;
+ }
+ else
+ {
+ if (m_Button.Expanded || m_Button.IsMouseOverExpand)
+ state |= (System.Windows.Forms.AccessibleStates.Focused | System.Windows.Forms.AccessibleStates.HotTracked);
+ if (m_Button.Expanded)
+ state |= System.Windows.Forms.AccessibleStates.Expanded;
+ else
+ state |= System.Windows.Forms.AccessibleStates.Collapsed;
+ }
+ }
+ return state;
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleObject Parent
+ {
+ get
+ {
+ return m_Button.AccessibleObject;
+ }
+ }
+
+ public override System.Drawing.Rectangle Bounds
+ {
+ get
+ {
+ System.Windows.Forms.Control parent = m_Button.ContainerControl as System.Windows.Forms.Control;
+ Rectangle r = Rectangle.Empty;
+
+ if (m_PushButtonPart)
+ {
+ Rectangle rs = m_Button.SubItemsRect;
+ rs.Offset(m_Button.Bounds.Location);
+ r = m_Button.Bounds;
+ if (rs.X == r.X && rs.Y == r.Y)
+ {
+ r.X += rs.Width;
+ r.Width -= rs.Width;
+ }
+ else if (rs.X == r.X && rs.Bottom == r.Bottom && rs.Y > r.Y)
+ {
+ r.Y += rs.Height;
+ r.Height -= rs.Height;
+ }
+ else
+ {
+ r.Width -= rs.Width;
+ }
+ }
+ else
+ {
+ r = m_Button.SubItemsRect;
+ r.Offset(m_Button.Bounds.Location);
+ }
+ if (parent != null)
+ r.Location = parent.PointToScreen(r.Location);
+ return r;
+ }
+ }
+
+ public override int GetChildCount()
+ {
+ if (m_PushButtonPart)
+ return 0;
+ return m_Button.SubItems.Count;
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetChild(int iIndex)
+ {
+ if (m_Button == null || m_PushButtonPart)
+ return null;
+
+ return m_Button.SubItems[iIndex].AccessibleObject;
+ }
+
+ public override string DefaultAction
+ {
+ get
+ {
+ if (m_Button.AccessibleDefaultActionDescription != "")
+ return m_Button.AccessibleDefaultActionDescription;
+ if (m_PushButtonPart)
+ return "Press";
+ else
+ return "Open";
+ }
+ }
+
+ public override void DoDefaultAction()
+ {
+ if (m_Button == null)
+ return;
+
+ if (m_PushButtonPart)
+ m_Button._AccessibleExpandAction = false;
+ else
+ m_Button._AccessibleExpandAction = true;
+
+ System.Windows.Forms.Control cont = m_Button.ContainerControl as System.Windows.Forms.Control;
+ if (cont is MenuPanel && !(cont is IAccessibilitySupport))
+ {
+ cont = ((MenuPanel)cont).ParentItem.ContainerControl as System.Windows.Forms.Control;
+ }
+
+ IAccessibilitySupport ias = cont as IAccessibilitySupport;
+ if (ias != null)
+ {
+ ias.DoDefaultActionItem = m_Button;
+ NativeFunctions.PostMessage(cont.Handle, NativeFunctions.WM_USER + 107, IntPtr.Zero, IntPtr.Zero);
+ }
+
+ base.DoDefaultAction();
+ }
+
+ public override string KeyboardShortcut
+ {
+ get
+ {
+ return m_Button.ShortcutString;
+ }
+ }
+
+ public override System.Windows.Forms.AccessibleObject GetSelected()
+ {
+ if (m_Button == null || m_PushButtonPart)
+ return base.GetSelected();
+
+ foreach (BaseItem item in m_Button.SubItems)
+ {
+ if ((item.AccessibleObject.State & System.Windows.Forms.AccessibleStates.HotTracked) == System.Windows.Forms.AccessibleStates.HotTracked)
+ return item.AccessibleObject;
+ }
+
+ return base.GetSelected();
+ }
+
+ public override System.Windows.Forms.AccessibleObject HitTest(int x, int y)
+ {
+ if (m_Button == null)
+ return base.HitTest(x, y);
+
+ Point screen = new Point(x, y);
+ foreach (BaseItem item in m_Button.SubItems)
+ {
+ System.Windows.Forms.Control cont = item.ContainerControl as System.Windows.Forms.Control;
+ if (cont != null)
+ {
+ Point p = cont.PointToClient(screen);
+ if (item.DisplayRectangle.Contains(p))
+ return item.AccessibleObject;
+ }
+ }
+
+ return base.HitTest(x, y);
+ }
+
+ public override System.Windows.Forms.AccessibleObject Navigate(System.Windows.Forms.AccessibleNavigation navdir)
+ {
+ if (m_Button == null || m_PushButtonPart)
+ return base.Navigate(navdir);
+
+ BaseItem item = null;
+
+ if (navdir == System.Windows.Forms.AccessibleNavigation.Down || navdir == System.Windows.Forms.AccessibleNavigation.Right
+ || navdir == System.Windows.Forms.AccessibleNavigation.Next)
+ {
+ if (m_Button.Parent != null)
+ {
+ BaseItem parent = m_Button.Parent;
+ item = GetFirstVisible(parent.SubItems, parent.SubItems.IndexOf(m_Button) + 1);
+ }
+ }
+ else if (navdir == System.Windows.Forms.AccessibleNavigation.FirstChild)
+ {
+ item = GetFirstVisible(m_Button.SubItems, 0);
+ }
+ else if (navdir == System.Windows.Forms.AccessibleNavigation.LastChild)
+ {
+ item = GetFirstVisibleReverse(m_Button.SubItems, m_Button.SubItems.Count - 1);
+ }
+ else if (navdir == System.Windows.Forms.AccessibleNavigation.Up || navdir == System.Windows.Forms.AccessibleNavigation.Left
+ || navdir == System.Windows.Forms.AccessibleNavigation.Previous)
+ {
+ BaseItem parent = m_Button.Parent;
+ item = GetFirstVisibleReverse(m_Button.SubItems, parent.SubItems.IndexOf(m_Button) - 1);
+ }
+
+ if (item != null)
+ return item.AccessibleObject;
+
+ return base.Navigate(navdir);
+ }
+
+ private BaseItem GetFirstVisible(SubItemsCollection col, int startIndex)
+ {
+ int count = col.Count;
+ if (count == 0) return null;
+ if (startIndex >= col.Count) startIndex = col.Count - 1;
+
+ for (int i = startIndex; i < count; i++)
+ {
+ if (col[i].Visible)
+ return col[i];
+ }
+ return null;
+ }
+
+ private BaseItem GetFirstVisibleReverse(SubItemsCollection col, int startIndex)
+ {
+ if (col.Count == 0) return null;
+ if (startIndex >= col.Count) startIndex = col.Count - 1;
+ for (int i = startIndex; i >= 0; i--)
+ {
+ if (col[i].Visible)
+ return col[i];
+ }
+ return null;
+ }
+ }
+ #endregion
+ }
+
+ #region OptionGroupChangingEventHandler
+ ///
+ /// Delegate for OptionGroupChanging event.
+ ///
+ public delegate void OptionGroupChangingEventHandler(object sender, OptionGroupChangingEventArgs e);
+ #endregion
+
+ #region OptionGroupChangingEventArgs
+ ///
+ /// Represents event arguments for OptionGroupChanging event.
+ ///
+ public class OptionGroupChangingEventArgs : EventArgs
+ {
+ ///
+ /// Set to true to cancel the checking on NewChecked button.
+ ///
+ public bool Cancel = false;
+ ///
+ /// Button that will become checked if operation is not canceled.
+ ///
+ public readonly BaseItem NewChecked;
+ ///
+ /// Button that is currently checked and which will be unchecked if operation is not canceled.
+ ///
+ public readonly BaseItem OldChecked;
+ ///
+ /// Default constructor.
+ ///
+ public OptionGroupChangingEventArgs(BaseItem oldchecked, BaseItem newchecked)
+ {
+ NewChecked = newchecked;
+ OldChecked = oldchecked;
+ }
+ }
+ #endregion
+
+ #region SideBarImage
+ ///
+ /// Stores all information for side bar images that are used by Bar or Popup menu.
+ ///
+ public struct SideBarImage
+ {
+ ///
+ /// Gets or sets the side bar image.
+ ///
+ public Image Picture;
+ ///
+ /// Gets or sets the side bar back color.
+ ///
+ public Color BackColor;
+ ///
+ /// Gets or sets the gradient staring color.
+ ///
+ public Color GradientColor1;
+ ///
+ /// Gets or sets the gradient ending color.
+ ///
+ public Color GradientColor2;
+ ///
+ /// Gets or sets the gradient angle.
+ ///
+ public float GradientAngle;
+ ///
+ /// Gets or sets the gradient staring color.
+ ///
+ public eAlignment Alignment;
+
+ ///
+ /// Gets or sets whether image is stretched so it fills the side bar or not if image is smaller than current side bar size.
+ ///
+ public bool StretchPicture;
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/ButtonItemLayout.cs b/PROMS/DotNetBar Source Code/ButtonItemLayout.cs
new file mode 100644
index 00000000..17cc306a
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ButtonItemLayout.cs
@@ -0,0 +1,985 @@
+using System.Drawing;
+using System.Drawing.Text;
+using System.Windows.Forms;
+using System;
+using DevComponents.DotNetBar.Controls;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for ButtonItemLayout.
+ ///
+ internal class ButtonItemLayout
+ {
+ ///
+ /// Arranges the button inner parts when button size has changed externally.
+ ///
+ /// Button to arrange inner parts for.
+ public static void Arrange(ButtonItem button)
+ {
+ int minTextSize = Dpi.Width8;
+ bool isOnMenu = button.IsOnMenu;
+ if (isOnMenu && button.Parent is ItemContainer)
+ isOnMenu = false;
+ bool hasImage = false;
+
+ Size imageSize = Size.Empty;
+ if (!string.IsNullOrEmpty(button.SymbolRealized))
+ {
+ hasImage = true;
+ imageSize = button.ImageSize;
+ }
+ else
+ {
+ using (CompositeImage buttonImage = button.GetImage())
+ {
+ if (buttonImage != null)
+ hasImage = true;
+ }
+ imageSize = GetLayoutImageSize(button, hasImage, isOnMenu, false);
+ }
+
+ bool rightToLeft = button.IsRightToLeft;
+ Rectangle bounds = button.DisplayRectangle;
+
+ if (isOnMenu)
+ {
+ // Add 4 pixel padding to the image size, 2 pixels on each side
+ imageSize.Height += Dpi.Width2;
+ imageSize.Width += Dpi.Width7;
+ // Center image if any...
+ //if (rightToLeft)
+ //{
+ // if (button.IsOnCustomizeMenu)
+ // button.ImageDrawRect = new Rectangle(bounds.Width - (imageSize.Width + bounds.Height + 2), Math.Max(0, (bounds.Height - imageSize.Height) / 2), imageSize.Width, imageSize.Height);
+ // else
+ // button.ImageDrawRect = new Rectangle(bounds.Width - imageSize.Width - 1, Math.Max(0, (bounds.Height - imageSize.Height) / 2), imageSize.Width, imageSize.Height);
+ //}
+ //else
+ {
+ if (button.IsOnCustomizeMenu && !rightToLeft)
+ button.ImageDrawRect = new Rectangle(bounds.Height + 2, Math.Max(0, (bounds.Height - imageSize.Height) / 2), imageSize.Width, imageSize.Height);
+ else
+ button.ImageDrawRect = new Rectangle(0, Math.Max(0, (bounds.Height - imageSize.Height) / 2), imageSize.Width, imageSize.Height);
+ }
+
+ //if (rightToLeft)
+ // button.TextDrawRect = new Rectangle(Math.Max(0, button.ImageDrawRect.X - button.TextDrawRect.Width - 2), Math.Max(0, (bounds.Height - button.TextDrawRect.Height) / 2), button.TextDrawRect.Width, button.TextDrawRect.Height);
+ //else
+ button.TextDrawRect = new Rectangle(button.ImageDrawRect.Right + 8, Math.Max(0, (bounds.Height - button.TextDrawRect.Height) / 2), button.TextDrawRect.Width, button.TextDrawRect.Height);
+
+ return;
+ }
+ int x = 0;
+ if (!button.SubItemsRect.IsEmpty)
+ {
+ Rectangle subItemsRect = button.SubItemsRect;
+ if (button.ContainerControl is RibbonBar && (button.ImagePosition == eImagePosition.Top || button.ImagePosition == eImagePosition.Bottom))
+ {
+ subItemsRect = new Rectangle(0, bounds.Height - subItemsRect.Height, bounds.Width, subItemsRect.Height);
+ bounds.Height -= subItemsRect.Height;
+ }
+ else
+ {
+ if (button.Orientation == eOrientation.Horizontal)
+ {
+ if (rightToLeft)
+ {
+ subItemsRect = new Rectangle(0, 0, subItemsRect.Width, bounds.Height);
+ //bounds.Width -= subItemsRect.Width;
+ //bounds.X += subItemsRect.Width;
+ x = subItemsRect.Width;
+ }
+ else
+ {
+ subItemsRect = new Rectangle(bounds.Width - subItemsRect.Width, 0, subItemsRect.Width, bounds.Height);
+ bounds.Width -= subItemsRect.Width;
+ }
+ }
+ else
+ {
+ subItemsRect = new Rectangle(0, 0, bounds.Width, subItemsRect.Height);
+ bounds.Height -= subItemsRect.Height;
+ }
+ }
+ button.SubItemsRect = subItemsRect;
+ }
+
+ if (!hasImage || button.ButtonStyle == eButtonStyle.TextOnlyAlways)
+ {
+ int newHeight = bounds.Height - 2;
+ button.TextDrawRect = new Rectangle(2,
+ Math.Max(0, (bounds.Height - newHeight) / 2), bounds.Width - 4, newHeight);
+ return;
+ }
+ else if (button.ButtonStyle == eButtonStyle.Default && !(button.ImagePosition == eImagePosition.Top || button.ImagePosition == eImagePosition.Bottom) || bounds.Width < imageSize.Width + minTextSize)
+ {
+ // Display image only in center of the button
+ button.ImageDrawRect = new Rectangle(Math.Max(0, (bounds.Width - button.ImageDrawRect.Width) / 2),
+ Math.Max(0, (bounds.Height - button.ImageDrawRect.Height) / 2), button.ImageDrawRect.Width, button.ImageDrawRect.Height);
+ if (bounds.Width < imageSize.Width + minTextSize)
+ button.TextDrawRect = Rectangle.Empty;
+ return;
+ }
+
+ // Displays both image and text
+ if (button.ImagePosition == eImagePosition.Left && !rightToLeft || button.ImagePosition == eImagePosition.Right && rightToLeft)
+ {
+ button.ImageDrawRect = new Rectangle(0, Math.Max(0, (bounds.Height - button.ImageDrawRect.Height) / 2),
+ button.ImageDrawRect.Width, button.ImageDrawRect.Height);
+ button.TextDrawRect = new Rectangle(button.ImageDrawRect.Right - 2, Math.Max(0, (bounds.Height - button.TextDrawRect.Height) / 2),
+ Math.Min(button.TextDrawRect.Width, bounds.Width - (button.ImageDrawRect.Right - 2)), button.TextDrawRect.Height);
+ }
+ else if (button.ImagePosition == eImagePosition.Right && !rightToLeft || button.ImagePosition == eImagePosition.Left && rightToLeft)
+ {
+ button.ImageDrawRect = new Rectangle(bounds.Width - button.ImageDrawRect.Width, Math.Max(0, (bounds.Height - button.TextDrawRect.Height) / 2),
+ button.ImageDrawRect.Width, button.ImageDrawRect.Height);
+ button.TextDrawRect = new Rectangle(Math.Max(x, button.ImageDrawRect.X - button.TextDrawRect.Width + 2), Math.Max(0, (bounds.Height - button.TextDrawRect.Height) / 2),
+ Math.Min(button.TextDrawRect.Width, button.ImageDrawRect.X), button.TextDrawRect.Height);
+ }
+ else if (button.ImagePosition == eImagePosition.Top)
+ {
+ int y = Math.Max(2, (bounds.Height - (button.TextDrawRect.Height + button.ImageDrawRect.Height - 2)) / 2);
+ if (button.Name != "sysOverflowButton" && button.Parent is ItemContainer && ((ItemContainer)button.Parent).LayoutOrientation == eOrientation.Horizontal && ((ItemContainer)button.Parent).VerticalItemAlignment == eVerticalItemsAlignment.Top)
+ y = 2;
+
+ button.ImageDrawRect = new Rectangle(0, y,
+ bounds.Width, button.ImageDrawRect.Height);
+
+ button.TextDrawRect = new Rectangle(Math.Max(0, (bounds.Width - button.TextDrawRect.Width) / 2), button.ImageDrawRect.Bottom,
+ button.TextDrawRect.Width, button.TextDrawRect.Height);
+ }
+ else if (button.ImagePosition == eImagePosition.Bottom)
+ {
+ int y = Math.Max(0, (bounds.Height - (button.TextDrawRect.Height + button.ImageDrawRect.Height - 2)) / 2);
+ //button.ImageDrawRect = new Rectangle(Math.Max(0, (bounds.Width - button.ImageDrawRect.Width) / 2), bounds.Height - y - button.ImageDrawRect.Height,
+ // button.ImageDrawRect.Width, button.ImageDrawRect.Height);
+ button.ImageDrawRect = new Rectangle(0, bounds.Height - y - button.ImageDrawRect.Height,
+ bounds.Width, button.ImageDrawRect.Height);
+ button.TextDrawRect = new Rectangle(Math.Max(0, (bounds.Width - button.ImageDrawRect.Width) / 2), Math.Max(0, button.ImageDrawRect.Y + 2 - button.TextDrawRect.Height),
+ button.TextDrawRect.Width, Math.Min(button.TextDrawRect.Height, button.ImageDrawRect.Y));
+ }
+ }
+
+ public static Size MeasureItemText(BaseItem item, Graphics g, int containerWidth, Font font, eTextFormat stringFormat, bool rightToLeft)
+ {
+ return MeasureItemText(item, g, containerWidth, font, stringFormat, rightToLeft, false, eImagePosition.Left);
+ }
+
+ public static Size MeasureItemText(BaseItem item, Graphics g, int containerWidth, Font font, eTextFormat stringFormat, bool rightToLeft, bool ribbonBarButton, eImagePosition imagePosition)
+ {
+ if (item.Text == "" && item.TextMarkupBody == null) return Size.Empty;
+
+ Size textSize = Size.Empty;
+
+ if (item.TextMarkupBody == null)
+ {
+ textSize = TextDrawing.MeasureString(g, ButtonItemPainter.GetDrawText(item.Text), font, containerWidth, stringFormat);
+ }
+ else
+ {
+ Size availSize = new Size(containerWidth, 1);
+ if (containerWidth == 0)
+ availSize.Width = 1600;
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, Color.Empty, false);
+ item.TextMarkupBody.Measure(availSize, d);
+ availSize = item.TextMarkupBody.Bounds.Size;
+ if (containerWidth != 0 && !(ribbonBarButton && imagePosition == eImagePosition.Top))
+ availSize.Width = containerWidth;
+ d.RightToLeft = rightToLeft;
+ item.TextMarkupBody.Arrange(new Rectangle(0, 0, availSize.Width, availSize.Height), d);
+
+ textSize = item.TextMarkupBody.Bounds.Size;
+ }
+
+ return textSize;
+ }
+
+ public static void LayoutButton(ButtonItem button)
+ {
+ LayoutButton(button, false);
+ }
+
+ private static bool UseRibbonWordBreak(ButtonItem button)
+ {
+ if (button.TextMarkupBody == null)
+ return button.Text.IndexOf(' ') > 0 || button.Text.IndexOf(Environment.NewLine)> 0;
+
+ return (button.Text.IndexOf(' ') > 0 && !button.TextMarkupBody.HasExpandElement || button.Text.Split(' ').Length > 2 && button.TextMarkupBody.HasExpandElement && button.ButtonStyle != eButtonStyle.Default);
+ }
+
+ public static void LayoutButton(ButtonItem button, bool startButtonType)
+ {
+ Control objCtrl = button.ContainerControl as Control;
+ if (objCtrl == null || objCtrl.Disposing || objCtrl.IsDisposed) //if(!BarFunctions.IsHandleValid(objCtrl))
+ return;
+ if (objCtrl is ButtonX && button._FitContainer)
+ {
+ LayoutButtonX(button);
+ return;
+ }
+ else if (button.FixedSize.Width > 0 && button.FixedSize.Height > 0)
+ {
+ Size fixedSize=Dpi.Size(button.FixedSize);
+ button.SetDisplayRectangle(new Rectangle(button.DisplayRectangle.Location, fixedSize));
+ LayoutButtonX(button);
+ return;
+ }
+
+ bool isOnMenu = button.IsOnMenu;
+ if (isOnMenu && button.Parent is ItemContainer)
+ isOnMenu = false;
+ bool bHasImage = false;
+ bool isSymbolImage = false;
+ eDotNetBarStyle effectiveStyle = button.EffectiveStyle;
+ bool ignoreImage = false;
+ if (startButtonType && (effectiveStyle == eDotNetBarStyle.Office2010 || effectiveStyle == eDotNetBarStyle.Office2013 || effectiveStyle == eDotNetBarStyle.Metro))
+ ignoreImage = true;
+ if (!ignoreImage)
+ {
+ if (!string.IsNullOrEmpty(button.SymbolRealized))
+ {
+ bHasImage = true;
+ isSymbolImage = true;
+ }
+ else
+ {
+ using (CompositeImage buttonImage = button.GetImage())
+ {
+ if (buttonImage != null || startButtonType)
+ bHasImage = true;
+ }
+ }
+ }
+
+ eImagePosition imagePosition = button.ImagePosition;
+ bool rightToLeft = (objCtrl.RightToLeft == RightToLeft.Yes);
+
+ Rectangle textDrawRect = Rectangle.Empty;
+ Rectangle imageDrawRect = Rectangle.Empty;
+ Rectangle subItemsRect = Rectangle.Empty;
+ Rectangle bounds = new Rectangle(button.DisplayRectangle.Location, Size.Empty); // Critical to preserve the location for compatibility reasons
+
+ if (rightToLeft && button.Orientation == eOrientation.Horizontal)
+ {
+ if (imagePosition == eImagePosition.Left)
+ imagePosition = eImagePosition.Right;
+ else if (imagePosition == eImagePosition.Right)
+ imagePosition = eImagePosition.Left;
+ }
+
+ int measureStringWidth = 0;
+
+ if (button._FitContainer)
+ measureStringWidth = button.DisplayRectangle.Width - 4;
+
+ bounds.Width = 0;
+ bounds.Height = 0;
+
+ Graphics g = BarFunctions.CreateGraphics(objCtrl);
+ try
+ {
+ eTextFormat stringFormat = GetTextFormat(button);
+
+ // Get the right image size that we will use for calculation
+ Size imageSize = Size.Empty;
+ if (isSymbolImage)
+ {
+ Font symFont = Symbols.GetFont(button.SymbolSize, button.SymbolSet);
+
+ if(button.IsOnMenu || objCtrl is SideNavStrip) // Need to do this to get consistent size for the symbol since they are not all the same width we pick widest
+ imageSize = TextDrawing.MeasureStringLegacy(g, "\uF00A", symFont, Size.Empty, eTextFormat.Default);
+ else
+ imageSize = TextDrawing.MeasureStringLegacy(g, button.SymbolRealized, symFont, Size.Empty, eTextFormat.Default);
+
+ //int descent = (int)Math.Ceiling((symFont.FontFamily.GetCellDescent(symFont.Style) *
+ //symFont.Size / symFont.FontFamily.GetEmHeight(symFont.Style)));
+ //imageSize.Height -= descent;
+ button.ImageSize = imageSize;
+ }
+ else
+ {
+ imageSize = GetLayoutImageSize(button, bHasImage, isOnMenu, startButtonType);
+ }
+ bool ribbonBarButton = false;
+ if (button._FitContainer && bHasImage && (imagePosition == eImagePosition.Left || imagePosition == eImagePosition.Right))
+ {
+ measureStringWidth -= (imageSize.Width + Dpi.Width10);
+ }
+ else if (button.RibbonWordWrap && bHasImage && imagePosition == eImagePosition.Top && objCtrl is RibbonBar && UseRibbonWordBreak(button))
+ {
+ measureStringWidth = imageSize.Width + Dpi.Width4;
+ stringFormat |= eTextFormat.WordBreak;
+ ribbonBarButton = true;
+ }
+
+ // Measure string
+ Font font = button.GetFont(null, true);
+
+ SizeF textSize = SizeF.Empty;
+
+ if ((button.Text != "" || button.TextMarkupBody != null) && (!bHasImage || isOnMenu || button.ButtonStyle != eButtonStyle.Default || button.ImagePosition != eImagePosition.Left && bHasImage))
+ {
+ textSize = ButtonItemLayout.MeasureItemText(button, g, measureStringWidth, font, stringFormat, rightToLeft, ribbonBarButton, imagePosition);
+ //if (button.HotFontBold) textSize.Width += textSize.Width * .15f;
+ int maxItt = 0;
+ int increase = Math.Max(14, imageSize.Width / 2);
+ while (ribbonBarButton && textSize.Height > font.Height * 2.2 && maxItt < 4)
+ {
+ measureStringWidth += increase;
+ textSize = ButtonItemLayout.MeasureItemText(button, g, measureStringWidth, font, stringFormat, rightToLeft, ribbonBarButton, imagePosition);
+ maxItt++;
+ }
+ if (maxItt > 0)
+ {
+ measureStringWidth += increase;
+ textSize = ButtonItemLayout.MeasureItemText(button, g, measureStringWidth, font, stringFormat, rightToLeft, ribbonBarButton, imagePosition);
+ }
+ if (/*!ribbonBarButton &&*/ objCtrl is RibbonBar && bHasImage && imagePosition == eImagePosition.Top)
+ textSize.Height += Dpi.Width2;
+ if (startButtonType && ignoreImage)
+ textSize.Width = Dpi.Width((int)Math.Max(51, textSize.Width+6));
+ }
+
+ // See if this button is on menu, and do appropriate calculations
+ if (isOnMenu)
+ {
+ if (imageSize.IsEmpty)
+ imageSize = new Size(Dpi.Width16, Dpi.Height16);
+
+ // Add 4 pixel padding to the image size, 2 pixels on each side
+ imageSize.Height += Dpi.Width2;
+ imageSize.Width += Dpi.Width7;
+
+ // Calculate item height
+ if (textSize.Height > imageSize.Height)
+ bounds.Height = (int)textSize.Height + Dpi.Height4;
+ else
+ bounds.Height = imageSize.Height + Dpi.Height4;
+
+ // Add Vertical Padding to it
+ bounds.Height += Dpi.Height(button.VerticalPadding);
+
+ // We know the image position now, we will center it into this area
+ if (button.IsOnCustomizeMenu && !rightToLeft)
+ imageDrawRect = new Rectangle(bounds.Height + Dpi.Width2, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ else
+ imageDrawRect = new Rectangle(0, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+
+ bounds.Width = (int)textSize.Width;
+ // Add short-cut size if we have short-cut
+ if (button.DrawShortcutText != "")
+ {
+ Size objSizeShortcut = TextDrawing.MeasureString(g, button.DrawShortcutText, font, 0, stringFormat);
+ bounds.Width += (objSizeShortcut.Width + 14); // 14 distance between text and shortcut
+ }
+
+ textDrawRect = new Rectangle(imageDrawRect.Right + 8, 2, bounds.Width, bounds.Height - 4);
+
+ // 8 pixels distance between image and text, 22 pixels if this item has sub items
+ bounds.Width += (imageDrawRect.Right + Dpi.Width34);
+ bounds.Width += Dpi.Width(button.HorizontalPadding);
+ }
+ else
+ {
+ bool bThemed = button.IsThemed;
+ if (StyleManager.Style == eStyle.OfficeMobile2014)
+ {
+ imageSize.Width += Dpi.Width6; imageSize.Height += Dpi.Height4;
+ }
+ else if (StyleManager.Style == eStyle.Office2016)
+ {
+ imageSize.Width += Dpi.Width4; imageSize.Height += Dpi.Width2;
+ }
+ if (button.Orientation == eOrientation.Horizontal && (imagePosition == eImagePosition.Left || imagePosition == eImagePosition.Right))
+ {
+ // Recalc size for the Bar button
+ // Add 8 pixel padding to the image size, 4 pixels on each side
+ //objImageSize.Height+=4;
+ imageSize.Width += Dpi.Width(button.ImagePaddingHorizontal);
+
+ // Calculate item height
+ if (textSize.Height > imageSize.Height)
+ bounds.Height = (int)textSize.Height + Dpi.Height(button.ImagePaddingVertical);
+ else
+ bounds.Height = imageSize.Height + Dpi.Height(button.ImagePaddingVertical);
+
+ // Add Vertical Padding
+ bounds.Height += Dpi.Height(button.VerticalPadding);
+
+ if (bThemed && !button.IsOnMenuBar)
+ bounds.Height += Dpi.Height4;
+
+ imageDrawRect = Rectangle.Empty;
+ if (button.ButtonStyle != eButtonStyle.TextOnlyAlways && bHasImage)
+ {
+ // We know the image position now, we will center it into this area
+ imageDrawRect = new Rectangle(0, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ }
+
+ // Draw Text only if needed
+ textDrawRect = Rectangle.Empty;
+ if (button.ButtonStyle != eButtonStyle.Default || !bHasImage)
+ {
+ if (imageDrawRect.Right > 0)
+ {
+ bounds.Width = (int)textSize.Width + 1;
+ textDrawRect = new Rectangle(imageDrawRect.Right - 2, 2, bounds.Width, bounds.Height - 4);
+ }
+ else
+ {
+ bounds.Width = (int)textSize.Width + Dpi.Width6;
+ if (!bHasImage && button.IsOnMenuBar)
+ {
+ bounds.Width += Dpi.Width6;
+ textDrawRect = new Rectangle(2, 2, bounds.Width, bounds.Height - 4);
+ }
+ else
+ textDrawRect = new Rectangle(2, 2, bounds.Width + Dpi.Width(button.HorizontalPadding - 4), bounds.Height - 4);
+ }
+ }
+ bounds.Width += imageDrawRect.Right;
+
+ if (imagePosition == eImagePosition.Right && imageDrawRect.Right > 0 && bHasImage)
+ {
+ textDrawRect.X = 3;
+ imageDrawRect.X = bounds.Width - imageDrawRect.Width;
+ }
+
+ // Add Horizontal padding
+ bounds.Width += Dpi.Width(button.HorizontalPadding);
+ }
+ else
+ {
+ // Image is on top or bottom
+ // Calculate width, that is easy
+ if (button.Orientation == eOrientation.Horizontal)
+ {
+
+ if (textSize.Width > imageSize.Width)
+ bounds.Width = (int)textSize.Width + Dpi.Width(button.ImagePaddingHorizontal);
+ else
+ bounds.Width = imageSize.Width + Dpi.Width(button.ImagePaddingHorizontal);
+
+ // Calculate item height 3 padding on top and bottom and 2 pixels distance between the image and text
+ bounds.Height = (int)(imageSize.Height + textSize.Height + Dpi.Height(button.ImagePaddingVertical) /*10*/);
+
+ // Add Horizontal/Vertical padding
+ bounds.Width += Dpi.Width(button.HorizontalPadding);
+ bounds.Height += Dpi.Height(button.VerticalPadding);
+
+ if (imagePosition == eImagePosition.Top)
+ {
+ imageDrawRect = new Rectangle(0, Dpi.Height(button.VerticalPadding) / 2 + 2, bounds.Width, imageSize.Height/*+2*/);
+ textDrawRect = new Rectangle((int)(bounds.Width - textSize.Width) / 2, imageDrawRect.Bottom, (int)textSize.Width, (int)textSize.Height + 5);
+ }
+ else
+ {
+ textDrawRect = new Rectangle((int)(bounds.Width - textSize.Width) / 2, Dpi.Height(button.VerticalPadding) / 2, (int)textSize.Width, (int)textSize.Height + 2);
+ imageDrawRect = new Rectangle(0, textDrawRect.Bottom, bounds.Width, imageSize.Height + 5);
+ }
+ }
+ else
+ {
+ if (textSize.Height > imageSize.Width && button.ButtonStyle != eButtonStyle.Default)
+ bounds.Width = (int)textSize.Height + 6;
+ else
+ bounds.Width = imageSize.Width + 10;
+
+ // Add Horizontal Padding
+ bounds.Width += Dpi.Width(button.HorizontalPadding);
+
+ // Calculate item height 3 padding on top and bottom and 2 pixels distance between the image and text
+ if (button.ButtonStyle != eButtonStyle.Default || !bHasImage)
+ {
+ if (bHasImage)
+ bounds.Height = (int)(imageSize.Height + textSize.Width + Dpi.Width12);
+ else
+ bounds.Height = (int)(textSize.Width + Dpi.Width6);
+ }
+ else
+ bounds.Height = imageSize.Height + Dpi.Height6;
+
+ if (imagePosition == eImagePosition.Top || imagePosition == eImagePosition.Left)
+ {
+ if (bHasImage)
+ imageDrawRect = new Rectangle(0, 0, bounds.Width, imageSize.Height + Dpi.Height6);
+ textDrawRect = new Rectangle((int)(bounds.Width - textSize.Height) / 2, imageDrawRect.Bottom + Dpi.Width2, (int)textSize.Height, (int)textSize.Width + Dpi.Width5);
+ }
+ else
+ {
+ textDrawRect = new Rectangle((int)(bounds.Width - textSize.Height) / 2, Dpi.Height5, (int)textSize.Height, (int)textSize.Width + Dpi.Width5);
+ if (bHasImage)
+ imageDrawRect = new Rectangle(0, textDrawRect.Bottom - Dpi.Height3, bounds.Width, imageSize.Height + Dpi.Height5);
+ }
+
+ // Add Vertical Padding
+ bounds.Height += Dpi.Height(button.VerticalPadding);
+ }
+ }
+
+ if (HasExpandPart(button))
+ {
+ subItemsRect = GetSubItemsButtonBounds(button, bounds, rightToLeft);
+ // Add small button to expand the item
+ Rectangle rTemp = subItemsRect;
+ rTemp.Offset(bounds.Location);
+
+ if (rightToLeft && !(objCtrl is RibbonBar &&
+ (button.ImagePosition == eImagePosition.Top || button.ImagePosition == eImagePosition.Bottom)))
+ {
+ if (!textDrawRect.IsEmpty)
+ textDrawRect.Offset(subItemsRect.Width + 1, 0);
+ if (!imageDrawRect.IsEmpty && (button.Orientation == eOrientation.Horizontal && (imagePosition == eImagePosition.Left || imagePosition == eImagePosition.Right)))
+ imageDrawRect.Offset(subItemsRect.Width, 0);
+ bounds.X += subItemsRect.Width;
+ }
+
+ bounds = Rectangle.Union(bounds, rTemp);
+ }
+ }
+ }
+ finally
+ {
+ g.TextRenderingHint = TextRenderingHint.SystemDefault;
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
+ g.Dispose();
+ }
+ objCtrl = null;
+
+ button.SetDisplayRectangle(bounds);
+ button.ImageDrawRect = imageDrawRect;
+ button.TextDrawRect = textDrawRect;
+ button.SubItemsRect = subItemsRect;
+ }
+
+ private static bool HasExpandPart(ButtonItem button)
+ {
+ return (button.SubItems.Count > 0 || button.PopupType == ePopupType.Container) && button.ShowSubItems && !button.IsOnMenuBar &&
+ !(button.TextMarkupBody != null && button.TextMarkupBody.HasExpandElement && button.ButtonStyle != eButtonStyle.Default);
+ }
+
+ //private static ButtonTextSize GetTextSize(ButtonItem button, int containerWidth, bool measureShortcut)
+ //{
+ // ButtonTextSize textSize = new ButtonTextSize();
+ // Control ctrl = button.ContainerControl as Control;
+ // Graphics g = BarFunctions.CreateGraphics(ctrl);
+ // try
+ // {
+ // eTextFormat stringFormat = GetTextFormat(button);
+ // Font font = button.GetFont(null);
+
+ // if (button.TextMarkupBody == null)
+ // {
+ // textSize.TextSize = TextDrawing.MeasureString(g, ButtonItemPainter.GetDrawText(button.Text), font, containerWidth, stringFormat);
+ // }
+ // else
+ // {
+ // Size availSize = new Size(containerWidth, 1);
+ // if (containerWidth == 0)
+ // availSize.Width = 1600;
+ // TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, Color.Empty, false);
+ // button.TextMarkupBody.Measure(availSize, d);
+ // availSize = button.TextMarkupBody.Bounds.Size;
+ // if (containerWidth != 0)
+ // availSize.Width = containerWidth;
+ // d.RightToLeft = button.IsRightToLeft;
+ // button.TextMarkupBody.Arrange(new Rectangle(0, 0, availSize.Width, availSize.Height), d);
+
+ // textSize.TextSize = button.TextMarkupBody.Bounds.Size;
+ // }
+
+ // if (measureShortcut && button.DrawShortcutText != "")
+ // textSize.ShortcutTextSize = TextDrawing.MeasureString(g, button.DrawShortcutText, font, 0, stringFormat);
+ // }
+ // finally
+ // {
+ // g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
+ // g.TextRenderingHint = TextRenderingHint.SystemDefault;
+ // g.Dispose();
+ // }
+ // return textSize;
+ //}
+
+ private static Size GetLayoutImageSize(ButtonItem button, bool hasImage, bool isOnMenu, bool startButtonType)
+ {
+ // Get the right image size that we will use for calculation
+ Size imageSize = Size.Empty;
+ if (button.Parent != null && button.ImageFixedSize.IsEmpty && button.UseParentSubItemsImageSize)
+ {
+ ImageItem parentImageItem = button.Parent as ImageItem;
+ if (parentImageItem != null && !parentImageItem.SubItemsImageSize.IsEmpty)
+ {
+ if (!hasImage || isOnMenu)
+ imageSize = new Size(parentImageItem.SubItemsImageSize.Width, parentImageItem.SubItemsImageSize.Height);
+ else
+ {
+ if (button.Orientation == eOrientation.Horizontal)
+ imageSize = new Size(button.ImageSize.Width, Math.Max(parentImageItem.SubItemsImageSize.Height, button.ImageSize.Height));
+ else
+ imageSize = new Size(Math.Max(parentImageItem.SubItemsImageSize.Width, button.ImageSize.Width), button.ImageSize.Height);
+ }
+ }
+ else
+ imageSize = button.ImageSize;
+ }
+ else if(startButtonType && !button.ImageFixedSize.IsEmpty)
+ imageSize = button.ImageFixedSize;
+ else if (!button.ImageFixedSize.IsEmpty)
+ imageSize = Dpi.Size(button.ImageFixedSize);
+ else
+ imageSize = button.ImageSize;
+
+ if (startButtonType)
+ {
+ Office2007Renderer renderer = GlobalManager.Renderer as Office2007Renderer;
+ if (renderer != null && renderer.ColorTable is Office2007ColorTable)
+ {
+ Office2007ColorTable table = renderer.ColorTable as Office2007ColorTable;
+ if (table.RibbonControl.StartButtonDefault != null)
+ {
+ if (imageSize.Width < table.RibbonControl.StartButtonDefault.Width)
+ imageSize.Width = table.RibbonControl.StartButtonDefault.Width;
+ if (imageSize.Height < table.RibbonControl.StartButtonDefault.Height)
+ imageSize.Height = table.RibbonControl.StartButtonDefault.Height;
+ }
+ }
+ imageSize = Dpi.ImageSize(imageSize);
+ }
+
+ return imageSize;
+ }
+
+ public static Rectangle GetSubItemsButtonBounds(ButtonItem button, Rectangle buttonBounds, bool rightToLeft)
+ {
+ Rectangle subItemsRect = Rectangle.Empty;
+
+ int subItemsExpandWidth = Dpi.Width(button.SubItemsExpandWidth);
+ if (button.ContainerControl is RibbonBar && (button.ImagePosition == eImagePosition.Top || button.ImagePosition == eImagePosition.Bottom))
+ {
+ subItemsRect = new Rectangle(0, buttonBounds.Height, buttonBounds.Width, subItemsExpandWidth);
+ }
+ else
+ {
+ // Add small button to expand the item
+ if (button.Orientation == eOrientation.Horizontal)
+ {
+ if (button.IsThemed)
+ {
+ if (rightToLeft)
+ subItemsRect = new Rectangle(0, 0, subItemsExpandWidth, buttonBounds.Height);
+ else
+ subItemsRect = new Rectangle(buttonBounds.Width, 0, subItemsExpandWidth, buttonBounds.Height);
+ }
+ else
+ {
+ if (rightToLeft)
+ subItemsRect = new Rectangle(0, 0, subItemsExpandWidth, buttonBounds.Height);
+ else
+ subItemsRect = new Rectangle(buttonBounds.Width + 1, 0, subItemsExpandWidth, buttonBounds.Height);
+ }
+ }
+ else
+ {
+ subItemsRect = new Rectangle(0, buttonBounds.Height - 2, buttonBounds.Width, subItemsExpandWidth);
+ }
+ }
+
+ return subItemsRect;
+ }
+
+ public static eTextFormat GetTextFormat(ButtonItem button)
+ {
+ eTextFormat format = eTextFormat.Default;
+ if (!button._FitContainer)
+ {
+ format |= eTextFormat.SingleLine;
+ }
+ else
+ format |= eTextFormat.WordBreak;
+
+ format |= eTextFormat.VerticalCenter;
+ return format;
+ }
+
+ public static void LayoutButtonX(ButtonItem button)
+ {
+ Control objCtrl = button.ContainerControl as Control;
+ ButtonX btnX = button.ContainerControl as ButtonX;
+ if (!BarFunctions.IsHandleValid(objCtrl))
+ return;
+ bool isOnMenu = button.IsOnMenu;
+ if (isOnMenu && button.Parent is ItemContainer)
+ isOnMenu = false;
+ bool bHasImage = false;
+
+ if (!string.IsNullOrEmpty(button.SymbolRealized))
+ {
+ bHasImage = true;
+ }
+ else
+ {
+ using (CompositeImage buttonImage = button.GetImage())
+ {
+ if (buttonImage != null)
+ bHasImage = true;
+ }
+ }
+
+ eImagePosition imagePosition = button.ImagePosition;
+ bool rightToLeft = (objCtrl.RightToLeft == RightToLeft.Yes);
+
+ Rectangle textDrawRect = Rectangle.Empty;
+ Rectangle imageDrawRect = Rectangle.Empty;
+ Rectangle subItemsRect = Rectangle.Empty;
+ Rectangle bounds = button.Bounds;
+
+ // Calculate sub-items rectangle
+ if (button.SubItems.Count > 0 && button.ShowSubItems &&
+ !(button.TextMarkupBody != null && button.TextMarkupBody.HasExpandElement && button.ButtonStyle != eButtonStyle.Default))
+ {
+ // Add small button to expand the item
+ int subItemsExpandWidth = Dpi.Width(button.SubItemsExpandWidth);
+ if (button.Orientation == eOrientation.Horizontal)
+ {
+ if (rightToLeft)
+ subItemsRect = new Rectangle(0, 0, subItemsExpandWidth, bounds.Height);
+ else
+ subItemsRect = new Rectangle(bounds.Width - subItemsExpandWidth, 0, subItemsExpandWidth, bounds.Height);
+ if (rightToLeft)
+ bounds.X += subItemsExpandWidth + 1;
+ bounds.Width -= subItemsExpandWidth + 1;
+ }
+ else
+ {
+ subItemsRect = new Rectangle(0, bounds.Height - subItemsExpandWidth, bounds.Width, subItemsExpandWidth);
+ bounds.Height -= subItemsExpandWidth + 1;
+ }
+ }
+
+ // Adjust image position
+ if (rightToLeft && button.Orientation == eOrientation.Horizontal)
+ {
+ if (imagePosition == eImagePosition.Left)
+ imagePosition = eImagePosition.Right;
+ else if (imagePosition == eImagePosition.Right)
+ imagePosition = eImagePosition.Left;
+ }
+
+ int measureStringWidth = 0;
+
+ measureStringWidth = bounds.Width;
+
+ Graphics g = BarFunctions.CreateGraphics(objCtrl);
+ try
+ {
+
+ // Get the right image size that we will use for calculation
+ Size imageSize = Size.Empty;
+ if (!string.IsNullOrEmpty(button.SymbolRealized))
+ {
+ Font symFont = Symbols.GetFont(button.SymbolSize, button.SymbolSet);
+ imageSize = TextDrawing.MeasureStringLegacy(g, button.SymbolRealized, symFont, Size.Empty, eTextFormat.Default);
+ int descent = (int)Math.Ceiling((symFont.FontFamily.GetCellDescent(symFont.Style) *
+ symFont.Size / symFont.FontFamily.GetEmHeight(symFont.Style)));
+ imageSize.Height -= descent;
+ button.ImageSize = imageSize;
+ }
+ else
+ {
+ if (!button.ImageFixedSize.IsEmpty)
+ imageSize = button.ImageFixedSize;
+ else
+ imageSize = button.ImageSize;
+ }
+
+ if (bHasImage && (imagePosition == eImagePosition.Left || imagePosition == eImagePosition.Right))
+ {
+ if (btnX != null)
+ measureStringWidth -= imageSize.Width + btnX.ImageTextSpacing * 2 + 3;
+ else
+ measureStringWidth -= (imageSize.Width + 8);
+ }
+
+ if (bHasImage && !imageSize.IsEmpty && btnX != null && btnX.ImageTextSpacing != 0)
+ {
+ if (imagePosition == eImagePosition.Left || imagePosition == eImagePosition.Right)
+ imageSize.Width += btnX.ImageTextSpacing * 2;
+ else
+ imageSize.Height += btnX.ImageTextSpacing * 2;
+ }
+
+ // Measure string
+ Font font = button.GetFont(null, true);
+
+ SizeF textSize = SizeF.Empty;
+ eTextFormat stringFormat = eTextFormat.Default | eTextFormat.VerticalCenter;
+#if FRAMEWORK20
+ if (BarFunctions.IsWindowsXP && BarUtilities.UseTextRenderer) stringFormat |= eTextFormat.LeftAndRightPadding;
+#endif
+ if (btnX != null || objCtrl is RibbonBar && button.RibbonWordWrap) stringFormat |= eTextFormat.WordBreak;
+ if (btnX != null && !btnX.UseMnemonic) stringFormat |= eTextFormat.NoPrefix;
+
+ if (button.Text != "")
+ {
+ if (button.TextMarkupBody == null)
+ {
+ if (button.Orientation == eOrientation.Vertical && !isOnMenu)
+ textSize = TextDrawing.MeasureStringLegacy(g, ButtonItemPainter.GetDrawText(button.Text), font, new Size(measureStringWidth, 0), stringFormat);
+ else
+ {
+ textSize = TextDrawing.MeasureString(g, ButtonItemPainter.GetDrawText(button.Text), font, measureStringWidth, stringFormat);
+#if FRAMEWORK20
+ if (BarFunctions.IsWindowsXP && BarUtilities.UseTextRenderer) textSize.Width += 2;
+#endif
+ }
+ }
+ else
+ {
+ Size availSize = new Size(measureStringWidth, 1);
+ if (measureStringWidth == 0)
+ availSize.Width = 1600;
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, Color.Empty, false);
+ d.RightToLeft = rightToLeft;
+ button.TextMarkupBody.Measure(availSize, d);
+ availSize = button.TextMarkupBody.Bounds.Size;
+ button.TextMarkupBody.Arrange(new Rectangle(0, 0, availSize.Width, availSize.Height), d);
+
+ textSize = button.TextMarkupBody.Bounds.Size;
+ }
+ }
+
+ if (button.Orientation == eOrientation.Horizontal && (imagePosition == eImagePosition.Left || imagePosition == eImagePosition.Right))
+ {
+ // Recalc size for the Bar button
+ // Add 8 pixel padding to the image size, 4 pixels on each side
+ if (button.ButtonStyle != eButtonStyle.Default || !bHasImage)
+ imageSize.Width += 4;
+
+ imageDrawRect = Rectangle.Empty;
+ if (button.ButtonStyle != eButtonStyle.TextOnlyAlways && bHasImage)
+ {
+ // We know the image position now, we will center it into this area
+ if (imagePosition == eImagePosition.Left)
+ {
+ if (btnX != null && btnX.TextAlignment == eButtonTextAlignment.Left)
+ imageDrawRect = new Rectangle(2, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ else if (btnX != null && btnX.TextAlignment == eButtonTextAlignment.Right)
+ imageDrawRect = new Rectangle(bounds.Width - (imageSize.Width + (int)Math.Ceiling(textSize.Width) + 4), (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ else if (btnX != null)
+ imageDrawRect = new Rectangle(/*bounds.X+*/(int)(bounds.Width - (textSize.Width + imageSize.Width)) / 2, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ else
+ {
+ if (subItemsRect.IsEmpty && button.ButtonStyle == eButtonStyle.Default)
+ imageDrawRect = new Rectangle((bounds.Width - imageSize.Width) / 2, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ else
+ imageDrawRect = new Rectangle(0, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ }
+ }
+ else
+ {
+ if (btnX != null && btnX.TextAlignment == eButtonTextAlignment.Left)
+ imageDrawRect = new Rectangle((int)textSize.Width + 4, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ else if (btnX != null && btnX.TextAlignment == eButtonTextAlignment.Right)
+ imageDrawRect = new Rectangle(bounds.Width - imageSize.Width, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ else if (btnX != null)
+ imageDrawRect = new Rectangle(bounds.Width - (int)(bounds.Width - (textSize.Width + imageSize.Width)) / 2 - (imageSize.Width), (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ else
+ imageDrawRect = new Rectangle(bounds.Width - imageSize.Width, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ }
+ }
+
+ // Draw Text only if needed
+ textDrawRect = Rectangle.Empty;
+ if (button.ButtonStyle != eButtonStyle.Default || !bHasImage)
+ {
+ if (bHasImage)
+ {
+ if (imagePosition == eImagePosition.Left)
+ {
+ if (btnX != null && btnX.TextAlignment == eButtonTextAlignment.Center)
+ textDrawRect = new Rectangle(imageDrawRect.Right + 1, (int)((bounds.Height - textSize.Height) / 2), (int)textSize.Width, (int)textSize.Height);
+ else if (btnX != null && (btnX.TextAlignment == eButtonTextAlignment.Right || btnX.TextAlignment == eButtonTextAlignment.Left))
+ textDrawRect = new Rectangle(imageDrawRect.Right + 1, (int)((bounds.Height - textSize.Height) / 2), bounds.Width - 3 - imageDrawRect.Width, (int)textSize.Height);
+ else
+ textDrawRect = new Rectangle(imageDrawRect.Right + 1, (int)((bounds.Height - textSize.Height) / 2), bounds.Width - 3 - imageDrawRect.Width, (int)textSize.Height);
+ }
+ else
+ {
+ if (btnX != null && btnX.TextAlignment == eButtonTextAlignment.Center)
+ textDrawRect = new Rectangle((int)(imageDrawRect.X - textSize.Width) - 1, (int)((bounds.Height - textSize.Height) / 2), (int)textSize.Width, (int)textSize.Height);
+ else if (btnX != null && btnX.TextAlignment == eButtonTextAlignment.Right)
+ textDrawRect = new Rectangle(imageDrawRect.X - ((int)textSize.Width + 4), (int)((bounds.Height - textSize.Height) / 2), (int)textSize.Width + 2, (int)textSize.Height);
+ else
+ textDrawRect = new Rectangle(3, (int)((bounds.Height - textSize.Height) / 2), imageDrawRect.X - 2, (int)textSize.Height);
+ }
+ }
+ else
+ {
+ if (btnX != null && btnX.TextAlignment == eButtonTextAlignment.Center || button._FixedSizeCenterText)
+ textDrawRect = new Rectangle(/*bounds.X+*/(int)((bounds.Width - textSize.Width) / 2), (int)((bounds.Height - textSize.Height) / 2), (int)textSize.Width, (int)textSize.Height);
+ else
+ textDrawRect = new Rectangle(/*bounds.X +*/ 3, (int)((bounds.Height - textSize.Height) / 2), bounds.Width - 6, (int)textSize.Height);
+ }
+ }
+ }
+ else
+ {
+ // Image is on top or bottom
+ // Calculate width, that is easy
+ if (button.Orientation == eOrientation.Horizontal)
+ {
+
+ if (imagePosition == eImagePosition.Top)
+ {
+ imageDrawRect = new Rectangle(0, (int)(bounds.Height - (imageSize.Height + textSize.Height)) / 2, bounds.Width, imageSize.Height/*+2*/);
+ textDrawRect = new Rectangle(0, imageDrawRect.Bottom, (int)textSize.Width, (int)textSize.Height + 5);
+ }
+ else
+ {
+ textDrawRect = new Rectangle((int)(bounds.Width - textSize.Width) / 2, (int)(bounds.Height - (imageSize.Height + textSize.Height)) / 2, (int)textSize.Width, (int)textSize.Height);
+ imageDrawRect = new Rectangle(0, textDrawRect.Bottom, bounds.Width, imageSize.Height + 5);
+ }
+ }
+ else
+ {
+ if (imagePosition == eImagePosition.Top || imagePosition == eImagePosition.Left)
+ {
+ if (bHasImage)
+ {
+ if (subItemsRect.IsEmpty && button.ButtonStyle == eButtonStyle.Default)
+ imageDrawRect = new Rectangle((bounds.Width - imageSize.Width) / 2, (bounds.Height - imageSize.Height) / 2, imageSize.Width, imageSize.Height);
+ else
+ imageDrawRect = new Rectangle(0, 0, bounds.Width, imageSize.Height + 6);
+ }
+ textDrawRect = new Rectangle((int)(bounds.Width - textSize.Height) / 2, imageDrawRect.Bottom + 2, (int)textSize.Height, (int)textSize.Width + 5);
+ }
+ else
+ {
+ textDrawRect = new Rectangle((int)(bounds.Width - textSize.Width) / 2, 0, (int)textSize.Height, (int)textSize.Width + 5);
+ if (bHasImage)
+ imageDrawRect = new Rectangle(0, textDrawRect.Bottom + 2, bounds.Width, imageSize.Height + 5);
+ }
+ }
+ }
+ }
+ finally
+ {
+ g.TextRenderingHint = TextRenderingHint.SystemDefault;
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
+ g.Dispose();
+ }
+
+ button.ImageDrawRect = imageDrawRect;
+ button.TextDrawRect = textDrawRect;
+ button.SubItemsRect = subItemsRect;
+ }
+
+ private struct ButtonTextSize
+ {
+ public Size TextSize;
+ public Size ShortcutTextSize;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ButtonX/ButtonX.cs b/PROMS/DotNetBar Source Code/ButtonX/ButtonX.cs
new file mode 100644
index 00000000..211bd86c
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ButtonX/ButtonX.cs
@@ -0,0 +1,1542 @@
+using System;
+using System.Text;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Drawing;
+using System.Collections;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+using System.Drawing.Design;
+
+namespace DevComponents.DotNetBar
+{
+ [ToolboxBitmap(typeof(ButtonX),"ButtonX.ButtonX.ico"),ToolboxItem(true), DefaultEvent("Click"), Designer("DevComponents.DotNetBar.Design.ButtonXDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false)]
+ public class ButtonX : PopupItemControl, IButtonControl, ICommandSource
+ {
+ #region Events
+ ///
+ /// Occurs when Checked property has changed.
+ ///
+ [Description("Occurs when Checked property has changed.")]
+ public event EventHandler CheckedChanged;
+ #endregion
+
+ #region Private Variables
+ private ButtonItem m_Button = null;
+ private ColorScheme m_ColorScheme = null;
+ private DialogResult m_DialogResult = DialogResult.None;
+ private bool m_IsDefault = false;
+ private bool m_FadeEffect = true;
+ private eButtonTextAlignment m_TextAlignment = eButtonTextAlignment.Center;
+ private Size m_PreferredSize = Size.Empty;
+ #endregion
+
+ #region Constructor
+ public ButtonX()
+ {
+ this.IsAccessible = true;
+ this.AccessibleRole = AccessibleRole.PushButton;
+ base.SetStyle(ControlStyles.StandardDoubleClick | ControlStyles.StandardClick, false);
+ StyleManager.Register(this);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ StyleManager.Unregister(this);
+ //m_Button.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ ///
+ /// Called by StyleManager to notify control that style on manager has changed and that control should refresh its appearance if
+ /// its style is controlled by StyleManager.
+ ///
+ /// New active style.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void StyleManagerStyleChanged(eDotNetBarStyle newStyle)
+ {
+ this.Style = this.Style;
+ }
+
+ protected virtual ButtonItem CreateButtonItem()
+ {
+ return new ButtonItem();
+ }
+
+ protected override PopupItem CreatePopupItem()
+ {
+ m_Button = CreateButtonItem();
+ m_Button.GlobalItem = false;
+ m_Button.Displayed = true;
+ m_Button.ContainerControl = this;
+ m_Button.ColorTable = eButtonColor.BlueWithBackground;
+ m_Button.ButtonStyle = eButtonStyle.ImageAndText;
+ m_Button._FitContainer = true;
+ m_Button.Style = eDotNetBarStyle.Office2007;
+ m_Button.SetOwner(this);
+ m_Button.CheckedChanged += new EventHandler(OnCheckedChanged);
+ return m_Button;
+ }
+
+ private void OnCheckedChanged(object sender, EventArgs e)
+ {
+ if (CheckedChanged != null)
+ CheckedChanged(this, e);
+ }
+
+ ///
+ /// Creates new accessibility instance.
+ ///
+ /// Reference to AccessibleObject.
+ protected override AccessibleObject CreateAccessibilityInstance()
+ {
+ return new ButtonXAccessibleObject(this);
+ }
+ #endregion
+
+ #region Internal Implementation
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
+ protected internal ButtonItem ButtonItem
+ {
+ get { return (m_Button); }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
+ protected bool IsMouseDown
+ {
+ get
+ {
+ return m_Button.IsMouseDown;
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected void StopFade()
+ {
+ m_Button.StopFade();
+ }
+ protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
+ {
+ base.ScaleControl(factor, specified);
+ m_Button.NotifyScaleItem(factor);
+ }
+ ///
+ /// Gets or sets whether text-markup support is enabled for controls Text property. Default value is true.
+ /// Set this property to false to display HTML or other markup in the control instead of it being parsed as text-markup.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether text-markup support is enabled for controls Text property.")]
+ public bool EnableMarkup
+ {
+ get { return m_Button.EnableMarkup; }
+ set
+ {
+ m_Button.EnableMarkup = value;
+ }
+ }
+
+ ///
+ /// Starts the button pulse effect which alternates slowly between the mouse over and the default state. The pulse effect
+ /// continues indefinitely until it is stopped by call to StopPulse method.
+ ///
+ public void Pulse()
+ {
+ m_Button.Pulse();
+ }
+
+ ///
+ /// Starts the button pulse effect which alternates slowly between the mouse over and the default state. Pulse effect
+ /// will alternate between the pulse state for the number of times specified by the pulseBeatCount parameter.
+ ///
+ /// Specifies the number of times button alternates between pulse states. 0 indicates indefinite pulse
+ public void Pulse(int pulseBeatCount)
+ {
+ m_Button.Pulse(pulseBeatCount);
+ }
+
+ ///
+ /// Stops the button Pulse effect.
+ ///
+ public void StopPulse()
+ {
+ m_Button.StopPulse();
+ }
+
+ ///
+ /// Gets whether the button is currently pulsing, alternating slowly between the mouse over and default state.
+ ///
+ [Browsable(false)]
+ public bool IsPulsing
+ {
+ get { return m_Button.IsPulsing; }
+ }
+
+ ///
+ /// Gets or sets whether pulse effect started with StartPulse method stops automatically when mouse moves over the button. Default value is true.
+ ///
+ [DefaultValue(true), Browsable(true), Category("Behavior"), Description("Indicates whether pulse effect started with Pulse method stops automatically when mouse moves over the button.")]
+ public bool StopPulseOnMouseOver
+ {
+ get { return m_Button.StopPulseOnMouseOver; }
+ set { m_Button.StopPulseOnMouseOver = value; }
+ }
+
+ ///
+ /// Gets or sets the pulse speed. The value must be greater than 0 and less than 128. Higher values indicate faster pulse. Default value is 12.
+ ///
+ [Browsable(true), DefaultValue(12), Category("Behavior"), Description("Indicates pulse speed. The value must be greater than 0 and less than 128.")]
+ public int PulseSpeed
+ {
+ get { return m_Button.PulseSpeed; }
+ set
+ {
+ m_Button.PulseSpeed = value;
+ }
+ }
+
+ protected override void OnEnabledChanged(EventArgs e)
+ {
+ if (!this.Enabled && this.IsPulsing) this.StopPulse();
+ base.OnEnabledChanged(e);
+ }
+
+ ///
+ /// Sets fixed size of the image. Image will be scaled and painted it size specified.
+ ///
+ [Browsable(true)]
+ public System.Drawing.Size ImageFixedSize
+ {
+ get { return m_Button.ImageFixedSize; }
+ set
+ {
+ m_Button.ImageFixedSize = value;
+ this.RecalcLayout();
+ }
+ }
+ ///
+ /// Gets whether ImageFixedSize property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeImageFixedSize()
+ {
+ return m_Button.ShouldSerializeImageFixedSize();
+ }
+
+ ///
+ /// Gets or sets the text alignment. Applies only when button text is not composed using text markup. Default value is center.
+ ///
+ [Browsable(true), DefaultValue(eButtonTextAlignment.Center), Category("Appearance"), Description("Indicates text alignment. Applies only when button text is not composed using text markup. Default value is center.")]
+ public eButtonTextAlignment TextAlignment
+ {
+ get { return m_TextAlignment; }
+ set
+ {
+ m_TextAlignment = value;
+ this.RecalcLayout();
+ }
+ }
+
+ private bool _CallBasePaintBackground = true;
+ ///
+ /// Gets or sets whether during painting OnPaintBackground on base control is called when BackColor=Transparent.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool CallBasePaintBackground
+ {
+ get { return _CallBasePaintBackground; }
+ set
+ {
+ _CallBasePaintBackground = value;
+ }
+ }
+
+ internal void InternalPaint(PaintEventArgs e)
+ {
+ OnPaint(e);
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if ((this.BackColor.IsEmpty || this.BackColor == Color.Transparent || this.BackgroundImage != null) && _CallBasePaintBackground)
+ {
+ base.OnPaintBackground(e);
+ }
+ else
+ {
+ DisplayHelp.FillRectangle(e.Graphics, this.ClientRectangle, this.BackColor, System.Drawing.Color.Empty);
+ }
+
+ Rectangle r = this.ClientRectangle;
+ Graphics g=e.Graphics;
+
+ ColorScheme cs = this.GetColorScheme();
+
+ if (!IsThemed)
+ {
+ if (BarFunctions.IsOffice2007Style(m_Button.EffectiveStyle))
+ {
+ //int cornerSize = this.CornerSize;
+ //SmoothingMode sm = g.SmoothingMode;
+ //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+ //DisplayHelp.FillRoundedRectangle(g, r, cornerSize, cs.BarBackground, cs.BarBackground2, cs.BarBackgroundGradientAngle);
+ //DisplayHelp.DrawRoundedRectangle(g, cs.BarDockedBorder, r, cornerSize);
+ //g.SmoothingMode = sm;
+ }
+ else
+ {
+ DisplayHelp.FillRectangle(g, r, cs.BarBackground, cs.BarBackground2, cs.BarBackgroundGradientAngle);
+ DisplayHelp.DrawRectangle(g, cs.BarDockedBorder, r);
+ }
+ }
+
+ SmoothingMode sm = g.SmoothingMode;
+ TextRenderingHint th = g.TextRenderingHint;
+
+ ItemPaintArgs pa = GetItemPaintArgs(g);
+
+ if (this.AntiAlias)
+ {
+ pa.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ pa.Graphics.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ IShapeDescriptor shape = GetButtonShape();
+ if (!(shape is RoundRectangleShapeDescriptor))
+ {
+ Rectangle rs = this.ClientRectangle;
+ rs.Y--;
+ rs.X--;
+ rs.Width++;
+ rs.Height++;
+ if (shape.CanDrawShape(rs))
+ {
+ using (GraphicsPath path = shape.GetShape(rs))
+ g.SetClip(path);
+ }
+ }
+
+ m_Button.Paint(pa);
+
+ g.SmoothingMode = sm;
+ g.TextRenderingHint = th;
+
+ base.OnPaint(e);
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ RecalcLayout();
+ base.OnResize(e);
+ }
+
+ protected override void OnTextChanged(EventArgs e)
+ {
+ m_Button.Text = this.Text;
+ UpdateButtonAutoSize();
+ base.OnTextChanged(e);
+ }
+
+ private void UpdateButtonAutoSize()
+ {
+ InvalidateAutoSize();
+#if FRAMEWORK20
+ this.AdjustSize();
+#endif
+ this.RecalcLayout();
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ base.OnFontChanged(e);
+ InvalidateAutoSize();
+ }
+
+ //protected override void OnForeColorChanged(EventArgs e)
+ //{
+ // if (this.ForeColor != SystemColors.ControlText)
+ // m_Button.ForeColor = this.ForeColor;
+ // else
+ // m_Button.ForeColor = Color.Empty;
+
+ // base.OnForeColorChanged(e);
+ //}
+
+ protected override void RecalcSize()
+ {
+ m_Button.Bounds = this.ClientRectangle;
+ m_Button.RecalcSize();
+ m_Button.Bounds = this.ClientRectangle;
+ }
+
+ private bool _IsSpaceKeyDown = false;
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ if(e.KeyCode == Keys.Space && !m_Button.Expanded)
+ {
+ if (m_Button.GetShouldAutoExpandOnClick())
+ m_Button.Expanded = true;
+ else
+ m_Button.SetMouseDown(true);
+ this.Invalidate();
+ }
+ _IsSpaceKeyDown = (e.KeyCode == Keys.Space);
+ base.OnKeyDown(e);
+ }
+
+ protected override void OnKeyUp(KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Space && _IsSpaceKeyDown && !m_Button.Expanded)
+ {
+ m_Button.SetMouseDown(false);
+ this.Invalidate();
+ PerformClick();
+ }
+ _IsSpaceKeyDown = false;
+ base.OnKeyUp(e);
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ m_Button.InternalMouseEnter();
+ base.OnMouseEnter(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ m_Button.InternalMouseMove(e);
+ base.OnMouseMove(e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ m_Button.InternalMouseLeave();
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseHover(EventArgs e)
+ {
+ m_Button.InternalMouseHover();
+ base.OnMouseHover(e);
+ }
+
+ private Point _MouseDownPoint = Point.Empty;
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ if (!this.Focused && this.CanSelect && _FocusOnLeftMouseButtonDown)
+ {
+ if (!this.Focus())
+ return;
+ }
+ _MouseDownPoint = new Point(e.X, e.Y);
+ }
+
+ m_Button.InternalMouseDown(e);
+ base.OnMouseDown(e);
+ }
+
+ private bool _FocusOnLeftMouseButtonDown = true;
+ ///
+ /// Gets or sets whether button is focused when pressed using left mouse button. Default value is true.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool FocusOnLeftMouseButtonDown
+ {
+ get { return _FocusOnLeftMouseButtonDown; }
+ set
+ {
+ _FocusOnLeftMouseButtonDown = value;
+ }
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ m_Button.InternalMouseUp(e);
+ if (e.Button == MouseButtons.Left && this.ClientRectangle.Contains(e.X, e.Y) && !_MouseDownPoint.IsEmpty)
+ {
+#if FRAMEWORK20
+ this.OnMouseClick(e);
+#endif
+ this.OnClick(e);
+ }
+ _MouseDownPoint = Point.Empty;
+ base.OnMouseUp(e);
+ }
+
+ protected override void OnVisibleChanged(EventArgs e)
+ {
+ if(m_Button.IsMouseOver)
+ m_Button.InternalMouseLeave();
+
+ base.OnVisibleChanged(e);
+ }
+
+ private bool IsImageSet
+ {
+ get
+ {
+ if (!string.IsNullOrEmpty(this.Symbol))
+ return true;
+ CompositeImage image = m_Button.GetImage();
+ bool imageSet = image != null;
+ if (image != null)
+ image.Dispose();
+ return imageSet;
+ }
+ }
+ protected override void OnClick(EventArgs e)
+ {
+ // Ignore Click event if it is fired when click occurred on sub items rectangle...
+ if (!m_Button.SubItemsRect.IsEmpty)
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ if (m_Button.SubItemsRect.Contains(p))
+ return;
+ }
+
+ if (this.SplitButton && !m_Button.TextDrawRect.IsEmpty && IsImageSet)
+ {
+ Point p = this.PointToClient(Control.MousePosition);
+ if (m_Button.TextDrawRect.Contains(p))
+ return;
+ }
+
+ Form form1 = this.FindForm();
+ if (form1 != null)
+ {
+ form1.DialogResult = this.DialogResult;
+ }
+
+ base.OnClick(e);
+
+ if(ExecuteCommandOnClick)
+ ExecuteCommand();
+ }
+
+ ///
+ /// Gets whether command is executed when button is clicked.
+ ///
+ protected virtual bool ExecuteCommandOnClick
+ {
+ get { return true; }
+ }
+
+ protected override void OnGotFocus(EventArgs e)
+ {
+ m_Button.OnGotFocus();
+ base.OnGotFocus(e);
+ }
+
+ protected override void OnLostFocus(EventArgs e)
+ {
+ m_Button.OnLostFocus();
+ base.OnLostFocus(e);
+ }
+
+ ///
+ /// Gets or sets the color of the Symbol.
+ ///
+ [Category("Appearance"), Description("Indicates color of the Symbol.")]
+ public Color SymbolColor
+ {
+ get { return m_Button.SymbolColor; }
+ set { m_Button.SymbolColor = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSymbolColor()
+ {
+ return m_Button.ShouldSerializeSymbolColor();
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSymbolColor()
+ {
+ m_Button.ResetSymbolColor();
+ }
+
+ ///
+ /// Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the image setting.
+ ///
+ [DefaultValue(""), Category("Appearance"), Description("Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the 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 m_Button.Symbol; }
+ set
+ {
+ m_Button.Symbol = value;
+ }
+ }
+ ///
+ /// Gets or sets the symbol set used to represent the Symbol.
+ ///
+ [Browsable(false), DefaultValue(eSymbolSet.Awesome)]
+ public eSymbolSet SymbolSet
+ {
+ get { return m_Button.SymbolSet; }
+ set { m_Button.SymbolSet = value; }
+ }
+ ///
+ /// Indicates the size of the symbol in points.
+ ///
+ [DefaultValue(0f), Category("Appearance"), Description("Indicates the size of the symbol in points.")]
+ public float SymbolSize
+ {
+ get { return m_Button.SymbolSize; }
+ set
+ {
+ m_Button.SymbolSize = value;
+ }
+ }
+
+ ///
+ /// Specifies the Button image which is used when button background is black or very dark. Image is used when button text is white. This is provided for Metro style applications.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("Specifies the Button image which is used when button background is black or very dark. Image is used when button text is white. This is provided for Metro style applications."), DefaultValue(null)]
+ public System.Drawing.Image ImageAlt
+ {
+ get { return m_Button.ImageAlt; }
+ set
+ {
+ m_Button.ImageAlt = value;
+ }
+ }
+ ///
+ /// Specifies the Button image.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("The image that will be displayed on the face of the button."), DefaultValue(null)]
+ public System.Drawing.Image Image
+ {
+ get { return m_Button.Image; }
+ set
+ {
+ m_Button.Image = value;
+ InvalidateAutoSize();
+#if FRAMEWORK20
+ this.AdjustSize();
+#endif
+ }
+ }
+
+ ///
+ /// Specifies the image for the button when mouse is over the item.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("The image that will be displayed when mouse hovers over the item."), DefaultValue(null)]
+ public System.Drawing.Image HoverImage
+ {
+ get { return m_Button.HoverImage; }
+ set { m_Button.HoverImage = value; }
+ }
+
+ ///
+ /// Specifies the image for the button when items Enabled property is set to false.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("The image that will be displayed when item is disabled."),DefaultValue(null)]
+ public System.Drawing.Image DisabledImage
+ {
+ get { return m_Button.DisabledImage; }
+ set { m_Button.DisabledImage = value; }
+ }
+
+ ///
+ /// Specifies the image for the button when mouse left button is pressed.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("The image that will be displayed when item is pressed."), DefaultValue(null)]
+ public System.Drawing.Image PressedImage
+ {
+ get { return m_Button.PressedImage; }
+ set { m_Button.PressedImage = value; }
+ }
+
+ ///
+ /// Gets or sets the location of popup in relation to it's parent.
+ ///
+ [Browsable(true), DevCoBrowsable(false), DefaultValue(ePopupSide.Default), Description("Indicates location of popup in relation to it's parent.")]
+ public ePopupSide PopupSide
+ {
+ get { return m_Button.PopupSide; }
+ set { m_Button.PopupSide = value; InvalidateAutoSize(); }
+ }
+
+ ///
+ /// Returns the collection of sub items.
+ ///
+ [Browsable(true), DevCoBrowsable(false), Editor("DevComponents.DotNetBar.Design.ButtonItemEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Category("Data"), Description("Collection of sub items."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public virtual SubItemsCollection SubItems
+ {
+ get
+ {
+ return m_Button.SubItems;
+ }
+ }
+
+ ///
+ /// Gets or sets whether button appears as split button. Split button appearance divides button into two parts. Image which raises the click event
+ /// when clicked and text and expand sign which shows button sub items on popup menu when clicked. Button must have both text and image visible (ButtonStyle property) in order to appear as a full split button.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance"), Description("Indicates whether button appears as split button.")]
+ public bool SplitButton
+ {
+ get { return m_Button.SplitButton; }
+ set { m_Button.SplitButton = value; InvalidateAutoSize(); }
+ }
+
+ ///
+ /// Gets or sets whether button displays the expand part that indicates that button has popup.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.DefaultValue(true), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Determines whether sub-items are displayed.")]
+ public bool ShowSubItems
+ {
+ get
+ {
+ return m_Button.ShowSubItems;
+ }
+ set
+ {
+ m_Button.ShowSubItems = value;
+ }
+ }
+
+ ///
+ /// Gets/Sets the image position inside the button.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("The alignment of the image in relation to text displayed by this item."), DefaultValue(eImagePosition.Left)]
+ public eImagePosition ImagePosition
+ {
+ get { return m_Button.ImagePosition; }
+ set
+ {
+ m_Button.ImagePosition = value;
+ InvalidateAutoSize();
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets whether mouse over fade effect is enabled. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether mouse over fade effect is enabled")]
+ public bool FadeEffect
+ {
+ get { return m_FadeEffect; }
+ set
+ {
+ m_FadeEffect = value;
+ }
+ }
+
+ internal bool IsFadeEnabled
+ {
+ get
+ {
+ if (this.DesignMode || (!BarFunctions.IsOffice2007Style(m_Button.EffectiveStyle)) ||
+ m_FadeEffect && NativeFunctions.IsTerminalSession() || IsThemed || TextDrawing.UseTextRenderer)
+ return false;
+ return m_FadeEffect;
+ }
+ }
+
+ ///
+ /// Indicates the way button is rendering the mouse over state. Setting the value to Color will render the image in gray-scale when mouse is not over the item.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Indicates the button mouse over tracking style. Setting the value to Color will render the image in gray-scale when mouse is not over the item."), System.ComponentModel.DefaultValue(eHotTrackingStyle.Default)]
+ public virtual eHotTrackingStyle HotTrackingStyle
+ {
+ get { return m_Button.HotTrackingStyle; }
+ set
+ {
+ m_Button.HotTrackingStyle = value;
+ }
+ }
+
+ internal override ItemPaintArgs GetItemPaintArgs(Graphics g)
+ {
+ ItemPaintArgs pa = base.GetItemPaintArgs(g);
+ pa.IsDefaultButton = m_IsDefault && _FocusCuesEnabled;
+
+ return pa;
+ }
+
+ ///
+ /// Gets or sets the width of the expand part of the button item.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Behavior"), Description("Indicates the width of the expand part of the button item."), DefaultValue(12)]
+ public virtual int SubItemsExpandWidth
+ {
+ get { return m_Button.SubItemsExpandWidth; }
+ set
+ {
+ m_Button.SubItemsExpandWidth = value;
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets the text associated with this button.
+ ///
+ [Browsable(true), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Category("Appearance"), Description("Indicates text associated with this button.."), Localizable(true), DefaultValue("")]
+ public override string Text
+ {
+ get { return base.Text; }
+ set { base.Text = value; }
+ }
+
+ ///
+ /// Gets/Sets informational text (tooltip) for the button.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(""), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Category("Appearance"), Description("Indicates informational text (tooltip) for the button."), Localizable(true)]
+ public virtual string Tooltip
+ {
+ get { return m_Button.Tooltip; }
+ set { m_Button.Tooltip = value; }
+ }
+
+ private bool _EnableMnemonicWithAltKeyOnly = false;
+ ///
+ /// Gets or sets whether mnemonic character assigned to button is processed only if Alt key is pressed. Default value is false which indicate that Alt key is not required.
+ ///
+ [DefaultValue(false), Category("Behavior"), Description("Indicates whether mnemonic character assigned to button is processed only if Alt key is pressed")]
+ public bool EnableMnemonicWithAltKeyOnly
+ {
+ get { return _EnableMnemonicWithAltKeyOnly; }
+ set
+ {
+ _EnableMnemonicWithAltKeyOnly = value;
+ }
+ }
+
+ private bool _UseMnemonic = true;
+ ///
+ /// Gets or sets a value indicating whether the control interprets an ampersand character (&) in the control's Text property to be an access key prefix character.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether the control interprets an ampersand character (&) in the control's Text property to be an access key prefix character.")]
+ public bool UseMnemonic
+ {
+ get { return _UseMnemonic; }
+ set
+ {
+ _UseMnemonic = value;
+ if (this.IsHandleCreated)
+ UpdateButtonAutoSize();
+ }
+ }
+
+ protected override bool ProcessMnemonic(char charCode)
+ {
+ if (CanSelect && IsMnemonic(charCode, this.Text) && this.Enabled && _UseMnemonic &&
+ (!_EnableMnemonicWithAltKeyOnly || Control.ModifierKeys == Keys.Alt || this.Focused) && !m_Button.IsUsingTextMarkup)
+ {
+ if (Focus())
+ {
+ PerformClick();
+ return true;
+ }
+ }
+ return base.ProcessMnemonic(charCode);
+ }
+
+ ///
+ /// Indicates whether the button will auto-expand when clicked.
+ /// When button contains sub-items, sub-items will be shown only if user
+ /// click the expand part of the button. Setting this property to true will expand the button and show sub-items when user
+ /// clicks anywhere inside of the button. Default value is false which indicates that button is expanded only
+ /// if its expand part is clicked.
+ ///
+ [DefaultValue(false), Browsable(true), DevCoBrowsable(true), Category("Behavior"), Description("Indicates whether the button will auto-expand (display pop-up menu or toolbar) when clicked.")]
+ public virtual bool AutoExpandOnClick
+ {
+ get { return (InternalAutoExpandOnClick); }
+ set { InternalAutoExpandOnClick = value; }
+ }
+
+ protected bool InternalAutoExpandOnClick
+ {
+ get { return m_Button.AutoExpandOnClick; }
+ set
+ {
+ m_Button.AutoExpandOnClick = value;
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets whether Checked property is automatically inverted, button checked/unchecked, when button is clicked. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Behavior"), Description("Indicates whether Checked property is automatically inverted when button is clicked.")]
+ public bool AutoCheckOnClick
+ {
+ get { return m_Button.AutoCheckOnClick; }
+ set { m_Button.AutoCheckOnClick = value; }
+ }
+
+ ///
+ /// Gets or set a value indicating whether the button is in the checked state.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("Indicates whether item is checked or not."), DefaultValue(false)]
+ public virtual bool Checked
+ {
+ get
+ {
+ return m_Button.Checked;
+ }
+ set
+ {
+ m_Button.Checked = value;
+ this.Invalidate();
+ }
+ }
+
+ private static RoundRectangleShapeDescriptor _DefaultButtonShape = new RoundRectangleShapeDescriptor(2);
+ private static RoundRectangleShapeDescriptor _DefaultMetroButtonShape = new RoundRectangleShapeDescriptor(0);
+ internal IShapeDescriptor GetButtonShape()
+ {
+ if (this.Shape != null)
+ return this.Shape;
+ if (StyleManager.IsMetro(m_Button.EffectiveStyle))
+ return _DefaultMetroButtonShape;
+ return _DefaultButtonShape;
+ }
+
+ private ShapeDescriptor _Shape = null;
+ ///
+ /// Gets or sets an shape descriptor for the button which describes the shape of the button. Default value is null
+ /// which indicates that system default shape is used.
+ ///
+ [DefaultValue(null), Editor("DevComponents.DotNetBar.Design.ShapeTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(UITypeEditor)), TypeConverter("DevComponents.DotNetBar.Design.ShapeStringConverter, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), MergableProperty(false)]
+ public ShapeDescriptor Shape
+ {
+ get { return _Shape; }
+ set
+ {
+ if (_Shape != value)
+ {
+ _Shape = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ private bool _FocusCuesEnabled = true;
+ ///
+ /// Gets or sets whether control displays focus cues when focused.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether control displays focus cues when focused.")]
+ public virtual bool FocusCuesEnabled
+ {
+ get { return (InternalFocusCuesEnabled); }
+ set { InternalFocusCuesEnabled = value; }
+ }
+
+ protected bool InternalFocusCuesEnabled
+ {
+ get { return _FocusCuesEnabled; }
+ set
+ {
+ _FocusCuesEnabled = value;
+ if (this.Focused) this.Invalidate();
+ }
+ }
+
+ internal int CornerSize
+ {
+ get { return 2; }
+ }
+
+ ///
+ /// Gets or sets the custom color name. Name specified here must be represented by the corresponding object with the same name that is part
+ /// of the Office2007ColorTable.ButtonItemColors collection. See documentation for Office2007ColorTable.ButtonItemColors for more information.
+ /// If color table with specified name cannot be found default color will be used. Valid settings for this property override any
+ /// setting to the Color property.
+ /// Applies to items with Office 2007 style only.
+ ///
+ [Browsable(true), DevCoBrowsable(false), DefaultValue(""), Category("Appearance"), Description("Indicates custom color table name for the button when Office 2007 style is used.")]
+ public string CustomColorName
+ {
+ get { return m_Button.CustomColorName; }
+ set
+ {
+ m_Button.CustomColorName = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets the predefined color of the button. Color specified applies to buttons with Office 2007 style only. It does not have
+ /// any effect on other styles. Default value is eButtonColor.Default
+ ///
+ [Browsable(true), DevCoBrowsable(false), DefaultValue(eButtonColor.BlueWithBackground), Category("Appearance"), Description("Indicates predefined color of button when Office 2007 style is used.")]
+ public eButtonColor ColorTable
+ {
+ get { return m_Button.ColorTable; }
+ set
+ {
+ if (m_Button.ColorTable != value)
+ {
+ m_Button.ColorTable = value;
+ this.Invalidate();
+ }
+ }
+ }
+ protected override void InvalidateAutoSize()
+ {
+ m_PreferredSize = Size.Empty;
+ }
+
+#if FRAMEWORK20
+ //[Localizable(true), Browsable(false)]
+ //public new System.Windows.Forms.Padding Padding
+ //{
+ // get { return base.Padding; }
+ // set { base.Padding = value; }
+ //}
+
+ public override Size GetPreferredSize(Size proposedSize)
+ {
+ if (!m_PreferredSize.IsEmpty) return m_PreferredSize;
+
+ if (!BarFunctions.IsHandleValid(this))
+ return base.GetPreferredSize(proposedSize);
+ if (this.Text.Length == 0 && this.Image == null)
+ return base.GetPreferredSize(proposedSize);
+
+ int oldWidth = m_Button.WidthInternal, oldHeight = m_Button.HeightInternal;
+
+ m_Button._FitContainer = false;
+ m_Button.RecalcSize();
+
+ Size s = m_Button.Size;
+ if (s.Width < this.MinimumSize.Width)
+ s.Width = this.MinimumSize.Width;
+ if (s.Height < this.MinimumSize.Height)
+ s.Height = this.MinimumSize.Height;
+
+ if (m_AutoSizeMode == AutoSizeMode.GrowOnly)
+ {
+ if (s.Width < this.Size.Width)
+ s.Width = this.Size.Width;
+ if (s.Height < this.Size.Height)
+ s.Height = this.Size.Height;
+
+ if (proposedSize.Width > 0 && proposedSize.Width < 50000 && s.Width < proposedSize.Width)
+ s.Width = proposedSize.Width;
+ if (proposedSize.Height > 0 && proposedSize.Height < 50000 && s.Height < proposedSize.Height)
+ s.Height = proposedSize.Height;
+
+ }
+ m_Button._FitContainer = true;
+ RecalcSize();
+ m_PreferredSize = s;
+ return m_PreferredSize;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the control is automatically resized to display its entire contents. You can set MaximumSize.Width property to set the maximum width used by the control.
+ ///
+ [Browsable(true), DefaultValue(false), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public override bool AutoSize
+ {
+ get
+ {
+ return base.AutoSize;
+ }
+ set
+ {
+ if (this.AutoSize != value)
+ {
+ base.AutoSize = value;
+ InvalidateAutoSize();
+ AdjustSize();
+ }
+ }
+ }
+
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ if (this.AutoSize)
+ {
+ Size preferredSize = base.PreferredSize;
+ if(preferredSize.Width>0)
+ width = preferredSize.Width;
+ if (preferredSize.Height > 0)
+ height = preferredSize.Height;
+ }
+ base.SetBoundsCore(x, y, width, height, specified);
+ }
+
+ protected override void AdjustSize()
+ {
+ if (this.AutoSize)
+ {
+ System.Drawing.Size prefSize = base.PreferredSize;
+ if(prefSize.Width>0 && prefSize.Height>0)
+ this.Size = base.PreferredSize;
+ }
+ }
+
+ private AutoSizeMode m_AutoSizeMode = AutoSizeMode.GrowOnly;
+ ///
+ /// Gets or sets the mode by which the Button automatically resizes itself.
+ ///
+ [LocalizableAttribute(true), Browsable(true), DefaultValue(AutoSizeMode.GrowOnly), Category("Layout"), Description("Indicates the mode by which the Button automatically resizes itself. ")]
+ public AutoSizeMode AutoSizeMode
+ {
+ get { return m_AutoSizeMode; }
+ set
+ {
+ if (m_AutoSizeMode != value)
+ {
+ m_AutoSizeMode = value;
+ InvalidateAutoSize();
+ AdjustSize();
+ }
+ }
+ }
+
+ //[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ //public override Image BackgroundImage
+ //{
+ // get { return base.BackgroundImage; }
+ // set { base.BackgroundImage = value; }
+ //}
+ //[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ //public override ImageLayout BackgroundImageLayout
+ //{
+ // get
+ // {
+ // return base.BackgroundImageLayout;
+ // }
+ // set
+ // {
+ // base.BackgroundImageLayout = value;
+ // }
+ //}
+#endif
+ private int _ImageTextSpacing = 0;
+ ///
+ /// Gets or sets the amount of spacing between button image if specified and text.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout"), Description("Indicates amount of spacing between button image if specified and text.")]
+ public virtual int ImageTextSpacing
+ {
+ get { return _ImageTextSpacing; }
+ set
+ {
+ _ImageTextSpacing = value;
+ RecalcLayout();
+ }
+ }
+
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override Color ForeColor
+ {
+ get
+ {
+ return base.ForeColor;
+ }
+ set
+ {
+ base.ForeColor = value;
+ }
+ }
+
+ private static readonly Color DefaultTextColor = Color.Empty;
+ private Color _TextColor = DefaultTextColor;
+ ///
+ /// Gets or sets the text color.
+ ///
+ [Category("Appearance"), Description("Indicates text color.")]
+ public Color TextColor
+ {
+ get { return _TextColor; }
+ set
+ {
+ _TextColor = value;
+ m_Button.ForeColor = value;
+ }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTextColor()
+ {
+ return _TextColor != DefaultTextColor;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTextColor()
+ {
+ this.TextColor = DefaultTextColor;
+ }
+ #endregion
+
+ #region IButtonControl Members
+ ///
+ /// Gets or sets the value returned to the parent form when the button is clicked.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(DialogResult.None), Description("Gets or sets the value returned to the parent form when the button is clicked.")]
+ public DialogResult DialogResult
+ {
+ get
+ {
+ return m_DialogResult;
+ }
+
+ set
+ {
+ if (Enum.IsDefined(typeof(DialogResult), value))
+ {
+ m_DialogResult = value;
+ }
+ }
+ }
+
+ ///
+ /// Notifies a control that it is the default button so that its appearance and behavior is adjusted accordingly.
+ ///
+ /// true if the control should behave as a default button; otherwise false.
+ public void NotifyDefault(bool value)
+ {
+ if (m_IsDefault != value)
+ {
+ m_IsDefault = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Generates a Click event for the control.
+ ///
+ public override void PerformClick()
+ {
+ if (!this.Enabled) return;
+
+ Form form1 = this.FindForm();
+ if (form1 != null)
+ {
+ form1.DialogResult = this.DialogResult;
+ }
+ if (this.AutoCheckOnClick) this.Checked = !this.Checked;
+
+ if (ExecuteCommandOnClick)
+ ExecuteCommand();
+
+ // Must call base since this class overrides OnClick to prevent it from firing when sub-items rect is clicked
+ base.OnClick(EventArgs.Empty);
+ }
+ #endregion
+
+ #region IOwner
+
+ ///
+ /// Gets or sets a value indicating whether the button is expanded (displays drop-down) or not.
+ ///
+ [Browsable(false), DefaultValue(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual bool Expanded
+ {
+ get { return m_Button.Expanded; }
+ set { m_Button.Expanded = value; }
+ }
+
+ ///
+ /// Gets or sets the collection of shortcut keys associated with the button. When shortcut key is pressed button Click event is raised.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Design"), Description("Indicates list of shortcut keys for this button."), Editor("DevComponents.DotNetBar.Design.ShortcutsDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.TypeConverter("DevComponents.DotNetBar.Design.ShortcutsConverter, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public virtual ShortcutsCollection Shortcuts
+ {
+ get { return m_Button.Shortcuts; }
+ set { m_Button.Shortcuts = value; }
+ }
+
+ ///
+ /// Displays the sub-items on popup specified by PopupType.
+ ///
+ /// Popup location.
+ public virtual void Popup(Point p)
+ {
+ m_Button.Popup(p);
+ }
+
+ ///
+ /// Displays the sub-items on popup specified by PopupType.
+ ///
+ /// Horizontal coordinate in pixels of the upper left corner of a popup.
+ /// Vertical coordinate in pixels of the upper left corner of a popup.
+ public virtual void Popup(int x, int y)
+ {
+ m_Button.Popup(x, y);
+ }
+ #endregion
+
+ #region ICommandSource Members
+ protected virtual void ExecuteCommand()
+ {
+ if (_Command == null) return;
+ CommandManager.ExecuteCommand(this);
+ }
+
+ ///
+ /// Gets or sets the command assigned to the item. Default value is null.
+ /// Note that if this property is set to null Enabled property will be set to false automatically to disable the item.
+ ///
+ [DefaultValue(null), Category("Commands"), Description("Indicates the command assigned to the item.")]
+ public Command Command
+ {
+ get { return (Command)((ICommandSource)this).Command; }
+ set
+ {
+ ((ICommandSource)this).Command = value;
+ }
+ }
+
+ private ICommand _Command = null;
+ //[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ ICommand ICommandSource.Command
+ {
+ get
+ {
+ return _Command;
+ }
+ set
+ {
+ bool changed = false;
+ if (_Command != value)
+ changed = true;
+
+ if (_Command != null)
+ CommandManager.UnRegisterCommandSource(this, _Command);
+ _Command = value;
+ if (value != null)
+ CommandManager.RegisterCommand(this, value);
+ if(changed)
+ OnCommandChanged();
+ }
+ }
+
+ ///
+ /// Called when Command property value changes.
+ ///
+ protected virtual void OnCommandChanged()
+ {
+ }
+
+ private object _CommandParameter = null;
+ ///
+ /// Gets or sets user defined data value that can be passed to the command when it is executed.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Commands"), Description("Indicates user defined data value that can be passed to the command when it is executed."), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)), System.ComponentModel.Localizable(true)]
+ public object CommandParameter
+ {
+ get
+ {
+ return _CommandParameter;
+ }
+ set
+ {
+ _CommandParameter = value;
+ }
+ }
+
+ #endregion
+ }
+
+ #region ButtonXAccessibleObject
+ ///
+ /// Represents class for Accessibility support.
+ ///
+ public class ButtonXAccessibleObject : Control.ControlAccessibleObject
+ {
+ private ButtonX m_Owner = null;
+ ///
+ /// Creates new instance of the object and initializes it with owner control.
+ ///
+ /// Reference to owner control.
+ public ButtonXAccessibleObject(ButtonX owner)
+ : base(owner)
+ {
+ m_Owner = owner;
+ }
+
+ protected ButtonX Owner
+ {
+ get { return m_Owner; }
+ }
+
+ /////
+ ///// Gets or sets accessible name.
+ /////
+ //public override string Name
+ //{
+ // get
+ // {
+ // if (m_Owner != null && !m_Owner.IsDisposed && !string.IsNullOrEmpty(m_Owner.AccessibleName))
+ // return m_Owner.AccessibleName;
+ // if (m_Owner != null) return TextWithoutMnemonics(m_Owner.Text);
+ // return "";
+ // }
+ // set
+ // {
+ // if (m_Owner != null && !m_Owner.IsDisposed)
+ // m_Owner.AccessibleName = value;
+ // }
+ //}
+
+ //internal static string TextWithoutMnemonics(string text)
+ //{
+ // if (text == null)
+ // {
+ // return null;
+ // }
+ // int index = text.IndexOf('&');
+ // if (index == -1)
+ // {
+ // return text;
+ // }
+ // StringBuilder builder = new StringBuilder(text.Substring(0, index));
+ // while (index < text.Length)
+ // {
+ // if (text[index] == '&')
+ // {
+ // index++;
+ // }
+ // if (index < text.Length)
+ // {
+ // builder.Append(text[index]);
+ // }
+ // index++;
+ // }
+ // return builder.ToString();
+ //}
+
+ /////
+ ///// Gets accessible description.
+ /////
+ //public override string Description
+ //{
+ // get
+ // {
+ // if (m_Owner != null && !m_Owner.IsDisposed)
+ // return m_Owner.AccessibleDescription;
+ // return "";
+ // }
+ //}
+
+ /////
+ ///// Gets accessible role.
+ /////
+ //public override AccessibleRole Role
+ //{
+ // get
+ // {
+ // if (m_Owner != null && !m_Owner.IsDisposed)
+ // return m_Owner.AccessibleRole;
+ // return System.Windows.Forms.AccessibleRole.None;
+ // }
+ //}
+
+ /////
+ ///// Gets parent accessibility object.
+ /////
+ //public override AccessibleObject Parent
+ //{
+ // get
+ // {
+ // if (m_Owner != null && !m_Owner.IsDisposed)
+ // return m_Owner.Parent.AccessibilityObject;
+ // return null;
+ // }
+ //}
+
+ /////
+ ///// Returns bounds of the control.
+ /////
+ //public override Rectangle Bounds
+ //{
+ // get
+ // {
+ // if (m_Owner != null && !m_Owner.IsDisposed && m_Owner.Parent != null)
+ // return this.m_Owner.Parent.RectangleToScreen(m_Owner.Bounds);
+ // return Rectangle.Empty;
+ // }
+ //}
+
+ ///
+ /// Returns number of child objects.
+ ///
+ /// Total number of child objects.
+ public override int GetChildCount()
+ {
+ if (m_Owner != null && !m_Owner.IsDisposed)
+ return m_Owner.InternalItem.AccessibleObject.GetChildCount();
+ return 0;
+ }
+
+ ///
+ /// Returns reference to child object given the index.
+ ///
+ /// 0 based index of child object.
+ /// Reference to child object.
+ public override System.Windows.Forms.AccessibleObject GetChild(int iIndex)
+ {
+ if (m_Owner != null && !m_Owner.IsDisposed)
+ return m_Owner.InternalItem.AccessibleObject.GetChild(iIndex); //return m_Owner.SubItems[iIndex].AccessibleObject;
+ return null;
+ }
+
+ ///
+ /// Returns current accessible state.
+ ///
+ public override AccessibleStates State
+ {
+ get
+ {
+ AccessibleStates state=m_Owner.InternalItem.AccessibleObject.State;
+ if(m_Owner.Focused)
+ state|= AccessibleStates.Focused;
+ return state;
+ }
+ }
+
+ /////
+ ///// Gets or sets the value of an accessible object.
+ /////
+ //public override string Value
+ //{
+ // get
+ // {
+ // return m_Owner.Text;
+ // }
+ // set
+ // {
+ // m_Owner.Text = value;
+ // }
+ //}
+
+ public override void DoDefaultAction()
+ {
+ if (m_Owner != null)
+ m_Owner.PerformClick();
+ }
+
+ public override string DefaultAction
+ {
+ get
+ {
+ if (m_Owner != null && m_Owner.AccessibleDefaultActionDescription != "")
+ return m_Owner.AccessibleDefaultActionDescription;
+
+ return "Click";
+ }
+ }
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/ButtonX/ButtonX.ico b/PROMS/DotNetBar Source Code/ButtonX/ButtonX.ico
new file mode 100644
index 00000000..66d1a417
Binary files /dev/null and b/PROMS/DotNetBar Source Code/ButtonX/ButtonX.ico differ
diff --git a/PROMS/DotNetBar Source Code/ButtonX/ThemedButtonXPainter.cs b/PROMS/DotNetBar Source Code/ButtonX/ThemedButtonXPainter.cs
new file mode 100644
index 00000000..93c76cd2
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ButtonX/ThemedButtonXPainter.cs
@@ -0,0 +1,191 @@
+using System;
+using System.Drawing;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for ThemedButtonItemPainter.
+ ///
+ internal class ThemedButtonXPainter
+ {
+ public static void PaintButton(ButtonItem button, ItemPaintArgs pa)
+ {
+ System.Drawing.Graphics g = pa.Graphics;
+ ThemeButton theme = pa.ThemeButton;
+ ThemeButtonParts part = ThemeButtonParts.PushButton;
+ ThemeButtonStates state = ThemeButtonStates.PushButtonNormal;
+ Color textColor = ButtonItemPainterHelper.GetTextColor(button, pa);
+ ButtonX buttonX = pa.ContainerControl as ButtonX;
+ bool paintFocusCues = true;
+ if (buttonX != null) paintFocusCues = buttonX.FocusCuesEnabled;
+ Rectangle rectImage = Rectangle.Empty;
+ Rectangle itemRect = button.DisplayRectangle;
+
+ Font font = null;
+ CompositeImage image = button.GetImage();
+
+ eTextFormat format = GetStringFormat(button, pa, image);
+
+ font = button.GetFont(pa, false);
+
+ bool bSplitButton = (button.SubItems.Count > 0 || button.PopupType == ePopupType.Container) && button.ShowSubItems && !button.SubItemsRect.IsEmpty;
+
+ // Calculate image position
+ if (image != null)
+ {
+ if (button.ImagePosition == eImagePosition.Top || button.ImagePosition == eImagePosition.Bottom)
+ rectImage = new Rectangle(button.ImageDrawRect.X, button.ImageDrawRect.Y, itemRect.Width, button.ImageDrawRect.Height);
+ else
+ rectImage = new Rectangle(button.ImageDrawRect.X, button.ImageDrawRect.Y, button.ImageDrawRect.Width, button.ImageDrawRect.Height);
+
+ rectImage.Offset(itemRect.Left, itemRect.Top);
+ rectImage.Offset((rectImage.Width - button.ImageSize.Width) / 2, (rectImage.Height - button.ImageSize.Height) / 2);
+ rectImage.Width = button.ImageSize.Width;
+ rectImage.Height = button.ImageSize.Height;
+ }
+
+ // Set the state and text brush
+ if (!ButtonItemPainter.IsItemEnabled(button, pa))
+ {
+ state = ThemeButtonStates.PushButtonDisabled;
+ }
+ else if (button.IsMouseDown || button.Expanded)
+ {
+ state = ThemeButtonStates.PushButtonPressed;
+ }
+ else if (button.IsMouseOver && button.Checked)
+ {
+ state = ThemeButtonStates.PushButtonPressed;
+ }
+ else if (button.IsMouseOver)
+ {
+ state = ThemeButtonStates.PushButtonHot;
+ }
+ else if (button.Checked || button.Expanded)
+ {
+ state = ThemeButtonStates.PushButtonPressed;
+ }
+ else if (button.Focused || pa.ContainerControl.Focused)
+ state = ThemeButtonStates.PushButtonDefaulted;
+
+ Rectangle backRect = button.DisplayRectangle;
+ if (button.HotTrackingStyle == eHotTrackingStyle.Image && image != null)
+ {
+ backRect = rectImage;
+ backRect.Inflate(3, 3);
+ }
+ //else if (bSplitButton)
+ //{
+ // backRect.Width = backRect.Width - button.SubItemsRect.Width;
+ //}
+
+ // Draw Button Background
+ if (button.HotTrackingStyle != eHotTrackingStyle.None)
+ {
+ theme.DrawBackground(g, part, state, backRect);
+ }
+
+ // Draw Image
+ if (image != null && button.ButtonStyle != eButtonStyle.TextOnlyAlways)
+ {
+ if (state == ThemeButtonStates.PushButtonNormal && button.HotTrackingStyle == eHotTrackingStyle.Color)
+ {
+ // Draw gray-scale image for this hover style...
+ float[][] array = new float[5][];
+ array[0] = new float[5] { 0.2125f, 0.2125f, 0.2125f, 0, 0 };
+ array[1] = new float[5] { 0.5f, 0.5f, 0.5f, 0, 0 };
+ array[2] = new float[5] { 0.0361f, 0.0361f, 0.0361f, 0, 0 };
+ array[3] = new float[5] { 0, 0, 0, 1, 0 };
+ array[4] = new float[5] { 0.2f, 0.2f, 0.2f, 0, 1 };
+ System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array);
+ System.Drawing.Imaging.ImageAttributes att = new System.Drawing.Imaging.ImageAttributes();
+ att.SetColorMatrix(grayMatrix);
+ //g.DrawImage(image,rectImage,0,0,image.Width,image.Height,GraphicsUnit.Pixel,att);
+ image.DrawImage(g, rectImage, 0, 0, image.ActualWidth, image.ActualHeight, GraphicsUnit.Pixel, att);
+ }
+ else if (state == ThemeButtonStates.PushButtonNormal && !image.IsIcon)
+ {
+ // Draw image little bit lighter, I decied to use gamma it is easy
+ System.Drawing.Imaging.ImageAttributes lightImageAttr = new System.Drawing.Imaging.ImageAttributes();
+ lightImageAttr.SetGamma(.7f, System.Drawing.Imaging.ColorAdjustType.Bitmap);
+ //g.DrawImage(image,rectImage,0,0,image.Width,image.Height,GraphicsUnit.Pixel,lightImageAttr);
+ image.DrawImage(g, rectImage, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, lightImageAttr);
+ }
+ else
+ {
+ image.DrawImage(g, rectImage);
+ }
+ }
+
+ // Draw Text
+ if (button.ButtonStyle == eButtonStyle.ImageAndText || button.ButtonStyle == eButtonStyle.TextOnlyAlways || image == null)
+ {
+ Rectangle rectText = button.TextDrawRect;
+ if (button.ImagePosition == eImagePosition.Top || button.ImagePosition == eImagePosition.Bottom)
+ {
+ if (button.Orientation == eOrientation.Vertical)
+ {
+ rectText = new Rectangle(button.TextDrawRect.X, button.TextDrawRect.Y, button.TextDrawRect.Width, button.TextDrawRect.Height);
+ }
+ else
+ {
+ rectText = new Rectangle(button.TextDrawRect.X, button.TextDrawRect.Y, button.TextDrawRect.Width, button.TextDrawRect.Height);
+ //if ((button.SubItems.Count > 0 || button.PopupType == ePopupType.Container) && button.ShowSubItems)
+ // rectText.Width -= 10;
+ }
+ format |= eTextFormat.HorizontalCenter;
+ }
+
+ rectText.Offset(itemRect.Left, itemRect.Top);
+
+ if (button.Orientation == eOrientation.Vertical)
+ {
+ g.RotateTransform(90);
+ TextDrawing.DrawStringLegacy(g, ButtonItemPainter.GetDrawText(button.Text), font, textColor, new Rectangle(rectText.Top, -rectText.Right, rectText.Height, rectText.Width), format);
+ g.ResetTransform();
+ }
+ else
+ {
+ if (rectText.Right > button.DisplayRectangle.Right)
+ rectText.Width = button.DisplayRectangle.Right - rectText.Left;
+ TextDrawing.DrawString(g, ButtonItemPainter.GetDrawText(button.Text), font, textColor, rectText, format);
+ if (!button.DesignMode && button.Focused && paintFocusCues && !pa.IsOnMenu && !pa.IsOnMenuBar)
+ {
+ Rectangle r = button.Bounds;
+ r.Inflate(-3, -3);
+ System.Windows.Forms.ControlPaint.DrawFocusRectangle(g, r);
+ }
+ }
+ }
+
+ // If it has subitems draw the triangle to indicate that
+ if (bSplitButton)
+ {
+ ButtonItemPainter.PaintButtonExpandIndicator(button, pa);
+ }
+
+ if (image != null)
+ image.Dispose();
+ }
+
+ private static eTextFormat GetStringFormat(ButtonItem button, ItemPaintArgs pa, CompositeImage image)
+ {
+ eTextFormat stringFormat = pa.ButtonStringFormat;
+ bool isOnMenu = IsOnMenu(button, pa);
+ if (!isOnMenu)
+ {
+ if (image == null || button.ImagePosition == eImagePosition.Top || button.ImagePosition == eImagePosition.Bottom)
+ stringFormat |= eTextFormat.HorizontalCenter;
+ }
+ return stringFormat;
+ }
+
+ private static bool IsOnMenu(ButtonItem button, ItemPaintArgs pa)
+ {
+ bool isOnMenu = pa.IsOnMenu;
+ if (isOnMenu && button.Parent is ItemContainer)
+ isOnMenu = false;
+ return isOnMenu;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Calculator.ico b/PROMS/DotNetBar Source Code/Calculator.ico
new file mode 100644
index 00000000..af20d9d6
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Calculator.ico differ
diff --git a/PROMS/DotNetBar Source Code/CheckBoxItem/CheckBoxItem.cs b/PROMS/DotNetBar Source Code/CheckBoxItem/CheckBoxItem.cs
new file mode 100644
index 00000000..8c3516fe
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CheckBoxItem/CheckBoxItem.cs
@@ -0,0 +1,812 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Controls;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the Check-box item. Use a CheckBox to give the user an option, such as true/false or yes/no.
+ ///
+ [ToolboxItem(false), DesignTimeVisible(false), DefaultEvent("Click"), Designer("DevComponents.DotNetBar.Design.CheckBoxItemDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class CheckBoxItem : BaseItem
+ {
+ #region Private Variables
+ private bool m_Checked = false;
+ private eCheckBoxStyle m_CheckBoxStyle = eCheckBoxStyle.CheckBox;
+ private Size m_CheckSignSize = new Size(13, 13);
+ private eCheckBoxPosition m_CheckBoxPosition = eCheckBoxPosition.Left;
+ private int m_CheckTextSpacing = 6;
+ private int m_VerticalPadding = 3;
+ private bool m_MouseDown = false;
+ private bool m_MouseOver = false;
+ private bool m_TextVisible = true;
+ private Color m_TextColor = Color.Empty;
+ private bool m_ThreeState = false;
+ private CheckState m_CheckState = CheckState.Unchecked;
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs before Checked property is changed and allows you to cancel the change.
+ ///
+ public event CheckBoxChangeEventHandler CheckedChanging;
+ ///
+ /// Occurs after Checked property is changed. Action cannot be cancelled.
+ ///
+ public event CheckBoxChangeEventHandler CheckedChanged;
+ ///
+ /// Occurs when CheckState property has changed.
+ ///
+ public event EventHandler CheckStateChanged;
+ ///
+ /// Occurs when CheckedBindable property has changed.
+ ///
+ public event EventHandler CheckedBindableChanged;
+ #endregion
+
+ #region Constructor, Copy
+ ///
+ /// Creates new instance of CheckBoxItem.
+ ///
+ public CheckBoxItem():this("","") {}
+ ///
+ /// Creates new instance of CheckBoxItem and assigns the name to it.
+ ///
+ /// Item name.
+ public CheckBoxItem(string sItemName):this(sItemName,"") {}
+ ///
+ /// Creates new instance of CheckBoxItem and assigns the name and text to it.
+ ///
+ /// Item name.
+ /// item text.
+ public CheckBoxItem(string sItemName, string ItemText)
+ : base(sItemName, ItemText)
+ {
+ }
+
+ ///
+ /// Returns copy of the item.
+ ///
+ public override BaseItem Copy()
+ {
+ CheckBoxItem objCopy = new CheckBoxItem(m_Name);
+ this.CopyToItem(objCopy);
+ return objCopy;
+ }
+
+ ///
+ /// Copies the CheckBoxItem specific properties to new instance of the item.
+ ///
+ /// New CheckBoxItem instance.
+ internal void InternalCopyToItem(CheckBoxItem copy)
+ {
+ CopyToItem(copy);
+ }
+
+ ///
+ /// Copies the CheckBoxItem specific properties to new instance of the item.
+ ///
+ /// New CheckBoxItem instance.
+ protected override void CopyToItem(BaseItem copy)
+ {
+ CheckBoxItem objCopy = copy as CheckBoxItem;
+
+ if (objCopy != null)
+ {
+ objCopy.CheckBoxPosition = this.CheckBoxPosition;
+ objCopy.CheckBoxStyle = this.CheckBoxStyle;
+ objCopy.Checked = this.Checked;
+ objCopy.CheckState = this.CheckState;
+ objCopy.TextColor = this.TextColor;
+ objCopy.TextVisible = this.TextVisible;
+
+ objCopy.ThreeState = this.ThreeState;
+ objCopy.EnableMarkup = this.EnableMarkup;
+
+ objCopy.CheckBoxImageChecked = this.CheckBoxImageChecked;
+ objCopy.CheckBoxImageIndeterminate = this.CheckBoxImageIndeterminate;
+ objCopy.CheckBoxImageUnChecked = this.CheckBoxImageUnChecked;
+
+ base.CopyToItem(objCopy);
+ }
+ }
+ #endregion
+
+ #region Internal Implementation
+ private bool _AutoCheck = true;
+ ///
+ /// Gets or set whether the Checked values and the item appearance are automatically changed when the Check-Box is clicked. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether the Checked values and the item appearance are automatically changed when the Check-Box is clicked.")]
+ public bool AutoCheck
+ {
+ get { return _AutoCheck; }
+ set
+ {
+ if (value != _AutoCheck)
+ {
+ bool oldValue = _AutoCheck;
+ _AutoCheck = value;
+ OnAutoCheckChanged(oldValue, value);
+ }
+ }
+ }
+ private void OnAutoCheckChanged(bool oldValue, bool newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("AutoCheck"));
+ }
+
+ public override void Paint(ItemPaintArgs p)
+ {
+ Rendering.BaseRenderer renderer = p.Renderer;
+ if (renderer != null)
+ {
+ CheckBoxItemRenderEventArgs e = new CheckBoxItemRenderEventArgs(p.Graphics, this, p.Colors, p.Font, p.RightToLeft);
+ e.ItemPaintArgs = p;
+ renderer.DrawCheckBoxItem(e);
+ }
+ else
+ {
+ Rendering.CheckBoxItemPainter painter = PainterFactory.CreateCheckBoxItemPainter(this);
+ if (painter != null)
+ {
+ CheckBoxItemRenderEventArgs e = new CheckBoxItemRenderEventArgs(p.Graphics, this, p.Colors, p.Font, p.RightToLeft);
+ e.ItemPaintArgs = p;
+ painter.Paint(e);
+ }
+ }
+
+ this.DrawInsertMarker(p.Graphics);
+ }
+
+ internal int CheckTextSpacing
+ {
+ get { return m_CheckTextSpacing; }
+ }
+
+ internal int VerticalPadding
+ {
+ get { return m_VerticalPadding; }
+ set { m_VerticalPadding = value; }
+ }
+
+ ///
+ /// Gets or sets the size of the check or radio sign. Default value is 13x13. Minimum value is 6x6.
+ ///
+ [Category("Appearance"), Description("Indicates size of the check or radio sign. Default value is 13x13.")]
+ public Size CheckSignSize
+ {
+ get { return m_CheckSignSize; }
+ set
+ {
+ if (value.Width < 6) value.Width = 6;
+ if (value.Height < 6) value.Height = 6;
+
+ m_CheckSignSize = value; this.NeedRecalcSize = true; this.Refresh();
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeCheckSignSize()
+ {
+ return m_CheckSignSize.Width != 13 || m_CheckSignSize.Height != 13;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetCheckSignSize()
+ {
+ this.CheckSignSize = new Size(13, 13);
+ }
+
+ internal Size GetCheckSignSize()
+ {
+ Size checkSignSize = m_CheckSignSize;
+ if (_CheckBoxImageChecked != null || _CheckBoxImageIndeterminate != null || _CheckBoxImageUnChecked != null)
+ {
+ checkSignSize = Size.Empty;
+ if (_CheckBoxImageChecked != null)
+ checkSignSize = new Size(Math.Max(checkSignSize.Width, _CheckBoxImageChecked.Width),
+ Math.Max(checkSignSize.Height, _CheckBoxImageChecked.Height));
+ if (_CheckBoxImageIndeterminate != null)
+ checkSignSize = new Size(Math.Max(checkSignSize.Width, _CheckBoxImageIndeterminate.Width),
+ Math.Max(checkSignSize.Height, _CheckBoxImageIndeterminate.Height));
+ if (_CheckBoxImageUnChecked != null)
+ checkSignSize = new Size(Math.Max(checkSignSize.Width, _CheckBoxImageUnChecked.Width),
+ Math.Max(checkSignSize.Height, _CheckBoxImageUnChecked.Height));
+ return Dpi.ImageSize(checkSignSize);
+ }
+ return Dpi.Size(checkSignSize);
+ }
+
+ private bool _IsTextMultiLine = false;
+
+ internal bool IsTextMultiLine
+ {
+ get { return _IsTextMultiLine; }
+ }
+ private Size _TextSize = Size.Empty;
+ internal Size TextSize
+ {
+ get
+ {
+ return _TextSize;
+ }
+ }
+ public override void RecalcSize()
+ {
+ Control objCtrl = this.ContainerControl as Control;
+ if (objCtrl == null || objCtrl.Disposing || objCtrl.IsDisposed)
+ return;
+
+ int verticalPadding = Dpi.Height(m_VerticalPadding);
+ int checkTextSpacing = Dpi.Width(m_CheckTextSpacing);
+
+ Graphics g = BarFunctions.CreateGraphics(objCtrl);
+ if (g == null) return;
+
+ Size checkSignSize = GetCheckSignSize();
+
+ if (m_TextVisible)
+ {
+ try
+ {
+ Size textSize = Size.Empty;
+ _IsTextMultiLine = false;
+ if (objCtrl is CheckBoxX && !((CheckBoxX) objCtrl).AutoSize)
+ {
+ textSize = ButtonItemLayout.MeasureItemText(this, g,
+ m_Rect.Width - checkSignSize.Width - CheckTextSpacing, objCtrl.Font, eTextFormat.Default,
+ objCtrl.RightToLeft == RightToLeft.Yes);
+ Size singleLine = TextDrawing.MeasureString(g,"Abc", objCtrl.Font);
+ _IsTextMultiLine = (textSize.Height > singleLine.Height);
+ }
+ else
+ textSize = ButtonItemLayout.MeasureItemText(this, g, 0, objCtrl.Font, eTextFormat.Default,
+ objCtrl.RightToLeft == RightToLeft.Yes);
+ textSize.Width += 1;
+ _TextSize = textSize;
+ if (m_CheckBoxPosition == eCheckBoxPosition.Left || m_CheckBoxPosition == eCheckBoxPosition.Right)
+ {
+ m_Rect = new Rectangle(m_Rect.X, m_Rect.Y,
+ textSize.Width + checkTextSpacing + checkSignSize.Width,
+ Math.Max(checkSignSize.Height, textSize.Height) + verticalPadding * 2);
+ }
+ else
+ {
+ m_Rect = new Rectangle(m_Rect.X, m_Rect.Y,
+ Math.Max(textSize.Width, checkSignSize.Width) + verticalPadding * 2,
+ textSize.Height + checkTextSpacing + checkSignSize.Height);
+ }
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ }
+ else
+ {
+ Size s = checkSignSize;
+ s.Width += verticalPadding * 2;
+ s.Height += verticalPadding * 2;
+ m_Rect = new Rectangle(m_Rect.Location, s);
+ }
+
+ base.RecalcSize();
+ }
+
+ ///
+ /// Gets or sets the text associated with this item.
+ ///
+ [Browsable(true), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Category("Appearance"), Description("The text contained in the item."), Localizable(true), DefaultValue("")]
+ public override string Text
+ {
+ get
+ {
+ return base.Text;
+ }
+ set
+ {
+ base.Text = value;
+ }
+ }
+
+ #region Markup Implementation
+ ///
+ /// Gets whether item supports text markup. Default is false.
+ ///
+ protected override bool IsMarkupSupported
+ {
+ get { return _EnableMarkup; }
+ }
+
+ private bool _EnableMarkup = true;
+ ///
+ /// Gets or sets whether text-markup support is enabled for items Text property. Default value is true.
+ /// Set this property to false to display HTML or other markup in the item instead of it being parsed as text-markup.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether text-markup support is enabled for items Text property.")]
+ public bool EnableMarkup
+ {
+ get { return _EnableMarkup; }
+ set
+ {
+ if (_EnableMarkup != value)
+ {
+ _EnableMarkup = value;
+ NeedRecalcSize = true;
+ OnTextChanged();
+ }
+ }
+ }
+ #endregion
+
+ ///
+ /// Gets or sets whether text assigned to the check box is visible. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether text assigned to the check box is visible.")]
+ public bool TextVisible
+ {
+ get { return m_TextVisible; }
+ set
+ {
+ m_TextVisible = value;
+ this.NeedRecalcSize = true;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the text color. Default value is Color.Empty which indicates that default color is used.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates text color.")]
+ public Color TextColor
+ {
+ get { return m_TextColor; }
+ set
+ {
+ m_TextColor = value;
+ OnAppearanceChanged();
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTextColor()
+ {
+ return !m_TextColor.IsEmpty;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTextColor()
+ {
+ this.TextColor = Color.Empty;
+ }
+
+ ///
+ /// Gets or sets the appearance style of the item. Default value is CheckBox. Item can also assume the style of radio-button.
+ ///
+ [Browsable(true), DefaultValue(eCheckBoxStyle.CheckBox), Category("Appearance"), Description("Indicates appearance style of the item. Default value is CheckBox. Item can also assume the style of radio-button.")]
+ public eCheckBoxStyle CheckBoxStyle
+ {
+ get { return m_CheckBoxStyle; }
+ set
+ {
+ m_CheckBoxStyle = value;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Gets or sets the check box position relative to the text. Default value is Left.
+ ///
+ [Browsable(true), DefaultValue(eCheckBoxPosition.Left), Category("Appearance"), Description("Indicates the check box position relative to the text.")]
+ public eCheckBoxPosition CheckBoxPosition
+ {
+ get { return m_CheckBoxPosition; }
+ set
+ {
+ m_CheckBoxPosition = value;
+ this.NeedRecalcSize = true;
+ OnAppearanceChanged();
+ }
+ }
+
+ public override void InternalMouseEnter()
+ {
+ base.InternalMouseEnter();
+ if (!this.DesignMode && _AutoCheck)
+ {
+ m_MouseOver = true;
+ if (this.GetEnabled())
+ this.Refresh();
+ }
+ }
+
+ public override void InternalMouseLeave()
+ {
+ base.InternalMouseLeave();
+ if (!this.DesignMode)
+ {
+ m_MouseOver = false;
+ m_MouseDown = false;
+ if (this.GetEnabled())
+ this.Refresh();
+ }
+ }
+
+ public override void InternalMouseDown(MouseEventArgs objArg)
+ {
+ base.InternalMouseDown(objArg);
+ if (objArg.Button == MouseButtons.Left && !this.DesignMode && _AutoCheck)
+ {
+ m_MouseDown = true;
+ if (this.GetEnabled())
+ this.Refresh();
+ }
+ }
+
+ public override void InternalMouseUp(MouseEventArgs objArg)
+ {
+ base.InternalMouseUp(objArg);
+
+ if (m_MouseDown && !this.DesignMode)
+ {
+ m_MouseDown = false;
+ if (this.GetEnabled())
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Gets whether mouse is over the item.
+ ///
+ [Browsable(false)]
+ public bool IsMouseOver
+ {
+ get { return m_MouseOver; }
+ internal set { m_MouseOver = value; }
+ }
+
+ ///
+ /// Gets whether left mouse button is pressed on the item.
+ ///
+ [Browsable(false)]
+ public bool IsMouseDown
+ {
+ get { return m_MouseDown; }
+ internal set { m_MouseDown = value; }
+ }
+
+ ///
+ /// Gets or set a value indicating whether the button is in the checked state.
+ ///
+ [Browsable(true), RefreshProperties(RefreshProperties.All), Category("Appearance"), Description("Indicates whether item is checked or not."), DefaultValue(false), Bindable(false)]
+ public virtual bool Checked
+ {
+ get
+ {
+ return m_Checked;
+ }
+ set
+ {
+ if (m_Checked != value)
+ {
+ if (m_ThreeState && value && m_CheckState != CheckState.Unchecked) return;
+
+ SetChecked(value, eEventSource.Code);
+ }
+ }
+ }
+
+ ///
+ /// Gets or set a value indicating whether the button is in the checked state.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), RefreshProperties(RefreshProperties.All), Category("Appearance"), Description("Indicates whether item is checked or not."), DefaultValue(false), Bindable(true)]
+ public virtual bool CheckedBindable
+ {
+ get
+ {
+ return this.Checked;
+ }
+ set
+ {
+ this.Checked = value;
+ }
+ }
+
+ ///
+ /// Raises the click event and provide the information about the source of the event.
+ ///
+ ///
+ public override void RaiseClick(eEventSource source)
+ {
+ if (_AutoCheck && CanRaiseClick && !(this.CheckBoxStyle == eCheckBoxStyle.RadioButton && this.Checked))
+ {
+ if (this.ThreeState)
+ {
+ if (this.CheckState == CheckState.Unchecked)
+ SetChecked(CheckState.Checked, source);
+ else if (this.CheckState == CheckState.Checked)
+ SetChecked(CheckState.Indeterminate, source);
+ else if (this.CheckState == CheckState.Indeterminate)
+ SetChecked(CheckState.Unchecked, source);
+ }
+ else
+ SetChecked(!this.Checked, source);
+
+ ExecuteCommand();
+ }
+ base.RaiseClick(source);
+ }
+
+ ///
+ /// Sets the Checked property of the item, raises appropriate events and provides the information about the source of the change.
+ ///
+ /// New value for Checked property
+ /// Source of the change.
+ public virtual void SetChecked(bool newValue, eEventSource source)
+ {
+ // Allow user to cancel the checking
+ if (m_CheckBoxStyle == eCheckBoxStyle.RadioButton && newValue && this.Parent != null)
+ {
+ CheckBoxItem b = null;
+ foreach (BaseItem item in this.Parent.SubItems)
+ {
+ if (item == this)
+ continue;
+ b = item as CheckBoxItem;
+ if (b != null && b.Checked && b.CheckBoxStyle == eCheckBoxStyle.RadioButton)
+ {
+ break;
+ }
+ }
+ CheckBoxChangeEventArgs e = new CheckBoxChangeEventArgs(b, this, source);
+ InvokeCheckedChanging(e);
+ if (e.Cancel)
+ return;
+ }
+ else
+ {
+ CheckBoxChangeEventArgs e = new CheckBoxChangeEventArgs(null, this, source);
+ InvokeCheckedChanging(e);
+ if (e.Cancel)
+ return;
+ }
+
+ m_Checked = newValue;
+ if (m_Checked && m_CheckState == CheckState.Unchecked || !m_Checked && m_CheckState != CheckState.Unchecked)
+ {
+ m_CheckState = m_Checked ? CheckState.Checked : CheckState.Unchecked;
+ }
+
+ if (this.Command != null)
+ this.Command.Checked = m_Checked;
+
+ this.OnCheckedChanged(source);
+ OnCheckedBindableChanged(EventArgs.Empty);
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "Checked");
+
+ if (this.Displayed)
+ this.Refresh();
+ }
+
+ ///
+ /// Called when Command property value changes.
+ ///
+ protected override void OnCommandChanged()
+ {
+ Command command = this.Command;
+ if (command != null && command.Checked != this.Checked)
+ {
+ SetChecked(command.Checked, eEventSource.Code);
+ }
+ base.OnCommandChanged();
+ }
+
+ ///
+ /// Sets the Checked property of the item, raises appropriate events and provides the information about the source of the change.
+ ///
+ /// New value for Checked property
+ /// Source of the change.
+ public virtual void SetChecked(CheckState newValue, eEventSource source)
+ {
+ CheckBoxChangeEventArgs e = new CheckBoxChangeEventArgs(null, this, source);
+ InvokeCheckedChanging(e);
+ if (e.Cancel)
+ return;
+
+ m_CheckState = newValue;
+ m_Checked = (newValue != CheckState.Unchecked);
+ if (this.Command != null)
+ this.Command.Checked = m_Checked;
+ this.OnCheckedChanged(source);
+ OnCheckStateChanged(EventArgs.Empty);
+
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "CheckState");
+
+ if (this.Displayed)
+ this.Refresh();
+ }
+
+ ///
+ /// Raises CheckState changed event.
+ ///
+ /// Event arguments.
+ protected virtual void OnCheckStateChanged(EventArgs eventArgs)
+ {
+ if (CheckStateChanged != null)
+ CheckStateChanged(this, eventArgs);
+ }
+
+ ///
+ /// Raises CheckedBindableChanged changed event.
+ ///
+ /// Event arguments.
+ protected virtual void OnCheckedBindableChanged(EventArgs eventArgs)
+ {
+ if (CheckedBindableChanged != null)
+ CheckedBindableChanged(this, eventArgs);
+ }
+
+ ///
+ /// Called after Checked property has changed.
+ ///
+ protected virtual void OnCheckedChanged(eEventSource source)
+ {
+ CheckBoxItem previous = null;
+ if (m_CheckBoxStyle == eCheckBoxStyle.RadioButton && m_Checked && this.Parent != null)
+ {
+ BaseItem[] items = new BaseItem[this.Parent.SubItems.Count];
+ this.Parent.SubItems.CopyTo(items, 0);
+ foreach (BaseItem item in items)
+ {
+ if (item == this)
+ continue;
+ CheckBoxItem b = item as CheckBoxItem;
+ if (b != null && b.Checked && b.CheckBoxStyle == eCheckBoxStyle.RadioButton)
+ {
+ b.Checked = false;
+ previous = b;
+ }
+ }
+ }
+
+ InvokeCheckedChanged(new CheckBoxChangeEventArgs(previous, this, source));
+ }
+
+ ///
+ /// Raises the CheckedChanging event.
+ ///
+ protected virtual void InvokeCheckedChanging(CheckBoxChangeEventArgs e)
+ {
+ if (CheckedChanging != null)
+ CheckedChanging(this, e);
+ }
+
+ ///
+ /// Raises the CheckedChanged event.
+ ///
+ protected virtual void InvokeCheckedChanged(CheckBoxChangeEventArgs e)
+ {
+ if (CheckedChanged != null)
+ CheckedChanged(this, e);
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the CheckBox will allow three check states rather than two. If the ThreeState property is set to true
+ /// CheckState property should be used instead of Checked property to set the extended state of the control.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(false), Description("Indicates whether the CheckBox will allow three check states rather than two.")]
+ public bool ThreeState
+ {
+ get { return m_ThreeState; }
+ set { m_ThreeState = value; }
+ }
+
+ ///
+ /// Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(CheckState.Unchecked), RefreshProperties(RefreshProperties.All), Description("Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state"), Bindable(true)]
+ public CheckState CheckState
+ {
+ get { return m_CheckState; }
+ set
+ {
+ if (value != m_CheckState)
+ SetChecked(value, eEventSource.Code);
+ }
+ }
+
+ private Image _CheckBoxImageChecked = null;
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box is checked.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box is checked")]
+ public Image CheckBoxImageChecked
+ {
+ get { return _CheckBoxImageChecked; }
+ set
+ {
+ _CheckBoxImageChecked = value;
+ OnCheckBoxImageChanged();
+ }
+ }
+ private Image _CheckBoxImageUnChecked = null;
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box is unchecked.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box is unchecked")]
+ public Image CheckBoxImageUnChecked
+ {
+ get { return _CheckBoxImageUnChecked; }
+ set
+ {
+ _CheckBoxImageUnChecked = value;
+ OnCheckBoxImageChanged();
+ }
+ }
+ private Image _CheckBoxImageIndeterminate = null;
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box is in indeterminate state.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box is in indeterminate state")]
+ public Image CheckBoxImageIndeterminate
+ {
+ get { return _CheckBoxImageIndeterminate; }
+ set
+ {
+ _CheckBoxImageIndeterminate = value;
+ OnCheckBoxImageChanged();
+ }
+ }
+ private void OnCheckBoxImageChanged()
+ {
+ NeedRecalcSize = true;
+ Refresh();
+ }
+ #endregion
+ }
+
+ ///
+ /// Delegate for OptionGroupChanging event.
+ ///
+ public delegate void CheckBoxChangeEventHandler(object sender, CheckBoxChangeEventArgs e);
+
+ #region CheckBoxChangeEventArgs
+ ///
+ /// Represents event arguments for OptionGroupChanging event.
+ ///
+ public class CheckBoxChangeEventArgs : EventArgs
+ {
+ ///
+ /// Set to true to cancel the checking on NewChecked button.
+ ///
+ public bool Cancel = false;
+ ///
+ /// Check-box that will become checked if operation is not cancelled.
+ ///
+ public readonly CheckBoxItem NewChecked;
+ ///
+ /// Check-box that is currently checked and which will be unchecked if operation is not cancelled. This property will have only valid values for eCheckBoxStyle.RadioButton style CheckBoxItems.
+ ///
+ public readonly CheckBoxItem OldChecked;
+ ///
+ /// Indicates the action that has caused the event.
+ ///
+ public readonly eEventSource EventSource = eEventSource.Code;
+
+ ///
+ /// Default constructor.
+ ///
+ public CheckBoxChangeEventArgs(CheckBoxItem oldchecked, CheckBoxItem newchecked, eEventSource eventSource)
+ {
+ NewChecked = newchecked;
+ OldChecked = oldchecked;
+ EventSource = eventSource;
+ }
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/CheckBoxItem/CheckBoxItemPainter.cs b/PROMS/DotNetBar Source Code/CheckBoxItem/CheckBoxItemPainter.cs
new file mode 100644
index 00000000..9515523f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CheckBoxItem/CheckBoxItemPainter.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Text;
+
+namespace DevComponents.DotNetBar.Rendering
+{
+ ///
+ /// Represents painter for CheckBoxItem.
+ ///
+ internal class CheckBoxItemPainter
+ {
+ ///
+ /// Paints CheckBoxItem.
+ ///
+ /// Provides arguments for the operation.
+ public virtual void Paint(CheckBoxItemRenderEventArgs e) { }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CheckBoxItem/Office2007CheckBoxItemPainter.cs b/PROMS/DotNetBar Source Code/CheckBoxItem/Office2007CheckBoxItemPainter.cs
new file mode 100644
index 00000000..af9611b3
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CheckBoxItem/Office2007CheckBoxItemPainter.cs
@@ -0,0 +1,391 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Ribbon;
+
+namespace DevComponents.DotNetBar.Rendering
+{
+ internal class Office2007CheckBoxItemPainter : CheckBoxItemPainter, IOffice2007Painter
+ {
+ #region Private Variables
+
+ #endregion
+
+ #region IOffice2007Painter
+ private Office2007ColorTable m_ColorTable = null;
+
+ ///
+ /// Gets or sets color table used by renderer.
+ ///
+ public Office2007ColorTable ColorTable
+ {
+ get { return m_ColorTable; }
+ set { m_ColorTable = value; }
+ }
+ #endregion
+
+ #region Internal Implementation
+ public override void Paint(CheckBoxItemRenderEventArgs e)
+ {
+ Graphics g = e.Graphics;
+ CheckBoxItem item = e.CheckBoxItem;
+ bool rtl = e.RightToLeft;
+ Font font = e.Font;
+ Office2007CheckBoxStateColorTable ct = this.GetCheckBoxStateColorTable(e);
+ bool standalone = e.ItemPaintArgs.ContainerControl is DevComponents.DotNetBar.Controls.CheckBoxX;
+
+ Rectangle checkBoxPosition = Rectangle.Empty;
+ Rectangle textRect = Rectangle.Empty;
+ eTextFormat tf = eTextFormat.Default;
+ if (!(e.ItemPaintArgs != null && e.ItemPaintArgs.ContainerControl is DevComponents.DotNetBar.Controls.CheckBoxX ||
+ (e.ItemPaintArgs != null && e.ItemPaintArgs.ContainerControl is ItemControl) ||
+ (e.ItemPaintArgs != null && e.ItemPaintArgs.ContainerControl is Bar) ||
+ (e.ItemPaintArgs != null && e.ItemPaintArgs.ContainerControl is MenuPanel)))
+ {
+ tf |= eTextFormat.NoPrefix;
+ }
+
+ Size checkSignSize = item.GetCheckSignSize();
+
+ float baselineOffsetPixels = g.DpiY / 72f * (font.SizeInPoints / font.FontFamily.GetEmHeight(font.Style) * font.FontFamily.GetCellAscent(font.Style)) + .5f;
+ //float fontDescentPixels = g.DpiY / 72f * (font.SizeInPoints / font.FontFamily.GetEmHeight(font.Style) * font.FontFamily.GetCellDescent(font.Style));
+
+ if (item.CheckBoxPosition == eCheckBoxPosition.Left && !rtl || item.CheckBoxPosition == eCheckBoxPosition.Right && rtl)
+ {
+ checkBoxPosition = new Rectangle(item.DisplayRectangle.X + (standalone ? 0 : item.CheckTextSpacing / 2),
+ item.DisplayRectangle.Y + (item.DisplayRectangle.Height - checkSignSize.Height) / 2,
+ checkSignSize.Width, checkSignSize.Height);
+ textRect = new Rectangle(checkBoxPosition.Right + item.CheckTextSpacing / 2, item.DisplayRectangle.Y,
+ item.DisplayRectangle.Right - (checkBoxPosition.Right + item.CheckTextSpacing / 2), item.DisplayRectangle.Height);
+
+ if (item.TextMarkupBody == null)
+ {
+ if (!(item.Text.Contains(Environment.NewLine) || item.IsTextMultiLine) && item.TextSize.Width <= textRect.Width)
+ textRect.Y = checkBoxPosition.Bottom - (int)baselineOffsetPixels - Dpi.Height(3);
+ else
+ tf |= eTextFormat.VerticalCenter | eTextFormat.WordBreak;
+ }
+ else
+ tf |= eTextFormat.VerticalCenter;
+ }
+ else if (item.CheckBoxPosition == eCheckBoxPosition.Right && !rtl || item.CheckBoxPosition == eCheckBoxPosition.Left && rtl)
+ {
+ checkBoxPosition = new Rectangle(item.DisplayRectangle.Right - (standalone ? 1 : item.CheckTextSpacing / 2) - checkSignSize.Width,
+ item.DisplayRectangle.Y + (item.DisplayRectangle.Height - checkSignSize.Height) / 2,
+ checkSignSize.Width, checkSignSize.Height);
+ textRect = new Rectangle(item.DisplayRectangle.X, item.DisplayRectangle.Y,
+ checkBoxPosition.X - (item.DisplayRectangle.X + item.CheckTextSpacing / 2), item.DisplayRectangle.Height);
+
+ if (item.TextMarkupBody == null)
+ {
+ if (!item.Text.Contains(Environment.NewLine) && item.TextSize.Width <= textRect.Width)
+ textRect.Y = checkBoxPosition.Bottom - (int)baselineOffsetPixels - Dpi.Height(3);
+ else
+ tf |= eTextFormat.VerticalCenter | eTextFormat.WordBreak;
+ }
+ else
+ tf |= eTextFormat.VerticalCenter;
+
+ tf |= eTextFormat.Right;
+ }
+ else if (item.CheckBoxPosition == eCheckBoxPosition.Top)
+ {
+ checkBoxPosition = new Rectangle(item.DisplayRectangle.X + (item.DisplayRectangle.Width - checkSignSize.Width) / 2,
+ item.DisplayRectangle.Y + item.VerticalPadding, checkSignSize.Width, checkSignSize.Height);
+ textRect = new Rectangle(item.DisplayRectangle.X, checkBoxPosition.Bottom,
+ item.DisplayRectangle.Width, item.DisplayRectangle.Bottom - checkBoxPosition.Bottom);
+ tf |= eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter;
+ }
+ else if (item.CheckBoxPosition == eCheckBoxPosition.Bottom)
+ {
+ checkBoxPosition = new Rectangle(item.DisplayRectangle.X + (item.DisplayRectangle.Width - checkSignSize.Width) / 2,
+ item.DisplayRectangle.Bottom - item.VerticalPadding - checkSignSize.Height - 1, checkSignSize.Width, checkSignSize.Height);
+ textRect = new Rectangle(item.DisplayRectangle.X, item.DisplayRectangle.Y,
+ item.DisplayRectangle.Width, checkBoxPosition.Y - (item.DisplayRectangle.Y + item.VerticalPadding));
+
+ tf |= eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter;
+ }
+
+ if (item.CheckState == CheckState.Unchecked && item.CheckBoxImageUnChecked != null)
+ g.DrawImage(item.CheckBoxImageUnChecked, checkBoxPosition);
+ else if (item.CheckState == CheckState.Checked && item.CheckBoxImageChecked != null)
+ g.DrawImage(item.CheckBoxImageChecked, checkBoxPosition);
+ else if (item.CheckState == CheckState.Indeterminate && item.CheckBoxImageIndeterminate != null)
+ g.DrawImage(item.CheckBoxImageIndeterminate, checkBoxPosition);
+ else
+ {
+ if (item.CheckBoxStyle == eCheckBoxStyle.CheckBox)
+ {
+ PaintCheckBox(g, checkBoxPosition, ct, item.CheckState);
+ }
+ else
+ {
+ PaintRadioButton(g, checkBoxPosition, ct, item.Checked);
+ }
+ }
+
+ Color textColor = ct.Text;
+ if (!item.TextColor.IsEmpty) textColor = item.TextColor;
+ if (item.Text != "" && !textRect.IsEmpty && !textColor.IsEmpty && item.Orientation != eOrientation.Vertical && item.TextVisible)
+ {
+ if (item.TextMarkupBody != null)
+ {
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, textColor, rtl);
+ d.HotKeyPrefixVisible = !((tf & eTextFormat.HidePrefix) == eTextFormat.HidePrefix);
+ if ((tf & eTextFormat.VerticalCenter) == eTextFormat.VerticalCenter)
+ {
+ textRect.Y = item.TopInternal + (item.Bounds.Height - item.TextMarkupBody.Bounds.Height) / 2;
+ textRect.Height = item.TextMarkupBody.Bounds.Height;
+ }
+ else if ((tf & eTextFormat.Bottom) == eTextFormat.Bottom)
+ {
+ textRect.Y += (item.Bounds.Height - item.TextMarkupBody.Bounds.Height) + 1;
+ textRect.Height = item.TextMarkupBody.Bounds.Height;
+ }
+
+ item.TextMarkupBody.Bounds = textRect;
+ item.TextMarkupBody.Render(d);
+ }
+ else
+ {
+#if FRAMEWORK20
+ if (e.ItemPaintArgs != null && e.ItemPaintArgs.GlassEnabled && item.Parent is CaptionItemContainer && !(e.ItemPaintArgs.ContainerControl is QatToolbar))
+ {
+ if (!e.ItemPaintArgs.CachedPaint)
+ Office2007RibbonControlPainter.PaintTextOnGlass(g, item.Text, font, textRect, TextDrawing.GetTextFormat(tf));
+ }
+ else
+#endif
+ TextDrawing.DrawString(g, item.Text, font, textColor, textRect, tf);
+ }
+ }
+
+ if (item.Focused && item.DesignMode)
+ {
+ Rectangle r = item.DisplayRectangle;
+ r.Inflate(-1, -1);
+ DesignTime.DrawDesignTimeSelection(g, r, e.ColorScheme.ItemDesignTimeBorder);
+ }
+ }
+
+ public void PaintRadioButton(Graphics g, Rectangle checkBoxPosition, Office2007CheckBoxStateColorTable ct, bool isChecked)
+ {
+ Rectangle r = checkBoxPosition;
+ r.Inflate(-1, -1);
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddEllipse(r);
+ DisplayHelp.FillPath(g, path, ct.CheckBackground);
+ }
+ using (Pen pen = new Pen(ct.CheckBorder, 1))
+ {
+ g.DrawEllipse(pen, checkBoxPosition);
+ }
+ // Draw inner border
+ checkBoxPosition.Inflate(-3, -3);
+ using (Pen pen = new Pen(ct.CheckInnerBorder, 1))
+ {
+ g.DrawEllipse(pen, checkBoxPosition);
+ }
+
+ if (!ct.CheckInnerBackground.IsEmpty)
+ {
+ if (ct.CheckInnerBackground.End.IsEmpty)
+ {
+ r = checkBoxPosition;
+ r.Inflate(-1, -1);
+ using (SolidBrush brush = new SolidBrush(ct.CheckInnerBackground.Start))
+ g.FillEllipse(brush, r);
+ }
+ else
+ {
+ // Draw gradient
+ Region old = g.Clip;
+ g.SetClip(checkBoxPosition, System.Drawing.Drawing2D.CombineMode.Replace);
+
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddEllipse(checkBoxPosition);
+
+ using (PathGradientBrush brush = new PathGradientBrush(path))
+ {
+ brush.CenterColor = ct.CheckInnerBackground.Start;
+ brush.SurroundColors = new Color[] { ct.CheckInnerBackground.End };
+ brush.CenterPoint = new PointF(checkBoxPosition.X, checkBoxPosition.Y);
+ g.FillEllipse(brush, checkBoxPosition);
+ }
+ }
+ g.Clip = old;
+ }
+ }
+
+ if (isChecked && !ct.CheckSign.IsEmpty)
+ {
+ r = checkBoxPosition;
+ //r.Inflate(-1, -1);
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddEllipse(r);
+ DisplayHelp.FillPath(g, path, ct.CheckSign);
+ }
+ }
+ }
+
+ public void PaintCheckBox(Graphics g, Rectangle checkBoxPosition, Office2007CheckBoxStateColorTable ct, CheckState checkState)
+ {
+ Rectangle r = checkBoxPosition;
+ r.Inflate(-1, -1);
+ if (checkBoxPosition.Width < 5 || checkBoxPosition.Height < 5) return;
+
+ DisplayHelp.FillRectangle(g, r, ct.CheckBackground);
+ DisplayHelp.DrawRectangle(g, ct.CheckBorder, checkBoxPosition);
+
+ // Inside rectangle
+ checkBoxPosition.Inflate(-2, -2);
+
+ if (!ct.CheckInnerBackground.IsEmpty)
+ {
+ if (ct.CheckInnerBackground.End.IsEmpty)
+ {
+ r = checkBoxPosition;
+ r.Inflate(-1, -1);
+ DisplayHelp.FillRectangle(g, r, ct.CheckInnerBackground.Start);
+ }
+ else
+ {
+ // Draw gradient
+ Region old = g.Clip;
+ g.SetClip(checkBoxPosition, System.Drawing.Drawing2D.CombineMode.Intersect);
+
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ path.AddRectangle(checkBoxPosition);
+
+ using (PathGradientBrush brush = new PathGradientBrush(path))
+ {
+ brush.CenterColor = ct.CheckInnerBackground.Start;
+ brush.SurroundColors = new Color[] { ct.CheckInnerBackground.End };
+ brush.CenterPoint = new PointF(checkBoxPosition.X, checkBoxPosition.Y);
+ g.FillRectangle(brush, checkBoxPosition);
+ }
+ }
+ g.Clip = old;
+ }
+ }
+
+ DisplayHelp.DrawRectangle(g, ct.CheckInnerBorder, checkBoxPosition);
+
+ if (checkState == CheckState.Indeterminate)
+ {
+ checkBoxPosition.Inflate(-2, -2);
+ SmoothingMode sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.None;
+ DisplayHelp.FillRectangle(g, checkBoxPosition, ct.CheckSign);
+ g.SmoothingMode = sm;
+ }
+ else if (checkState == CheckState.Checked && !ct.CheckSign.IsEmpty)
+ {
+ using (GraphicsPath path = GetCheckSign(checkBoxPosition))
+ DisplayHelp.FillPath(g, path, ct.CheckSign);
+ }
+ }
+
+ private GraphicsPath GetCheckSign(Rectangle outterRect)
+ {
+ GraphicsPath path = new GraphicsPath();
+
+ Rectangle r = outterRect;
+ r.Inflate(-1, -1);
+
+ path.AddLine(r.X, r.Y + r.Height * .75f, r.X + r.Width * .3f, r.Bottom);
+ path.AddLine(r.X + r.Width * .4f, r.Bottom, r.Right, r.Y + r.Height * .05f);
+ path.AddLine(r.Right - r.Width * .3f, r.Y, r.X + r.Width * .25f, r.Y + r.Height * .75f);
+ path.AddLine(r.X + r.Width * .1f, r.Y + r.Height * .5f, r.X, r.Y + r.Height * .55f);
+ path.CloseAllFigures();
+
+ return path;
+ }
+ protected virtual Office2007CheckBoxColorTable GetColorTable(CheckBoxItem item, System.Windows.Forms.Control container)
+ {
+ if (container == null)
+ return m_ColorTable.CheckBoxItem;
+
+ Office2007ColorTable table = m_ColorTable;
+
+ string key = Office2007ColorTable.GetContextualKey(typeof(Office2007CheckBoxColorTable), container.GetType());
+ object st = null;
+
+ if (container is Bar)
+ {
+ if (table.ContextualTables.TryGetValue(key + "+" + ((Bar)container).BarType.ToString(), out st))
+ return (Office2007CheckBoxColorTable)st;
+ }
+
+ if (table.ContextualTables.TryGetValue(key, out st))
+ return (Office2007CheckBoxColorTable)st;
+
+ return m_ColorTable.CheckBoxItem;
+ }
+ private Office2007CheckBoxStateColorTable GetCheckBoxStateColorTable(CheckBoxItemRenderEventArgs e)
+ {
+ CheckBoxItem item = e.CheckBoxItem;
+ if (m_ColorTable != null && BarFunctions.IsOffice2007Style(e.CheckBoxItem.EffectiveStyle))
+ {
+ Office2007CheckBoxColorTable ct = GetColorTable(e.CheckBoxItem, e.ItemPaintArgs.ContainerControl); // m_ColorTable.CheckBoxItem;
+ if (!item.GetEnabled())
+ return ct.Disabled;
+ else if (item.IsMouseDown)
+ return ct.Pressed;
+ else if (item.IsMouseOver)
+ return ct.MouseOver;
+ return ct.Default;
+ }
+ else
+ {
+ ColorScheme cs = e.ColorScheme;
+ // Create color table based on the ColorScheme object...
+ Office2007CheckBoxStateColorTable ct = new Office2007CheckBoxStateColorTable();
+ if (!item.GetEnabled())
+ {
+ ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ ct.CheckBorder = cs.ItemDisabledText;
+ ct.CheckInnerBorder = cs.ItemDisabledText;
+ ct.CheckInnerBackground = new LinearGradientColorTable();
+ ct.CheckSign = new LinearGradientColorTable(cs.ItemDisabledText, Color.Empty);
+ ct.Text = cs.ItemDisabledText;
+ }
+ else if (item.IsMouseDown)
+ {
+ ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ ct.CheckBorder = cs.ItemPressedBorder;
+ ct.CheckInnerBorder = cs.ItemPressedBorder;
+ ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemPressedBackground, cs.ItemPressedBackground2);
+ ct.CheckSign = new LinearGradientColorTable(cs.ItemPressedText, Color.Empty);
+ ct.Text = cs.ItemPressedText;
+ }
+ else if (item.IsMouseOver)
+ {
+ ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ ct.CheckBorder = cs.ItemHotBorder;
+ ct.CheckInnerBorder = cs.ItemHotBorder;
+ ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemHotBackground, cs.ItemHotBackground2);
+ ct.CheckSign = new LinearGradientColorTable(cs.ItemHotText, Color.Empty);
+ ct.Text = cs.ItemHotText;
+ }
+ else
+ {
+ ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ ct.CheckBorder = cs.PanelBorder;
+ ct.CheckInnerBorder = ColorBlendFactory.SoftLight(cs.PanelBorder, Color.White);
+ ct.CheckInnerBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty);
+ ct.CheckSign = new LinearGradientColorTable(cs.ItemText, Color.Empty);
+ ct.Text = cs.ItemText;
+ }
+ return ct;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CircularProgressItem.cs b/PROMS/DotNetBar Source Code/CircularProgressItem.cs
new file mode 100644
index 00000000..69636f0f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CircularProgressItem.cs
@@ -0,0 +1,1339 @@
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+using System.Threading;
+using DevComponents.DotNetBar.Controls;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents circular progress indicator.
+ ///
+ [ToolboxItem(false), Designer("DevComponents.DotNetBar.Design.SimpleItemDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class CircularProgressItem : BaseItem
+ {
+ #region Events
+
+ #endregion
+
+ #region Constructor
+ ///
+ /// Creates new instance of circular progress indicator.
+ ///
+ public CircularProgressItem() : this("", "") { }
+ ///
+ /// Creates new instance of circular progress indicator and assigns the name to it.
+ ///
+ /// Item name.
+ public CircularProgressItem(string sItemName) : this(sItemName, "") { }
+ ///
+ /// Creates new instance of circular progress indicator and assigns the name and text to it.
+ ///
+ /// Item name.
+ /// item text.
+ public CircularProgressItem(string sItemName, string ItemText)
+ : base(sItemName, ItemText)
+ {
+ _SpokeAngles = GetSpokeAngles(_SpokeCount);
+ }
+ ///
+ /// Returns copy of the item.
+ ///
+ public override BaseItem Copy()
+ {
+ CircularProgressItem objCopy = new CircularProgressItem(m_Name);
+ this.CopyToItem(objCopy);
+ return objCopy;
+ }
+
+ ///
+ /// Copies the ProgressBarItem specific properties to new instance of the item.
+ ///
+ /// New ProgressBarItem instance.
+ internal void InternalCopyToItem(ProgressBarItem copy)
+ {
+ CopyToItem(copy);
+ }
+
+ ///
+ /// Copies the ProgressBarItem specific properties to new instance of the item.
+ ///
+ /// New ProgressBarItem instance.
+ protected override void CopyToItem(BaseItem copy)
+ {
+ CircularProgressItem objCopy = copy as CircularProgressItem;
+ base.CopyToItem(objCopy);
+
+
+ }
+
+ private bool _IsDisposing = false;
+ protected override void Dispose(bool disposing)
+ {
+ _IsDisposing = true;
+ Stop(true);
+ base.Dispose(disposing);
+ _IsDisposing = false;
+ }
+ #endregion
+
+ #region Implementation
+ public override void Paint(ItemPaintArgs e)
+ {
+ //e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
+ //e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
+
+ if (_ProgressBarType == eCircularProgressType.Line)
+ {
+ PaintLineProgressBar(e);
+ }
+ else if (_ProgressBarType == eCircularProgressType.Dot)
+ {
+ PaintDotProgressBar(e);
+ }
+ else if (_ProgressBarType == eCircularProgressType.Donut)
+ {
+ PaintDonutProgressBar(e);
+ }
+ else if (_ProgressBarType == eCircularProgressType.Spoke)
+ {
+ PaintSpokeProgressBar(e);
+ }
+ else if (_ProgressBarType == eCircularProgressType.Pie)
+ {
+ PaintPieProgressBar(e);
+ }
+
+ PaintLabel(e);
+
+ if (this.Focused && this.DesignMode)
+ {
+ Rectangle r = this.DisplayRectangle;
+ r.Inflate(-1, -1);
+ DesignTime.DrawDesignTimeSelection(e.Graphics, r, e.Colors.ItemDesignTimeBorder);
+ }
+
+ this.DrawInsertMarker(e.Graphics);
+ }
+
+ private void PaintLabel(ItemPaintArgs e)
+ {
+ if (!_TextVisible || string.IsNullOrEmpty(this.Text))
+ return;
+ Font font = e.Font;
+ Graphics g = e.Graphics;
+ Color textColor = GetTextColor(e);
+ Rectangle textBounds = Rectangle.Empty;
+ Rectangle bounds = m_Rect;
+ Rectangle progressBounds = GetProgressBarBounds();
+ eTextFormat format = eTextFormat.Default | eTextFormat.NoClipping;
+
+ int textContentSpacing = Dpi.Width(TextContentSpacing);
+ if (_TextPosition == eTextPosition.Left)
+ {
+ textBounds = new Rectangle(bounds.X + _TextPadding.Left, bounds.Y + _TextPadding.Top,
+ m_Rect.Width - _TextPadding.Horizontal - textContentSpacing - progressBounds.Width,
+ m_Rect.Height - _TextPadding.Vertical);
+ format |= eTextFormat.VerticalCenter;
+ }
+ else if (_TextPosition == eTextPosition.Right)
+ {
+ textBounds = new Rectangle(bounds.X + _TextPadding.Left + textContentSpacing + progressBounds.Width, bounds.Y + _TextPadding.Top,
+ m_Rect.Width - _TextPadding.Horizontal - textContentSpacing - progressBounds.Width,
+ m_Rect.Height - _TextPadding.Vertical);
+ format |= eTextFormat.VerticalCenter;
+ }
+ else if (_TextPosition == eTextPosition.Top)
+ {
+ textBounds = new Rectangle(bounds.X + _TextPadding.Left, bounds.Y + _TextPadding.Top,
+ m_Rect.Width - _TextPadding.Horizontal,
+ m_Rect.Height - _TextPadding.Vertical - progressBounds.Height - textContentSpacing);
+ format |= eTextFormat.HorizontalCenter;
+ }
+ else if (_TextPosition == eTextPosition.Bottom)
+ {
+ textBounds = new Rectangle(bounds.X + _TextPadding.Left, bounds.Y + _TextPadding.Top + textContentSpacing + progressBounds.Height,
+ m_Rect.Width - _TextPadding.Horizontal,
+ m_Rect.Height - _TextPadding.Vertical - progressBounds.Height - textContentSpacing);
+ format |= eTextFormat.HorizontalCenter;
+ }
+ if (_TextWidth > 0)
+ {
+ textBounds.Width = _TextWidth;
+ format |= eTextFormat.WordBreak;
+ }
+ //g.FillRectangle(Brushes.WhiteSmoke, textBounds);
+ TextDrawing.DrawString(g, this.Text, font, textColor, textBounds, format);
+ }
+
+ private Color GetTextColor(ItemPaintArgs e)
+ {
+ if (!_TextColor.IsEmpty) return _TextColor;
+ return LabelItem.GetTextColor(e, this.EffectiveStyle, this.GetEnabled(), _TextColor);
+ }
+
+ private bool RenderesProgressText
+ {
+ get
+ {
+ return _ProgressTextVisible && (!_IsEndlessProgressBar || !string.IsNullOrEmpty(_ProgressText));
+ }
+ }
+ private void PaintPieProgressBar(ItemPaintArgs e)
+ {
+ Graphics g = e.Graphics;
+ Rectangle bounds = GetProgressBarBounds();
+ PointF centerPoint = new PointF(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
+ float penWidth = (float)Math.Max(1.5f, bounds.Height * .2);
+ bounds.Inflate(-1, -1);
+ bounds.Width--;
+ bounds.Height--;
+
+ float borderWidth = 1f;
+ if (bounds.Height > 31)
+ borderWidth = bounds.Height * .05f;
+
+ if (!_IsEndlessProgressBar)
+ {
+ int value = GetValue();
+ Rectangle pieBounds = bounds;
+ pieBounds.Inflate(-(int)borderWidth, -(int)borderWidth);
+
+ int sweepAngle = (int)(360 * ((double)value / Math.Max(1, (_Maximum - _Minimum))));
+ using (SolidBrush brush = new SolidBrush(_ProgressColor))
+ {
+ g.FillPie(brush, pieBounds, 270, sweepAngle);
+ }
+ }
+ else
+ {
+ Rectangle pieBounds = bounds;
+ pieBounds.Inflate(-(int)borderWidth, -(int)borderWidth);
+
+ int startAngle = (int)(360 * _EndlessProgressValue / (double)_SpokeCount);
+ int sweepAngle = 90;
+ using (SolidBrush brush = new SolidBrush(_ProgressColor))
+ {
+ g.FillPie(brush, pieBounds, startAngle, sweepAngle);
+ }
+ }
+
+ Rectangle borderBounds = bounds;
+ borderBounds.Width--;
+ borderBounds.Height--;
+
+ borderBounds.Offset(1, 1);
+ using (Pen pen = new Pen(_PieBorderDark, borderWidth))
+ {
+ pen.Alignment = PenAlignment.Inset;
+ g.DrawEllipse(pen, borderBounds);
+ }
+ borderBounds.Offset(-1, -1);
+ //using (Pen pen = new Pen(_PieBorderLight, borderWidth))
+ // g.DrawEllipse(pen, borderBounds);
+
+ using (Pen pen = new Pen(_PieBorderLight, borderWidth + .5f))
+ {
+ pen.Alignment = PenAlignment.Inset;
+ g.DrawEllipse(pen, borderBounds);
+ g.DrawEllipse(pen, borderBounds);
+ }
+
+ if (RenderesProgressText)
+ {
+ bounds.Offset(1, 0);
+ PaintProgressText(g, bounds, (int)(bounds.Height * .4f), e.Font);
+ }
+ }
+
+ private void PaintSpokeProgressBar(ItemPaintArgs e)
+ {
+ Graphics g = e.Graphics;
+ Rectangle bounds = GetProgressBarBounds();
+ // Account for border and shade
+ bounds.Width -= 2;
+ bounds.Height -= 2;
+
+ PointF centerPoint = new PointF(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
+ float penWidth = (float)Math.Max(1.5f, bounds.Height * .2);
+ //bounds.Inflate(-(int)(penWidth / 2), -(int)(penWidth / 2));
+ GraphicsPath clipPath = new GraphicsPath();
+ Rectangle clipPathEllipse = bounds;
+ clipPathEllipse.Inflate(-(int)((float)bounds.Height / 3f), -(int)((float)bounds.Height / 3f));
+ clipPath.AddEllipse(clipPathEllipse);
+ Region oldClip = g.Clip;
+ g.SetClip(clipPath, CombineMode.Exclude);
+
+ if (!_IsEndlessProgressBar)
+ {
+ int value = GetValue();
+
+ int sweepAngle = (int)(360 * ((double)value / Math.Max(1, (_Maximum - _Minimum))));
+ using (SolidBrush brush = new SolidBrush(_ProgressColor))
+ {
+ g.FillPie(brush, bounds, 270, sweepAngle);
+ }
+ }
+ else
+ {
+ int startAngle = (int)(360 * _EndlessProgressValue / (double)_SpokeCount);
+ int sweepAngle = 90;
+ using (SolidBrush brush = new SolidBrush(_ProgressColor))
+ {
+ g.FillPie(brush, bounds, startAngle, sweepAngle);
+ }
+ }
+
+ int radius = bounds.Width / 2;
+
+ PointF shadeCenterPoint = centerPoint;
+ float shadeSpokeWidth = 1f;
+ float circleWidth = 1f;
+ float shadeCircleWidth = 1f;
+ //if (bounds.Height < 28)
+ //{
+ // shadeSpokeWidth = 1f;
+ // circleWidth = 1f;
+ // shadeCircleWidth = 1f;
+ //}
+ radius--;
+ using (Pen pen = new Pen(_SpokeBorderDark, shadeSpokeWidth))
+ {
+ pen.Alignment = PenAlignment.Right;
+ PointF p1 = GetCoordinate(centerPoint, radius, 315); p1.X++;
+ PointF p2 = GetCoordinate(shadeCenterPoint, radius, 135); p2.X++;
+ g.DrawLine(pen, p1, p2); g.DrawLine(pen, p1, p2);
+ p1 = GetCoordinate(centerPoint, radius, 270); p1.X++;
+ p2 = GetCoordinate(shadeCenterPoint, radius, 90); p2.X++;
+ g.DrawLine(pen, p1, p2);
+ p1 = GetCoordinate(centerPoint, radius, 225); p1.Y++;
+ p2 = GetCoordinate(shadeCenterPoint, radius, 45); p2.Y++;
+ g.DrawLine(pen, p1, p2);
+ p1 = GetCoordinate(centerPoint, radius, 180); p1.Y++;
+ p2 = GetCoordinate(shadeCenterPoint, radius, 0); p2.Y++;
+ g.DrawLine(pen, p1, p2);
+ }
+
+ using (Pen pen = new Pen(_SpokeBorderDark, shadeCircleWidth))
+ {
+ pen.Alignment = PenAlignment.Inset;
+ Rectangle shadeBounds = bounds;
+ shadeBounds.Offset(1, 1);
+ //shadeBounds.Width--;
+ //shadeBounds.Height--;
+ g.DrawEllipse(pen, shadeBounds);
+ }
+
+ using (Pen pen = new Pen(_SpokeBorderLight, shadeSpokeWidth))
+ {
+ g.DrawLine(pen, GetCoordinate(centerPoint, radius, 315), GetCoordinate(centerPoint, radius, 135));
+ g.DrawLine(pen, GetCoordinate(centerPoint, radius, 270), GetCoordinate(centerPoint, radius, 90));
+ g.DrawLine(pen, GetCoordinate(centerPoint, radius, 225), GetCoordinate(centerPoint, radius, 45));
+ g.DrawLine(pen, GetCoordinate(centerPoint, radius, 180), GetCoordinate(centerPoint, radius, 0));
+ }
+
+ using (Pen pen = new Pen(_SpokeBorderLight, circleWidth))
+ {
+ pen.Alignment = PenAlignment.Inset;
+ g.DrawEllipse(pen, bounds);
+ g.DrawEllipse(pen, bounds);
+ }
+ g.Clip = oldClip;
+ oldClip.Dispose();
+
+ float innerCircleWidth = 1f;
+ using (Pen pen = new Pen(Color.White, innerCircleWidth))
+ {
+ pen.Alignment = PenAlignment.Inset;
+ g.DrawEllipse(pen, clipPathEllipse);
+ g.DrawEllipse(pen, clipPathEllipse);
+ }
+
+ if (RenderesProgressText)
+ {
+ //bounds.Y--;
+ PaintProgressText(g, bounds, (int)(bounds.Height * .35f), e.Font);
+ }
+ }
+
+ private int GetValue()
+ {
+ int value = Math.Min(_Maximum, Math.Max(_Minimum, _Value));
+ if (this.DesignMode && value == _Minimum) value = (int)(_Maximum * .75d);
+ return value;
+ }
+
+ private void PaintDonutProgressBar(ItemPaintArgs e)
+ {
+ Graphics g = e.Graphics;
+ RectangleF bounds = GetProgressBarBounds();
+ PointF centerPoint = new PointF(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
+ float penWidth = (float)Math.Max(1.5f, bounds.Height * .2);
+ bounds.Inflate(-Math.Max(1, penWidth / 2), -Math.Max(1, penWidth / 2));
+ bounds.Width--;
+ bounds.Height--;
+ if (!_IsEndlessProgressBar)
+ {
+ int value = GetValue();
+
+ int sweepAngle = (int)(360 * ((double)value / Math.Max(1, (_Maximum - _Minimum))));
+ using (Pen pen = new Pen(_ProgressColor, penWidth))
+ {
+
+ g.DrawArc(pen, bounds, 270, sweepAngle);
+ }
+ }
+ else
+ {
+ int startAngle = (int)(360 * _EndlessProgressValue / (double)_SpokeCount);
+ int sweepAngle = 140;
+ using (Pen pen = new Pen(_ProgressColor, penWidth))
+ {
+ pen.EndCap = LineCap.Round;
+ pen.StartCap = LineCap.Round;
+ g.DrawArc(pen, bounds, startAngle, sweepAngle);
+ }
+ }
+
+ if (RenderesProgressText)
+ {
+ PaintProgressText(g, bounds, (int)(bounds.Height * .4f), e.Font);
+ }
+ }
+
+ private void PaintDotProgressBar(ItemPaintArgs e)
+ {
+ Graphics g = e.Graphics;
+ Rectangle bounds = GetProgressBarBounds();
+ PointF centerPoint = new PointF(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
+
+ int outerRadius = 14;
+ int circleSize = 2;
+
+ outerRadius = (int)Math.Round(bounds.Width * .40d);
+ circleSize = Math.Max(1, (int)Math.Round(outerRadius * .25d));
+
+ int value = GetValue();
+
+ if (!_IsEndlessProgressBar)
+ {
+ int spoke = (int)Math.Round(_SpokeCount * ((double)value / Math.Max(1, (_Maximum - _Minimum))));
+ for (int i = 0; i < spoke; i++)
+ {
+ PointF endPoint = GetCoordinate(centerPoint, outerRadius, _SpokeAngles[i]);
+ RectangleF circleBounds = new RectangleF(endPoint, Size.Empty);
+ circleBounds.Inflate(circleSize, circleSize);
+ using (SolidBrush brush = new SolidBrush(ColorFromSpokeIndex(i)))
+ {
+ g.FillEllipse(brush, circleBounds);
+ }
+ }
+ }
+ else if (_IsRunning) // Endless Progress Bar
+ {
+ int position = _EndlessProgressValue;
+ for (int i = 0; i < _SpokeCount; i++)
+ {
+ position = position % _SpokeCount;
+
+ PointF endPoint = GetCoordinate(centerPoint, outerRadius, _SpokeAngles[position]);
+ RectangleF circleBounds = new RectangleF(endPoint, Size.Empty);
+ circleBounds.Inflate(circleSize, circleSize);
+ using (SolidBrush brush = new SolidBrush(ColorFromSpokeIndex(i)))
+ {
+ g.FillEllipse(brush, circleBounds);
+ }
+
+ position++;
+
+ }
+ }
+
+ if (RenderesProgressText)
+ {
+ PaintProgressText(g, bounds, (int)(bounds.Height * .35f), e.Font);
+ }
+ }
+
+ private int _SpokeCount = 12;
+ private int _EndlessProgressValue = 0;
+ private void PaintLineProgressBar(ItemPaintArgs e)
+ {
+ //e.Graphics.DrawRectangle(Pens.Green, new Rectangle(0, 0, this.Width - 1, this.Height - 1));
+ Graphics g = e.Graphics;
+ Rectangle bounds = GetProgressBarBounds();
+ PointF centerPoint = new PointF(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
+
+ int innerRadius = 6;
+ int outerRadius = 14;
+ int spokeSize = 2;
+
+ outerRadius = (int)Math.Round(bounds.Width * .45d);
+ innerRadius = (int)Math.Round(outerRadius * .45d);
+ spokeSize = Math.Max(2, (int)Math.Round(outerRadius * .15d));
+
+ int value = GetValue();
+
+ if (!_IsEndlessProgressBar)
+ {
+ int spoke = (int)Math.Round(_SpokeCount * ((double)value / Math.Max(1, (_Maximum - _Minimum))));
+ for (int i = 0; i < spoke; i++)
+ {
+ PointF startPoint = GetCoordinate(centerPoint, innerRadius, _SpokeAngles[i]);
+ PointF endPoint = GetCoordinate(centerPoint, outerRadius, _SpokeAngles[i]);
+ using (Pen pen = new Pen(ColorFromSpokeIndex(i), spokeSize))
+ {
+ pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
+ pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
+ g.DrawLine(pen, startPoint, endPoint);
+ }
+ }
+ }
+ else if (_IsRunning) // Endless Progress Bar
+ {
+ int position = _EndlessProgressValue;
+ for (int i = 0; i < _SpokeCount; i++)
+ {
+ position = position % _SpokeCount;
+
+ PointF startPoint = GetCoordinate(centerPoint, innerRadius, _SpokeAngles[position]);
+ PointF endPoint = GetCoordinate(centerPoint, outerRadius, _SpokeAngles[position]);
+ using (Pen pen = new Pen(ColorFromSpokeIndex(i), spokeSize))
+ {
+ pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
+ pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
+ g.DrawLine(pen, startPoint, endPoint);
+ }
+
+ position++;
+
+ }
+ }
+
+ if (RenderesProgressText)
+ {
+ PaintProgressText(g, bounds, innerRadius, e.Font);
+ }
+
+ }
+
+ private string GetProgressValueText()
+ {
+ try
+ {
+ if (!string.IsNullOrEmpty(_ProgressText)) return _ProgressText;
+ return string.Format(_ProgressTextFormat, _Value);
+ }
+ catch
+ {
+ return "Format Error";
+ }
+ }
+ private void PaintProgressText(Graphics g, RectangleF bounds, int innerRadius, Font baseFont)
+ {
+ //StringFormat format = (StringFormat)StringFormat.GenericDefault.Clone();
+ //format.Alignment = StringAlignment.Center;
+ //format.LineAlignment = StringAlignment.Center;
+ //format.FormatFlags = StringFormatFlags.NoWrap;
+ //format.Trimming = StringTrimming.None;
+ eTextFormat format = eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.NoPadding | eTextFormat.SingleLine | eTextFormat.NoClipping;
+ float fontSize = Math.Max(1f, innerRadius / 1.8f);
+ Color textColor = _ProgressTextColor.IsEmpty ? _ProgressColor : _ProgressTextColor;
+
+ using (Font font = new Font(baseFont.FontFamily, fontSize, FontStyle.Regular))
+ {
+ TextDrawing.DrawString(g, GetProgressValueText(), font, textColor, Rectangle.Round(bounds), format);
+ //using (SolidBrush brush = new SolidBrush(textColor))
+ // g.DrawString(string.Format("{0}%", _Value), font, brush, bounds, format);
+ }
+ }
+ private Color ColorFromSpokeIndex(int spokeIndex, int spokeCount)
+ {
+ return Color.FromArgb((int)(210 * (double)spokeIndex / spokeCount) + 45, _ProgressColor);
+ }
+ private Color ColorFromSpokeIndex(int spokeIndex)
+ {
+ return ColorFromSpokeIndex(spokeIndex, _SpokeCount);
+ }
+
+ private PointF GetCoordinate(PointF centerPoint, int radius, double angle)
+ {
+ double dblAngle = Math.PI * angle / 180;
+
+ return new PointF(centerPoint.X + radius * (float)Math.Cos(dblAngle),
+ centerPoint.Y + radius * (float)Math.Sin(dblAngle));
+ }
+
+ internal static readonly int TextContentSpacing = 3;
+ private Size _TextSize = Size.Empty;
+ public override void RecalcSize()
+ {
+ int diameter = _Diameter;
+ if (!(this.ContainerControl is CircularProgress))
+ diameter = Dpi.Width(_Diameter);
+ Rectangle r = new Rectangle(m_Rect.X, m_Rect.Y, diameter, diameter);
+ if (_TextVisible && !string.IsNullOrEmpty(this.Text))
+ {
+ Control parent = this.ContainerControl as Control;
+ if (parent != null)
+ {
+ Font font = parent.Font;
+ using (Graphics g = parent.CreateGraphics())
+ {
+ Size textSize = ButtonItemLayout.MeasureItemText(this, g, _TextWidth, font, (_TextWidth > 0 ? eTextFormat.WordBreak : eTextFormat.SingleLine), parent.RightToLeft == RightToLeft.Yes);
+ _TextSize = textSize;
+ textSize.Width += _TextPadding.Horizontal;
+ textSize.Height += _TextPadding.Vertical;
+ int textContentSpacing = Dpi.Width(TextContentSpacing);
+ if (_TextPosition == eTextPosition.Left || _TextPosition == eTextPosition.Right)
+ {
+ textSize.Width += textContentSpacing;
+ r.Width += textSize.Width;
+ r.Height = Math.Max(r.Height, textSize.Height);
+ }
+ else
+ {
+ textSize.Height += textContentSpacing;
+ r.Height += textSize.Height;
+ r.Width = Math.Max(r.Width, textSize.Width);
+ }
+
+ }
+ }
+ }
+
+ m_Rect = r;
+ base.RecalcSize();
+ }
+
+ private Rectangle _ProgressBarBounds = Rectangle.Empty;
+ private Rectangle GetProgressBarBounds()
+ {
+ int diameter = _Diameter;
+ if (!(this.ContainerControl is CircularProgress))
+ diameter = Dpi.Width(_Diameter);
+ if (string.IsNullOrEmpty(Text) || !_TextVisible)
+ {
+ return new Rectangle(m_Rect.X + (m_Rect.Width - diameter) / 2, m_Rect.Y + (m_Rect.Height - diameter) / 2, diameter, diameter);
+ }
+
+ if (_TextPosition == eTextPosition.Top)
+ {
+ return new Rectangle(m_Rect.X + (m_Rect.Width - diameter) / 2, m_Rect.Y + (m_Rect.Height - diameter), diameter, diameter);
+ }
+ else if (_TextPosition == eTextPosition.Right)
+ {
+ return new Rectangle(m_Rect.X, m_Rect.Y + (m_Rect.Height - diameter) / 2, diameter, diameter);
+ }
+ else if (_TextPosition == eTextPosition.Left)
+ {
+ return new Rectangle(m_Rect.Right - diameter,
+ m_Rect.Y + (m_Rect.Height - diameter) / 2,
+ diameter, diameter);
+ }
+ else if (_TextPosition == eTextPosition.Bottom)
+ {
+ return new Rectangle(m_Rect.X + (m_Rect.Width - diameter) / 2, m_Rect.Y, diameter, diameter);
+ }
+ return new Rectangle(m_Rect.X, m_Rect.Y, diameter, diameter);
+ }
+
+ private double[] _SpokeAngles = null;
+ private double[] GetSpokeAngles(int numberOfSpokes)
+ {
+ double[] angles = new double[numberOfSpokes];
+ double angleStep = 360d / numberOfSpokes;
+
+ for (int i = 0; i < numberOfSpokes; i++)
+ angles[i] = (i == 0 ? 270 + angleStep : angles[i - 1] + angleStep);
+
+ return angles;
+ }
+
+ private eCircularProgressType _ProgressBarType = eCircularProgressType.Line;
+ ///
+ /// Gets or sets the circular progress bar type.
+ ///
+ [DefaultValue(eCircularProgressType.Line), Category("Appearance"), Description("Indicates circular progress bar type.")]
+ public eCircularProgressType ProgressBarType
+ {
+ get { return _ProgressBarType; }
+ set
+ {
+ if (value != _ProgressBarType)
+ {
+ eCircularProgressType oldValue = _ProgressBarType;
+ _ProgressBarType = value;
+ OnProgressBarTypeChanged(oldValue, value);
+ }
+ }
+ }
+
+ private void OnProgressBarTypeChanged(eCircularProgressType oldValue, eCircularProgressType newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("ProgressBarType"));
+ this.Refresh();
+ }
+
+ private int _Maximum = 100;
+ ///
+ /// Gets or sets the maximum value of the progress bar.
+ ///
+ [Description("Indicates maximum value of the progress bar."), Category("Behavior"), DefaultValue(100)]
+ public int Maximum
+ {
+ get { return _Maximum; }
+ set
+ {
+ if (value != _Maximum)
+ {
+ int oldValue = _Maximum;
+ _Maximum = value;
+ OnMaximumChanged(oldValue, value);
+ }
+ }
+ }
+ private void OnMaximumChanged(int oldValue, int newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("Maximum"));
+ CoerceValue();
+ }
+
+ private int _Minimum = 0;
+ ///
+ /// Gets or sets the minimum value of the progress bar.
+ ///
+ [Description("Indicates minimum value of the progress bar."), Category("Behavior"), DefaultValue(0)]
+ public int Minimum
+ {
+ get { return _Minimum; }
+ set
+ {
+ if (value != _Minimum)
+ {
+ int oldValue = _Minimum;
+ _Minimum = value;
+ OnMinimumChanged(oldValue, value);
+ }
+ }
+ }
+ private void OnMinimumChanged(int oldValue, int newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("Minimum"));
+ CoerceValue();
+ }
+
+ private void CoerceValue()
+ {
+ int newValue = _Value;
+ if (_Value < _Minimum)
+ newValue = _Minimum;
+ else if (_Value > _Maximum)
+ newValue = _Maximum;
+ Value = newValue;
+ }
+
+ private Color _ProgressTextColor = Color.Empty;
+ ///
+ /// Gets or sets the color of the progress percentage text.
+ ///
+ [Category("Appearance"), Description("Indicates color of progress percentage text")]
+ public Color ProgressTextColor
+ {
+ get { return _ProgressTextColor; }
+ set { _ProgressTextColor = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeProgressTextColor()
+ {
+ return !_ProgressTextColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetProgressTextColor()
+ {
+ this.ProgressTextColor = Color.Empty;
+ }
+
+ private bool _ProgressTextVisible = false;
+ ///
+ /// Gets or sets whether text that displays the progress bar completion percentage text is visible. Default value is false.
+ ///
+ [DefaultValue(false), Category("Appearance"), Description("Indicates whether text that displays the progress bar completion percentage text is visible")]
+ public bool ProgressTextVisible
+ {
+ get { return _ProgressTextVisible; }
+ set
+ {
+ if (value != _ProgressTextVisible)
+ {
+ bool oldValue = _ProgressTextVisible;
+ _ProgressTextVisible = value;
+ OnProgressTextVisibleChanged(oldValue, value);
+ }
+ }
+ }
+
+ private void OnProgressTextVisibleChanged(bool oldValue, bool newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("ProgressTextVisible"));
+ this.Refresh();
+ }
+
+ private string _ProgressText = "";
+ ///
+ /// Gets or sets the text displayed on top of the circular progress bar.
+ ///
+ [DefaultValue(""), Category("Appearance"), Description("Indicates text displayed on top of the circular progress bar.")]
+ public string ProgressText
+ {
+ get { return _ProgressText; }
+ set
+ {
+ if (value != _ProgressText)
+ {
+ string oldValue = _ProgressText;
+ _ProgressText = value;
+ OnProgressTextChanged(oldValue, value);
+ }
+ }
+ }
+
+ private void OnProgressTextChanged(string oldValue, string newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("ProgressText"));
+ Refresh();
+ }
+
+ private int _Value;
+ ///
+ /// Gets or sets the current value of the progress bar.
+ ///
+ [Description("Indicates current value of the progress bar."), Category("Behavior"), DefaultValue(0)]
+ public int Value
+ {
+ get { return _Value; }
+ set
+ {
+ value = Math.Min(_Maximum, Math.Max(value, _Minimum));
+
+ if (value != _Value)
+ {
+ int oldValue = _Value;
+ _Value = value;
+ OnValueChanged(oldValue, value);
+ }
+ }
+ }
+
+ private void OnValueChanged(int oldValue, int newValue)
+ {
+ if (!_IsEndlessProgressBar)
+ this.Refresh();
+ OnValueChanged(EventArgs.Empty);
+ OnPropertyChanged(new PropertyChangedEventArgs("Value"));
+ }
+
+ ///
+ /// Occurs when Value property has changed.
+ ///
+ public event EventHandler ValueChanged;
+ ///
+ /// Raises ValueChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnValueChanged(EventArgs e)
+ {
+ EventHandler handler = ValueChanged;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Called when property on CircularProgressBar changes.
+ ///
+ /// Property Change Arguments
+ protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
+ {
+ }
+
+ private void MoveEndlessProgressBar()
+ {
+ if (!this.IsRunning || this.IsDisposed || _IsDisposing) return;
+
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new MethodInvoker(delegate()
+ {
+ MoveEndlessProgressBar();
+ }));
+ return;
+ }
+
+ _EndlessProgressValue = ++_EndlessProgressValue % _SpokeCount;
+ this.Refresh();
+ Control container = this.ContainerControl as Control;
+ if (container != null)
+ container.Update();
+ }
+
+ private bool _IsEndlessProgressBar = false;
+ private BackgroundWorker _LoopWorker = null;
+ ///
+ /// Starts the progress bar loop for endless type progress bar. Progress bar will continue to run until Stop() method is called.
+ ///
+ public void Start()
+ {
+ if (_IsRunning) return;
+
+ _IsEndlessProgressBar = true;
+ _IsRunning = true;
+ _LoopWorker = new BackgroundWorker();
+ _LoopWorker.WorkerSupportsCancellation = true;
+ _LoopWorker.DoWork += LoopWorkerDoWork;
+ _LoopWorker.RunWorkerAsync();
+ }
+
+ void LoopWorkerDoWork(object sender, DoWorkEventArgs e)
+ {
+ BackgroundWorker worker = (BackgroundWorker)sender;
+ while (!worker.CancellationPending)
+ {
+ MoveEndlessProgressBar();
+ try
+ {
+ using (
+ System.Threading.ManualResetEvent wait =
+ new System.Threading.ManualResetEvent(false))
+ wait.WaitOne(_AnimationSpeed);
+ //Thread.Sleep(_AnimationSpeed);
+ }
+ catch
+ {
+ e.Cancel = true;
+ }
+ }
+ e.Cancel = true;
+ }
+
+ ///
+ /// Stops the progress bar loop for endless type progress bar.
+ ///
+ public void Stop()
+ {
+ Stop(false);
+ }
+ public void Stop(bool disposing)
+ {
+ if (!_IsRunning) return;
+
+ _IsEndlessProgressBar = false;
+
+ _IsRunning = false;
+ BackgroundWorker worker = _LoopWorker;
+ _LoopWorker = null;
+
+ worker.CancelAsync();
+ while (worker.IsBusy)
+ Application.DoEvents();
+ worker.DoWork -= LoopWorkerDoWork;
+ worker.Dispose();
+ if (!disposing)
+ this.Refresh();
+ }
+
+ private bool _IsRunning = false;
+ ///
+ /// Gets or sets whether endless type progress bar is running.
+ ///
+ [Browsable(false), DefaultValue(false)]
+ public bool IsRunning
+ {
+ get { return _IsRunning; }
+ set
+ {
+ if (_IsRunning != value)
+ {
+ if (value)
+ Start();
+ else
+ Stop();
+ }
+ }
+ }
+
+ private static readonly Color DefaultProgressColor = Color.DarkSlateGray;//Color.FromArgb(143, 223, 95);
+ private Color _ProgressColor = DefaultProgressColor;
+ ///
+ /// Gets or sets the color of the color of progress indicator.
+ ///
+ [Category("Columns"), Description("Indicates color of progress indicator.")]
+ public Color ProgressColor
+ {
+ get { return _ProgressColor; }
+ set { _ProgressColor = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeProgressColor()
+ {
+ return _ProgressColor != DefaultProgressColor;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetProgressColor()
+ {
+ this.ProgressColor = DefaultProgressColor;
+ }
+
+ private int _Diameter = 24;
+ ///
+ /// Gets or sets circular progress indicator diameter in pixels.
+ ///
+ [DefaultValue(24), Category("Appearance"), Description("Indicates circular progress indicator diameter in pixels.")]
+ public int Diameter
+ {
+ get { return _Diameter; }
+ set
+ {
+ if (value != _Diameter)
+ {
+ int oldValue = _Diameter;
+ _Diameter = value;
+ OnDiameterChanged(oldValue, value);
+ }
+ }
+ }
+ private void OnDiameterChanged(int oldValue, int newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("Diameter"));
+ NeedRecalcSize = true;
+ this.Refresh();
+ }
+
+ private eTextPosition _TextPosition = eTextPosition.Left;
+ ///
+ /// Gets or sets the text position in relation to the circular progress indicator.
+ ///
+ [DefaultValue(eTextPosition.Left), Category("Appearance"), Description("Indicatesd text position in relation to the circular progress indicator.")]
+ public eTextPosition TextPosition
+ {
+ get { return _TextPosition; }
+ set
+ {
+ if (value != _TextPosition)
+ {
+ eTextPosition oldValue = _TextPosition;
+ _TextPosition = value;
+ OnTextPositionChanged(oldValue, value);
+ }
+ }
+ }
+ private void OnTextPositionChanged(eTextPosition oldValue, eTextPosition newValue)
+ {
+ NeedRecalcSize = true;
+ this.Refresh();
+ OnPropertyChanged(new PropertyChangedEventArgs("TextPosition"));
+ }
+
+ private bool _TextVisible = true;
+ ///
+ /// Gets or sets whether text/label displayed next to the item is visible.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether caption/label set using Text property is visible.")]
+ public bool TextVisible
+ {
+ get { return _TextVisible; }
+ set
+ {
+ if (value != _TextVisible)
+ {
+ bool oldValue = _TextVisible;
+ _TextVisible = value;
+ OnTextVisibleChanged(oldValue, value);
+ }
+ }
+ }
+
+ private void OnTextVisibleChanged(bool oldValue, bool newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("TextVisible"));
+ NeedRecalcSize = true;
+ this.Refresh();
+ }
+
+ private int _TextWidth = 0;
+ ///
+ /// Gets or sets the suggested text-width. If you want to make sure that text you set wraps over multiple lines you can set suggested text-width so word break is performed.
+ ///
+ [DefaultValue(0), Category("Appearance"), Description("Indicates suggested text-width. If you want to make sure that text you set wraps over multiple lines you can set suggested text-width so word break is performed.")]
+ public int TextWidth
+ {
+ get { return _TextWidth; }
+ set
+ {
+ if (value != _TextWidth)
+ {
+ int oldValue = _TextWidth;
+ _TextWidth = value;
+ OnTextWidthChanged(oldValue, value);
+ }
+ }
+ }
+ private void OnTextWidthChanged(int oldValue, int newValue)
+ {
+ OnPropertyChanged(new PropertyChangedEventArgs("TextWidth"));
+ NeedRecalcSize = true;
+ Refresh();
+ }
+
+ private Padding _TextPadding = new Padding(0, 0, 0, 0);
+ ///
+ /// Gets or sets text padding.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Gets or sets text padding."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public Padding TextPadding
+ {
+ get { return _TextPadding; }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTextPadding()
+ {
+ return _TextPadding.Bottom != 0 || _TextPadding.Top != 0 || _TextPadding.Left != 0 || _TextPadding.Right != 0;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTextPadding()
+ {
+ _TextPadding = new Padding(0, 0, 0, 0);
+ }
+ private void TextPaddingPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ NeedRecalcSize = true;
+ this.Refresh();
+ }
+
+ private Color _TextColor = Color.Empty;
+ ///
+ /// Gets or sets the color of the text label.
+ ///
+ [Category("Columns"), Description("Indicates color of text label.")]
+ public Color TextColor
+ {
+ get { return _TextColor; }
+ set { _TextColor = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTextColor()
+ {
+ return !_TextColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTextColor()
+ {
+ this.TextColor = Color.Empty;
+ }
+
+ private static readonly Color DefaultPieBorderDarkColor = Color.FromArgb(50, Color.Black);
+ private Color _PieBorderDark = DefaultPieBorderDarkColor;
+ ///
+ /// Gets or sets the color of the pie progress bar dark border.
+ ///
+ [Category("Pie"), Description("Indicates color of pie progress bar dark border.")]
+ public Color PieBorderDark
+ {
+ get { return _PieBorderDark; }
+ set { _PieBorderDark = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializePieBorderDark()
+ {
+ return _PieBorderDark != DefaultPieBorderDarkColor;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetPieBorderDark()
+ {
+ this.PieBorderDark = DefaultPieBorderDarkColor;
+ }
+
+ private static readonly Color DefaultPieBorderLightColor = Color.FromArgb(255, Color.White);
+ private Color _PieBorderLight = DefaultPieBorderLightColor;
+ ///
+ /// Gets or sets the color of the pie progress bar light border.
+ ///
+ [Category("Pie"), Description("Indicates color of pie progress bar light border. ")]
+ public Color PieBorderLight
+ {
+ get { return _PieBorderLight; }
+ set { _PieBorderLight = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializePieBorderLight()
+ {
+ return _PieBorderLight != DefaultPieBorderLightColor;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetPieBorderLight()
+ {
+ this.PieBorderLight = DefaultPieBorderLightColor;
+ }
+
+ private static readonly Color DefaultSpokeBorderDarkColor = Color.FromArgb(48, Color.Black);
+ private Color _SpokeBorderDark = DefaultSpokeBorderDarkColor;
+ ///
+ /// Gets or sets the color of the spoke progress bar dark border.
+ ///
+ [Category("Spoke"), Description("Indicates color of spoke progress bar dark border.")]
+ public Color SpokeBorderDark
+ {
+ get { return _SpokeBorderDark; }
+ set { _SpokeBorderDark = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSpokeBorderDark()
+ {
+ return _SpokeBorderDark != DefaultSpokeBorderDarkColor;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSpokeBorderDark()
+ {
+ this.SpokeBorderDark = DefaultSpokeBorderDarkColor;
+ }
+
+ private static readonly Color DefaultSpokeBorderLightColor = Color.FromArgb(255, Color.White);
+ private Color _SpokeBorderLight = DefaultSpokeBorderLightColor;
+ ///
+ /// Gets or sets the color of the spoke progress bar light border.
+ ///
+ [Category("Spoke"), Description("Indicates color of spoke progress bar light border..")]
+ public Color SpokeBorderLight
+ {
+ get { return _SpokeBorderLight; }
+ set { _SpokeBorderLight = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSpokeBorderLight()
+ {
+ return _SpokeBorderLight != DefaultSpokeBorderLightColor;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSpokeBorderLight()
+ {
+ this.SpokeBorderLight = DefaultSpokeBorderLightColor;
+ }
+
+ private string _ProgressTextFormat = "{0}%";
+ ///
+ /// Gets or sets format string for progress value.
+ ///
+ [DefaultValue("{0}%"), Category("Appearance"), Description("Indicates format string for progress value.")]
+ public string ProgressTextFormat
+ {
+ get { return _ProgressTextFormat; }
+ set
+ {
+ if (value != _ProgressTextFormat)
+ {
+ string oldValue = _ProgressTextFormat;
+ _ProgressTextFormat = value;
+ OnProgressTextFormatChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when ProgressTextFormat property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnProgressTextFormatChanged(string oldValue, string newValue)
+ {
+ this.Refresh();
+ OnPropertyChanged(new PropertyChangedEventArgs("ProgressTextFormat"));
+ }
+
+ private int _AnimationSpeed = 100;
+ ///
+ /// Gets or sets the animation speed for endless running progress. Lower number means faster running.
+ ///
+ [DefaultValue(100), Description("Indicates the animation speed for endless running progress. Lower number means faster running."), Category("Behavior")]
+ public int AnimationSpeed
+ {
+ get { return _AnimationSpeed; }
+ set
+ {
+ if (value < 1)
+ value = 1;
+ _AnimationSpeed = value;
+ }
+ }
+ #endregion
+ }
+
+ ///
+ /// Defines available circular progress bar types.
+ ///
+ public enum eCircularProgressType
+ {
+ ///
+ /// Line spokes progress bar.
+ ///
+ Line,
+ ///
+ /// Dot type/FireFox progress bar.
+ ///
+ Dot,
+ ///
+ /// Donut type progress bar.
+ ///
+ Donut,
+ ///
+ /// Spoke type progress bar.
+ ///
+ Spoke,
+ ///
+ /// Pie type progress bar.
+ ///
+ Pie
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorFunctions.cs b/PROMS/DotNetBar Source Code/ColorFunctions.cs
new file mode 100644
index 00000000..d1ab3f8a
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorFunctions.cs
@@ -0,0 +1,441 @@
+namespace DevComponents.DotNetBar
+{
+ using System;
+ using System.Drawing;
+
+ ///
+ /// Summary description for ColorFunctions.
+ ///
+ public class ColorFunctions
+ {
+ private static Color m_HoverBackColor;
+ private static Color m_HoverBackColor2;
+ private static Color m_HoverBackColor3;
+ private static Color m_CheckBoxBackColor;
+ private static Color m_MenuBackColor;
+ private static Color m_MenuFocusBorderColor;
+ private static Color m_PressedBackColor;
+ private static Color m_ToolMenuFocusBackColor;
+ private static Color m_SideRecentlyBackColor;
+ private static Color m_RecentlyUsedOfficeBackColor;
+
+ private static Bitmap m_PushedBrushBmp = null;
+
+ internal static bool ColorsLoaded = false;
+
+ public static void LoadColors()
+ {
+ RefreshColors();
+ if (!ColorsLoaded)
+ Microsoft.Win32.SystemEvents.UserPreferenceChanged += new Microsoft.Win32.UserPreferenceChangedEventHandler(ColorFunctions.PreferenceChanged);
+ ColorsLoaded = true;
+ }
+
+ private static void PreferenceChanged(object sender, Microsoft.Win32.UserPreferenceChangedEventArgs e)
+ {
+ RefreshColors();
+ NativeFunctions.RefreshSettings();
+ BarFunctions.RefreshScreens();
+ }
+
+ private static void RefreshColors()
+ {
+ if (NativeFunctions.ColorDepth >= 16)
+ {
+ int red = (int)((System.Drawing.SystemColors.Highlight.R - System.Drawing.SystemColors.Window.R) * .30 + System.Drawing.SystemColors.Window.R);
+ int green = (int)((System.Drawing.SystemColors.Highlight.G - System.Drawing.SystemColors.Window.G) * .30 + System.Drawing.SystemColors.Window.G);
+ int blue = (int)((System.Drawing.SystemColors.Highlight.B - System.Drawing.SystemColors.Window.B) * .30 + System.Drawing.SystemColors.Window.B);
+ m_HoverBackColor = Color.FromArgb(red, green, blue);
+
+ red = (int)((System.Drawing.SystemColors.Highlight.R - System.Drawing.SystemColors.Window.R) * .45 + System.Drawing.SystemColors.Window.R);
+ green = (int)((System.Drawing.SystemColors.Highlight.G - System.Drawing.SystemColors.Window.G) * .45 + System.Drawing.SystemColors.Window.G);
+ blue = (int)((System.Drawing.SystemColors.Highlight.B - System.Drawing.SystemColors.Window.B) * .45 + System.Drawing.SystemColors.Window.B);
+ m_HoverBackColor2 = Color.FromArgb(red, green, blue);
+
+ red = (int)((System.Drawing.SystemColors.Highlight.R - System.Drawing.SystemColors.Window.R) * .10 + System.Drawing.SystemColors.Window.R);
+ green = (int)((System.Drawing.SystemColors.Highlight.G - System.Drawing.SystemColors.Window.G) * .10 + System.Drawing.SystemColors.Window.G);
+ blue = (int)((System.Drawing.SystemColors.Highlight.B - System.Drawing.SystemColors.Window.B) * .10 + System.Drawing.SystemColors.Window.B);
+ m_HoverBackColor3 = Color.FromArgb(red, green, blue);
+
+ red = (int)((System.Drawing.SystemColors.Highlight.R - System.Drawing.SystemColors.Window.R) * .25 + System.Drawing.SystemColors.Window.R);
+ green = (int)((System.Drawing.SystemColors.Highlight.G - System.Drawing.SystemColors.Window.G) * .25 + System.Drawing.SystemColors.Window.G);
+ blue = (int)((System.Drawing.SystemColors.Highlight.B - System.Drawing.SystemColors.Window.B) * .25 + System.Drawing.SystemColors.Window.B);
+ m_CheckBoxBackColor = Color.FromArgb(red, green, blue);
+
+ if (NativeFunctions.ColorDepth <= 16)
+ {
+ m_MenuBackColor = System.Drawing.SystemColors.ControlLightLight;
+ }
+ else
+ {
+ red = (int)((System.Drawing.SystemColors.Control.R - System.Drawing.Color.White.R) * .20 + System.Drawing.Color.White.R);
+ green = (int)((System.Drawing.SystemColors.Control.G - System.Drawing.Color.White.G) * .20 + System.Drawing.Color.White.G);
+ blue = (int)((System.Drawing.SystemColors.Control.B - System.Drawing.Color.White.B) * .20 + System.Drawing.Color.White.B);
+ m_MenuBackColor = Color.FromArgb(red, green, blue);
+ }
+
+ red = (int)(System.Drawing.SystemColors.ControlDark.R * .80);
+ green = (int)(System.Drawing.SystemColors.ControlDark.G * .80);
+ blue = (int)(System.Drawing.SystemColors.ControlDark.B * .80);
+ m_MenuFocusBorderColor = Color.FromArgb(red, green, blue);
+
+ // and Highlight color
+ red = (int)((System.Drawing.SystemColors.Highlight.R - System.Drawing.SystemColors.Window.R) * .25 + System.Drawing.SystemColors.Window.R);
+ green = (int)((System.Drawing.SystemColors.Highlight.G - System.Drawing.SystemColors.Window.G) * .25 + System.Drawing.SystemColors.Window.G);
+ blue = (int)((System.Drawing.SystemColors.Highlight.B - System.Drawing.SystemColors.Window.B) * .25 + System.Drawing.SystemColors.Window.B);
+ m_PressedBackColor = Color.FromArgb(red, green, blue);
+
+ red = (int)((System.Drawing.SystemColors.Control.R - System.Drawing.Color.White.R) * .80 + System.Drawing.Color.White.R);
+ green = (int)((System.Drawing.SystemColors.Control.G - System.Drawing.Color.White.G) * .80 + System.Drawing.Color.White.G);
+ blue = (int)((System.Drawing.SystemColors.Control.B - System.Drawing.Color.White.B) * .80 + System.Drawing.Color.White.B);
+ m_ToolMenuFocusBackColor = Color.FromArgb(red, green, blue);
+
+ red = (int)((System.Drawing.SystemColors.Control.R - System.Drawing.Color.White.R) * .50 + System.Drawing.Color.White.R);
+ green = (int)((System.Drawing.SystemColors.Control.G - System.Drawing.Color.White.G) * .50 + System.Drawing.Color.White.G);
+ blue = (int)((System.Drawing.SystemColors.Control.B - System.Drawing.Color.White.B) * .50 + System.Drawing.Color.White.B);
+ m_RecentlyUsedOfficeBackColor = Color.FromArgb(red, green, blue);
+
+ m_SideRecentlyBackColor = System.Drawing.SystemColors.Control;
+ }
+ else
+ {
+ m_HoverBackColor = System.Drawing.SystemColors.ControlLightLight;
+ m_HoverBackColor2 = m_HoverBackColor;
+ m_HoverBackColor3 = m_HoverBackColor;
+ m_CheckBoxBackColor = System.Drawing.SystemColors.ControlLight;
+ m_MenuBackColor = System.Drawing.SystemColors.ControlLightLight;
+ m_MenuFocusBorderColor = System.Drawing.SystemColors.ControlDark;
+ m_PressedBackColor = System.Drawing.SystemColors.ControlLight;
+ m_ToolMenuFocusBackColor = System.Drawing.SystemColors.ControlLight;
+ m_RecentlyUsedOfficeBackColor = System.Drawing.SystemColors.ControlLight;
+ m_SideRecentlyBackColor = System.Drawing.SystemColors.Control;
+ }
+
+ if (m_PushedBrushBmp != null)
+ {
+ m_PushedBrushBmp.Dispose();
+ m_PushedBrushBmp = new System.Drawing.Bitmap(2, 2);
+ m_PushedBrushBmp.SetPixel(0, 0, System.Drawing.SystemColors.Control);
+ m_PushedBrushBmp.SetPixel(1, 0, System.Drawing.SystemColors.ControlLightLight);
+ m_PushedBrushBmp.SetPixel(0, 1, System.Drawing.SystemColors.ControlLightLight);
+ m_PushedBrushBmp.SetPixel(1, 1, System.Drawing.SystemColors.Control);
+ }
+ }
+
+ public static Color GetShade(Color color, int shadePercent)
+ {
+ HLSColor hls = RGBToHSL(color);
+ if (hls.Lightness == 0)
+ return HLSToRGB(hls.Hue, shadePercent / 100, hls.Saturation);
+ else
+ return HLSToRGB(hls.Hue, Math.Max(0, (hls.Lightness - shadePercent / 100)), hls.Saturation);
+ }
+
+ public struct HLSColor
+ {
+ public double Hue;
+ public double Lightness;
+ public double Saturation;
+ }
+ //public struct RGBColor
+ //{
+ // public int Red;
+ // public int Green;
+ // public int Blue;
+ //}
+ public static HLSColor RGBToHSL(int Red, int Green, int Blue)
+ {
+ double Max, Min, delta;
+ double rR, rG, rB;
+ HLSColor ret = new HLSColor();
+
+ rR = (double)Red / 255;
+ rG = (double)Green / 255;
+ rB = (double)Blue / 255;
+
+ // Given: rgb each in [0,1].
+ // Desired: h in [0,360] and s in [0,1], except if s=0, then h=UNDEFINED.}
+ Max = Maximum(rR, rG, rB);
+ Min = Minimum(rR, rG, rB);
+ delta = Max - Min;
+ ret.Lightness = (Max + Min) / 2; // {This is the lightness}
+ // {Next calculate saturation}
+
+ if (Max == Min)
+ {
+ // begin {Acrhomatic case}
+ ret.Saturation = 0;
+ ret.Hue = 0;
+ // end {Acrhomatic case}
+ }
+ else
+ {
+ // begin {Chromatic case}
+ // {First calculate the saturation.}
+ if (ret.Lightness <= 0.5)
+ ret.Saturation = (Max - Min) / (Max + Min);
+ else
+ ret.Saturation = (Max - Min) / (2 - Max - Min);
+ // {Next calculate the hue.}
+
+ double delr = (((Max - rR) / 6) + (delta / 2)) / delta;
+ double delg = (((Max - rG) / 6) + (delta / 2)) / delta;
+ double delb = (((Max - rB) / 6) + (delta / 2)) / delta;
+
+ if (rR == Max)
+ ret.Hue = delb - delg; //{Resulting color is between yellow and magenta}
+ else if (rG == Max)
+ ret.Hue = (1d / 3d) + delr - delb; // {Resulting color is between cyan and yellow}
+ else if (rB == Max)
+ ret.Hue = (2d / 3d) + delg - delr;; // {Resulting color is between magenta and cyan}
+
+ if (ret.Hue < 0) ret.Hue += 1;
+ if (ret.Hue > 1) ret.Hue -= 1;
+ }
+ return ret;
+ }
+
+ public static HLSColor RGBToHSL(Color color)
+ {
+ return RGBToHSL(color.R, color.G, color.B);
+ }
+
+ private static double Maximum(double rR, double rG, double rB)
+ {
+ double ret = 0;
+ if (rR > rG)
+ {
+ if (rR > rB)
+ ret = rR;
+ else
+ ret = rB;
+ }
+ else
+ {
+ if (rB > rG)
+ ret = rB;
+ else
+ ret = rG;
+ }
+ return ret;
+ }
+
+ private static double Minimum(double rR, double rG, double rB)
+ {
+ double ret = 0;
+ if (rR < rG)
+ {
+ if (rR < rB)
+ ret = rR;
+ else
+ ret = rB;
+ }
+ else
+ {
+ if (rB < rG)
+ ret = rB;
+ else
+ ret = rG;
+ }
+ return ret;
+ }
+
+ public static Color HLSToRGB(double Hue, double Lightness, double Saturation)
+ {
+ if (Lightness < 0) Lightness = 0; else if (Lightness > 1) Lightness = 1;
+ if (Saturation < 0) Saturation = 0; else if (Saturation > 1) Saturation = 1;
+
+ int r, g, b;
+ double var1, var2;
+ if (Saturation == 0)
+ {
+ r = (int)(Lightness * 255);
+ g = (int)(Lightness * 255);
+ b = (int)(Lightness * 255);
+ }
+ else
+ {
+ if (Lightness < 0.5)
+ {
+ var2 = Lightness * (1 + Saturation);
+ }
+ else
+ {
+ var2 = (Lightness + Saturation) - (Saturation * Lightness);
+ }
+
+ var1 = 2 * Lightness - var2;
+ r = (int)(255 * hue_2_rgb(var1, var2, Hue + (1d / 3d)));
+ g = (int)(255 * hue_2_rgb(var1, var2, Hue));
+ b = (int)(255 * hue_2_rgb(var1, var2, Hue - (1d / 3d)));
+ }
+
+ return Color.FromArgb(r, g, b);
+ }
+
+ private static double hue_2_rgb(double v1, double v2,double vh)
+ {
+ if (vh < 0)
+ {
+ vh += 1;
+ }
+
+ if (vh > 1)
+ {
+ vh -= 1;
+ }
+
+ if ((6 * vh) < 1)
+ {
+ return (v1 + (v2 - v1) * 6 * vh);
+ };
+
+ if ((2 * vh) < 1)
+ {
+ return (v2);
+ };
+
+ if ((3 * vh) < 2)
+ {
+ return (v1 + (v2 - v1) * ((2d / 3d - vh) * 6));
+ };
+
+ return (v1);
+ }
+
+ public static Color HLSToRGB(HLSColor clr)
+ {
+ return HLSToRGB(clr.Hue, clr.Lightness, clr.Saturation);
+ }
+
+ public static System.Drawing.Color HoverBackColor()
+ {
+ return m_HoverBackColor;
+ }
+
+ public static System.Drawing.Color HoverBackColor2()
+ {
+ return m_HoverBackColor2;
+ }
+
+ public static System.Drawing.Color HoverBackColor3()
+ {
+ return m_HoverBackColor3;
+ }
+
+ public static System.Drawing.Color HoverBackColor(System.Drawing.Graphics g)
+ {
+ return g.GetNearestColor(HoverBackColor());
+ }
+
+ public static System.Drawing.Color PressedBackColor()
+ {
+ return m_PressedBackColor;
+ }
+
+ public static System.Drawing.Color PressedBackColor(System.Drawing.Graphics g)
+ {
+ return g.GetNearestColor(PressedBackColor());
+ }
+
+ public static System.Drawing.Color CheckBoxBackColor()
+ {
+ return m_CheckBoxBackColor;
+ }
+
+ public static System.Drawing.Color CheckBoxBackColor(System.Drawing.Graphics g)
+ {
+ return g.GetNearestColor(CheckBoxBackColor());
+ }
+
+ public static System.Drawing.Color ToolMenuFocusBackColor()
+ {
+ return m_ToolMenuFocusBackColor;
+ }
+
+ public static System.Drawing.Color RecentlyUsedOfficeBackColor()
+ {
+ return m_RecentlyUsedOfficeBackColor;
+ }
+
+ public static System.Drawing.Color RecentlyUsedOfficeBackColor(System.Drawing.Graphics g)
+ {
+ return g.GetNearestColor(RecentlyUsedOfficeBackColor());
+ }
+
+ public static System.Drawing.Color SideRecentlyBackColor(System.Drawing.Graphics g)
+ {
+ return g.GetNearestColor(SideRecentlyBackColor());
+ }
+
+ public static System.Drawing.Color SideRecentlyBackColor()
+ {
+ return m_SideRecentlyBackColor;
+ }
+
+ public static System.Drawing.Color ToolMenuFocusBackColor(System.Drawing.Graphics g)
+ {
+ return g.GetNearestColor(ToolMenuFocusBackColor());
+ }
+
+ public static System.Drawing.Color MenuFocusBorderColor()
+ {
+ return m_MenuFocusBorderColor;
+ }
+
+ public static System.Drawing.Color MenuFocusBorderColor(System.Drawing.Graphics g)
+ {
+ return g.GetNearestColor(MenuFocusBorderColor());
+ }
+
+ public static System.Drawing.Color MenuBackColor()
+ {
+ return m_MenuBackColor;
+ }
+
+ public static System.Drawing.Color MenuBackColor(System.Drawing.Graphics g)
+ {
+ return g.GetNearestColor(MenuBackColor());
+ }
+ public static System.Drawing.Brush GetPushedBrush(BaseItem item)
+ {
+ if (item.Parent is GenericItemContainer)
+ {
+ if (!((GenericItemContainer)item.Parent).m_BackgroundColor.IsEmpty)
+ {
+ return new SolidBrush(((GenericItemContainer)item.Parent).m_BackgroundColor);
+ }
+ }
+ else if (item.Parent is SideBarPanelItem)
+ {
+ if (((SideBarPanelItem)item.Parent).BackgroundStyle.ShouldSerializeBackColor1())
+ {
+ return new SolidBrush(((SideBarPanelItem)item.Parent).BackgroundStyle.BackColor1.Color);
+ }
+ else if (((SideBarPanelItem)item.Parent).BackgroundStyle.ShouldSerializeBackColor1())
+ {
+ return new SolidBrush(((SideBarPanelItem)item.Parent).BackgroundStyle.BackColor1.Color);
+ }
+ }
+
+ return ColorFunctions.GetPushedBrush();
+ }
+ public static System.Drawing.TextureBrush GetPushedBrush()
+ {
+ if (m_PushedBrushBmp == null)
+ {
+ m_PushedBrushBmp = new System.Drawing.Bitmap(2, 2);
+ m_PushedBrushBmp.SetPixel(0, 0, System.Drawing.SystemColors.Control);
+ m_PushedBrushBmp.SetPixel(1, 0, System.Drawing.SystemColors.ControlLightLight);
+ m_PushedBrushBmp.SetPixel(0, 1, System.Drawing.SystemColors.ControlLightLight);
+ m_PushedBrushBmp.SetPixel(1, 1, System.Drawing.SystemColors.Control);
+ }
+ return (new System.Drawing.TextureBrush(m_PushedBrushBmp));
+ }
+
+ public static bool IsEqual(Color color1, Color color2)
+ {
+ return color1.A == color2.A && color1.R == color2.R && color1.G == color2.G && color1.B == color2.B;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorPicker.cs b/PROMS/DotNetBar Source Code/ColorPicker.cs
new file mode 100644
index 00000000..0be40a33
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPicker.cs
@@ -0,0 +1,659 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Reflection;
+using System.Windows.Forms;
+using System.Windows.Forms.Design;
+
+namespace DevComponents.UI
+{
+ ///
+ /// Provides popup color picker.
+ ///
+ [ToolboxItem(false)]
+ internal class ColorPicker : UserControl
+ {
+ #region Private Variables
+ private Color[] m_CustomColors=new Color[48];
+ private Rectangle[] m_CustomColorsPos=new Rectangle[48];
+ private object m_ColorScheme=null;
+ private string m_TransText="";
+
+ private TabControl tabControl1;
+ private TabPage tabPage1;
+ private TabPage tabPage2;
+ private TabPage tabPage3;
+ private TabPage tabPage4;
+ private Label label1;
+ private ListBox listScheme;
+ private Button btnOK;
+ private Button btnCancel;
+ private Panel colorPanel;
+ private ListBox listSystem;
+ private ListBox listWeb;
+
+ private Color m_SelectedColor=Color.Empty;
+ private string m_SelectedColorSchemeName="";
+ private Panel colorPreview;
+ private TrackBar transparencyTrack;
+
+ private bool m_Canceled=false;
+
+ private IWindowsFormsEditorService m_EditorService=null;
+
+ ///
+ /// Required designer variable.
+ ///
+ private Container components = null;
+ #endregion
+
+ #region Constructor and Dispose
+ public ColorPicker()
+ {
+ // This call is required by the Windows.Forms Form Designer.
+ InitializeComponent();
+
+ InitCustomColors();
+ InitOtherColors();
+ m_TransText=label1.Text;
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+ #endregion
+
+ #region Component Designer generated code
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.tabControl1 = new System.Windows.Forms.TabControl();
+ this.tabPage1 = new System.Windows.Forms.TabPage();
+ this.listScheme = new System.Windows.Forms.ListBox();
+ this.tabPage2 = new System.Windows.Forms.TabPage();
+ this.listSystem = new System.Windows.Forms.ListBox();
+ this.tabPage3 = new System.Windows.Forms.TabPage();
+ this.listWeb = new System.Windows.Forms.ListBox();
+ this.tabPage4 = new System.Windows.Forms.TabPage();
+ this.colorPanel = new System.Windows.Forms.Panel();
+ this.transparencyTrack = new System.Windows.Forms.TrackBar();
+ this.label1 = new System.Windows.Forms.Label();
+ this.colorPreview = new System.Windows.Forms.Panel();
+ this.btnOK = new System.Windows.Forms.Button();
+ this.btnCancel = new System.Windows.Forms.Button();
+ this.tabControl1.SuspendLayout();
+ this.tabPage1.SuspendLayout();
+ this.tabPage2.SuspendLayout();
+ this.tabPage3.SuspendLayout();
+ this.tabPage4.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.transparencyTrack)).BeginInit();
+ this.SuspendLayout();
+ //
+ // tabControl1
+ //
+ this.tabControl1.Controls.Add(this.tabPage1);
+ this.tabControl1.Controls.Add(this.tabPage2);
+ this.tabControl1.Controls.Add(this.tabPage3);
+ this.tabControl1.Controls.Add(this.tabPage4);
+ this.tabControl1.Location = new System.Drawing.Point(1, 1);
+ this.tabControl1.Name = "tabControl1";
+ this.tabControl1.SelectedIndex = 0;
+ this.tabControl1.Size = new System.Drawing.Size(208, 192);
+ this.tabControl1.TabIndex = 0;
+ this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
+ //
+ // tabPage1
+ //
+ this.tabPage1.Controls.Add(this.listScheme);
+ this.tabPage1.Location = new System.Drawing.Point(4, 22);
+ this.tabPage1.Name = "tabPage1";
+ this.tabPage1.Size = new System.Drawing.Size(200, 166);
+ this.tabPage1.TabIndex = 0;
+ this.tabPage1.Text = "Scheme";
+ //
+ // listScheme
+ //
+ this.listScheme.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.listScheme.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
+ this.listScheme.IntegralHeight = false;
+ this.listScheme.Location = new System.Drawing.Point(0, 0);
+ this.listScheme.Name = "listScheme";
+ this.listScheme.Size = new System.Drawing.Size(200, 166);
+ this.listScheme.TabIndex = 0;
+ this.listScheme.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.DrawColorItem);
+ this.listScheme.SelectedIndexChanged += new System.EventHandler(this.ListSelectionChange);
+ //
+ // tabPage2
+ //
+ this.tabPage2.Controls.Add(this.listSystem);
+ this.tabPage2.Location = new System.Drawing.Point(4, 22);
+ this.tabPage2.Name = "tabPage2";
+ this.tabPage2.Size = new System.Drawing.Size(200, 166);
+ this.tabPage2.TabIndex = 1;
+ this.tabPage2.Text = "System";
+ //
+ // listSystem
+ //
+ this.listSystem.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.listSystem.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
+ this.listSystem.IntegralHeight = false;
+ this.listSystem.Location = new System.Drawing.Point(0, 0);
+ this.listSystem.Name = "listSystem";
+ this.listSystem.Size = new System.Drawing.Size(200, 166);
+ this.listSystem.TabIndex = 1;
+ this.listSystem.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.DrawColorItem);
+ this.listSystem.SelectedIndexChanged += new System.EventHandler(this.ListSelectionChange);
+ //
+ // tabPage3
+ //
+ this.tabPage3.Controls.Add(this.listWeb);
+ this.tabPage3.Location = new System.Drawing.Point(4, 22);
+ this.tabPage3.Name = "tabPage3";
+ this.tabPage3.Size = new System.Drawing.Size(200, 166);
+ this.tabPage3.TabIndex = 2;
+ this.tabPage3.Text = "Web";
+ //
+ // listWeb
+ //
+ this.listWeb.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.listWeb.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
+ this.listWeb.IntegralHeight = false;
+ this.listWeb.Location = new System.Drawing.Point(0, 0);
+ this.listWeb.Name = "listWeb";
+ this.listWeb.Size = new System.Drawing.Size(200, 166);
+ this.listWeb.TabIndex = 1;
+ this.listWeb.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.DrawColorItem);
+ this.listWeb.SelectedIndexChanged += new System.EventHandler(this.ListSelectionChange);
+ //
+ // tabPage4
+ //
+ this.tabPage4.Controls.Add(this.colorPanel);
+ this.tabPage4.Location = new System.Drawing.Point(4, 22);
+ this.tabPage4.Name = "tabPage4";
+ this.tabPage4.Size = new System.Drawing.Size(200, 166);
+ this.tabPage4.TabIndex = 3;
+ this.tabPage4.Text = "Custom";
+ //
+ // colorPanel
+ //
+ this.colorPanel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.colorPanel.Location = new System.Drawing.Point(0, 0);
+ this.colorPanel.Name = "colorPanel";
+ this.colorPanel.Size = new System.Drawing.Size(200, 166);
+ this.colorPanel.TabIndex = 0;
+ this.colorPanel.MouseUp += new System.Windows.Forms.MouseEventHandler(this.CustomColorMouseUp);
+ this.colorPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.PaintCustomColors);
+ //
+ // transparencyTrack
+ //
+ this.transparencyTrack.Enabled = false;
+ this.transparencyTrack.Location = new System.Drawing.Point(1, 204);
+ this.transparencyTrack.Maximum = 255;
+ this.transparencyTrack.Name = "transparencyTrack";
+ this.transparencyTrack.Size = new System.Drawing.Size(200, 45);
+ this.transparencyTrack.TabIndex = 1;
+ this.transparencyTrack.TickFrequency = 16;
+ this.transparencyTrack.Value = 255;
+ this.transparencyTrack.ValueChanged += new System.EventHandler(this.transparencyTrack_ValueChanged);
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(1, 194);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(136, 16);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "Transparency";
+ //
+ // colorPreview
+ //
+ this.colorPreview.BackColor = System.Drawing.Color.White;
+ this.colorPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.colorPreview.Location = new System.Drawing.Point(8, 240);
+ this.colorPreview.Name = "colorPreview";
+ this.colorPreview.Size = new System.Drawing.Size(40, 32);
+ this.colorPreview.TabIndex = 3;
+ this.colorPreview.Paint += new System.Windows.Forms.PaintEventHandler(this.colorPreview_Paint);
+ //
+ // btnOK
+ //
+ this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.btnOK.Location = new System.Drawing.Point(72, 248);
+ this.btnOK.Name = "btnOK";
+ this.btnOK.Size = new System.Drawing.Size(64, 24);
+ this.btnOK.TabIndex = 4;
+ this.btnOK.Text = "OK";
+ this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
+ //
+ // btnCancel
+ //
+ this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.btnCancel.Location = new System.Drawing.Point(142, 248);
+ this.btnCancel.Name = "btnCancel";
+ this.btnCancel.Size = new System.Drawing.Size(64, 24);
+ this.btnCancel.TabIndex = 5;
+ this.btnCancel.Text = "Cancel";
+ this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
+ //
+ // ColorPicker
+ //
+ this.Controls.Add(this.btnCancel);
+ this.Controls.Add(this.btnOK);
+ this.Controls.Add(this.colorPreview);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.tabControl1);
+ this.Controls.Add(this.transparencyTrack);
+ this.DockPadding.All = 1;
+ this.Name = "ColorPicker";
+ this.Size = new System.Drawing.Size(211, 280);
+ this.Paint += new System.Windows.Forms.PaintEventHandler(this.ColorPicker_Paint);
+ this.tabControl1.ResumeLayout(false);
+ this.tabPage1.ResumeLayout(false);
+ this.tabPage2.ResumeLayout(false);
+ this.tabPage3.ResumeLayout(false);
+ this.tabPage4.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.transparencyTrack)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ #region Color Init
+ private void InitCustomColors()
+ {
+ m_CustomColors[0]=Color.FromArgb(255,255,255);
+ m_CustomColors[1]=Color.FromArgb(255,195,198);
+ m_CustomColors[2]=Color.FromArgb(255,227,198);
+ m_CustomColors[3]=Color.FromArgb(255,255,198);
+ m_CustomColors[4]=Color.FromArgb(198,255,198);
+ m_CustomColors[5]=Color.FromArgb(198,255,255);
+ m_CustomColors[6]=Color.FromArgb(198,195,255);
+ m_CustomColors[7]=Color.FromArgb(255,195,255);
+
+ m_CustomColors[8]=Color.FromArgb(231,227,231);
+ m_CustomColors[9]=Color.FromArgb(255,130,132);
+ m_CustomColors[10]=Color.FromArgb(255,195,132);
+ m_CustomColors[11]=Color.FromArgb(255,255,132);
+ m_CustomColors[12]=Color.FromArgb(132,255,132);
+ m_CustomColors[13]=Color.FromArgb(132,255,255);
+ m_CustomColors[14]=Color.FromArgb(132,130,255);
+ m_CustomColors[15]=Color.FromArgb(255,130,255);
+
+ m_CustomColors[16]=Color.FromArgb(198,195,198);
+ m_CustomColors[17]=Color.FromArgb(255,0,0);
+ m_CustomColors[18]=Color.FromArgb(255,130,0);
+ m_CustomColors[19]=Color.FromArgb(255,255,0);
+ m_CustomColors[20]=Color.FromArgb(0,255,0);
+ m_CustomColors[21]=Color.FromArgb(0,255,255);
+ m_CustomColors[22]=Color.FromArgb(0,0,255);
+ m_CustomColors[23]=Color.FromArgb(255,0,255);
+
+ m_CustomColors[24]=Color.FromArgb(132,130,132);
+ m_CustomColors[25]=Color.FromArgb(198,0,0);
+ m_CustomColors[26]=Color.FromArgb(198,65,0);
+ m_CustomColors[27]=Color.FromArgb(198,195,0);
+ m_CustomColors[28]=Color.FromArgb(0,195,0);
+ m_CustomColors[29]=Color.FromArgb(0,195,198);
+ m_CustomColors[30]=Color.FromArgb(0,0,198);
+ m_CustomColors[31]=Color.FromArgb(198,0,198);
+
+ m_CustomColors[32]=Color.FromArgb(66,65,66);
+ m_CustomColors[33]=Color.FromArgb(132,0,0);
+ m_CustomColors[34]=Color.FromArgb(132,65,0);
+ m_CustomColors[35]=Color.FromArgb(132,130,0);
+ m_CustomColors[36]=Color.FromArgb(0,130,0);
+ m_CustomColors[37]=Color.FromArgb(0,130,132);
+ m_CustomColors[38]=Color.FromArgb(0,0,132);
+ m_CustomColors[39]=Color.FromArgb(132,0,132);
+
+ m_CustomColors[40]=Color.FromArgb(0,0,0);
+ m_CustomColors[41]=Color.FromArgb(66,0,0);
+ m_CustomColors[42]=Color.FromArgb(132,65,66);
+ m_CustomColors[43]=Color.FromArgb(66,65,0);
+ m_CustomColors[44]=Color.FromArgb(0,65,0);
+ m_CustomColors[45]=Color.FromArgb(0,65,66);
+ m_CustomColors[46]=Color.FromArgb(0,0,66);
+ m_CustomColors[47]=Color.FromArgb(66,0,66);
+ }
+
+ private void InitOtherColors()
+ {
+ listWeb.BeginUpdate();
+ listWeb.Items.Clear();
+ Type type = typeof(Color);
+ PropertyInfo[] fields=type.GetProperties(BindingFlags.Public | BindingFlags.Static);
+ Color clr=new Color();
+ foreach(PropertyInfo pi in fields)
+ listWeb.Items.Add(pi.GetValue(clr,null));
+ listWeb.EndUpdate();
+
+ listSystem.BeginUpdate();
+ listSystem.Items.Clear();
+ type=typeof(SystemColors);
+ fields=type.GetProperties(BindingFlags.Public | BindingFlags.Static);
+ foreach(PropertyInfo pi in fields)
+ listSystem.Items.Add(pi.GetValue(clr,null));
+ listSystem.EndUpdate();
+ }
+
+ private void InitColorSchemeColors()
+ {
+ if(m_ColorScheme!=null)
+ {
+ if(!tabControl1.TabPages.Contains(tabPage1))
+ {
+ tabControl1.TabPages.Add(tabPage1);
+ }
+ listScheme.BeginUpdate();
+ listScheme.Items.Clear();
+ Type type=m_ColorScheme.GetType();
+ PropertyInfo[] fields=type.GetProperties();
+ foreach(PropertyInfo pi in fields)
+ {
+ if(pi.PropertyType==typeof(Color))
+ listScheme.Items.Add(pi.Name);
+ }
+ listScheme.EndUpdate();
+ }
+ else
+ {
+ if(tabControl1.TabPages.Contains(tabPage1))
+ tabControl1.TabPages.Remove(tabPage1);
+ }
+ }
+ #endregion
+
+ #region Public Interface
+
+ ///
+ /// Gets or sets the reference to the IWindowsFormsEditorService interface used for Windows Forms design time support.
+ ///
+ internal IWindowsFormsEditorService EditorService
+ {
+ get {return m_EditorService;}
+ set {m_EditorService=value;}
+ }
+
+ ///
+ /// Gets or sets the ColorScheme object for Scheme colors.
+ ///
+ [Browsable(false),DefaultValue(null)]
+ public object ColorScheme
+ {
+ get {return m_ColorScheme;}
+ set
+ {
+ m_ColorScheme=value;
+ InitColorSchemeColors();
+ }
+ }
+
+ ///
+ /// Gets or sets currently selected color.
+ ///
+ public Color SelectedColor
+ {
+ get {return m_SelectedColor;}
+ set
+ {
+ m_SelectedColor=value;
+ OnSelectedColorChanged();
+ }
+ }
+
+ ///
+ /// Gets the selected color color scheme name if color scheme color is selected otherwise it returns an empty string.
+ ///
+ public string SelectedColorSchemeName
+ {
+ get {return m_SelectedColorSchemeName;}
+ set {m_SelectedColorSchemeName=value;}
+ }
+
+ ///
+ /// Returns true if color selection was cancelled.
+ ///
+ public bool Canceled
+ {
+ get {return m_Canceled;}
+ }
+ #endregion
+
+ #region Painting
+ private void PaintCustomColors(object sender, PaintEventArgs e)
+ {
+ Rectangle r=Rectangle.Empty;
+ int x=6, y=12;
+ Graphics g=e.Graphics;
+ Border3DSide side=(Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
+ int width=colorPanel.ClientRectangle.Width;
+ int iIndex=0;
+ foreach(Color clr in m_CustomColors)
+ {
+ r=new Rectangle(x,y,21,21);
+ if(r.Right>width)
+ {
+ y+=25;
+ x=6;
+ r.X=x;
+ r.Y=y;
+ }
+ ControlPaint.DrawBorder3D(g,x,y,21,21,Border3DStyle.Sunken,side);
+ r.Inflate(-2,-2);
+ g.FillRectangle(new SolidBrush(clr),r);
+
+ m_CustomColorsPos[iIndex]=r;
+ iIndex++;
+
+ x+=24;
+ }
+ }
+
+ private void DrawColorItem(object sender, DrawItemEventArgs e)
+ {
+ Rectangle r=e.Bounds;
+ Rectangle rClr=new Rectangle(r.X+1,r.Y+2,24,r.Height-4);
+ ListBox list=sender as ListBox;
+
+ Color textColor=SystemColors.ControlText;
+ if((e.State & DrawItemState.Selected)!=0)
+ {
+ textColor=SystemColors.HighlightText;
+ e.Graphics.FillRectangle(SystemBrushes.Highlight,e.Bounds);
+ }
+ else
+ e.Graphics.FillRectangle(SystemBrushes.Window,e.Bounds);
+
+ Color clr=Color.Empty;
+ string colorName="";
+ if(list.Items[e.Index].GetType()==typeof(Color))
+ {
+ clr=(Color)list.Items[e.Index];
+ colorName=clr.Name;
+ }
+ else
+ {
+ colorName=list.Items[e.Index].ToString();
+ clr=(Color)m_ColorScheme.GetType().GetProperty(colorName).GetValue(m_ColorScheme,null);
+ }
+
+ e.Graphics.FillRectangle(new SolidBrush(clr),rClr);
+ e.Graphics.DrawRectangle(SystemPens.ControlText,rClr);
+ r.Offset(30,0);
+ r.Width-=30;
+ DevComponents.DotNetBar.TextDrawing.DrawString(e.Graphics,colorName,list.Font,textColor,r,DevComponents.DotNetBar.eTextFormat.Default);
+ }
+ #endregion
+
+ #region Internals
+
+ private void CustomColorMouseUp(object sender, MouseEventArgs e)
+ {
+ for(int i=0;i<48;i++)
+ {
+ if(m_CustomColorsPos[i].Contains(e.X,e.Y))
+ {
+ this.SelectedColor=m_CustomColors[i];
+ m_SelectedColorSchemeName="";
+ break;
+ }
+ }
+ }
+
+ private void ListSelectionChange(object sender, EventArgs e)
+ {
+ ListBox list=sender as ListBox;
+
+ if(list.SelectedItem!=null)
+ {
+ if(list.SelectedItem is Color)
+ {
+ this.SelectedColor=(Color)list.SelectedItem;
+ m_SelectedColorSchemeName="";
+ }
+ else
+ {
+ m_SelectedColorSchemeName = list.SelectedItem.ToString();
+ this.SelectedColor=(Color)m_ColorScheme.GetType().GetProperty(this.SelectedColorSchemeName).GetValue(m_ColorScheme,null);
+ }
+ }
+ else
+ {
+ this.SelectedColor=Color.Empty;
+ m_SelectedColorSchemeName = "";
+ }
+ }
+
+ private void OnSelectedColorChanged()
+ {
+ colorPreview.BackColor=m_SelectedColor;
+ transparencyTrack.Value=m_SelectedColor.A;
+ UpdateTransparencyText();
+ }
+
+ public void UpdateUIWithSelection()
+ {
+ listSystem.SelectedIndex = -1;
+ listWeb.SelectedIndex = -1;
+ listScheme.SelectedIndex = -1;
+ if (m_SelectedColor.IsSystemColor)
+ {
+ tabControl1.SelectedTab = tabPage2;
+ SelectListBoxItem(listSystem, m_SelectedColor.Name);
+ }
+ else if (m_SelectedColor.IsNamedColor)
+ {
+ tabControl1.SelectedTab = tabPage3;
+ SelectListBoxItem(listWeb, m_SelectedColor.Name);
+ }
+ else if (m_SelectedColorSchemeName != "")
+ {
+ tabControl1.SelectedTab = tabPage1;
+ SelectListBoxItem(listScheme, m_SelectedColorSchemeName);
+ }
+ else
+ {
+ tabControl1.SelectedTab = tabPage4;
+ }
+ }
+
+ private void SelectListBoxItem(ListBox listBox, string item)
+ {
+ foreach (object o in listBox.Items)
+ {
+ if (o.ToString() == item)
+ {
+ listBox.SelectedItem = o;
+ return;
+ }
+ }
+ }
+
+ private void UpdateTransparencyText()
+ {
+ if(!this.SelectedColor.IsEmpty)
+ {
+ label1.Text=m_TransText + " (" + this.SelectedColor.A.ToString()+")";
+ }
+ else
+ label1.Text=m_TransText;
+ }
+
+ private void transparencyTrack_ValueChanged(object sender, EventArgs e)
+ {
+ if(!this.SelectedColor.IsEmpty && this.SelectedColor.A!=transparencyTrack.Value)
+ {
+ this.SelectedColor=Color.FromArgb(transparencyTrack.Value,this.SelectedColor);
+ m_SelectedColorSchemeName="";
+ }
+ UpdateTransparencyText();
+ }
+
+ private void colorPreview_Paint(object sender, PaintEventArgs e)
+ {
+ if(this.SelectedColor.IsEmpty)
+ {
+ Rectangle r=this.colorPreview.ClientRectangle;
+ r.Inflate(-2,-2);
+ e.Graphics.DrawLine(SystemPens.ControlText,r.X,r.Y,r.Right,r.Bottom);
+ e.Graphics.DrawLine(SystemPens.ControlText,r.Right,r.Y,r.X,r.Bottom);
+ }
+ }
+
+ private void btnOK_Click(object sender, EventArgs e)
+ {
+ this.ClosePicker();
+ }
+
+ private void btnCancel_Click(object sender, EventArgs e)
+ {
+ m_Canceled=true;
+ this.ClosePicker();
+ }
+
+ private void ClosePicker()
+ {
+ if(m_EditorService!=null)
+ {
+ m_EditorService.CloseDropDown();
+ }
+ else
+ {
+ if(this.Parent!=null)
+ this.Parent.Hide();
+ else
+ this.Hide();
+ }
+ }
+
+ private void ColorPicker_Paint(object sender, PaintEventArgs e)
+ {
+ Rectangle r=this.ClientRectangle;
+ r.Width--;
+ r.Height--;
+ e.Graphics.DrawRectangle(SystemPens.ControlDarkDark,r);
+ }
+
+ private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
+ {
+ if(tabControl1.SelectedIndex==0 && m_ColorScheme!=null && m_SelectedColorSchemeName!="")
+ transparencyTrack.Enabled=false;
+ else
+ transparencyTrack.Enabled=true;
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorPicker.resx b/PROMS/DotNetBar Source Code/ColorPicker.resx
new file mode 100644
index 00000000..ddae5a77
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPicker.resx
@@ -0,0 +1,319 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ False
+
+
+ True
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ 8, 8
+
+
+ True
+
+
+ False
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ 8, 8
+
+
+ Private
+
+
+ Private
+
+
+ True
+
+
+ True
+
+
+ False
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ 8, 8
+
+
+ Private
+
+
+ True
+
+
+ Private
+
+
+ True
+
+
+ False
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ 8, 8
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ True
+
+
+ False
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ 8, 8
+
+
+ True
+
+
+ False
+
+
+ Private
+
+
+ 8, 8
+
+
+ True
+
+
+ Private
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ True
+
+
+ False
+
+
+ Private
+
+
+ 8, 8
+
+
+ True
+
+
+ Private
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ True
+
+
+ Private
+
+
+ Private
+
+
+ False
+
+
+ True
+
+
+ False
+
+
+ True
+
+
+ 80
+
+
+ (Default)
+
+
+ False
+
+
+ Private
+
+
+ 8, 8
+
+
+ ColorPicker
+
+
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/ColorCombControl.cs b/PROMS/DotNetBar Source Code/ColorPickers/ColorCombControl.cs
new file mode 100644
index 00000000..0fbef30c
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPickers/ColorCombControl.cs
@@ -0,0 +1,427 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.ColorPickers
+{
+ ///
+ /// Represents the color comb control that allows color choice from pre-defined color comb palette.
+ ///
+ [ToolboxItem(true), DefaultEvent("SelectedColorChanged"), DefaultProperty("SelectedColor"), ToolboxBitmap(typeof(ColorCombControl), "ColorPickerItem.ColorCombControl.ico")]
+ public class ColorCombControl : System.Windows.Forms.Control
+ {
+ #region Events
+ ///
+ /// Occurs when SelectedColor has changed.
+ ///
+ public event EventHandler SelectedColorChanged;
+ ///
+ /// Raises SelectedColorChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnSelectedColorChanged(EventArgs e)
+ {
+ EventHandler handler = SelectedColorChanged;
+ if (handler != null)
+ handler(this, e);
+ }
+ #endregion
+
+ #region Private Variables
+ private CombCell[] m_ColorCombs = new CombCell[144];
+ private const float YOffset = .824f;
+ private float[] arrXOffset = new float[] { -0.5f, -1.0f, -0.5f, 0.5f, 1.0f, 0.5f };
+ private float[] arrYOffset = new float[] { YOffset, 0.0f, -YOffset, -YOffset, 0.0f, YOffset };
+ private int CombDepth = 7;
+ private int m_MouseOverIndex = -1;
+ private int m_SelectedIndex = -1;
+
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.Container components = null;
+ #endregion
+
+ #region Constructor, Dispose
+ ///
+ /// Creates new instance of the control.
+ ///
+ public ColorCombControl()
+ {
+ for (int i = 0; i < m_ColorCombs.Length; i++)
+ m_ColorCombs[i] = new CombCell();
+
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
+ InitializeComponent();
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose(disposing);
+ }
+ #endregion
+
+ #region Component Designer generated code
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+ #endregion
+
+ #region Internal Implementation
+ private bool m_AntiAlias = true;
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting. Default value is true.
+ ///
+ [DefaultValue(true), Browsable(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting.")]
+ public bool AntiAlias
+ {
+ get { return m_AntiAlias; }
+ set
+ {
+ if (m_AntiAlias != value)
+ {
+ m_AntiAlias = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ private int GetCellSize(int height)
+ {
+ int cellSize = height / (2 * CombDepth - 1) + 1;
+ if ((int)(Math.Floor((double)cellSize / 2)) * 2 < cellSize)
+ cellSize--;
+ return cellSize;
+ }
+
+ private void InitializeColorComb()
+ {
+ Rectangle clientRect = this.ClientRectangle;
+ clientRect.Inflate(-8, -8);
+ clientRect.Height -= GetCellSize(Math.Min(clientRect.Height, clientRect.Width));
+
+ // Normalize...
+ if (clientRect.Height < clientRect.Width)
+ clientRect.Inflate(-(clientRect.Width - clientRect.Height) / 2, 0);
+ else
+ clientRect.Inflate(0, -(clientRect.Height - clientRect.Width) / 2);
+
+ int cellSize = GetCellSize(clientRect.Height);
+ clientRect.Height -= cellSize * 2;
+ //clientRect.Inflate(-cellSize, 0);
+ int x = (clientRect.Left + clientRect.Right) / 2;
+ int y = (clientRect.Top + clientRect.Bottom) / 2;
+
+ // Center White Comb
+ m_ColorCombs[0].Color = Color.White;
+ m_ColorCombs[0].SetPosition(x, y, cellSize);
+
+ int index = 1;
+ for (int nLevel = 1; nLevel < CombDepth; nLevel++)
+ {
+ float posX = x + (cellSize * nLevel);
+ float posY = y;
+
+ for (int nSide = 0; nSide < CombDepth - 1; nSide++)
+ {
+ int xIncrease = (int)((cellSize) * arrXOffset[nSide]);
+ int yIncrease = (int)((cellSize) * arrYOffset[nSide]);
+
+ for (int nCell = 0; nCell < nLevel; nCell++)
+ {
+ float nAngle = GetAngleFromPoint(posX - x, posY - y);
+ double L = .936 * (CombDepth - nLevel) / CombDepth + .12;
+
+ m_ColorCombs[index].Color = GetRGBFromHLSExtend((float)nAngle, L, 1.0F);
+ m_ColorCombs[index].SetPosition(posX, posY, cellSize);
+ index++;
+
+ posX += xIncrease;
+ posY += yIncrease;
+ }
+ }
+ }
+
+ m_ColorCombs[index].Color = Color.Black;
+ index++;
+ m_ColorCombs[index].Color = Color.White;
+
+ int RGBOffset = 255 / (15 + 2);
+
+ int rgb = 255 - RGBOffset;
+
+ x = clientRect.X + cellSize * 3;
+ y = clientRect.Bottom + cellSize;
+
+ for (int i = 0; i < 15; i++)
+ {
+ Color color = Color.FromArgb(rgb, rgb, rgb);
+ m_ColorCombs[index].Color = color;
+ m_ColorCombs[index].SetPosition(x, y, cellSize);
+ x += cellSize;
+ index++;
+ if (i == 7)
+ {
+ x = clientRect.X + (int)(cellSize * 3.5);
+ y += (int)(cellSize * YOffset);
+ }
+ rgb -= RGBOffset;
+ }
+ m_ColorCombs[index].Color = Color.Black;
+ }
+
+
+ private Color GetRGBFromHLSExtend(double H, double L, double S)
+ {
+ int R, G, B;
+
+ if (S == 0.0)
+ {
+ R = G = B = (int)(L * 255.0);
+ }
+ else
+ {
+ float rm1, rm2;
+
+ if (L <= 0.5f)
+ rm2 = (float)(L + L * S);
+ else
+ rm2 = (float)(L + S - L * S);
+
+ rm1 = (float)(2.0f * L - rm2);
+
+ R = GetRGBFromHue(rm1, rm2, (float)(H + 120.0f));
+ G = GetRGBFromHue(rm1, rm2, (float)(H));
+ B = GetRGBFromHue(rm1, rm2, (float)(H - 120.0f));
+ }
+
+ return Color.FromArgb(R, G, B);
+ }
+
+ private float GetAngleFromPoint(float nX, float nY)
+ {
+ double dAngle = Math.Atan2(nY, nX);
+ return (float)(dAngle * 180.0 / Math.PI);
+ }
+
+ private int GetRGBFromHue(float rm1, float rm2, float rh)
+ {
+ if (rh > 360.0f)
+ rh -= 360.0f;
+ else if (rh < 0.0f)
+ rh += 360.0f;
+
+ if (rh < 60.0f)
+ rm1 = rm1 + (rm2 - rm1) * rh / 60.0f;
+ else if (rh < 180.0f)
+ rm1 = rm2;
+ else if (rh < 240.0f)
+ rm1 = rm1 + (rm2 - rm1) * (240.0f - rh) / 60.0f;
+
+ return (int)(rm1 * 255);
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+
+ if (m_AntiAlias)
+ {
+ e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ e.Graphics.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ using (SolidBrush brush = new SolidBrush(this.BackColor))
+ g.FillRectangle(brush, -1, -1, this.Width + 1, this.Height + 1);
+
+ if (this.BackColor == Color.Transparent || this.BackgroundImage != null)
+ {
+ base.OnPaintBackground(e);
+ }
+
+
+ foreach (CombCell c in m_ColorCombs)
+ c.Draw(g);
+
+ if (m_MouseOverIndex >= 0)
+ m_ColorCombs[m_MouseOverIndex].Draw(g);
+ if (m_SelectedIndex >= 0)
+ m_ColorCombs[m_SelectedIndex].Draw(g);
+
+ base.OnPaint(e);
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ InitializeColorComb();
+ base.OnResize(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+
+ int newMouseOver = GetCellAt(e.X, e.Y);
+ SetMouseOver(newMouseOver);
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ if (m_SelectedIndex >= 0)
+ {
+ m_ColorCombs[m_SelectedIndex].Selected = false;
+ this.Invalidate(m_ColorCombs[m_SelectedIndex].Bounds);
+ }
+ m_SelectedIndex = -1;
+
+ if (m_MouseOverIndex >= 0)
+ {
+ m_SelectedIndex = m_MouseOverIndex;
+ m_ColorCombs[m_SelectedIndex].Selected = true;
+ this.Invalidate(m_ColorCombs[m_SelectedIndex].Bounds);
+ OnSelectedColorChanged(EventArgs.Empty);
+ }
+ }
+ base.OnMouseDown(e);
+ }
+
+ ///
+ /// Gets the color mouse is currently over. If mouse is not over any color in comb Color.Empty is returned.
+ ///
+ [Browsable(false)]
+ public Color MouseOverColor
+ {
+ get
+ {
+ if (m_MouseOverIndex < 0)
+ return Color.Empty;
+ return m_ColorCombs[m_MouseOverIndex].Color;
+ }
+ }
+
+ ///
+ /// Gets or sets the selected color. When setting the color note that color must be already present in the color comb otherwise the selected color will be reset to Color.Empty.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Color SelectedColor
+ {
+ get
+ {
+ if (m_SelectedIndex < 0)
+ return Color.Empty;
+ return m_ColorCombs[m_SelectedIndex].Color;
+ }
+ set
+ {
+ if (value == Color.Empty && m_SelectedIndex >= 0)
+ {
+ m_ColorCombs[m_SelectedIndex].Selected = false;
+ m_SelectedIndex = -1;
+ this.Invalidate();
+ OnSelectedColorChanged(EventArgs.Empty);
+ }
+ else
+ {
+ int colorIndex = GetCombColorIndex(value);
+ if (colorIndex != m_SelectedIndex)
+ {
+ if (m_SelectedIndex >= 0)
+ m_ColorCombs[m_SelectedIndex].Selected = false;
+ m_SelectedIndex = colorIndex;
+ if (m_SelectedIndex >= 0)
+ m_ColorCombs[m_SelectedIndex].Selected = true;
+ this.Invalidate();
+ OnSelectedColorChanged(EventArgs.Empty);
+ }
+ }
+ }
+ }
+ private int GetCombColorIndex(Color value)
+ {
+ for (int i = 0; i < m_ColorCombs.Length; i++)
+ {
+ if (m_ColorCombs[i].Color.Equals(value))
+ return i;
+ }
+ return -1;
+ }
+
+ ///
+ /// Occurs when MouseOverColor property has changed.
+ ///
+ public event EventHandler MouseOverColorChanged;
+ ///
+ /// Raises MouseOverColorChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnMouseOverColorChanged(EventArgs e)
+ {
+ EventHandler handler = MouseOverColorChanged;
+ if (handler != null)
+ handler(this, e);
+ }
+ private void SetMouseOver(int newMouseOver)
+ {
+ if (newMouseOver != m_MouseOverIndex)
+ {
+ if (m_MouseOverIndex >= 0)
+ {
+ m_ColorCombs[m_MouseOverIndex].MouseOver = false;
+ this.Invalidate(m_ColorCombs[m_MouseOverIndex].Bounds);
+ }
+ m_MouseOverIndex = newMouseOver;
+ if (m_MouseOverIndex >= 0)
+ {
+ m_ColorCombs[m_MouseOverIndex].MouseOver = true;
+ this.Invalidate(m_ColorCombs[m_MouseOverIndex].Bounds);
+ }
+ OnMouseOverColorChanged(EventArgs.Empty);
+ }
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+ SetMouseOver(-1);
+ }
+
+ private int GetCellAt(int x, int y)
+ {
+ for (int i = 0; i < m_ColorCombs.Length; i++)
+ {
+ if (m_ColorCombs[i].Bounds.Contains(x, y))
+ {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/ColorCombControl.ico b/PROMS/DotNetBar Source Code/ColorPickers/ColorCombControl.ico
new file mode 100644
index 00000000..8167ada4
Binary files /dev/null and b/PROMS/DotNetBar Source Code/ColorPickers/ColorCombControl.ico differ
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/ColorContrastControl.cs b/PROMS/DotNetBar Source Code/ColorPickers/ColorContrastControl.cs
new file mode 100644
index 00000000..710c61c7
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPickers/ColorContrastControl.cs
@@ -0,0 +1,290 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.ColorPickerItem
+{
+ ///
+ /// Represents the color selection control.
+ ///
+ [ToolboxItem(false)]
+ internal class ColorContrastControl : System.Windows.Forms.Control
+ {
+ #region Events
+ ///
+ /// Occurs when SelectedColor has changed.
+ ///
+ public event EventHandler SelectedColorChanged;
+ ///
+ /// Raises SelectedColorChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnSelectedColorChanged(EventArgs e)
+ {
+ EventHandler handler = SelectedColorChanged;
+ if (handler != null)
+ handler(this, e);
+ }
+ #endregion
+
+ #region Private Variables
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.Container components = null;
+ private Color m_SelectedColor = Color.White;
+ private Bitmap m_BlendBitmap=null;
+ private double m_SelectedLuminance = -1;
+ #endregion
+
+ #region Constructor, Dispose
+ public ColorContrastControl()
+ {
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
+
+ // This call is required by the Windows.Forms Form Designer.
+ InitializeComponent();
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+ #endregion
+
+ #region Internal Implementation
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+
+ if(this.BackColor == Color.Transparent)
+ {
+ base.OnPaintBackground(e);
+ }
+ else
+ {
+ using(SolidBrush brush=new SolidBrush(this.BackColor))
+ g.FillRectangle(brush, this.ClientRectangle);
+ }
+
+ if(m_BlendBitmap!=null)
+ g.DrawImageUnscaled(m_BlendBitmap, 0, 0);
+
+ if(m_SelectedLuminance>=0)
+ {
+ int y = (int)(this.ClientRectangle.Height * (1 - m_SelectedLuminance));
+ int x = m_BlendBitmap.Width + 4;
+ GraphicsPath path = new GraphicsPath();
+ path.AddLine(x, y, x + 7, y - 4);
+ path.AddLine(x+ 7 , y - 4, x + 7, y + 4);
+ path.CloseAllFigures();
+ using(SolidBrush brush=new SolidBrush(Color.Black))
+ g.FillPath(brush, path);
+ path.Dispose();
+ }
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ CreateBlendBitmap();
+ base.OnResize (e);
+ }
+
+
+ private void CreateBlendBitmap()
+ {
+ Rectangle clientRect = this.ClientRectangle;
+
+ Bitmap bmp = new Bitmap(12, clientRect.Height, PixelFormat.Format24bppRgb);
+ using (Graphics graph = Graphics.FromImage(bmp))
+ {
+ graph.FillRectangle(SystemBrushes.Control, clientRect);
+
+ Color color = m_SelectedColor;
+ int ry = color.R, gy = color.G, by = color.B;
+
+ int pointHeight = 4;
+ int pointWidth = 12;
+
+ int x = clientRect.X;
+ int y = clientRect.Y;
+ double h = 0, s = 0, l = 0;
+ GetHSLFromRGB(m_SelectedColor, ref h, ref s, ref l);
+
+ for (int j = clientRect.Y; j < clientRect.Height; j += pointHeight)
+ {
+ double lumCurrent = 1 - (double) j / (double) clientRect.Height;
+ Color c = GetColorFromHSL(h, s, lumCurrent);
+ using (SolidBrush brush = new SolidBrush(c))
+ graph.FillRectangle(brush, new Rectangle(x, y, pointWidth, pointHeight));
+ y += pointHeight;
+ }
+ }
+
+ if(m_BlendBitmap!=null)
+ m_BlendBitmap.Dispose();
+ m_BlendBitmap = bmp;
+ }
+
+ ///
+ /// Gets or sets the selected color.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Color SelectedColor
+ {
+ get
+ {
+ if(m_SelectedLuminance>=0)
+ {
+ double h = 0, s = 0, l = 0;
+ GetHSLFromRGB(m_SelectedColor, ref h, ref s, ref l);
+ return GetColorFromHSL(h, s, m_SelectedLuminance);
+ }
+ return m_SelectedColor;
+ }
+ set
+ {
+ m_SelectedColor = value;
+ double h = 0, s = 0, l = 0;
+ GetHSLFromRGB(m_SelectedColor, ref h, ref s, ref l);
+ //if(m_SelectedLuminance<0)
+ m_SelectedLuminance = l;
+ CreateBlendBitmap();
+ this.Invalidate();
+ }
+ }
+
+ private int GetRGBFromHue(float rm1, float rm2, float rh)
+ {
+ if (rh > 360.0f)
+ rh -= 360.0f;
+ else if (rh < 0.0f)
+ rh += 360.0f;
+
+ if (rh < 60.0f)
+ rm1 = rm1 + (rm2 - rm1) * rh / 60.0f;
+ else if (rh < 180.0f)
+ rm1 = rm2;
+ else if (rh < 240.0f)
+ rm1 = rm1 + (rm2 - rm1) * (240.0f - rh) / 60.0f;
+
+ return (int)(rm1 * 255);
+ }
+
+ private Color GetColorFromHSL( double H, double S, double L)
+ {
+ double r=0,g=0,b=0;
+ double temp1,temp2;
+ if(L==0)
+ {
+ r=g=b=0;
+ }
+ else
+ {
+ if(S==0)
+ {
+ r=g=b=L;
+ }
+ else
+ {
+ temp2 = ((L<=0.5) ? L*(1.0+S) : L+S-(L*S));
+ temp1 = 2.0*L-temp2;
+ double[] t3=new double[]{H+1.0/3.0,H,H-1.0/3.0};
+ double[] clr=new double[]{0,0,0};
+ for(int i=0;i<3;i++)
+ {
+ if(t3[i]<0)
+ t3[i]+=1.0;
+
+ if(t3[i]>1)
+ t3[i]-=1.0;
+
+ if(6.0*t3[i] < 1.0)
+ clr[i]=temp1+(temp2-temp1)*t3[i]*6.0;
+ else if(2.0*t3[i] < 1.0)
+ clr[i]=temp2;
+ else if(3.0*t3[i] < 2.0)
+ clr[i]=(temp1+(temp2-temp1)*((2.0/3.0)-t3[i])*6.0);
+ else
+ clr[i]=temp1;
+ }
+
+ r=clr[0];
+ g=clr[1];
+ b=clr[2];
+ }
+ }
+
+ return Color.FromArgb((int)(255*r),(int)(255*g),(int)(255*b));
+ }
+
+ private void GetHSLFromRGB(Color color, ref double H, ref double S, ref double L )
+ {
+ H=color.GetHue()/360.0; // we store hue as 0-1 as opposed to 0-360
+ L=color.GetBrightness();
+ S=color.GetSaturation();
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ double d = 1 - (double) e.Y / (double) ClientRectangle.Height;
+ SetLuminance(d);
+ base.OnMouseDown (e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ if(e.Button==MouseButtons.Left && e.Y>=0 && e.Y
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ //
+ // ColorContrastControl
+ //
+ this.Name = "ColorContrastControl";
+ this.Size = new System.Drawing.Size(24, 248);
+
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/ColorItem.cs b/PROMS/DotNetBar Source Code/ColorPickers/ColorItem.cs
new file mode 100644
index 00000000..56b28a07
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPickers/ColorItem.cs
@@ -0,0 +1,198 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents color item used for color picker control. Color item can only be used as part of the color picker DotNetBar feature.
+ ///
+ public class ColorItem : BaseItem
+ {
+ #region Private Variables
+ private Color m_Color = Color.Black;
+ private Size m_DesiredSize = new Size(13, 13);
+ private bool m_MouseOver = false;
+ private eColorItemBorder m_Border = eColorItemBorder.All;
+ #endregion
+
+ #region Internal Implementation
+ public ColorItem():this("","") {}
+ public ColorItem(string sName):this(sName,""){}
+ public ColorItem(string sName, string ItemText)
+ : base(sName, ItemText)
+ {
+ this.IsAccessible=false;
+ this.CanCustomize = false;
+ }
+
+ public ColorItem(string sName, string ItemText, Color color)
+ : base(sName, ItemText)
+ {
+ this.IsAccessible = false;
+ this.CanCustomize = false;
+ m_Color = color;
+ }
+
+ public override BaseItem Copy()
+ {
+ ColorItem copy = new ColorItem(m_Name);
+ this.CopyToItem(copy);
+
+ return copy;
+ }
+ protected override void CopyToItem(BaseItem copy)
+ {
+ ColorItem ci = copy as ColorItem;
+ base.CopyToItem(ci);
+ ci.DesiredSize = this.DesiredSize;
+ ci.Color = this.Color;
+ ci.Border = this.Border;
+ if (this.ShouldSerializeDesiredSize())
+ ci.DesiredSize = this.DesiredSize;
+ }
+
+ public override void Paint(ItemPaintArgs p)
+ {
+ Rendering.BaseRenderer renderer = p.Renderer;
+ if (renderer != null)
+ {
+ ColorItemRendererEventArgs e = new ColorItemRendererEventArgs(p.Graphics, this);
+ renderer.DrawColorItem(e);
+ }
+ else
+ {
+ Rendering.ColorItemPainter painter = PainterFactory.CreateColorItemPainter(this);
+ if (painter != null)
+ {
+ ColorItemRendererEventArgs e = new ColorItemRendererEventArgs(p.Graphics, this);
+ painter.PaintColorItem(e);
+ }
+ }
+ }
+
+ public override void RecalcSize()
+ {
+ m_Rect.Size = Dpi.Size(m_DesiredSize);
+ base.RecalcSize();
+ }
+
+ ///
+ /// Gets or sets the color represented by this item. Default value is Color.Black.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DevCoSerialize(), Category("Appearance"), Description("Indicates the color represented by this item.")]
+ public System.Drawing.Color Color
+ {
+ get { return m_Color; }
+ set
+ {
+ m_Color = value;
+ OnAppearanceChanged();
+ }
+ }
+ private bool ShouldSerializeColor()
+ {
+ return (m_Color != Color.Black);
+ }
+
+ ///
+ /// Gets or sets the size of the item when displayed. Default value is 13x13 pixels.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DevCoSerialize(), Category("Appearance"), Description("Indicates the size of the item when displayed.")]
+ public System.Drawing.Size DesiredSize
+ {
+ get { return m_DesiredSize; }
+ set
+ {
+ if (value.Width > 0 && value.Height > 0)
+ {
+ m_DesiredSize = value;
+ NeedRecalcSize = true;
+ OnAppearanceChanged();
+ }
+ }
+ }
+ private bool ShouldSerializeDesiredSize()
+ {
+ return (m_DesiredSize.Width!=13 || m_DesiredSize.Height!=13);
+ }
+
+ ///
+ /// Gets or sets border drawn around the item. Default value is eColorItemBorder.All which indicates that border is drawn
+ /// on all four sides.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(eColorItemBorder.All), Description("Indicate border drawn around the item"), DevCoSerialize()]
+ public eColorItemBorder Border
+ {
+ get { return m_Border; }
+ set
+ {
+ m_Border = value;
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Gets whether mouse is over the item.
+ ///
+ public bool IsMouseOver
+ {
+ get { return m_MouseOver; }
+ }
+
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseEnter()
+ {
+ base.InternalMouseEnter();
+ SetMouseOver(true);
+ BaseItem parent = this.Parent;
+ while (parent != null && !(parent is ColorPickerDropDown))
+ parent = parent.Parent;
+ if (parent != null && parent is ColorPickerDropDown)
+ ((ColorPickerDropDown)parent).InvokeColorPreview(new ColorPreviewEventArgs(this.Color, this));
+ }
+
+
+ [System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseLeave()
+ {
+ base.InternalMouseLeave();
+ SetMouseOver(false);
+ }
+
+ private void SetMouseOver(bool value)
+ {
+ if (value != m_MouseOver)
+ {
+ m_MouseOver = value;
+ this.Refresh();
+ }
+ }
+ #endregion
+
+ #region Serialization
+ ///
+ /// Overloaded. Serializes the item and all sub-items into the XmlElement.
+ ///
+ /// XmlElement to serialize the item to.
+ protected internal override void Serialize(ItemSerializationContext context)
+ {
+ base.Serialize(context);
+ System.Xml.XmlElement xml = context.ItemXmlElement;
+ ElementSerializer.Serialize(this, xml);
+ }
+
+ //
+ /// Overloaded. Deserializes the Item from the XmlElement.
+ ///
+ /// Source XmlElement.
+ public override void Deserialize(ItemSerializationContext context)
+ {
+ base.Deserialize(context);
+ System.Xml.XmlElement xml = context.ItemXmlElement;
+ ElementSerializer.Deserialize(this, xml);
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/ColorPickerDropDown.cs b/PROMS/DotNetBar Source Code/ColorPickers/ColorPickerDropDown.cs
new file mode 100644
index 00000000..525f5107
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPickers/ColorPickerDropDown.cs
@@ -0,0 +1,978 @@
+using System;
+using System.Text;
+using System.Collections;
+using System.Drawing;
+using System.ComponentModel;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the color picker drop down button.
+ ///
+ [DefaultEvent("SelectedColorChanged")]
+ public class ColorPickerDropDown : ButtonItem
+ {
+ #region Events
+ ///
+ /// Occurs when color is chosen from drop-down color picker or from Custom Colors dialog box. Selected color can be accessed through SelectedColor property.
+ ///
+ [Description("Occurs when color is chosen from drop-down color picker or from Custom Colors dialog box.")]
+ public event EventHandler SelectedColorChanged;
+
+ ///
+ /// Occurs when mouse is moving over the colors presented by the color picker. You can use it to preview the color before it is selected.
+ ///
+ [Description("Occurs when mouse is moving over the colors presented by the color picker")]
+ public event ColorPreviewEventHandler ColorPreview;
+
+ ///
+ /// Occurs before color picker dialog is shown. Data property of the event arguments will hold the reference to the Form about to be shown.
+ ///
+ public event CancelObjectValueEventHandler BeforeColorDialog;
+ #endregion
+
+ #region Private Variables
+ private bool m_ColorsInitialized = false;
+ private bool m_DisplayThemeColors = true;
+ private bool m_DisplayStandardColors = true;
+ private bool m_DisplayMoreColors = true;
+
+ private bool m_Localized = false;
+ private string m_ThemeColorsLabel = "Theme Colors";
+ private string m_StandardColorsLabel = "Standard Colors";
+ private string m_MoreColorsLabel = "&More Colors...";
+ private Color m_SelectedColor = System.Drawing.Color.Empty;
+ private Rectangle m_SelectedColorRectangle = Rectangle.Empty;
+ private bool m_SelectedImageCreated = false;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Creates new instance of ButtonItem.
+ ///
+ public ColorPickerDropDown() : this("", "") { }
+ ///
+ /// Creates new instance of ButtonItem and assigns the name to it.
+ ///
+ /// Item name.
+ public ColorPickerDropDown(string sItemName) : this(sItemName, "") { }
+ ///
+ /// Creates new instance of ButtonItem and assigns the name and text to it.
+ ///
+ /// Item name.
+ /// item text.
+ public ColorPickerDropDown(string sItemName, string ItemText)
+ : base(sItemName, ItemText)
+ {
+ //this.AutoExpandOnClick = true;
+ this.SubItems.Add(new ButtonItem("tempColorPickerItem"));
+ }
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Returns copy of the item.
+ ///
+ public override BaseItem Copy()
+ {
+ ColorPickerDropDown objCopy = new ColorPickerDropDown();
+ this.CopyToItem(objCopy);
+ return objCopy;
+ }
+ ///
+ /// Copies the ButtonItem specific properties to new instance of the item.
+ ///
+ /// New ButtonItem instance.
+ protected override void CopyToItem(BaseItem c)
+ {
+ ColorPickerDropDown copy = c as ColorPickerDropDown;
+ copy.DisplayMoreColors = this.DisplayMoreColors;
+ copy.DisplayStandardColors = this.DisplayStandardColors;
+ copy.DisplayThemeColors = this.DisplayThemeColors;
+ copy.SelectedColorChanged = this.SelectedColorChanged;
+ copy.CustomStandardColors = GetCopy(this.CustomStandardColors);
+ copy.CustomThemeColors = GetCopy(this.CustomThemeColors);
+ copy.SelectedColorImageRectangle = this.SelectedColorImageRectangle;
+ copy.SelectedColor = this.SelectedColor;
+
+ base.CopyToItem(copy);
+ }
+
+ private ColorItem[][] GetCopy(ColorItem[][] colorItems)
+ {
+ if (colorItems == null || colorItems.Length == 0)
+ return null;
+ ColorItem[][] copies=new ColorItem[colorItems.Length][];
+ for (int i = 0; i < colorItems.Length; i++)
+ {
+ ColorItem[] items = colorItems[i];
+ copies[i]=new ColorItem[items.Length];
+ for (int j = 0; j < items.Length; j++)
+ {
+ copies[i][j] = (ColorItem) items[j].Copy();
+ }
+ }
+
+ return copies;
+ }
+
+
+ ///
+ /// Raises the ColorPreview event.
+ ///
+ /// Provides the data for the event.
+ protected virtual void OnColorPreview(ColorPreviewEventArgs e)
+ {
+ if (ColorPreview != null)
+ ColorPreview(this, e);
+ }
+
+ ///
+ /// Invokes the ColorPreview event.
+ ///
+ /// Provides data for the event.
+ public void InvokeColorPreview(ColorPreviewEventArgs e)
+ {
+ OnColorPreview(e);
+ }
+
+ ///
+ /// Gets or sets the last selected color from either the drop-down or Custom Color dialog box. Default value is
+ /// Color.Empty. You can use SelectedColorChanged event to be notified when this property changes.
+ ///
+ [Browsable(false), DevCoBrowsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Color SelectedColor
+ {
+ get { return m_SelectedColor; }
+ set { SetSelectedColor(value, false); }
+ }
+
+ ///
+ /// Gets or sets whether theme colors are displayed on drop-down. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), DevCoBrowsable(true), DevCoSerialize(), Category("Appearance"), Description("Indicates whether theme colors are displayed on drop-down.")]
+ public bool DisplayThemeColors
+ {
+ get { return m_DisplayThemeColors; }
+ set { m_DisplayThemeColors = value; }
+ }
+
+ ///
+ /// Gets or sets whether standard colors are displayed on drop-down. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), DevCoBrowsable(true), DevCoSerialize(), Category("Appearance"), Description("Indicates whether standard colors are displayed on drop-down.")]
+ public bool DisplayStandardColors
+ {
+ get { return m_DisplayStandardColors; }
+ set { m_DisplayStandardColors = value; }
+ }
+
+ ///
+ /// Gets or sets more colors menu item is visible which allows user to open Custom Colors dialog box. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), DevCoBrowsable(true), DevCoSerialize(), Category("Appearance"), Description("Indicates more colors menu item is visible which allows user to open Custom Colors dialog box.")]
+ public bool DisplayMoreColors
+ {
+ get { return m_DisplayMoreColors; }
+ set { m_DisplayMoreColors = value; }
+ }
+
+ ///
+ /// Indicates whether SubItems collection is serialized. ColorPickerDropDown does not serialize the sub items.
+ ///
+ protected override bool ShouldSerializeSubItems()
+ {
+ return false;
+ }
+
+ ///
+ /// Gets or sets the rectangle in Image coordinates where selected color will be painted. Setting this property will
+ /// have an effect only if Image property is used to set the image. Default value is an empty rectangle which indicates
+ /// that selected color will not be painted on the image.
+ ///
+ [Browsable(true), Description("Indicates rectangle in Image coordinates where selected color will be painted. Property will have effect only if Image property is used to set the image."), Category("Behaviour")]
+ public Rectangle SelectedColorImageRectangle
+ {
+ get { return m_SelectedColorRectangle; }
+ set
+ {
+ m_SelectedColorRectangle = value;
+ UpdateSelectedColorImage();
+ }
+ }
+
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSelectedColorImageRectangle()
+ {
+ return !m_SelectedColorRectangle.IsEmpty;
+ }
+
+ ///
+ /// Resets the property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSelectedColorImageRectangle()
+ {
+ SelectedColorImageRectangle = Rectangle.Empty;
+ }
+
+ /////
+ ///// Indicates whether the item will auto-expand when clicked.
+ ///// When item is on top level bar and not on menu and contains sub-items, sub-items will be shown only if user
+ ///// click the expand part of the button. Setting this property to true will expand the button and show sub-items when user
+ ///// clicks anywhere inside of the button. Default value is true which indicates that button is expanded only
+ ///// if its expand part is clicked.
+ /////
+ //[DefaultValue(true), Browsable(true), DevCoBrowsable(true), Category("Behavior"), Description("Indicates whether the item will auto-expand (display pop-up menu or toolbar) when clicked.")]
+ //public override bool AutoExpandOnClick
+ //{
+ // get { return base.AutoExpandOnClick; }
+ // set { base.AutoExpandOnClick = value; }
+ //}
+
+ ///
+ /// Gets whether internal representation of color items on popup has been initialized.
+ ///
+ [Browsable(false)]
+ public bool ColorsInitialized
+ {
+ get
+ {
+ return m_ColorsInitialized;
+ }
+ }
+
+ protected override void OnStyleChanged()
+ {
+ m_ColorsInitialized = false;
+ base.OnStyleChanged();
+ }
+
+ protected override void OnPopupOpen(PopupOpenEventArgs e)
+ {
+ base.OnPopupOpen(e); // Fire events first then initialize
+ if (!m_ColorsInitialized)
+ InitializeColorDropDown();
+ }
+
+ private void InitializeColorDropDown()
+ {
+ this.SubItems.Clear();
+
+ LoadResources();
+ if (m_DisplayThemeColors)
+ {
+ LabelItem label = new LabelItem();
+ label.CanCustomize = false;
+ label.Text = m_ThemeColorsLabel;
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ label.BackColor = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.Gallery.GroupLabelBackground;
+ label.ForeColor = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.Gallery.GroupLabelText;
+ label.SingleLineColor = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.Gallery.GroupLabelBorder;
+ }
+ else
+ {
+ label.BackColor = ColorScheme.GetColor("DDE7EE");
+ label.ForeColor = ColorScheme.GetColor("00156E");
+ label.SingleLineColor = ColorScheme.GetColor("C5C5C5");
+ }
+ label.PaddingBottom = 1;
+ label.PaddingLeft = 0;
+ label.PaddingRight = 0;
+ label.PaddingTop = 1;
+ label.BorderSide = eBorderSide.Bottom;
+ label.BorderType = eBorderType.SingleLine;
+ this.SubItems.Add(label);
+ ArrayList colors = this.GetThemeColors();
+ AddColors(colors);
+ }
+
+ if (m_DisplayStandardColors)
+ {
+ LabelItem label = new LabelItem();
+ label.CanCustomize = false;
+ label.Text = m_StandardColorsLabel;
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ label.BackColor = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.QuickAccessToolbar.QatCustomizeMenuLabelBackground;
+ label.ForeColor = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.QuickAccessToolbar.QatCustomizeMenuLabelText;
+ label.SingleLineColor = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.Gallery.GroupLabelBorder;
+ }
+ else
+ {
+ label.BackColor = ColorScheme.GetColor("DDE7EE");
+ label.ForeColor = ColorScheme.GetColor("00156E");
+ label.SingleLineColor = ColorScheme.GetColor("C5C5C5");
+ }
+ label.PaddingBottom = 1;
+ label.PaddingLeft = 0;
+ label.PaddingRight = 0;
+ label.PaddingTop = 1;
+ label.BorderSide = eBorderSide.Bottom;
+ label.BorderType = eBorderType.SingleLine;
+ this.SubItems.Add(label);
+ ArrayList colors = this.GetStandardColors();
+ AddColors(colors);
+ }
+
+ if (m_DisplayMoreColors)
+ {
+ ButtonItem button = new ButtonItem("sys_CPMoreColors", m_MoreColorsLabel);
+ button.CanCustomize = false;
+ button.Image = BarFunctions.LoadBitmap("SystemImages.ColorPickerCustomColors.png");
+ button.Click += new EventHandler(MoreColorsButtonClick);
+ button.BeginGroup = true;
+ this.SubItems.Add(button);
+ }
+
+ m_ColorsInitialized = true;
+
+ OnColorItemsInitialized(EventArgs.Empty);
+ }
+
+ ///
+ /// "Occurs after popup colors have been added to the SubItems collection. This event can be used to effectively add custom items to the popup.
+ ///
+ [Description("Occurs after popup colors have been added to the SubItems collection. This event can be used to effectively add custom items to the popup.")]
+ public event EventHandler ColorItemsInitialized;
+
+ ///
+ /// Raises RemovingToken event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnColorItemsInitialized(EventArgs e)
+ {
+ EventHandler handler = ColorItemsInitialized;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ private void MoreColorsButtonClick(object sender, EventArgs e)
+ {
+ DisplayMoreColorsDialog();
+ }
+
+ ///
+ /// Displays the Colors dialog that allows user to choose the color or create a custom color. If new color is chosen the
+ /// SelectedColorChanged event is raised.
+ ///
+ public DialogResult DisplayMoreColorsDialog()
+ {
+ DialogResult result = DialogResult.Cancel;
+
+ if (StyleManager.IsMetro(this.EffectiveStyle))
+ {
+ ColorPickerItem.CustomColorDialogMetro d = new ColorPickerItem.CustomColorDialogMetro();
+ d.SetStyle(this.EffectiveStyle);
+ d.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ if (!this.SelectedColor.IsEmpty)
+ d.CurrentColor = this.SelectedColor;
+ LocalizeDialog(d);
+ CancelObjectValueEventArgs e = new CancelObjectValueEventArgs(d);
+ OnBeforeColorDialog(e);
+ if (e.Cancel)
+ {
+ d.Dispose();
+ return DialogResult.None;
+ }
+ if (_OwnerWindow != null)
+ {
+ if (_OwnerWindow is Form && ((Form)_OwnerWindow).TopMost)
+ d.TopMost = true;
+ d.ShowDialog(_OwnerWindow);
+ }
+ else
+ d.ShowDialog();
+
+ result = d.DialogResult;
+ if (result == System.Windows.Forms.DialogResult.OK)
+ {
+ if (!d.NewColor.IsEmpty)
+ {
+ this.SetSelectedColor(d.NewColor);
+ }
+ }
+
+ d.Dispose();
+ }
+ else
+ {
+ ColorPickerItem.CustomColorDialog d = new ColorPickerItem.CustomColorDialog();
+ d.SetStyle(this.EffectiveStyle);
+ d.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ if (!this.SelectedColor.IsEmpty)
+ d.CurrentColor = this.SelectedColor;
+ LocalizeDialog(d);
+ CancelObjectValueEventArgs e = new CancelObjectValueEventArgs(d);
+ OnBeforeColorDialog(e);
+ if (e.Cancel)
+ {
+ d.Dispose();
+ return DialogResult.None;
+ }
+ if (_OwnerWindow != null)
+ {
+ if (_OwnerWindow is Form && ((Form)_OwnerWindow).TopMost)
+ d.TopMost = true;
+ d.ShowDialog(_OwnerWindow);
+ }
+ else
+ d.ShowDialog();
+
+ result = d.DialogResult;
+ if (result == System.Windows.Forms.DialogResult.OK)
+ {
+ if (!d.NewColor.IsEmpty)
+ {
+ this.SetSelectedColor(d.NewColor);
+ }
+ }
+
+ d.Dispose();
+ }
+ return result;
+ }
+
+ ///
+ /// Raises the BeforeColorDialog event.
+ ///
+ ///
+ protected virtual void OnBeforeColorDialog(CancelObjectValueEventArgs e)
+ {
+ CancelObjectValueEventHandler h = this.BeforeColorDialog;
+ if (h != null)
+ h(this, e);
+ }
+
+ private IWin32Window _OwnerWindow = null;
+ ///
+ /// Gets or sets the Owner Window that will be used as owner for the colors modal dialog when displayed.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public IWin32Window OwnerWindow
+ {
+ get { return _OwnerWindow; }
+ set { _OwnerWindow = value; }
+ }
+
+ private void LocalizeDialog(ColorPickerItem.CustomColorDialog d)
+ {
+ if (this.GetOwner() != null)
+ m_Localized = true;
+ using (LocalizationManager lm = new LocalizationManager(this.GetOwner() as IOwnerLocalize))
+ {
+ string s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogOKButton);
+ if (s != "") d.buttonOK.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogCancelButton);
+ if (s != "") d.buttonCancel.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogNewColorLabel);
+ if (s != "") d.labelNewColor.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogCurrentColorLabel);
+ if (s != "") d.labelCurrentColor.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogStandardColorsLabel);
+ if (s != "") d.labelStandardColors.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogCustomColorsLabel);
+ if (s != "") d.labelCustomColors.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogGreenLabel);
+ if (s != "") d.labelGreen.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogBlueLabel);
+ if (s != "") d.labelBlue.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogRedLabel);
+ if (s != "") d.labelRed.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerTabStandard);
+ if (s != "") d.tabItemStandard.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerTabCustom);
+ if (s != "") d.tabItemCustom.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerCaption);
+ if (s != "") d.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogColorModelLabel);
+ if (s != "") d.labelColorModel.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogRgbLabel);
+ if (s != "") d.comboColorModel.Items[0] = s;
+ }
+ }
+ private void LocalizeDialog(ColorPickerItem.CustomColorDialogMetro d)
+ {
+ if (this.GetOwner() != null)
+ m_Localized = true;
+ using (LocalizationManager lm = new LocalizationManager(this.GetOwner() as IOwnerLocalize))
+ {
+ string s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogOKButton);
+ if (s != "") d.buttonOK.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogCancelButton);
+ if (s != "") d.buttonCancel.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogNewColorLabel);
+ if (s != "") d.labelNewColor.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogCurrentColorLabel);
+ if (s != "") d.labelCurrentColor.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogStandardColorsLabel);
+ if (s != "") d.labelStandardColors.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogCustomColorsLabel);
+ if (s != "") d.labelCustomColors.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogGreenLabel);
+ if (s != "") d.labelGreen.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogBlueLabel);
+ if (s != "") d.labelBlue.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogRedLabel);
+ if (s != "") d.labelRed.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerTabStandard);
+ if (s != "") d.tabItemStandard.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerTabCustom);
+ if (s != "") d.tabItemCustom.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerCaption);
+ if (s != "") d.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogColorModelLabel);
+ if (s != "") d.labelColorModel.Text = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerDialogRgbLabel);
+ if (s != "") d.comboColorModel.Items[0] = s;
+ }
+ }
+
+ private void AddColors(ArrayList colors)
+ {
+ int colorItemSpacing = 3;
+ for (int i = 0; i < colors.Count; i++)
+ {
+ ItemContainer cont = new ItemContainer();
+ cont.Orientation = eOrientation.Horizontal;
+ cont.ItemSpacing = colorItemSpacing;
+ if (i == 0)
+ {
+ cont.BackgroundStyle.MarginBottom = 5;
+ cont.BackgroundStyle.MarginTop = 3;
+ }
+ if (i == colors.Count - 1)
+ cont.BackgroundStyle.MarginBottom = 3;
+
+ ColorItem[] colorLine = (ColorItem[])colors[i];
+ foreach (ColorItem ci in colorLine)
+ {
+ cont.SubItems.Add(ci);
+ ci.Click += new EventHandler(ColorItemClick);
+ ci.AutoCollapseOnClick = false;
+ }
+ this.SubItems.Add(cont);
+ }
+ }
+
+ private void ColorItemClick(object sender, EventArgs e)
+ {
+ ColorItem ci = sender as ColorItem;
+ if (ci == null)
+ return;
+
+ SetSelectedColor(ci.Color);
+ if (AutoCollapseOnClick)
+ BaseItem.CollapseAll(this);
+ else if (this.PopupControl != null)
+ this.PopupControl.Invalidate();
+ }
+
+ private void SetSelectedColor(Color c)
+ {
+ SetSelectedColor(c, true);
+ }
+
+ private void SetSelectedColor(Color c, bool raiseClick)
+ {
+ bool valueChanged = (m_SelectedColor != c);
+ m_SelectedColor = c;
+
+ OnSelectedColorChanged(new EventArgs());
+ if (raiseClick)
+ RaiseClick();
+
+ if (valueChanged && ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "SelectedColor");
+
+ UpdateSelectedColorImage();
+ }
+
+ protected override void ScaleItem(SizeF factor)
+ {
+ base.ScaleItem(factor);
+ UpdateSelectedColorImage();
+ }
+
+ ///
+ /// Update the selected color image if the SelectedColorImageRectangle has been set and button is using Image property to display the image.
+ ///
+ public void UpdateSelectedColorImage()
+ {
+ if (m_SelectedColorRectangle.IsEmpty || m_SelectedColorRectangle.Width <= 0 || m_SelectedColorRectangle.Height <= 0 ||
+ this.Image == null || this.DesignMode) return;
+
+ Bitmap bmp = new Bitmap(this.Image.Width, this.Image.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ using (Graphics g = Graphics.FromImage(bmp))
+ {
+ Rectangle r = m_SelectedColorRectangle;
+ g.DrawImage(this.Image, 0, 0, this.Image.Width, this.Image.Height);
+ Color selColor = this.SelectedColor;
+ bool noColor = false;
+ if (selColor.IsEmpty || selColor == Color.Transparent)
+ {
+ selColor = Color.White;
+ noColor = true;
+ }
+ using (SolidBrush b = new SolidBrush(selColor))
+ {
+ g.FillRectangle(b, r);
+ }
+ if (noColor && r.Height > 5)
+ {
+ r.Width--;
+ r.Height--;
+ using (Pen p = new Pen(Color.Black))
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+ g.DrawLine(p, r.X, r.Y, r.Right, r.Bottom);
+ g.DrawLine(p, r.Right, r.Y, r.X, r.Bottom);
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
+ }
+ }
+ }
+ if (m_SelectedImageCreated)
+ {
+ Image img = this.Image;
+ this.Image = bmp;
+ img.Dispose();
+ }
+ else
+ this.Image = bmp;
+ m_SelectedImageCreated = true;
+ }
+
+#if FRAMEWORK20
+ private ColorItem[][] _CustomThemeColors = null;
+ ///
+ /// Gets or sets the array of ColorItem objects that will be used as theme colors instead of built-in color palette.
+ /// See: http://www.devcomponents.com/kb2/?p=79 for instructions.
+ ///
+ [DefaultValue(null), Category("Colors"), Description("Array of ColorItem objects that will be used as theme colors instead of built-in color palette.")]
+ public ColorItem[][] CustomThemeColors
+ {
+ get { return _CustomThemeColors; }
+ set
+ {
+ _CustomThemeColors = value;
+ m_ColorsInitialized = false;
+ }
+ }
+#endif
+
+ ///
+ /// Gets collection of ColorItem[] arrays that represent themed colors. Each ColorItem[] array is used to represent single line of theme colors.
+ ///
+ /// Collection of ColorItem[] arrays.
+ protected virtual ArrayList GetThemeColors()
+ {
+ ArrayList colors = new ArrayList();
+#if FRAMEWORK20
+ if (_CustomThemeColors == null || _CustomThemeColors.Length == 0)
+#endif
+ {
+ eDotNetBarStyle effectiveStyle = EffectiveStyle;
+ if (effectiveStyle == eDotNetBarStyle.Office2010 || StyleManager.IsMetro(effectiveStyle))
+ {
+ colors.Add(new ColorItem[] {
+ GetColorItem("FFFFFF"),
+ GetColorItem("000000"),
+ GetColorItem("EEECE1"),
+ GetColorItem("1F497D"),
+ GetColorItem("4F81BD"),
+ GetColorItem("C0504D"),
+ GetColorItem("9BBB59"),
+ GetColorItem("8064A2"),
+ GetColorItem("4BACC6"),
+ GetColorItem("F79646")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemTop("F2F2F2"),
+ GetColorItemTop("7F7F7F"),
+ GetColorItemTop("DDD9C3"),
+ GetColorItemTop("C6D9F0"),
+ GetColorItemTop("DBE5F1"),
+ GetColorItemTop("F2DCDB"),
+ GetColorItemTop("EBF1DD"),
+ GetColorItemTop("E5E0EC"),
+ GetColorItemTop("DBEEF3"),
+ GetColorItemTop("FDEADA")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemMiddle("D8D8D8"),
+ GetColorItemMiddle("595959"),
+ GetColorItemMiddle("C4BD97"),
+ GetColorItemMiddle("8DB3E2"),
+ GetColorItemMiddle("B8CCE4"),
+ GetColorItemMiddle("E5B9B7"),
+ GetColorItemMiddle("D7E3BC"),
+ GetColorItemMiddle("CCC1D9"),
+ GetColorItemMiddle("B7DDE8"),
+ GetColorItemMiddle("FBD5B5")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemMiddle("BFBFBF"),
+ GetColorItemMiddle("3F3F3F"),
+ GetColorItemMiddle("938953"),
+ GetColorItemMiddle("548DD4"),
+ GetColorItemMiddle("95B3D7"),
+ GetColorItemMiddle("D99694"),
+ GetColorItemMiddle("C3D69B"),
+ GetColorItemMiddle("B2A1C7"),
+ GetColorItemMiddle("92CDDC"),
+ GetColorItemMiddle("FAC08F")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemMiddle("A5A5A5"),
+ GetColorItemMiddle("262626"),
+ GetColorItemMiddle("494429"),
+ GetColorItemMiddle("17365D"),
+ GetColorItemMiddle("366092"),
+ GetColorItemMiddle("953734"),
+ GetColorItemMiddle("76923C"),
+ GetColorItemMiddle("5F497A"),
+ GetColorItemMiddle("31859B"),
+ GetColorItemMiddle("E36C09")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemBottom("7F7F7F"),
+ GetColorItemBottom("0C0C0C"),
+ GetColorItemBottom("1D1B10"),
+ GetColorItemBottom("0F243E"),
+ GetColorItemBottom("244061"),
+ GetColorItemBottom("632423"),
+ GetColorItemBottom("4F6128"),
+ GetColorItemBottom("3F3151"),
+ GetColorItemBottom("205867"),
+ GetColorItemBottom("974806")});
+ }
+ else
+ {
+ colors.Add(new ColorItem[] {
+ GetColorItem("FFFFFF"),
+ GetColorItem("000000"),
+ GetColorItem("FAF3E8"),
+ GetColorItem("1F497D"),
+ GetColorItem("5C83B4"),
+ GetColorItem("C0504D"),
+ GetColorItem("9DBB61"),
+ GetColorItem("8066A0"),
+ GetColorItem("4BACC6"),
+ GetColorItem("F59D56")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemTop("D8D8D8"),
+ GetColorItemTop("7F7F7F"),
+ GetColorItemTop("BBB6AE"),
+ GetColorItemTop("C7D1DE"),
+ GetColorItemTop("D6E0EC"),
+ GetColorItemTop("EFD3D2"),
+ GetColorItemTop("E6EED7"),
+ GetColorItemTop("DFD8E7"),
+ GetColorItemTop("D2EAF0"),
+ GetColorItemTop("FCE6D4")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemMiddle("BFBFBF"),
+ GetColorItemMiddle("727272"),
+ GetColorItemMiddle("A29D96"),
+ GetColorItemMiddle("8FA4BE"),
+ GetColorItemMiddle("ADC1D9"),
+ GetColorItemMiddle("DFA7A6"),
+ GetColorItemMiddle("CEDDB0"),
+ GetColorItemMiddle("BFB2CF"),
+ GetColorItemMiddle("A5D5E2"),
+ GetColorItemMiddle("FACEAA")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemMiddle("A5A5A5"),
+ GetColorItemMiddle("595959"),
+ GetColorItemMiddle("7D7974"),
+ GetColorItemMiddle("57769D"),
+ GetColorItemMiddle("84A2C6"),
+ GetColorItemMiddle("CF7B79"),
+ GetColorItemMiddle("B5CC88"),
+ GetColorItemMiddle("9F8CB7"),
+ GetColorItemMiddle("78C0D4"),
+ GetColorItemMiddle("F7B580")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemMiddle("8C8C8C"),
+ GetColorItemMiddle("3F3F3F"),
+ GetColorItemMiddle("575551"),
+ GetColorItemMiddle("17365D"),
+ GetColorItemMiddle("456287"),
+ GetColorItemMiddle("903C39"),
+ GetColorItemMiddle("758C48"),
+ GetColorItemMiddle("604C78"),
+ GetColorItemMiddle("388194"),
+ GetColorItemMiddle("B77540")});
+
+ colors.Add(new ColorItem[] {
+ GetColorItemBottom("7F7F7F"),
+ GetColorItemBottom("262626"),
+ GetColorItemBottom("3E3C3A"),
+ GetColorItemBottom("0F243E"),
+ GetColorItemBottom("2E415A"),
+ GetColorItemBottom("602826"),
+ GetColorItemBottom("4E5D30"),
+ GetColorItemBottom("403350"),
+ GetColorItemBottom("255663"),
+ GetColorItemBottom("7A4E2B")});
+ }
+ }
+#if FRAMEWORK20
+ else
+ colors.AddRange(_CustomThemeColors);
+#endif
+
+ return colors;
+ }
+
+ ///
+ /// Returns an array that represents the standard colors. Usually instances of ColorItem are included.
+ ///
+ /// ArrayList containing objects that describe standard colors.
+ protected virtual ArrayList GetStandardColors()
+ {
+ ArrayList colors = new ArrayList();
+#if FRAMEWORK20
+ if (_CustomStandardColors == null || _CustomStandardColors.Length == 0)
+#endif
+ {
+ eDotNetBarStyle effectiveStyle = EffectiveStyle;
+ if (effectiveStyle == eDotNetBarStyle.Office2010 || StyleManager.IsMetro(effectiveStyle))
+ {
+ colors.Add(new ColorItem[] {
+ GetColorItem("C00000"),
+ GetColorItem("FF0000"),
+ GetColorItem("FFC000"),
+ GetColorItem("FFFF00"),
+ GetColorItem("92D050"),
+ GetColorItem("00B050"),
+ GetColorItem("00B0F0"),
+ GetColorItem("0070C0"),
+ GetColorItem("002060"),
+ GetColorItem("7030A0")});
+ }
+ else
+ {
+ colors.Add(new ColorItem[] {
+ GetColorItem("BA1419"),
+ GetColorItem("ED1C24"),
+ GetColorItem("FFC20E"),
+ GetColorItem("FFF200"),
+ GetColorItem("9DDA4E"),
+ GetColorItem("22B14C"),
+ GetColorItem("00B7EF"),
+ GetColorItem("0072BC"),
+ GetColorItem("2F3699"),
+ GetColorItem("6F3198")});
+ }
+ }
+#if FRAMEWORK20
+ else
+ colors.AddRange(_CustomStandardColors);
+#endif
+
+ return colors;
+ }
+#if FRAMEWORK20
+ private ColorItem[][] _CustomStandardColors = null;
+ ///
+ /// Gets or sets the array of ColorItem objects that will be used as standard colors instead of built-in color palette.
+ /// See: http://www.devcomponents.com/kb2/?p=79 for instructions.
+ ///
+ [DefaultValue(null), Category("Colors"), Description("Array of ColorItem objects that will be used as standard colors instead of built-in color palette.")]
+ public ColorItem[][] CustomStandardColors
+ {
+ get { return _CustomStandardColors; }
+ set
+ {
+ _CustomStandardColors = value;
+ m_ColorsInitialized = false;
+ }
+ }
+#endif
+
+ private ColorItem GetColorItem(string color)
+ {
+ ColorItem c = new ColorItem("", "", ColorScheme.GetColor(color));
+
+ return c;
+ }
+
+ private ColorItem GetColorItemTop(string color)
+ {
+ ColorItem c = new ColorItem("", "", ColorScheme.GetColor(color));
+ eColorItemBorder border = eColorItemBorder.Top | eColorItemBorder.Left | eColorItemBorder.Right;
+ c.Border = border;
+ return c;
+ }
+
+ private ColorItem GetColorItemMiddle(string color)
+ {
+ ColorItem c = new ColorItem("", "", ColorScheme.GetColor(color));
+ eColorItemBorder border = eColorItemBorder.Left | eColorItemBorder.Right;
+ c.Border = border;
+ return c;
+ }
+
+ private ColorItem GetColorItemBottom(string color)
+ {
+ ColorItem c = new ColorItem("", "", ColorScheme.GetColor(color));
+ eColorItemBorder border = eColorItemBorder.Bottom | eColorItemBorder.Left | eColorItemBorder.Right;
+ c.Border = border;
+ return c;
+ }
+
+ private void LoadResources()
+ {
+ if (!m_Localized)
+ {
+ if (this.GetOwner() != null)
+ m_Localized = true;
+ using (LocalizationManager lm = new LocalizationManager(this.GetOwner() as IOwnerLocalize))
+ {
+ string s = lm.GetLocalizedString(LocalizationKeys.ColorPickerThemeColorsLabel);
+ if (s != "") m_ThemeColorsLabel = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerStandardColorsLabel);
+ if (s != "") m_StandardColorsLabel = s;
+ s = lm.GetLocalizedString(LocalizationKeys.ColorPickerMoreColorsMenuItem);
+ if (s != "") m_MoreColorsLabel = s;
+ }
+ }
+ }
+
+ ///
+ /// Invokes SelectedColorChanged event.
+ ///
+ protected virtual void OnSelectedColorChanged(EventArgs e)
+ {
+ if (SelectedColorChanged != null)
+ SelectedColorChanged(this, e);
+ DotNetBarManager manager = this.GetOwner() as DotNetBarManager;
+ if (manager != null)
+ manager.InvokeColorPickerSelectedColorChanged(this);
+ }
+
+ ///
+ /// Indicates whether button should popup when clicked automatically.
+ ///
+ protected override bool ShouldAutoExpandOnClick
+ {
+ get { return base.ShouldAutoExpandOnClick || m_SelectedColor.IsEmpty; }
+ }
+
+ protected override void OnCommandChanged()
+ {
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/ColorSelectionPreviewControl.cs b/PROMS/DotNetBar Source Code/ColorPickers/ColorSelectionPreviewControl.cs
new file mode 100644
index 00000000..e92f1570
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPickers/ColorSelectionPreviewControl.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.ColorPickerItem
+{
+ [ToolboxItem(false)]
+ internal class ColorSelectionPreviewControl : System.Windows.Forms.UserControl
+ {
+ #region Private Variables
+ private Color m_CurrentColor = Color.Black;
+ private Color m_NewColor = Color.Empty;
+ #endregion
+
+ #region Constructor
+ public ColorSelectionPreviewControl()
+ {
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ }
+ #endregion
+
+ #region Internal Implementation
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if(this.BackColor == Color.Transparent)
+ {
+ base.OnPaintBackground(e);
+ }
+
+ Graphics g = e.Graphics;
+
+ Rectangle r = this.ClientRectangle;
+
+ g.FillRectangle(SystemBrushes.Control, r);
+
+ if(!m_NewColor.IsEmpty)
+ {
+ using(SolidBrush brush = new SolidBrush(m_NewColor))
+ g.FillRectangle(brush, r.X, r.Y, r.Width, r.Height / 2);
+ }
+
+ if(!m_CurrentColor.IsEmpty)
+ {
+ using(SolidBrush brush = new SolidBrush(m_CurrentColor))
+ g.FillRectangle(brush, r.X, r.Y + r.Height / 2, r.Width, r.Height / 2);
+ }
+
+ using(Pen pen=new Pen(Color.Black))
+ {
+ r.Width--;
+ r.Height--;
+ g.DrawRectangle(pen, r);
+
+ g.DrawLine(pen, r.X, r.Y + r.Height / 2, r.Right, r.Y + r.Height / 2);
+ }
+ }
+
+ public Color NewColor
+ {
+ get { return m_NewColor;}
+ set
+ {
+ m_NewColor = value;
+ this.Invalidate();
+ }
+ }
+
+ public Color CurrentColor
+ {
+ get { return m_CurrentColor;}
+ set
+ {
+ m_CurrentColor = value;
+ this.Invalidate();
+ }
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/CombCell.cs b/PROMS/DotNetBar Source Code/ColorPickers/CombCell.cs
new file mode 100644
index 00000000..854a0d5b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPickers/CombCell.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.DotNetBar.ColorPickers
+{
+ internal class CombCell
+ {
+ #region Private Variables
+ private Color m_Color = Color.Empty;
+ private Point[] m_HexagonPoints=new Point[6];
+ private const float Tan30 = 0.57735026918962F;
+ private bool m_MouseOver = false;
+ private bool m_Selected = false;
+ private Rectangle m_Bounds = Rectangle.Empty;
+ #endregion
+
+ #region Internal Implementation
+ public Color Color
+ {
+ get { return m_Color; }
+ set { m_Color=value; }
+ }
+
+ public void SetPosition(float x, float y, int nWidth)
+ {
+ float nSideLength = (float)((float)nWidth * Tan30);
+ m_HexagonPoints[0] = new Point((int)Math.Floor(x - (float)(nWidth / 2)), (int)Math.Floor(y - (nSideLength / 2))-1);
+ m_HexagonPoints[1] = new Point((int)Math.Floor((float)x), (int)Math.Floor(y - (float)(nWidth / 2))-1);
+ m_HexagonPoints[2] = new Point((int)Math.Floor(x + (float)(nWidth / 2)), (int)Math.Floor(y - (nSideLength / 2))-1);
+ m_HexagonPoints[3] = new Point((int)Math.Floor(x + (float)(nWidth / 2)), (int)Math.Floor(y + (nSideLength / 2)) + 1);
+ m_HexagonPoints[4] = new Point((int)Math.Floor((float)x), (int)Math.Floor(y + (float)(nWidth / 2)) + 1);
+ m_HexagonPoints[5] = new Point((int)Math.Floor(x - (float)(nWidth / 2)), (int)Math.Floor(y + (nSideLength / 2)) + 1);
+
+ GraphicsPath path = new GraphicsPath();
+ path.AddPolygon(m_HexagonPoints);
+ m_Bounds = Rectangle.Round(path.GetBounds());
+ m_Bounds.Inflate(2, 2);
+ }
+
+ public void Draw(Graphics g)
+ {
+ GraphicsPath path = new GraphicsPath();
+ path.AddPolygon(m_HexagonPoints);
+ path.CloseAllFigures();
+
+ using (SolidBrush brush = new SolidBrush(m_Color))
+ {
+ g.FillPath(brush, path);
+ }
+
+ if (m_MouseOver || m_Selected)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+ using (Pen pen = new Pen(Color.FromArgb(41, 92, 150), 2))
+ g.DrawPath(pen, path);
+ using (Pen pen = new Pen(Color.FromArgb(149, 178, 239), 1))
+ g.DrawPath(pen, path);
+ g.SmoothingMode = sm;
+ }
+
+ path.Dispose();
+ }
+
+ public void Draw(Graphics g, Color c)
+ {
+ GraphicsPath path = new GraphicsPath();
+ path.AddPolygon(m_HexagonPoints);
+ using (SolidBrush brush = new SolidBrush(c))
+ {
+ g.FillPath(brush, path);
+ }
+ path.Dispose();
+ }
+
+ public Rectangle Bounds
+ {
+ get
+ {
+ return m_Bounds;
+ }
+ }
+
+ public bool MouseOver
+ {
+ get { return m_MouseOver; }
+ set { m_MouseOver = value; }
+ }
+
+ public bool Selected
+ {
+ get { return m_Selected; }
+ set { m_Selected = value; }
+ }
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/CustomColorBlender.cs b/PROMS/DotNetBar Source Code/ColorPickers/CustomColorBlender.cs
new file mode 100644
index 00000000..2c413af1
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPickers/CustomColorBlender.cs
@@ -0,0 +1,340 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+using System.Drawing.Imaging;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar.ColorPickers
+{
+ ///
+ /// Represents custom color blend selection control.
+ ///
+ [ToolboxItem(true), DefaultEvent("SelectedColorChanged"), DefaultProperty("SelectedColor"), ToolboxBitmap(typeof(CustomColorBlender), "ColorPickerItem.CustomColorBlender.ico")]
+ public class CustomColorBlender : System.Windows.Forms.Control
+ {
+ #region Events
+ ///
+ /// Occurs when SelectedColor has changed.
+ ///
+ public event EventHandler SelectedColorChanged;
+ ///
+ /// Raises SelectedColorChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnSelectedColorChanged(EventArgs e)
+ {
+ EventHandler handler = SelectedColorChanged;
+ if (handler != null)
+ handler(this, e);
+ }
+ #endregion
+
+ #region Private Variables
+ private Bitmap m_ColorBlendBitmap = null;
+ private Point m_SelectedPoint = new Point(-1, -1);
+ #endregion
+
+ #region Constructor, Dispose
+ public CustomColorBlender()
+ {
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (m_ColorBlendBitmap != null)
+ {
+ m_ColorBlendBitmap.Dispose();
+ m_ColorBlendBitmap = null;
+ }
+ }
+ base.Dispose(disposing);
+ }
+
+ private void CreateBlendBitmap()
+ {
+ int stripeCount = 6;
+ Rectangle clientRect = this.ClientRectangle;
+
+ int stripeWidth = clientRect.Width / stripeCount;
+ int ySteps=127;
+ int xStart = clientRect.X;
+ Bitmap bmp = new Bitmap(clientRect.Width, clientRect.Height, PixelFormat.Format24bppRgb);
+ using (Graphics graph = Graphics.FromImage(bmp))
+ {
+ graph.FillRectangle(SystemBrushes.Control, clientRect);
+
+ for (int stripe = 0; stripe < stripeCount; stripe++)
+ {
+ // Calculate X steps and point Width
+ int pointWidth = 4;
+ int colorStepX = 255 / (stripeWidth / pointWidth);
+
+ if (colorStepX<1)
+ {
+ pointWidth = stripeWidth / 255;
+ colorStepX = 1;
+ }
+
+ int pointHeight = 4;
+ int colorStepY = ySteps / (clientRect.Height / pointHeight);
+
+ if (colorStepY<1)
+ {
+ pointHeight = clientRect.Height / ySteps;
+ colorStepY = 1;
+ }
+
+ int x = xStart;
+ int y = clientRect.Y;
+ int r = 0, g = 0, b = 0;
+ int rXInc = 0, gXInc = 0, bXInc = 0;
+ int rYInc = 0, gYInc = 0, bYInc = 0;
+
+ if (stripe == 0)
+ {
+ r = 255;
+ g = 0;
+ b = 0;
+ gXInc = colorStepX;
+ }
+ else if (stripe == 1)
+ {
+ r = 255;
+ g = 255;
+ b = 0;
+ rXInc = - colorStepX;
+ }
+ else if (stripe == 2)
+ {
+ r = 0;
+ g = 255;
+ b = 0;
+ bXInc = colorStepX;
+ }
+ else if (stripe == 3)
+ {
+ r = 0;
+ g = 255;
+ b = 255;
+ gXInc = -colorStepX;
+ }
+ else if (stripe == 4)
+ {
+ r = 0;
+ g = 0;
+ b = 255;
+ rXInc = colorStepX;
+ }
+ else if (stripe == 5)
+ {
+ r = 255;
+ g = 0;
+ b = 255;
+ bXInc = -colorStepX;
+ }
+
+ for (int i = 0; i < stripeWidth; i += pointWidth)
+ {
+ int ry = r, gy = g, by = b;
+ rYInc = 127-r;
+ gYInc = 127-g;
+ bYInc = 127-b;
+
+ for (int j = clientRect.Y; j < clientRect.Height; j += pointHeight)
+ {
+ using (SolidBrush brush = new SolidBrush(Color.FromArgb(ry, gy, by)))
+ graph.FillRectangle(brush, new Rectangle(x, y, pointWidth, pointHeight));
+ y += pointHeight;
+
+ ry = r + (int)(rYInc * ((float)j / (float)clientRect.Height));
+ gy = g + (int)(gYInc * ((float)j / (float)clientRect.Height));
+ by = b + (int)(bYInc * ((float)j / (float)clientRect.Height));
+ }
+
+ x += pointWidth;
+ y = clientRect.Y;
+ r += rXInc;
+ g += gXInc;
+ b += bXInc;
+
+ }
+ xStart = x;
+ if (stripe == 5)
+ break;
+ }
+ }
+
+ if (m_ColorBlendBitmap != null)
+ m_ColorBlendBitmap.Dispose();
+ m_ColorBlendBitmap = bmp;
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+
+ if (!this.BackColor.IsEmpty && this.BackColor != Color.Transparent)
+ {
+ using (SolidBrush brush = new SolidBrush(this.BackColor))
+ g.FillRectangle(brush, -1, -1, this.Width + 1, this.Height + 1);
+ }
+
+ if (this.BackColor == Color.Transparent || this.BackgroundImage != null)
+ {
+ base.OnPaintBackground(e);
+ }
+
+ if (m_ColorBlendBitmap == null) return;
+
+ g.DrawImageUnscaled(m_ColorBlendBitmap, 0, 0);
+
+ if (m_SelectedPoint.X >= 0 && m_SelectedPoint.Y >= 0)
+ {
+ Color clr = Color.White;
+ using (SolidBrush brush = new SolidBrush(clr))
+ {
+ Rectangle r = new Rectangle(m_SelectedPoint.X - 2, m_SelectedPoint.Y - 9, 3, 5);
+ g.FillRectangle(brush, r);
+ r.Offset(0, 10);
+ g.FillRectangle(brush, r);
+ r = new Rectangle(m_SelectedPoint.X - 8, m_SelectedPoint.Y - 3, 5, 3);
+ g.FillRectangle(brush, r);
+ r.Offset(10, 0);
+ g.FillRectangle(brush, r);
+ }
+
+ }
+
+ base.OnPaint(e);
+ }
+
+ private void SetSelectedPoint(Point p)
+ {
+ Rectangle r = this.ClientRectangle;
+
+ if (m_ColorBlendBitmap != null)
+ {
+ r.Width = m_ColorBlendBitmap.Width;
+ r.Height = m_ColorBlendBitmap.Height;
+ }
+
+ if (p.X < 0)
+ p.X = 0;
+ if (p.Y < 0)
+ p.Y = 0;
+ if (p.X > r.Right)
+ p.X = r.Right - 1;
+ if (p.Y > r.Bottom)
+ p.Y = r.Bottom - 1;
+
+ if (p != m_SelectedPoint)
+ {
+ if (m_SelectedPoint.X >= 0 && m_SelectedPoint.Y >= 0)
+ {
+ Rectangle inv = new Rectangle(m_SelectedPoint, Size.Empty);
+ inv.Inflate(10, 10);
+ this.Invalidate(inv);
+ }
+ m_SelectedPoint = p;
+ if (m_SelectedPoint.X >= 0 && m_SelectedPoint.Y >= 0)
+ {
+ Rectangle inv = new Rectangle(m_SelectedPoint, Size.Empty);
+ inv.Inflate(10, 10);
+ this.Invalidate(inv);
+ }
+ OnSelectedColorChanged(EventArgs.Empty);
+ }
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+ SetSelectedPoint(new Point(e.X, e.Y));
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if (e.Button == MouseButtons.Left)
+ {
+ int x = e.X;
+ int y = e.Y;
+ if(x<0)
+ x = 0;
+ if(x>=this.ClientRectangle.Width)
+ x = this.ClientRectangle.Width - 1;
+ if(y<0)
+ y = 0;
+ if(y>=this.ClientRectangle.Height)
+ y = this.ClientRectangle.Height - 1;
+ SetSelectedPoint(new Point(x, y));
+ }
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ CreateBlendBitmap();
+ base.OnResize(e);
+ }
+
+ ///
+ /// Gets or sets the color selected by the control. Color that is assigned must be visible on the face of the control otherwise the SelectedColor will be set to Color.Empty
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Color SelectedColor
+ {
+ get
+ {
+ if (m_SelectedPoint.X < 0 || m_SelectedPoint.Y < 0 || m_ColorBlendBitmap==null)
+ return Color.Empty;
+ return m_ColorBlendBitmap.GetPixel(m_SelectedPoint.X, m_SelectedPoint.Y);
+ }
+ set
+ {
+ if (value.Equals(Color.Transparent) || value.IsEmpty)
+ {
+ if (!m_SelectedPoint.IsEmpty)
+ {
+ m_SelectedPoint = new Point(-1, -1);
+ this.Invalidate();
+ OnSelectedColorChanged(EventArgs.Empty);
+ }
+ }
+ else
+ {
+ Point colorPoint = FindColorPoint(value);
+ if (m_SelectedPoint != colorPoint)
+ {
+ m_SelectedPoint = colorPoint;
+ this.Invalidate();
+ OnSelectedColorChanged(EventArgs.Empty);
+ }
+ }
+ }
+ }
+ private Point FindColorPoint(Color value)
+ {
+ if (m_ColorBlendBitmap == null || value.IsEmpty || value == Color.Transparent) return new Point(-1, -1);
+ for (int x = 0; x < m_ColorBlendBitmap.Width; x++)
+ {
+ for (int y = 0; y < m_ColorBlendBitmap.Height; y++)
+ {
+ Color color = m_ColorBlendBitmap.GetPixel(x, y);
+ if (Math.Abs(color.R-value.R)<=30 && Math.Abs(color.G-value.G)<=30 && Math.Abs(color.B-value.B)<=30)
+ return new Point(x, y);
+ }
+ }
+ return new Point(-1, -1);
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/CustomColorBlender.ico b/PROMS/DotNetBar Source Code/ColorPickers/CustomColorBlender.ico
new file mode 100644
index 00000000..849d5562
Binary files /dev/null and b/PROMS/DotNetBar Source Code/ColorPickers/CustomColorBlender.ico differ
diff --git a/PROMS/DotNetBar Source Code/ColorPickers/CustomColorDialog.cs b/PROMS/DotNetBar Source Code/ColorPickers/CustomColorDialog.cs
new file mode 100644
index 00000000..9ba808bb
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorPickers/CustomColorDialog.cs
@@ -0,0 +1,1079 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Data;
+using DevComponents.DotNetBar.Controls;
+using DevComponents.Editors;
+using DevComponents.DotNetBar.ColorPickers;
+
+namespace DevComponents.DotNetBar.ColorPickerItem
+{
+ [ToolboxItem(false)]
+ internal class CustomColorDialog : DevComponents.DotNetBar.OfficeForm
+ {
+ #region Private Variables
+ internal ButtonX buttonOK;
+ internal ButtonX buttonCancel;
+ internal System.Windows.Forms.Label labelNewColor;
+ internal System.Windows.Forms.Label labelCurrentColor;
+
+ private Color m_CurrentColor = Color.Black;
+ private Color m_NewColor = Color.Empty;
+ private ColorCombControl colorCombControl1;
+ internal System.Windows.Forms.Label labelStandardColors;
+ internal System.Windows.Forms.Label labelCustomColors;
+ internal System.Windows.Forms.Label labelGreen;
+ internal System.Windows.Forms.Label labelBlue;
+ private DevComponents.DotNetBar.TabControl tabControl2;
+ internal DevComponents.DotNetBar.TabItem tabItemStandard;
+ private DevComponents.DotNetBar.TabControlPanel tabControlPanel1;
+ internal DevComponents.DotNetBar.TabItem tabItemCustom;
+ private DevComponents.DotNetBar.TabControlPanel tabControlPanel2;
+ private CustomColorBlender customColorBlender3;
+ internal System.Windows.Forms.Label labelRed;
+ internal System.Windows.Forms.Label labelColorModel;
+ internal ComboBoxEx comboColorModel;
+#if FRAMEWORK20
+ private IntegerInput numericBlue;
+ private IntegerInput numericGreen;
+ private IntegerInput numericRed;
+#else
+ private System.Windows.Forms.NumericUpDown numericBlue;
+ private System.Windows.Forms.NumericUpDown numericGreen;
+ private System.Windows.Forms.NumericUpDown numericRed;
+#endif
+ private ColorContrastControl colorContrastControl1;
+ private ColorSelectionPreviewControl colorSelectionPreview;
+ private System.ComponentModel.IContainer components;
+ #endregion
+
+ #region Constructor, Dispose
+ public CustomColorDialog()
+ {
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+
+ //
+ // TODO: Add any constructor code after InitializeComponent call
+ //
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if (components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+ #endregion
+
+ #region Windows Form Designer generated code
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.labelStandardColors = new System.Windows.Forms.Label();
+ this.colorCombControl1 = new ColorCombControl();
+ this.labelBlue = new System.Windows.Forms.Label();
+ this.labelGreen = new System.Windows.Forms.Label();
+#if (FRAMEWORK20)
+ this.numericBlue = new IntegerInput();
+ this.numericGreen = new IntegerInput();
+ this.numericRed = new IntegerInput();
+#else
+ this.numericBlue = new System.Windows.Forms.NumericUpDown();
+ this.numericGreen = new System.Windows.Forms.NumericUpDown();
+ this.numericRed = new System.Windows.Forms.NumericUpDown();
+#endif
+ this.labelCustomColors = new System.Windows.Forms.Label();
+ this.buttonOK = new ButtonX();
+ this.buttonCancel = new ButtonX();
+ this.labelNewColor = new System.Windows.Forms.Label();
+ this.labelCurrentColor = new System.Windows.Forms.Label();
+ this.tabControl2 = new DevComponents.DotNetBar.TabControl();
+ this.tabControlPanel1 = new DevComponents.DotNetBar.TabControlPanel();
+ this.tabItemStandard = new DevComponents.DotNetBar.TabItem(this.components);
+ this.tabControlPanel2 = new DevComponents.DotNetBar.TabControlPanel();
+ this.colorContrastControl1 = new ColorContrastControl();
+ this.customColorBlender3 = new CustomColorBlender();
+ this.comboColorModel = new ComboBoxEx();
+ this.labelRed = new System.Windows.Forms.Label();
+ this.labelColorModel = new System.Windows.Forms.Label();
+ this.tabItemCustom = new DevComponents.DotNetBar.TabItem(this.components);
+ this.colorSelectionPreview = new ColorSelectionPreviewControl();
+ ((System.ComponentModel.ISupportInitialize)(this.numericBlue)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericGreen)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericRed)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.tabControl2)).BeginInit();
+ this.tabControl2.SuspendLayout();
+ this.tabControlPanel1.SuspendLayout();
+ this.tabControlPanel2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // label3
+ //
+ this.labelStandardColors.BackColor = System.Drawing.Color.Transparent;
+ this.labelStandardColors.Dock = System.Windows.Forms.DockStyle.Top;
+ this.labelStandardColors.Location = new System.Drawing.Point(1, 1);
+ this.labelStandardColors.Name = "labelStandardColors";
+ this.labelStandardColors.Size = new System.Drawing.Size(224, 19);
+ this.labelStandardColors.TabIndex = 1;
+ this.labelStandardColors.Text = " Colors:";
+ this.labelStandardColors.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
+ //
+ // colorCombControl1
+ //
+ this.colorCombControl1.BackColor = System.Drawing.Color.Transparent;
+ this.colorCombControl1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.colorCombControl1.Location = new System.Drawing.Point(1, 20);
+ this.colorCombControl1.Name = "colorCombControl1";
+ this.colorCombControl1.Size = new System.Drawing.Size(224, 267);
+ this.colorCombControl1.TabIndex = 0;
+ this.colorCombControl1.SelectedColorChanged += new System.EventHandler(this.colorCombControl1_SelectedColorChanged);
+ //
+ // label8
+ //
+ this.labelBlue.BackColor = System.Drawing.Color.Transparent;
+ this.labelBlue.Location = new System.Drawing.Point(4, 256);
+ this.labelBlue.Name = "labelBlue";
+ this.labelBlue.Size = new System.Drawing.Size(90, 16);
+ this.labelBlue.TabIndex = 10;
+ this.labelBlue.Text = "&Blue:";
+ //
+ // label7
+ //
+ this.labelGreen.BackColor = System.Drawing.Color.Transparent;
+ this.labelGreen.Location = new System.Drawing.Point(4, 232);
+ this.labelGreen.Name = "labelGreen";
+ this.labelGreen.Size = new System.Drawing.Size(90, 16);
+ this.labelGreen.TabIndex = 8;
+ this.labelGreen.Text = "&Green:";
+ //
+ // numericBlue
+ //
+ this.numericBlue.Location = new System.Drawing.Point(98, 260);
+#if (FRAMEWORK20)
+ this.numericBlue.MaxValue = 255;
+ this.numericBlue.MinValue = 0;
+ this.numericBlue.ShowUpDown = true;
+ this.numericBlue.AllowEmptyState = false;
+#else
+ this.numericBlue.Maximum = new System.Decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+#endif
+ this.numericBlue.Name = "numericBlue";
+ this.numericBlue.Size = new System.Drawing.Size(47, 20);
+ this.numericBlue.TabIndex = 11;
+ this.numericBlue.ValueChanged += new System.EventHandler(this.numericRGBValueChanged);
+ //
+ // numericGreen
+ //
+ this.numericGreen.Location = new System.Drawing.Point(98, 236);
+#if (FRAMEWORK20)
+ this.numericGreen.MaxValue = 255;
+ this.numericGreen.MinValue = 0;
+ this.numericGreen.ShowUpDown = true;
+ this.numericGreen.AllowEmptyState = false;
+#else
+ this.numericGreen.Maximum = new System.Decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+#endif
+ this.numericGreen.Name = "numericGreen";
+ this.numericGreen.Size = new System.Drawing.Size(47, 20);
+ this.numericGreen.TabIndex = 9;
+ this.numericGreen.ValueChanged += new System.EventHandler(this.numericRGBValueChanged);
+ //
+ // numericRed
+ //
+ this.numericRed.Location = new System.Drawing.Point(98, 212);
+#if (FRAMEWORK20)
+ this.numericRed.MaxValue = 255;
+ this.numericRed.MinValue = 0;
+ this.numericRed.ShowUpDown = true;
+ this.numericRed.AllowEmptyState = false;
+#else
+ this.numericRed.Maximum = new System.Decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+#endif
+ this.numericRed.Name = "numericRed";
+ this.numericRed.Size = new System.Drawing.Size(47, 20);
+ this.numericRed.TabIndex = 7;
+ this.numericRed.ValueChanged += new System.EventHandler(this.numericRGBValueChanged);
+ //
+ // label4
+ //
+ this.labelCustomColors.BackColor = System.Drawing.Color.Transparent;
+ this.labelCustomColors.Dock = System.Windows.Forms.DockStyle.Top;
+ this.labelCustomColors.Location = new System.Drawing.Point(1, 1);
+ this.labelCustomColors.Name = "labelCustomColors";
+ this.labelCustomColors.Size = new System.Drawing.Size(224, 20);
+ this.labelCustomColors.TabIndex = 2;
+ this.labelCustomColors.Text = " Colors:";
+ this.labelCustomColors.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
+ //
+ // button1
+ //
+ this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.buttonOK.Location = new System.Drawing.Point(242, 6);
+ this.buttonOK.ColorTable = eButtonColor.OrangeWithBackground;
+ this.buttonOK.Name = "buttonOK";
+ this.buttonOK.Size = new System.Drawing.Size(74, 24);
+ this.buttonOK.TabIndex = 1;
+ this.buttonOK.Text = "OK";
+ //
+ // button2
+ //
+ this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.buttonCancel.Location = new System.Drawing.Point(242, 36);
+ this.buttonCancel.ColorTable = eButtonColor.OrangeWithBackground;
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(74, 24);
+ this.buttonCancel.TabIndex = 2;
+ this.buttonCancel.Text = "Cancel";
+ //
+ // label1
+ //
+ this.labelNewColor.Location = new System.Drawing.Point(246, 232);
+ this.labelNewColor.Name = "labelNewColor";
+ this.labelNewColor.Size = new System.Drawing.Size(70, 12);
+ this.labelNewColor.TabIndex = 4;
+ this.labelNewColor.Text = "New";
+ this.labelNewColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // label2
+ //
+ this.labelCurrentColor.Location = new System.Drawing.Point(246, 306);
+ this.labelCurrentColor.Name = "labelCurrentColor";
+ this.labelCurrentColor.Size = new System.Drawing.Size(70, 16);
+ this.labelCurrentColor.TabIndex = 5;
+ this.labelCurrentColor.Text = "Current";
+ this.labelCurrentColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // tabControl2
+ //
+ this.tabControl2.BackColor = Color.Transparent;
+ this.tabControl2.CanReorderTabs = true;
+ this.tabControl2.ColorScheme.TabBackground = Color.Transparent;
+ this.tabControl2.Controls.Add(this.tabControlPanel2);
+ this.tabControl2.Controls.Add(this.tabControlPanel1);
+ this.tabControl2.FixedTabSize = new System.Drawing.Size(60, 0);
+ this.tabControl2.Location = new System.Drawing.Point(8, 8);
+ this.tabControl2.Name = "tabControl2";
+ this.tabControl2.SelectedTabFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
+ this.tabControl2.SelectedTabIndex = 0;
+ this.tabControl2.Size = new System.Drawing.Size(226, 314);
+ this.tabControl2.Style = DevComponents.DotNetBar.eTabStripStyle.VS2005;
+ this.tabControl2.TabIndex = 6;
+ this.tabControl2.TabLayoutType = DevComponents.DotNetBar.eTabLayoutType.FixedWithNavigationBox;
+ this.tabControl2.Tabs.Add(this.tabItemStandard);
+ this.tabControl2.Tabs.Add(this.tabItemCustom);
+ this.tabControl2.ThemeAware = true;
+ //
+ // tabControlPanel1
+ //
+ this.tabControlPanel1.Controls.Add(this.colorCombControl1);
+ this.tabControlPanel1.Controls.Add(this.labelStandardColors);
+ this.tabControlPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabControlPanel1.DockPadding.All = 1;
+ this.tabControlPanel1.Location = new System.Drawing.Point(0, 26);
+ this.tabControlPanel1.Name = "tabControlPanel1";
+ this.tabControlPanel1.Size = new System.Drawing.Size(226, 288);
+ this.tabControlPanel1.Style.BackColor1.Color = System.Drawing.SystemColors.Control;
+ this.tabControlPanel1.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
+ this.tabControlPanel1.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right)
+ | DevComponents.DotNetBar.eBorderSide.Bottom)));
+ this.tabControlPanel1.Style.GradientAngle = 90;
+ this.tabControlPanel1.TabIndex = 1;
+ this.tabControlPanel1.TabItem = this.tabItemStandard;
+ this.tabControlPanel1.ThemeAware = true;
+ //
+ // tabItem1
+ //
+ this.tabItemStandard.AttachedControl = this.tabControlPanel1;
+ this.tabItemStandard.CloseButtonBounds = new System.Drawing.Rectangle(0, 0, 0, 0);
+ this.tabItemStandard.Name = "tabItemStandard";
+ this.tabItemStandard.Text = "Standard";
+ //
+ // tabControlPanel2
+ //
+ this.tabControlPanel2.Controls.Add(this.colorContrastControl1);
+ this.tabControlPanel2.Controls.Add(this.numericGreen);
+ this.tabControlPanel2.Controls.Add(this.labelGreen);
+ this.tabControlPanel2.Controls.Add(this.numericRed);
+ this.tabControlPanel2.Controls.Add(this.customColorBlender3);
+ this.tabControlPanel2.Controls.Add(this.comboColorModel);
+ this.tabControlPanel2.Controls.Add(this.labelRed);
+ this.tabControlPanel2.Controls.Add(this.labelColorModel);
+ this.tabControlPanel2.Controls.Add(this.numericBlue);
+ this.tabControlPanel2.Controls.Add(this.labelBlue);
+ this.tabControlPanel2.Controls.Add(this.labelCustomColors);
+ this.tabControlPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabControlPanel2.DockPadding.All = 1;
+ this.tabControlPanel2.Location = new System.Drawing.Point(0, 26);
+ this.tabControlPanel2.Name = "tabControlPanel2";
+ this.tabControlPanel2.Size = new System.Drawing.Size(226, 288);
+ this.tabControlPanel2.Style.BackColor1.Color = System.Drawing.SystemColors.Control;
+ this.tabControlPanel2.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
+ this.tabControlPanel2.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right)
+ | DevComponents.DotNetBar.eBorderSide.Bottom)));
+ this.tabControlPanel2.Style.GradientAngle = 90;
+ this.tabControlPanel2.TabIndex = 2;
+ this.tabControlPanel2.TabItem = this.tabItemCustom;
+ this.tabControlPanel2.ThemeAware = true;
+ //
+ // colorContrastControl1
+ //
+ this.colorContrastControl1.BackColor = System.Drawing.Color.Transparent;
+ this.colorContrastControl1.Location = new System.Drawing.Point(188, 28);
+ this.colorContrastControl1.Name = "colorContrastControl1";
+ this.colorContrastControl1.SelectedColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
+ this.colorContrastControl1.Size = new System.Drawing.Size(32, 152);
+ this.colorContrastControl1.TabIndex = 12;
+ this.colorContrastControl1.SelectedColorChanged += new System.EventHandler(this.colorContrastControl1_SelectedColorChanged);
+ //
+ // customColorBlender3
+ //
+ this.customColorBlender3.Location = new System.Drawing.Point(8, 28);
+ this.customColorBlender3.Name = "customColorBlender3";
+ this.customColorBlender3.Size = new System.Drawing.Size(174, 152);
+ this.customColorBlender3.TabIndex = 3;
+ this.customColorBlender3.SelectedColorChanged += new System.EventHandler(this.customColorBlender3_SelectedColorChanged);
+ //
+ // comboColorModel
+ //
+ this.comboColorModel.DrawMode = DrawMode.OwnerDrawFixed;
+ this.comboColorModel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboColorModel.Items.AddRange(new object[] {
+ "RGB"});
+ this.comboColorModel.Location = new System.Drawing.Point(98, 188);
+ this.comboColorModel.Name = "comboColorModel";
+ this.comboColorModel.Size = new System.Drawing.Size(89, 21);
+ this.comboColorModel.TabIndex = 5;
+ //
+ // label9
+ //
+ this.labelRed.BackColor = System.Drawing.Color.Transparent;
+ this.labelRed.Location = new System.Drawing.Point(4, 212);
+ this.labelRed.Name = "labelRed";
+ this.labelRed.Size = new System.Drawing.Size(90, 16);
+ this.labelRed.TabIndex = 6;
+ this.labelRed.Text = "&Red:";
+ //
+ // label10
+ //
+ this.labelColorModel.BackColor = System.Drawing.Color.Transparent;
+ this.labelColorModel.Location = new System.Drawing.Point(4, 192);
+ this.labelColorModel.Name = "labelColorModel";
+ this.labelColorModel.Size = new System.Drawing.Size(90, 16);
+ this.labelColorModel.TabIndex = 4;
+ this.labelColorModel.Text = "Color Mo&del:";
+ //
+ // tabItem2
+ //
+ this.tabItemCustom.AttachedControl = this.tabControlPanel2;
+ this.tabItemCustom.CloseButtonBounds = new System.Drawing.Rectangle(0, 0, 0, 0);
+ this.tabItemCustom.Name = "tabItemCustom";
+ this.tabItemCustom.Text = "Custom";
+ //
+ // colorSelectionPreview
+ //
+ this.colorSelectionPreview.CurrentColor = System.Drawing.Color.Black;
+ this.colorSelectionPreview.Location = new System.Drawing.Point(252, 252);
+ this.colorSelectionPreview.Name = "colorSelectionPreview";
+ this.colorSelectionPreview.NewColor = System.Drawing.Color.Empty;
+ this.colorSelectionPreview.Size = new System.Drawing.Size(56, 48);
+ this.colorSelectionPreview.TabIndex = 7;
+ //
+ // CustomColorDialog
+ //
+ this.AcceptButton = this.buttonOK;
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.CancelButton = this.buttonCancel;
+ this.ClientSize = new System.Drawing.Size(324, 326);
+ this.Controls.Add(this.colorSelectionPreview);
+ this.Controls.Add(this.tabControl2);
+ this.Controls.Add(this.labelCurrentColor);
+ this.Controls.Add(this.labelNewColor);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonOK);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "CustomColorDialog";
+ this.ShowInTaskbar = false;
+ this.Text = "Colors";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.numericBlue)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericGreen)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericRed)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.tabControl2)).EndInit();
+ this.tabControl2.ResumeLayout(false);
+ this.tabControlPanel1.ResumeLayout(false);
+ this.tabControlPanel2.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ #region Internal Implementation
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+ Size fixedSize = tabControl2.FixedTabSize;
+ using (Graphics g = this.CreateGraphics())
+ {
+ System.Drawing.Size s = TextDrawing.MeasureString(g, tabItemCustom.Text, this.Font);
+ System.Drawing.Size s1 = TextDrawing.MeasureString(g, tabItemStandard.Text, this.Font);
+ fixedSize.Width = Math.Max(fixedSize.Width, s.Width + 5);
+ fixedSize.Width = Math.Max(fixedSize.Width, s1.Width + 5);
+ }
+ tabControl2.FixedTabSize = fixedSize;
+ if (fixedSize.Width > tabControl2.Width / 2)
+ {
+ tabControl2.FixedTabSize = Size.Empty;
+ }
+ }
+ internal void SetStyle(eDotNetBarStyle style)
+ {
+ if (BarFunctions.IsOffice2007Style(style))
+ {
+ this.EnableCustomStyle = true;
+ tabControl2.Style = eTabStripStyle.Office2007Dock;
+ }
+ else
+ {
+ this.EnableCustomStyle = false;
+ this.tabControl2.Style = DevComponents.DotNetBar.eTabStripStyle.VS2005;
+ }
+
+ buttonCancel.Style = style;
+ buttonOK.Style = style;
+
+ tabControl2.BackColor = Color.Transparent;
+ tabControl2.ColorScheme.TabBackground = Color.Transparent;
+ tabControl2.ColorScheme.TabBackground2 = Color.Empty;
+ }
+ private void colorCombControl1_SelectedColorChanged(object sender, System.EventArgs e)
+ {
+ SetNewColor(colorCombControl1.SelectedColor);
+ colorContrastControl1.SelectedColor = colorCombControl1.SelectedColor;
+ }
+
+ private void customColorBlender3_SelectedColorChanged(object sender, System.EventArgs e)
+ {
+ colorContrastControl1.SelectedColor = customColorBlender3.SelectedColor;
+ SetNewColor(colorContrastControl1.SelectedColor);
+ }
+
+ private bool m_SettingColor = false;
+ private void SetNewColor(Color color)
+ {
+ if(m_SettingColor) return;
+ m_SettingColor = true;
+ try
+ {
+ m_NewColor = color;
+ colorSelectionPreview.NewColor = color;
+
+ numericRed.Value = m_NewColor.R;
+ numericGreen.Value = m_NewColor.G;
+ numericBlue.Value = m_NewColor.B;
+ }
+ finally
+ {
+ m_SettingColor = false;
+ }
+ }
+
+ private void Form1_Load(object sender, System.EventArgs e)
+ {
+ comboColorModel.SelectedIndex = 0;
+ }
+
+ private void numericRGBValueChanged(object sender, System.EventArgs e)
+ {
+ SetNewColor(Color.FromArgb((int)numericRed.Value, (int)numericGreen.Value, (int)numericBlue.Value));
+ }
+
+ private void colorContrastControl1_SelectedColorChanged(object sender, System.EventArgs e)
+ {
+ SetNewColor(colorContrastControl1.SelectedColor);
+ }
+
+ public Color CurrentColor
+ {
+ get { return m_CurrentColor;}
+ set
+ {
+ m_CurrentColor = value;
+ colorSelectionPreview.CurrentColor = value;
+ customColorBlender3.SelectedColor = m_CurrentColor;
+ colorContrastControl1.SelectedColor = m_CurrentColor;
+ if (!value.IsEmpty)
+ {
+ numericRed.Value = value.R;
+ numericBlue.Value = value.B;
+ numericGreen.Value = value.G;
+ }
+ }
+ }
+
+ public Color NewColor
+ {
+ get { return m_NewColor;}
+ }
+ #endregion
+ }
+
+ [ToolboxItem(false)]
+ internal class CustomColorDialogMetro : DevComponents.DotNetBar.Metro.MetroForm
+ {
+ #region Private Variables
+ internal ButtonX buttonOK;
+ internal ButtonX buttonCancel;
+ internal System.Windows.Forms.Label labelNewColor;
+ internal System.Windows.Forms.Label labelCurrentColor;
+
+ private Color m_CurrentColor = Color.Black;
+ private Color m_NewColor = Color.Empty;
+ private ColorCombControl colorCombControl1;
+ internal System.Windows.Forms.Label labelStandardColors;
+ internal System.Windows.Forms.Label labelCustomColors;
+ internal System.Windows.Forms.Label labelGreen;
+ internal System.Windows.Forms.Label labelBlue;
+ private DevComponents.DotNetBar.TabControl tabControl2;
+ internal DevComponents.DotNetBar.TabItem tabItemStandard;
+ private DevComponents.DotNetBar.TabControlPanel tabControlPanel1;
+ internal DevComponents.DotNetBar.TabItem tabItemCustom;
+ private DevComponents.DotNetBar.TabControlPanel tabControlPanel2;
+ private CustomColorBlender customColorBlender3;
+ internal System.Windows.Forms.Label labelRed;
+ internal System.Windows.Forms.Label labelColorModel;
+ internal ComboBoxEx comboColorModel;
+#if FRAMEWORK20
+ private IntegerInput numericBlue;
+ private IntegerInput numericGreen;
+ private IntegerInput numericRed;
+#else
+ private System.Windows.Forms.NumericUpDown numericBlue;
+ private System.Windows.Forms.NumericUpDown numericGreen;
+ private System.Windows.Forms.NumericUpDown numericRed;
+#endif
+ private ColorContrastControl colorContrastControl1;
+ private ColorSelectionPreviewControl colorSelectionPreview;
+ private System.ComponentModel.IContainer components;
+ #endregion
+
+ #region Constructor, Dispose
+ public CustomColorDialogMetro()
+ {
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+
+ //
+ // TODO: Add any constructor code after InitializeComponent call
+ //
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose(disposing);
+ }
+ #endregion
+
+ #region Windows Form Designer generated code
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.labelStandardColors = new System.Windows.Forms.Label();
+ this.colorCombControl1 = new ColorCombControl();
+ this.labelBlue = new System.Windows.Forms.Label();
+ this.labelGreen = new System.Windows.Forms.Label();
+#if (FRAMEWORK20)
+ this.numericBlue = new IntegerInput();
+ this.numericGreen = new IntegerInput();
+ this.numericRed = new IntegerInput();
+#else
+ this.numericBlue = new System.Windows.Forms.NumericUpDown();
+ this.numericGreen = new System.Windows.Forms.NumericUpDown();
+ this.numericRed = new System.Windows.Forms.NumericUpDown();
+#endif
+ this.labelCustomColors = new System.Windows.Forms.Label();
+ this.buttonOK = new ButtonX();
+ this.buttonCancel = new ButtonX();
+ this.labelNewColor = new System.Windows.Forms.Label();
+ this.labelCurrentColor = new System.Windows.Forms.Label();
+ this.tabControl2 = new DevComponents.DotNetBar.TabControl();
+ this.tabControlPanel1 = new DevComponents.DotNetBar.TabControlPanel();
+ this.tabItemStandard = new DevComponents.DotNetBar.TabItem(this.components);
+ this.tabControlPanel2 = new DevComponents.DotNetBar.TabControlPanel();
+ this.colorContrastControl1 = new ColorContrastControl();
+ this.customColorBlender3 = new CustomColorBlender();
+ this.comboColorModel = new ComboBoxEx();
+ this.labelRed = new System.Windows.Forms.Label();
+ this.labelColorModel = new System.Windows.Forms.Label();
+ this.tabItemCustom = new DevComponents.DotNetBar.TabItem(this.components);
+ this.colorSelectionPreview = new ColorSelectionPreviewControl();
+ ((System.ComponentModel.ISupportInitialize)(this.numericBlue)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericGreen)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericRed)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.tabControl2)).BeginInit();
+ this.tabControl2.SuspendLayout();
+ this.tabControlPanel1.SuspendLayout();
+ this.tabControlPanel2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // label3
+ //
+ this.labelStandardColors.BackColor = System.Drawing.Color.Transparent;
+ this.labelStandardColors.Dock = System.Windows.Forms.DockStyle.Top;
+ this.labelStandardColors.Location = new System.Drawing.Point(1, 1);
+ this.labelStandardColors.Name = "labelStandardColors";
+ this.labelStandardColors.Size = new System.Drawing.Size(224, 19);
+ this.labelStandardColors.TabIndex = 1;
+ this.labelStandardColors.Text = " Colors:";
+ this.labelStandardColors.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
+ //
+ // colorCombControl1
+ //
+ this.colorCombControl1.BackColor = System.Drawing.Color.Transparent;
+ this.colorCombControl1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.colorCombControl1.Location = new System.Drawing.Point(1, 20);
+ this.colorCombControl1.Name = "colorCombControl1";
+ this.colorCombControl1.Size = new System.Drawing.Size(224, 267);
+ this.colorCombControl1.TabIndex = 0;
+ this.colorCombControl1.SelectedColorChanged += new System.EventHandler(this.colorCombControl1_SelectedColorChanged);
+ //
+ // label8
+ //
+ this.labelBlue.BackColor = System.Drawing.Color.Transparent;
+ this.labelBlue.Location = new System.Drawing.Point(4, 256);
+ this.labelBlue.Name = "labelBlue";
+ this.labelBlue.Size = new System.Drawing.Size(90, 16);
+ this.labelBlue.TabIndex = 10;
+ this.labelBlue.Text = "&Blue:";
+ //
+ // label7
+ //
+ this.labelGreen.BackColor = System.Drawing.Color.Transparent;
+ this.labelGreen.Location = new System.Drawing.Point(4, 232);
+ this.labelGreen.Name = "labelGreen";
+ this.labelGreen.Size = new System.Drawing.Size(90, 16);
+ this.labelGreen.TabIndex = 8;
+ this.labelGreen.Text = "&Green:";
+ //
+ // numericBlue
+ //
+ this.numericBlue.Location = new System.Drawing.Point(98, 260);
+#if (FRAMEWORK20)
+ this.numericBlue.MaxValue = 255;
+ this.numericBlue.MinValue = 0;
+ this.numericBlue.ShowUpDown = true;
+ this.numericBlue.AllowEmptyState = false;
+#else
+ this.numericBlue.Maximum = new System.Decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+#endif
+ this.numericBlue.Name = "numericBlue";
+ this.numericBlue.Size = new System.Drawing.Size(47, 20);
+ this.numericBlue.TabIndex = 11;
+ this.numericBlue.ValueChanged += new System.EventHandler(this.numericRGBValueChanged);
+ //
+ // numericGreen
+ //
+ this.numericGreen.Location = new System.Drawing.Point(98, 236);
+#if (FRAMEWORK20)
+ this.numericGreen.MaxValue = 255;
+ this.numericGreen.MinValue = 0;
+ this.numericGreen.ShowUpDown = true;
+ this.numericGreen.AllowEmptyState = false;
+#else
+ this.numericGreen.Maximum = new System.Decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+#endif
+ this.numericGreen.Name = "numericGreen";
+ this.numericGreen.Size = new System.Drawing.Size(47, 20);
+ this.numericGreen.TabIndex = 9;
+ this.numericGreen.ValueChanged += new System.EventHandler(this.numericRGBValueChanged);
+ //
+ // numericRed
+ //
+ this.numericRed.Location = new System.Drawing.Point(98, 212);
+#if (FRAMEWORK20)
+ this.numericRed.MaxValue = 255;
+ this.numericRed.MinValue = 0;
+ this.numericRed.ShowUpDown = true;
+ this.numericRed.AllowEmptyState = false;
+#else
+ this.numericRed.Maximum = new System.Decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+#endif
+ this.numericRed.Name = "numericRed";
+ this.numericRed.Size = new System.Drawing.Size(47, 20);
+ this.numericRed.TabIndex = 7;
+ this.numericRed.ValueChanged += new System.EventHandler(this.numericRGBValueChanged);
+ //
+ // label4
+ //
+ this.labelCustomColors.BackColor = System.Drawing.Color.Transparent;
+ this.labelCustomColors.Dock = System.Windows.Forms.DockStyle.Top;
+ this.labelCustomColors.Location = new System.Drawing.Point(1, 1);
+ this.labelCustomColors.Name = "labelCustomColors";
+ this.labelCustomColors.Size = new System.Drawing.Size(224, 20);
+ this.labelCustomColors.TabIndex = 2;
+ this.labelCustomColors.Text = " Colors:";
+ this.labelCustomColors.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
+ //
+ // button1
+ //
+ this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.buttonOK.Location = new System.Drawing.Point(242, 6);
+ this.buttonOK.ColorTable = eButtonColor.OrangeWithBackground;
+ this.buttonOK.Name = "buttonOK";
+ this.buttonOK.Size = new System.Drawing.Size(74, 24);
+ this.buttonOK.TabIndex = 1;
+ this.buttonOK.Text = "OK";
+ //
+ // button2
+ //
+ this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.buttonCancel.Location = new System.Drawing.Point(242, 36);
+ this.buttonCancel.ColorTable = eButtonColor.OrangeWithBackground;
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(74, 24);
+ this.buttonCancel.TabIndex = 2;
+ this.buttonCancel.Text = "Cancel";
+ //
+ // label1
+ //
+ this.labelNewColor.Location = new System.Drawing.Point(256, 232);
+ this.labelNewColor.Name = "labelNewColor";
+ this.labelNewColor.Size = new System.Drawing.Size(44, 12);
+ this.labelNewColor.TabIndex = 4;
+ this.labelNewColor.Text = "New";
+ this.labelNewColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // label2
+ //
+ this.labelCurrentColor.Location = new System.Drawing.Point(256, 306);
+ this.labelCurrentColor.Name = "labelCurrentColor";
+ this.labelCurrentColor.Size = new System.Drawing.Size(44, 16);
+ this.labelCurrentColor.TabIndex = 5;
+ this.labelCurrentColor.Text = "Current";
+ this.labelCurrentColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // tabControl2
+ //
+ this.tabControl2.BackColor = Color.White;
+ this.tabControl2.ForeColor = System.Drawing.Color.Black;
+ this.tabControl2.CanReorderTabs = false;
+ this.tabControl2.Controls.Add(this.tabControlPanel2);
+ this.tabControl2.Controls.Add(this.tabControlPanel1);
+ this.tabControl2.FixedTabSize = new System.Drawing.Size(60, 0);
+ this.tabControl2.Location = new System.Drawing.Point(8, 8);
+ this.tabControl2.Name = "tabControl2";
+ this.tabControl2.SelectedTabFont = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold);
+ this.tabControl2.SelectedTabIndex = 0;
+ this.tabControl2.Size = new System.Drawing.Size(226, 314);
+ this.tabControl2.Style = DevComponents.DotNetBar.eTabStripStyle.Metro;
+ this.tabControl2.TabIndex = 6;
+ this.tabControl2.TabLayoutType = DevComponents.DotNetBar.eTabLayoutType.FixedWithNavigationBox;
+ this.tabControl2.Tabs.Add(this.tabItemStandard);
+ this.tabControl2.Tabs.Add(this.tabItemCustom);
+ this.tabControl2.ThemeAware = true;
+ //
+ // tabControlPanel1
+ //
+ this.tabControlPanel1.Controls.Add(this.colorCombControl1);
+ this.tabControlPanel1.Controls.Add(this.labelStandardColors);
+ this.tabControlPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabControlPanel1.DockPadding.All = 1;
+ this.tabControlPanel1.Location = new System.Drawing.Point(0, 26);
+ this.tabControlPanel1.Name = "tabControlPanel1";
+ this.tabControlPanel1.Size = new System.Drawing.Size(226, 288);
+ this.tabControlPanel1.Style.BackColor1.Color = System.Drawing.Color.White;
+ this.tabControlPanel1.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
+ this.tabControlPanel1.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right)
+ | DevComponents.DotNetBar.eBorderSide.Bottom)));
+ this.tabControlPanel1.Style.GradientAngle = 90;
+ this.tabControlPanel1.TabIndex = 1;
+ this.tabControlPanel1.TabItem = this.tabItemStandard;
+ this.tabControlPanel1.ThemeAware = false;
+ //
+ // tabItem1
+ //
+ this.tabItemStandard.AttachedControl = this.tabControlPanel1;
+ this.tabItemStandard.CloseButtonBounds = new System.Drawing.Rectangle(0, 0, 0, 0);
+ this.tabItemStandard.Name = "tabItemStandard";
+ this.tabItemStandard.Text = "Standard";
+ //
+ // tabControlPanel2
+ //
+ this.tabControlPanel2.Controls.Add(this.colorContrastControl1);
+ this.tabControlPanel2.Controls.Add(this.numericGreen);
+ this.tabControlPanel2.Controls.Add(this.labelGreen);
+ this.tabControlPanel2.Controls.Add(this.numericRed);
+ this.tabControlPanel2.Controls.Add(this.customColorBlender3);
+ this.tabControlPanel2.Controls.Add(this.comboColorModel);
+ this.tabControlPanel2.Controls.Add(this.labelRed);
+ this.tabControlPanel2.Controls.Add(this.labelColorModel);
+ this.tabControlPanel2.Controls.Add(this.numericBlue);
+ this.tabControlPanel2.Controls.Add(this.labelBlue);
+ this.tabControlPanel2.Controls.Add(this.labelCustomColors);
+ this.tabControlPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabControlPanel2.DockPadding.All = 1;
+ this.tabControlPanel2.Location = new System.Drawing.Point(0, 26);
+ this.tabControlPanel2.Name = "tabControlPanel2";
+ this.tabControlPanel2.Size = new System.Drawing.Size(226, 288);
+ this.tabControlPanel2.Style.BackColor1.Color = System.Drawing.Color.White;
+ this.tabControlPanel2.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
+ this.tabControlPanel2.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right)
+ | DevComponents.DotNetBar.eBorderSide.Bottom)));
+ this.tabControlPanel2.Style.GradientAngle = 90;
+ this.tabControlPanel2.TabIndex = 2;
+ this.tabControlPanel2.TabItem = this.tabItemCustom;
+ this.tabControlPanel2.ThemeAware = true;
+ //
+ // colorContrastControl1
+ //
+ this.colorContrastControl1.BackColor = System.Drawing.Color.Transparent;
+ this.colorContrastControl1.Location = new System.Drawing.Point(188, 28);
+ this.colorContrastControl1.Name = "colorContrastControl1";
+ this.colorContrastControl1.SelectedColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
+ this.colorContrastControl1.Size = new System.Drawing.Size(32, 152);
+ this.colorContrastControl1.TabIndex = 12;
+ this.colorContrastControl1.SelectedColorChanged += new System.EventHandler(this.colorContrastControl1_SelectedColorChanged);
+ //
+ // customColorBlender3
+ //
+ this.customColorBlender3.Location = new System.Drawing.Point(8, 28);
+ this.customColorBlender3.Name = "customColorBlender3";
+ this.customColorBlender3.Size = new System.Drawing.Size(174, 152);
+ this.customColorBlender3.TabIndex = 3;
+ this.customColorBlender3.SelectedColorChanged += new System.EventHandler(this.customColorBlender3_SelectedColorChanged);
+ //
+ // comboColorModel
+ //
+ this.comboColorModel.DrawMode = DrawMode.OwnerDrawFixed;
+ this.comboColorModel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboColorModel.Items.AddRange(new object[] {
+ "RGB"});
+ this.comboColorModel.Location = new System.Drawing.Point(98, 188);
+ this.comboColorModel.Name = "comboColorModel";
+ this.comboColorModel.Size = new System.Drawing.Size(89, 21);
+ this.comboColorModel.TabIndex = 5;
+ //
+ // label9
+ //
+ this.labelRed.BackColor = System.Drawing.Color.Transparent;
+ this.labelRed.Location = new System.Drawing.Point(4, 212);
+ this.labelRed.Name = "labelRed";
+ this.labelRed.Size = new System.Drawing.Size(90, 16);
+ this.labelRed.TabIndex = 6;
+ this.labelRed.Text = "&Red:";
+ //
+ // label10
+ //
+ this.labelColorModel.BackColor = System.Drawing.Color.Transparent;
+ this.labelColorModel.Location = new System.Drawing.Point(4, 192);
+ this.labelColorModel.Name = "labelColorModel";
+ this.labelColorModel.Size = new System.Drawing.Size(90, 16);
+ this.labelColorModel.TabIndex = 4;
+ this.labelColorModel.Text = "Color Mo&del:";
+ //
+ // tabItem2
+ //
+ this.tabItemCustom.AttachedControl = this.tabControlPanel2;
+ this.tabItemCustom.CloseButtonBounds = new System.Drawing.Rectangle(0, 0, 0, 0);
+ this.tabItemCustom.Name = "tabItemCustom";
+ this.tabItemCustom.Text = "Custom";
+ //
+ // colorSelectionPreview
+ //
+ this.colorSelectionPreview.CurrentColor = System.Drawing.Color.Black;
+ this.colorSelectionPreview.Location = new System.Drawing.Point(252, 252);
+ this.colorSelectionPreview.Name = "colorSelectionPreview";
+ this.colorSelectionPreview.NewColor = System.Drawing.Color.Empty;
+ this.colorSelectionPreview.Size = new System.Drawing.Size(56, 48);
+ this.colorSelectionPreview.TabIndex = 7;
+ //
+ // CustomColorDialog
+ //
+ this.AcceptButton = this.buttonOK;
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.CancelButton = this.buttonCancel;
+ this.ClientSize = new System.Drawing.Size(324, 326);
+ this.Controls.Add(this.colorSelectionPreview);
+ this.Controls.Add(this.tabControl2);
+ this.Controls.Add(this.labelCurrentColor);
+ this.Controls.Add(this.labelNewColor);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonOK);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "CustomColorDialog";
+ this.ShowInTaskbar = false;
+ this.Text = "Colors";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.numericBlue)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericGreen)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericRed)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.tabControl2)).EndInit();
+ this.tabControl2.ResumeLayout(false);
+ this.tabControlPanel1.ResumeLayout(false);
+ this.tabControlPanel2.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ #region Internal Implementation
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+ Size fixedSize = tabControl2.FixedTabSize;
+ using (Graphics g = this.CreateGraphics())
+ {
+ System.Drawing.Size s = TextDrawing.MeasureString(g, tabItemCustom.Text, this.Font);
+ System.Drawing.Size s1 = TextDrawing.MeasureString(g, tabItemStandard.Text, this.Font);
+ fixedSize.Width = Math.Max(fixedSize.Width, s.Width + 5);
+ fixedSize.Width = Math.Max(fixedSize.Width, s1.Width + 5);
+ }
+ tabControl2.FixedTabSize = fixedSize;
+ if (fixedSize.Width > tabControl2.Width / 2)
+ {
+ tabControl2.FixedTabSize = Size.Empty;
+ }
+ }
+ internal void SetStyle(eDotNetBarStyle style)
+ {
+ buttonCancel.Style = style;
+ buttonOK.Style = style;
+
+ //tabControl2.BackColor = Color.Transparent;
+ //tabControl2.ColorScheme.TabBackground = Color.Transparent;
+ //tabControl2.ColorScheme.TabBackground2 = Color.Empty;
+ }
+ private void colorCombControl1_SelectedColorChanged(object sender, System.EventArgs e)
+ {
+ SetNewColor(colorCombControl1.SelectedColor);
+ colorContrastControl1.SelectedColor = colorCombControl1.SelectedColor;
+ }
+
+ private void customColorBlender3_SelectedColorChanged(object sender, System.EventArgs e)
+ {
+ colorContrastControl1.SelectedColor = customColorBlender3.SelectedColor;
+ SetNewColor(colorContrastControl1.SelectedColor);
+ }
+
+ private bool m_SettingColor = false;
+ private void SetNewColor(Color color)
+ {
+ if (m_SettingColor) return;
+ m_SettingColor = true;
+ try
+ {
+ m_NewColor = color;
+ colorSelectionPreview.NewColor = color;
+
+ numericRed.Value = m_NewColor.R;
+ numericGreen.Value = m_NewColor.G;
+ numericBlue.Value = m_NewColor.B;
+ }
+ finally
+ {
+ m_SettingColor = false;
+ }
+ }
+
+ private void Form1_Load(object sender, System.EventArgs e)
+ {
+ comboColorModel.SelectedIndex = 0;
+ }
+
+ private void numericRGBValueChanged(object sender, System.EventArgs e)
+ {
+ SetNewColor(Color.FromArgb((int)numericRed.Value, (int)numericGreen.Value, (int)numericBlue.Value));
+ }
+
+ private void colorContrastControl1_SelectedColorChanged(object sender, System.EventArgs e)
+ {
+ SetNewColor(colorContrastControl1.SelectedColor);
+ }
+
+ public Color CurrentColor
+ {
+ get { return m_CurrentColor; }
+ set
+ {
+ m_CurrentColor = value;
+ colorSelectionPreview.CurrentColor = value;
+ customColorBlender3.SelectedColor = value;
+ colorContrastControl1.SelectedColor = value;
+ if (!value.IsEmpty)
+ {
+ numericRed.Value = value.R;
+ numericBlue.Value = value.B;
+ numericGreen.Value = value.G;
+ }
+
+ }
+ }
+
+ public Color NewColor
+ {
+ get { return m_NewColor; }
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorScheme.cs b/PROMS/DotNetBar Source Code/ColorScheme.cs
new file mode 100644
index 00000000..f59b1b5b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorScheme.cs
@@ -0,0 +1,4764 @@
+using System;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the Color scheme used by items on the Bar.
+ ///
+ public class ColorScheme
+ {
+ #region Private Variables
+ private Color m_MenuBarBackground;
+ private bool m_MenuBarBackgroundCustom=false;
+
+ private Color m_MenuBarBackground2=Color.Empty;
+ private bool m_MenuBarBackground2Custom=false;
+
+ private int m_MenuBarBackgroundGradientAngle=90;
+
+ private Color m_BarBackground;
+ private bool m_BarBackgroundCustom=false;
+
+ private Color m_BarBackground2=Color.Empty;
+ private bool m_BarBackground2Custom=false;
+
+ private int m_BarBackgroundGradientAngle=90;
+
+ private Color m_BarCaptionBackground;
+ private bool m_BarCaptionBackgroundCustom=false;
+
+ private Color m_BarCaptionBackground2=Color.Empty;
+ private bool m_BarCaptionBackground2Custom=false;
+
+ private int m_BarCaptionBackgroundGradientAngle=90;
+
+ private Color m_BarCaptionText;
+ private bool m_BarCaptionTextCustom=false;
+
+ private Color m_BarCaptionInactiveBackground;
+ private bool m_BarCaptionInactiveBackgroundCustom=false;
+
+ private Color m_BarCaptionInactiveBackground2=Color.Empty;
+ private bool m_BarCaptionInactiveBackground2Custom=false;
+
+ private int m_BarCaptionInactiveBackgroundGAngle=90;
+
+ private Color m_BarCaptionInactiveText;
+ private bool m_BarCaptionInactiveTextCustom=false;
+
+ private Color m_BarPopupBackground;
+ private bool m_BarPopupBackgroundCustom=false;
+
+ private Color m_BarPopupBorder;
+ private bool m_BarPopupBorderCustom=false;
+
+ private Color m_BarDockedBorder;
+ private bool m_BarDockedBorderCustom=false;
+
+ private Color m_BarStripeColor;
+ private bool m_BarStripeColorCustom=false;
+
+ private Color m_BarFloatingBorder;
+ private bool m_BarFloatingBorderCustom=false;
+
+ private Color m_ItemBackground;
+ private bool m_ItemBackgroundCustom=false;
+
+ private Color m_ItemBackground2;
+ private bool m_ItemBackground2Custom=false;
+
+ private int m_ItemBackgroundGradientAngle=90;
+
+ private Color m_ItemText;
+ private bool m_ItemTextCustom=false;
+
+ private Color m_ItemDisabledBackground;
+ private bool m_ItemDisabledBackgroundCustom=false;
+
+ private Color m_ItemDisabledText;
+ private bool m_ItemDisabledTextCustom=false;
+
+ private Color m_ItemHotBackground;
+ private bool m_ItemHotBackgroundCustom=false;
+
+ private Color m_ItemHotBackground2=Color.Empty;
+ private bool m_ItemHotBackground2Custom=false;
+
+ private int m_ItemHotBackgroundGradientAngle=90;
+
+ private Color m_ItemHotText;
+ private bool m_ItemHotTextCustom=false;
+
+ private Color m_ItemHotBorder;
+ private bool m_ItemHotBorderCustom=false;
+
+ private Color m_ItemPressedBackground;
+ private bool m_ItemPressedBackgroundCustom=false;
+
+ private Color m_ItemPressedBackground2=Color.Empty;
+ private bool m_ItemPressedBackground2Custom=false;
+ private int m_ItemPressedBackgroundGradientAngle=90;
+
+ private Color m_ItemPressedText;
+ private bool m_ItemPressedTextCustom=false;
+
+ private Color m_ItemPressedBorder;
+ private bool m_ItemPressedBorderCustom=false;
+
+ private Color m_ItemSeparator;
+ private bool m_ItemSeparatorCustom=false;
+
+ private Color m_ItemSeparatorShade=Color.Empty;
+ private bool m_ItemSeparatorShadeCustom=false;
+
+ private Color m_ItemExpandedBackground;
+ private bool m_ItemExpandedBackgroundCustom=false;
+
+ private Color m_ItemExpandedBackground2=Color.Empty;
+ private bool m_ItemExpandedBackground2Custom=false;
+ private int m_ItemExpandedBackgroundGradientAngle=90;
+
+ private Color m_ItemExpandedText;
+ private bool m_ItemExpandedTextCustom=false;
+
+ private Color m_ItemExpandedShadow;
+ private bool m_ItemExpandedShadowCustom=false;
+
+ private Color m_ItemExpandedBorder;
+ private bool m_ItemExpandedBorderCustom=false;
+
+ private Color m_ItemCheckedBackground;
+ private bool m_ItemCheckedBackgroundCustom=false;
+
+ private int m_ItemCheckedBackgroundGradientAngle=90;
+
+ private Color m_ItemCheckedBackground2=Color.Empty;
+ private bool m_ItemCheckedBackground2Custom=false;
+
+ private Color m_ItemCheckedBorder;
+ private bool m_ItemCheckedBorderCustom=false;
+
+ private Color m_ItemCheckedText;
+ private bool m_ItemCheckedTextCustom=false;
+
+ private Color m_MenuBorder;
+ private bool m_MenuBorderCustom=false;
+
+ private Color m_MenuBackground;
+ private bool m_MenuBackgroundCustom=false;
+
+ private Color m_MenuBackground2=Color.Empty;
+ private bool m_MenuBackground2Custom=false;
+
+ private int m_MenuBackgroundGradientAngle=0;
+
+ private Color m_MenuSide;
+ private bool m_MenuSideCustom=false;
+
+ private Color m_MenuSide2=Color.Empty;
+ private bool m_MenuSide2Custom=false;
+
+ private int m_MenuSideGradientAngle=0;
+
+ private Color m_MenuUnusedBackground;
+ private bool m_MenuUnusedBackgroundCustom=false;
+
+ private Color m_MenuUnusedSide;
+ private bool m_MenuUnusedSideCustom=false;
+
+ private Color m_MenuUnusedSide2=Color.Empty;
+ private bool m_MenuUnusedSide2Custom=false;
+
+ private int m_MenuUnusedSideGradientAngle=0;
+
+ private Color m_ItemDesignTimeBorder;
+ private bool m_ItemDesignTimeBorderCustom=false;
+
+ private Color m_CustomizeBackground=Color.Empty;
+ private bool m_CustomizeBackgroundCustom=false;
+ private Color m_CustomizeBackground2=Color.Empty;
+ private bool m_CustomizeBackground2Custom=false;
+ private int m_CustomizeBackgroundGradientAngle=90;
+ private Color m_CustomizeText=Color.Empty;
+ private bool m_CustomizeTextCustom=false;
+
+ // Panel Colors
+ private Color m_PanelBackground=Color.Empty;
+ private bool m_PanelBackgroundCustom=false;
+
+ private Color m_PanelBackground2=Color.Empty;
+ private bool m_PanelBackground2Custom=false;
+
+ private int m_PanelBackgroundGradientAngle=90;
+
+ private Color m_PanelText=Color.Empty;
+ private bool m_PanelTextCustom=false;
+
+ private Color m_PanelBorder=Color.Empty;
+ private bool m_PanelBorderCustom=false;
+
+ // Splitter Colors
+ private Color m_SplitterBackground = Color.Empty;
+ private bool m_SplitterBackgroundCustom = false;
+
+ private Color m_SplitterBackground2 = Color.Empty;
+ private bool m_SplitterBackground2Custom = false;
+
+ private int m_SplitterBackgroundGradientAngle = 90;
+
+ private Color m_SplitterText = Color.Empty;
+ private bool m_SplitterTextCustom = false;
+
+ private Color m_SplitterBorder = Color.Empty;
+ private bool m_SplitterBorderCustom = false;
+
+ private Color m_ExplorerBarBackground=Color.Empty;
+ private bool m_ExplorerBarBackgroundCustom=false;
+ private Color m_ExplorerBarBackground2=Color.Empty;
+ private bool m_ExplorerBarBackground2Custom=false;
+ private int m_ExplorerBarBackgroundGradientAngle=90;
+
+ internal bool _DesignTimeSchemeChanged=false;
+
+ private eDotNetBarStyle m_Style=eDotNetBarStyle.OfficeXP;
+
+ private Color m_DockSiteBackColor=Color.Empty;
+ private bool m_DockSiteBackColorCustom=false;
+ private Color m_DockSiteBackColor2=Color.Empty;
+ private bool m_DockSiteBackColor2Custom=false;
+ private int m_DockSiteBackColorGradientAngle=0;
+
+ private ePredefinedColorScheme m_PredefinedColorScheme=ePredefinedColorScheme.AutoGenerated;
+
+ private Color m_MdiSystemItemForeground = Color.Empty;
+ #endregion
+
+ #region Public Interface
+ public ColorScheme()
+ {
+ Refresh(null,false);
+ }
+ public ColorScheme(System.Drawing.Graphics graphics)
+ {
+ Refresh(graphics,false);
+ }
+
+ public ColorScheme(eDotNetBarStyle style)
+ {
+ m_Style=style;
+ Refresh(null,true);
+ }
+
+#if !NOTREE
+ public ColorScheme(DevComponents.AdvTree.eColorSchemeStyle cs)
+ {
+ eDotNetBarStyle style = eDotNetBarStyle.Office2003;
+ if (cs == DevComponents.AdvTree.eColorSchemeStyle.VS2005)
+ style = eDotNetBarStyle.VS2005;
+ else if (cs == DevComponents.AdvTree.eColorSchemeStyle.Office2007)
+ style = eDotNetBarStyle.Office2007;
+ m_Style = style;
+ Refresh(null, true);
+ }
+#endif
+
+ internal eDotNetBarStyle Style
+ {
+ get {return m_Style;}
+ set
+ {
+ if(m_Style!=value)
+ {
+ m_Style=value;
+ this.Refresh();
+ }
+ }
+ }
+
+ internal void SwitchStyle(eDotNetBarStyle style)
+ {
+ if(m_Style!=style)
+ {
+ m_Style=style;
+ this.Refresh(null,true);
+ }
+ }
+
+ ///
+ /// Specifies Dock Site BackColor.
+ ///
+ [Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Panel Colors"), System.ComponentModel.Description("Specifies starting color of dock site.")]
+ public Color DockSiteBackColor
+ {
+ get { return m_DockSiteBackColor; }
+ set
+ {
+ if(m_DockSiteBackColor != value)
+ {
+ m_DockSiteBackColor = value;
+ m_DockSiteBackColorCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeDockSiteBackColor()
+ {
+ return m_DockSiteBackColorCustom;
+ }
+ ///
+ /// Specifies Dock Site BackColor2.
+ ///
+ [Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Panel Colors"), System.ComponentModel.Description("Specifies ending gradient color of dock site.")]
+ public Color DockSiteBackColor2
+ {
+ get { return m_DockSiteBackColor2; }
+ set
+ {
+ if(m_DockSiteBackColor2 != value)
+ {
+ m_DockSiteBackColor2 = value;
+ m_DockSiteBackColor2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeDockSiteBackColor2()
+ {
+ return m_DockSiteBackColor2Custom;
+ }
+
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Panel Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(0)]
+ public int DockSiteBackColorGradientAngle
+ {
+ get {return m_DockSiteBackColorGradientAngle;}
+ set {m_DockSiteBackColorGradientAngle=value;}
+ }
+
+ ///
+ /// Specifies the menu bar background color.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the menu bar background color.")]
+ public Color MenuBarBackground
+ {
+ get{return m_MenuBarBackground;}
+ set
+ {
+ if(m_MenuBarBackground!=value)
+ {
+ m_MenuBarBackground=value;
+ m_MenuBarBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuBarBackground()
+ {
+ return m_MenuBarBackgroundCustom;
+ }
+ ///
+ /// Specifies the target menu bar gradient background color.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the target menu bar gradient background color.")]
+ public Color MenuBarBackground2
+ {
+ get{return m_MenuBarBackground2;}
+ set
+ {
+ if(m_MenuBarBackground2!=value)
+ {
+ m_MenuBarBackground2=value;
+ m_MenuBarBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuBarBackground2()
+ {
+ return m_MenuBarBackground2Custom;
+ }
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(90)]
+ public int MenuBarBackgroundGradientAngle
+ {
+ get {return m_MenuBarBackgroundGradientAngle;}
+ set {m_MenuBarBackgroundGradientAngle=value;}
+ }
+ ///
+ /// Specifies the background color for the bar when floating or when docked.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the background color for the bar when floating or when docked.")]
+ public Color BarBackground
+ {
+ get {return m_BarBackground;}
+ set
+ {
+ if(m_BarBackground!=value)
+ {
+ m_BarBackground=value;
+ m_BarBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarBackground()
+ {
+ return m_BarBackgroundCustom;
+ }
+ ///
+ /// Specifies the target gradient background color for the bar when floating or when docked.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the target gradient background color for the bar when floating or when docked.")]
+ public Color BarBackground2
+ {
+ get {return m_BarBackground2;}
+ set
+ {
+ if(m_BarBackground2!=value)
+ {
+ m_BarBackground2=value;
+ m_BarBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarBackground2()
+ {
+ return m_BarBackground2Custom;
+ }
+
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(90)]
+ public int BarBackgroundGradientAngle
+ {
+ get {return m_BarBackgroundGradientAngle;}
+ set {m_BarBackgroundGradientAngle=value;}
+ }
+
+ ///
+ /// Specifies the background color for the bar Caption.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the background color for the bar Caption.")]
+ public Color BarCaptionBackground
+ {
+ get{return m_BarCaptionBackground;}
+ set
+ {
+ if(m_BarCaptionBackground!=value)
+ {
+ m_BarCaptionBackground=value;
+ m_BarCaptionBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarCaptionBackground()
+ {
+ return m_BarCaptionBackgroundCustom;
+ }
+ ///
+ /// Specifies the target gradient background color for the bar Caption.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the target bar gradient background color for the bar Caption.")]
+ public Color BarCaptionBackground2
+ {
+ get{return m_BarCaptionBackground2;}
+ set
+ {
+ if(m_BarCaptionBackground2!=value)
+ {
+ m_BarCaptionBackground2=value;
+ m_BarCaptionBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarCaptionBackground2()
+ {
+ return m_BarCaptionBackground2Custom;
+ }
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(90)]
+ public int BarCaptionBackgroundGradientAngle
+ {
+ get {return m_BarCaptionBackgroundGradientAngle;}
+ set{m_BarCaptionBackgroundGradientAngle=value;}
+ }
+ ///
+ /// Specifies the color for text of the Caption.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the color for text of the Caption.")]
+ public Color BarCaptionText
+ {
+ get {return m_BarCaptionText;}
+ set
+ {
+ if(m_BarCaptionText!=value)
+ {
+ m_BarCaptionText=value;
+ m_BarCaptionTextCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarCaptionText()
+ {
+ return m_BarCaptionTextCustom;
+ }
+ ///
+ /// Specifies the Bar Caption inactive (lost focus) background color.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the Bar Caption inactive (lost focus) background color.")]
+ public Color BarCaptionInactiveBackground
+ {
+ get {return m_BarCaptionInactiveBackground;}
+ set
+ {
+ if(m_BarCaptionInactiveBackground!=value)
+ {
+ m_BarCaptionInactiveBackground=value;
+ m_BarCaptionInactiveBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarCaptionInactiveBackground()
+ {
+ return m_BarCaptionInactiveBackgroundCustom;
+ }
+ ///
+ /// Specifies the target background gradient Bar Caption inactive (lost focus) color.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the target background gradient Bar Caption inactive (lost focus) color.")]
+ public Color BarCaptionInactiveBackground2
+ {
+ get {return m_BarCaptionInactiveBackground2;}
+ set
+ {
+ if(m_BarCaptionInactiveBackground2!=value)
+ {
+ m_BarCaptionInactiveBackground2=value;
+ m_BarCaptionInactiveBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarCaptionInactiveBackground2()
+ {
+ return m_BarCaptionInactiveBackground2Custom;
+ }
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(90)]
+ internal int BarCaptionInactiveBackgroundGAngle
+ {
+ get {return m_BarCaptionInactiveBackgroundGAngle;}
+ set {m_BarCaptionInactiveBackgroundGAngle=value;}
+ }
+ ///
+ /// Specifies the Bar inactive (lost focus) text color.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the Bar inactive (lost focus) text color.")]
+ public Color BarCaptionInactiveText
+ {
+ get {return m_BarCaptionInactiveText;}
+ set
+ {
+ if(m_BarCaptionInactiveText!=value)
+ {
+ m_BarCaptionInactiveText=value;
+ m_BarCaptionInactiveTextCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarCaptionInactiveText()
+ {
+ return m_BarCaptionInactiveTextCustom;
+ }
+ ///
+ /// Specifies the background color for popup bars.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the background color for popup bars.")]
+ public Color BarPopupBackground
+ {
+ get {return m_BarPopupBackground;}
+ set
+ {
+ if(m_BarPopupBackground!=value)
+ {
+ m_BarPopupBackground=value;
+ m_BarPopupBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarPopupBackground()
+ {
+ return m_BarPopupBackgroundCustom;
+ }
+ ///
+ /// Specifies the border color for popup bars.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the border color for popup bars.")]
+ public Color BarPopupBorder
+ {
+ get {return m_BarPopupBorder;}
+ set
+ {
+ if(m_BarPopupBorder!=value)
+ {
+ m_BarPopupBorder=value;
+ m_BarPopupBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarPopupBorder()
+ {
+ return m_BarPopupBorderCustom;
+ }
+ ///
+ /// Specifies the border color for docked bars.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the border color for docked bars.")]
+ public Color BarDockedBorder
+ {
+ get {return m_BarDockedBorder;}
+ set
+ {
+ if(m_BarDockedBorder!=value)
+ {
+ m_BarDockedBorder=value;
+ m_BarDockedBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarDockedBorder()
+ {
+ return m_BarDockedBorderCustom;
+ }
+ ///
+ /// Specifies the color of the grab handle stripes.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the color of the grab handle stripes.")]
+ public Color BarStripeColor
+ {
+ get {return m_BarStripeColor;}
+ set
+ {
+ if(m_BarStripeColor!=value)
+ {
+ m_BarStripeColor=value;
+ m_BarStripeColorCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarStripeColor()
+ {
+ return m_BarStripeColorCustom;
+ }
+ ///
+ /// Specifies the border color for floating bars.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Bar Colors"),System.ComponentModel.Description("Specifies the border color for floating bars.")]
+ public Color BarFloatingBorder
+ {
+ get {return m_BarFloatingBorder;}
+ set
+ {
+ if(m_BarFloatingBorder!=value)
+ {
+ m_BarFloatingBorder=value;
+ m_BarFloatingBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBarFloatingBorder()
+ {
+ return m_BarFloatingBorderCustom;
+ }
+ ///
+ /// Specifies the item background color.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the item background color.")]
+ public Color ItemBackground
+ {
+ get {return m_ItemBackground;}
+ set
+ {
+ if(m_ItemBackground!=value)
+ {
+ m_ItemBackground=value;
+ m_ItemBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemBackground()
+ {
+ return m_ItemBackgroundCustom;
+ }
+ ///
+ /// Specifies the target item background gradient color.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the target item background gradient color.")]
+ public Color ItemBackground2
+ {
+ get {return m_ItemBackground2;}
+ set
+ {
+ if(m_ItemBackground2!=value)
+ {
+ m_ItemBackground2=value;
+ m_ItemBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemBackground2()
+ {
+ return m_ItemBackground2Custom;
+ }
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(90)]
+ public int ItemBackgroundGradientAngle
+ {
+ get {return m_ItemBackgroundGradientAngle;}
+ set {m_ItemBackgroundGradientAngle=value;}
+ }
+
+ ///
+ /// Specifies the item text color.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the item text color.")]
+ public Color ItemText
+ {
+ get {return m_ItemText;}
+ set
+ {
+ if(m_ItemText!=value)
+ {
+ m_ItemText=value;
+ m_ItemTextCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemText()
+ {
+ return m_ItemTextCustom;
+ }
+ ///
+ /// Specifies the background color for the item that is disabled.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the background color for the item that is disabled.")]
+ public Color ItemDisabledBackground
+ {
+ get {return m_ItemDisabledBackground;}
+ set
+ {
+ if(m_ItemDisabledBackground!=value)
+ {
+ m_ItemDisabledBackground=value;
+ m_ItemDisabledBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemDisabledBackground()
+ {
+ return m_ItemDisabledBackgroundCustom;
+ }
+ ///
+ /// Specifies the text color for the item that is disabled.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the text color for the item that is disabled.")]
+ public Color ItemDisabledText
+ {
+ get {return m_ItemDisabledText;}
+ set
+ {
+ if(m_ItemDisabledText!=value)
+ {
+ m_ItemDisabledText=value;
+ m_ItemDisabledTextCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemDisabledText()
+ {
+ return m_ItemDisabledTextCustom;
+ }
+ ///
+ /// Specifies the background color when mouse is over the item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the background color when mouse is over the item.")]
+ public Color ItemHotBackground
+ {
+ get {return m_ItemHotBackground;}
+ set
+ {
+ if(m_ItemHotBackground!=value)
+ {
+ m_ItemHotBackground=value;
+ m_ItemHotBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemHotBackground()
+ {
+ return m_ItemHotBackgroundCustom;
+ }
+ ///
+ /// Specifies the target gradient background color when mouse is over the item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the target gradient background color when mouse is over the item.")]
+ public Color ItemHotBackground2
+ {
+ get {return m_ItemHotBackground2;}
+ set
+ {
+ if(m_ItemHotBackground2!=value)
+ {
+ m_ItemHotBackground2=value;
+ m_ItemHotBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemHotBackground2()
+ {
+ return m_ItemHotBackground2Custom;
+ }
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(90)]
+ public int ItemHotBackgroundGradientAngle
+ {
+ get {return m_ItemHotBackgroundGradientAngle;}
+ set {m_ItemHotBackgroundGradientAngle=value;}
+ }
+ ///
+ /// Specifies the text color when mouse is over the item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the text color when mouse is over the item.")]
+ public Color ItemHotText
+ {
+ get {return m_ItemHotText;}
+ set
+ {
+ if(m_ItemHotText!=value)
+ {
+ m_ItemHotText=value;
+ m_ItemHotTextCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemHotText()
+ {
+ return m_ItemHotTextCustom;
+ }
+ ///
+ /// Specifies the border color when mouse is over the item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the border color when mouse is over the item.")]
+ public Color ItemHotBorder
+ {
+ get {return m_ItemHotBorder;}
+ set
+ {
+ if(m_ItemHotBorder!=value)
+ {
+ m_ItemHotBorder=value;
+ m_ItemHotBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemHotBorder()
+ {
+ return m_ItemHotBorderCustom;
+ }
+ ///
+ /// Specifies the background color when item is pressed.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the background color when item is pressed.")]
+ public Color ItemPressedBackground
+ {
+ get {return m_ItemPressedBackground;}
+ set
+ {
+ if(m_ItemPressedBackground!=value)
+ {
+ m_ItemPressedBackground=value;
+ m_ItemPressedBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemPressedBackground()
+ {
+ return m_ItemPressedBackgroundCustom;
+ }
+ ///
+ /// Specifies the target gradient background color when item is pressed.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the target gradient background color when item is pressed.")]
+ public Color ItemPressedBackground2
+ {
+ get {return m_ItemPressedBackground2;}
+ set
+ {
+ if(m_ItemPressedBackground2!=value)
+ {
+ m_ItemPressedBackground2=value;
+ m_ItemPressedBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemPressedBackground2()
+ {
+ return m_ItemPressedBackground2Custom;
+ }
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(90)]
+ public int ItemPressedBackgroundGradientAngle
+ {
+ get {return m_ItemPressedBackgroundGradientAngle;}
+ set {m_ItemPressedBackgroundGradientAngle=value;}
+ }
+ ///
+ /// Specifies the text color when item is pressed.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the text color when item is pressed.")]
+ public Color ItemPressedText
+ {
+ get {return m_ItemPressedText;}
+ set
+ {
+ if(m_ItemPressedText!=value)
+ {
+ m_ItemPressedText=value;
+ m_ItemPressedTextCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemPressedText()
+ {
+ return m_ItemPressedTextCustom;
+ }
+ ///
+ /// Specifies the border color when item is pressed.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the border color when item is pressed.")]
+ public Color ItemPressedBorder
+ {
+ get {return m_ItemPressedBorder;}
+ set
+ {
+ if(m_ItemPressedBorder!=value)
+ {
+ m_ItemPressedBorder=value;
+ m_ItemPressedBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemPressedBorder()
+ {
+ return m_ItemPressedBorderCustom;
+ }
+ ///
+ /// Specifies the color for the item group separator.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the color for the item group separator.")]
+ public Color ItemSeparator
+ {
+ get {return m_ItemSeparator;}
+ set
+ {
+ if(m_ItemSeparator!=value)
+ {
+ m_ItemSeparator=value;
+ m_ItemSeparatorCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemSeparator()
+ {
+ return m_ItemSeparatorCustom;
+ }
+ ///
+ /// Specifies the color for the item group separator shade.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the color for the item group separator shade.")]
+ public Color ItemSeparatorShade
+ {
+ get {return m_ItemSeparatorShade;}
+ set
+ {
+ if(m_ItemSeparatorShade!=value)
+ {
+ m_ItemSeparatorShade=value;
+ m_ItemSeparatorShadeCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemSeparatorShade()
+ {
+ return m_ItemSeparatorShadeCustom;
+ }
+ ///
+ /// Specifies the background color for the shadow of expanded item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the background color for the shadow of expanded item.")]
+ public Color ItemExpandedShadow
+ {
+ get {return m_ItemExpandedShadow;}
+ set
+ {
+ if(m_ItemExpandedShadow!=value)
+ {
+ m_ItemExpandedShadow=value;
+ m_ItemExpandedShadowCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemExpandedShadow()
+ {
+ return m_ItemExpandedShadowCustom;
+ }
+ ///
+ /// Specifies the background color for the expanded item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the background color for the expanded item.")]
+ public Color ItemExpandedBackground
+ {
+ get {return m_ItemExpandedBackground;}
+ set
+ {
+ if(m_ItemExpandedBackground!=value)
+ {
+ m_ItemExpandedBackground=value;
+ m_ItemExpandedBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemExpandedBackground()
+ {
+ return m_ItemExpandedBackgroundCustom;
+ }
+ ///
+ /// Specifies the target gradient background color for the expanded item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the target gradient background color for the expanded item.")]
+ public Color ItemExpandedBackground2
+ {
+ get {return m_ItemExpandedBackground2;}
+ set
+ {
+ if(m_ItemExpandedBackground2!=value)
+ {
+ m_ItemExpandedBackground2=value;
+ m_ItemExpandedBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemExpandedBackground2()
+ {
+ return m_ItemExpandedBackground2Custom;
+ }
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(90)]
+ public int ItemExpandedBackgroundGradientAngle
+ {
+ get {return m_ItemExpandedBackgroundGradientAngle;}
+ set {m_ItemExpandedBackgroundGradientAngle=value;}
+ }
+
+ ///
+ /// Specifies the text color for the expanded item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the text color for the expanded item.")]
+ public Color ItemExpandedText
+ {
+ get {return m_ItemExpandedText;}
+ set
+ {
+ if(m_ItemExpandedText!=value)
+ {
+ m_ItemExpandedText=value;
+ m_ItemExpandedTextCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemExpandedText()
+ {
+ return m_ItemExpandedTextCustom;
+ }
+ ///
+ /// Specifies the border color for the expanded item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the border color for the expanded item.")]
+ public Color ItemExpandedBorder
+ {
+ get {return m_ItemExpandedBorder;}
+ set
+ {
+ if(m_ItemExpandedBorder!=value)
+ {
+ m_ItemExpandedBorder=value;
+ m_ItemExpandedBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemExpandedBorder()
+ {
+ return m_ItemExpandedBorderCustom;
+ }
+
+ ///
+ /// Specifies the background color for the checked item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the background color for the checked item.")]
+ public Color ItemCheckedBackground
+ {
+ get {return m_ItemCheckedBackground;}
+ set
+ {
+ if(m_ItemCheckedBackground!=value)
+ {
+ m_ItemCheckedBackground=value;
+ m_ItemCheckedBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemCheckedBackground()
+ {
+ return m_ItemCheckedBackgroundCustom;
+ }
+ ///
+ /// Specifies the target gradient background color for the checked item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the target gradient background color for the checked item.")]
+ public Color ItemCheckedBackground2
+ {
+ get {return m_ItemCheckedBackground2;}
+ set
+ {
+ if(m_ItemCheckedBackground2!=value)
+ {
+ m_ItemCheckedBackground2=value;
+ m_ItemCheckedBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemCheckedBackground2()
+ {
+ return m_ItemCheckedBackground2Custom;
+ }
+ ///
+ /// Specifies the gradient angle.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the gradient angle."),DefaultValue(90)]
+ public int ItemCheckedBackgroundGradientAngle
+ {
+ get {return m_ItemCheckedBackgroundGradientAngle;}
+ set {m_ItemCheckedBackgroundGradientAngle=value;}
+ }
+
+ ///
+ /// Specifies the border color for the checked item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the border color for the checked item.")]
+ public Color ItemCheckedBorder
+ {
+ get {return m_ItemCheckedBorder;}
+ set
+ {
+ if(m_ItemCheckedBorder!=value)
+ {
+ m_ItemCheckedBorder=value;
+ m_ItemCheckedBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemCheckedBorder()
+ {
+ return m_ItemCheckedBorderCustom;
+ }
+ ///
+ /// Specifies the text color for the checked item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Item Colors"),System.ComponentModel.Description("Specifies the text color for the checked item.")]
+ public Color ItemCheckedText
+ {
+ get {return m_ItemCheckedText;}
+ set
+ {
+ if(m_ItemCheckedText!=value)
+ {
+ m_ItemCheckedText=value;
+ m_ItemCheckedTextCustom=true;
+ }
+ }
+
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemCheckedText()
+ {
+ return m_ItemCheckedTextCustom;
+ }
+ ///
+ /// Specifies the customize item background color. Applies to Office2003 style only.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Special Item Colors"),System.ComponentModel.Description("Specifies the customize item background color.")]
+ public Color CustomizeBackground
+ {
+ get {return m_CustomizeBackground;}
+ set
+ {
+ if(m_CustomizeBackground!=value)
+ {
+ m_CustomizeBackground=value;
+ m_CustomizeBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeCustomizeBackground()
+ {
+ return m_CustomizeBackgroundCustom;
+ }
+ ///
+ /// Specifies the customize item target gradient background color. Applies to Office2003 style only.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Special Item Colors"),System.ComponentModel.Description("Specifies the customize item target gradient background color.")]
+ public Color CustomizeBackground2
+ {
+ get {return m_CustomizeBackground2;}
+ set
+ {
+ if(m_CustomizeBackground2!=value)
+ {
+ m_CustomizeBackground2=value;
+ m_CustomizeBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeCustomizeBackground2()
+ {
+ return m_CustomizeBackground2Custom;
+ }
+ ///
+ /// Specifies the customize item background color gradient angle. Applies to Office2003 style only.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Special Item Colors"),System.ComponentModel.Description("Specifies the customize item background color gradient angle."),DefaultValue(90)]
+ public int CustomizeBackgroundGradientAngle
+ {
+ get {return m_CustomizeBackgroundGradientAngle;}
+ set {m_CustomizeBackgroundGradientAngle=value;}
+ }
+ ///
+ /// Specifies the customize item text color. Applies to Office2003 style only.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Special Item Colors"),System.ComponentModel.Description("Specifies the customize item text color.")]
+ public Color CustomizeText
+ {
+ get {return m_CustomizeText;}
+ set
+ {
+ if(m_CustomizeText!=value)
+ {
+ m_CustomizeText=value;
+ m_CustomizeTextCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeCustomizeText()
+ {
+ return m_CustomizeTextCustom;
+ }
+ ///
+ /// Specifies the color of the menu border.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the color of the menu border.")]
+ public Color MenuBorder
+ {
+ get {return m_MenuBorder;}
+ set
+ {
+ if(m_MenuBorder!=value)
+ {
+ m_MenuBorder=value;
+ m_MenuBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuBorder()
+ {
+ return m_MenuBorderCustom;
+ }
+ ///
+ /// Specifies the background color of the menu.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the background color of the menu.")]
+ public Color MenuBackground
+ {
+ get {return m_MenuBackground;}
+ set
+ {
+ if(m_MenuBackground!=value)
+ {
+ m_MenuBackground=value;
+ m_MenuBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuBackground()
+ {
+ return m_MenuBackgroundCustom;
+ }
+ ///
+ /// Specifies the target gradient background color of the menu.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the target gradient background color of the menu.")]
+ public Color MenuBackground2
+ {
+ get {return m_MenuBackground2;}
+ set
+ {
+ if(m_MenuBackground2!=value)
+ {
+ m_MenuBackground2=value;
+ m_MenuBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuBackground2()
+ {
+ return m_MenuBackground2Custom;
+ }
+ ///
+ /// Specifies the angle of the gradient fill for the menu background.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the angle of the gradient fill for the menu background."),DefaultValue(0)]
+ public int MenuBackgroundGradientAngle
+ {
+ get {return m_MenuBackgroundGradientAngle;}
+ set
+ {
+ if(m_MenuBackgroundGradientAngle!=value)
+ {
+ m_MenuBackgroundGradientAngle=value;
+ }
+ }
+ }
+ ///
+ /// Specifies the background color of the menu part (left side) that is showing the images.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the background color of the menu part (left side) that is showing the images.")]
+ public Color MenuSide
+ {
+ get {return m_MenuSide;}
+ set
+ {
+ if(m_MenuSide!=value)
+ {
+ m_MenuSide=value;
+ m_MenuSideCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuSide()
+ {
+ return m_MenuSideCustom;
+ }
+ ///
+ /// Specifies the target gradient background color of the menu part (left side) that is showing the images.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the target gradient background color of the menu part (left side) that is showing the images.")]
+ public Color MenuSide2
+ {
+ get {return m_MenuSide2;}
+ set
+ {
+ if(m_MenuSide2!=value)
+ {
+ m_MenuSide2=value;
+ m_MenuSide2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuSide2()
+ {
+ return m_MenuSide2Custom;
+ }
+ ///
+ /// Specifies the angle of the gradient fill for the menu part (left side) that is showing the images.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the angle of the gradient fill for the menu part (left side) that is showing the images."),DefaultValue(0)]
+ public int MenuSideGradientAngle
+ {
+ get {return m_MenuSideGradientAngle;}
+ set
+ {
+ if(m_MenuSideGradientAngle!=value)
+ {
+ m_MenuSideGradientAngle=value;
+ }
+ }
+ }
+ ///
+ /// Specifies the background color for the items that were not recently used.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the background color for the items that were not recently used.")]
+ public Color MenuUnusedBackground
+ {
+ get {return m_MenuUnusedBackground;}
+ set
+ {
+ if(m_MenuUnusedBackground!=value)
+ {
+ m_MenuUnusedBackground=value;
+ m_MenuUnusedBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuUnusedBackground()
+ {
+ return m_MenuUnusedBackgroundCustom;
+ }
+ ///
+ /// Specifies the side bar color for the items that were not recently used.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the side bar color for the items that were not recently used.")]
+ public Color MenuUnusedSide
+ {
+ get {return m_MenuUnusedSide;}
+ set
+ {
+ if(m_MenuUnusedSide!=value)
+ {
+ m_MenuUnusedSide=value;
+ m_MenuUnusedSideCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuUnusedSide()
+ {
+ return m_MenuUnusedSideCustom;
+ }
+ ///
+ /// Specifies the target gradient side bar color for the items that were not recently used.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the target gradient side bar color for the items that were not recently used.")]
+ public Color MenuUnusedSide2
+ {
+ get {return m_MenuUnusedSide2;}
+ set
+ {
+ if(m_MenuUnusedSide2!=value)
+ {
+ m_MenuUnusedSide2=value;
+ m_MenuUnusedSide2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMenuUnusedSide2()
+ {
+ return m_MenuUnusedSide2Custom;
+ }
+ ///
+ /// Specifies the angle of the gradient fill for the menu part (left side) that is showing the images.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Menu Colors"),System.ComponentModel.Description("Specifies the angle of the gradient fill for the menu part (left side) that is showing the images."),DefaultValue(0)]
+ public int MenuUnusedSideGradientAngle
+ {
+ get {return m_MenuUnusedSideGradientAngle;}
+ set
+ {
+ if(m_MenuUnusedSideGradientAngle!=value)
+ {
+ m_MenuUnusedSideGradientAngle=value;
+ }
+ }
+ }
+ ///
+ /// Specifies the border color for focused design-time item.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Design Colors"),System.ComponentModel.Description("Specifies the border color for focused design-time item.")]
+ public Color ItemDesignTimeBorder
+ {
+ get {return m_ItemDesignTimeBorder;}
+ set
+ {
+ if(m_ItemDesignTimeBorder!=value)
+ {
+ m_ItemDesignTimeBorder=value;
+ m_ItemDesignTimeBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeItemDesignTimeBorder()
+ {
+ return m_ItemDesignTimeBorderCustom;
+ }
+
+ ///
+ /// Gets or sets predefined color scheme. By default DotNetBar will automatically change and generate color scheme depending on system colors.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Color Scheme"),System.ComponentModel.Description("Indicates predefined color scheme. By default DotNetBar will automatically change and generate color scheme depending on system colors."),DefaultValue(ePredefinedColorScheme.AutoGenerated)]
+ public ePredefinedColorScheme PredefinedColorScheme
+ {
+ get {return m_PredefinedColorScheme;}
+ set
+ {
+ if(m_PredefinedColorScheme!=value)
+ {
+ m_PredefinedColorScheme=value;
+ this.Refresh();
+ }
+ }
+ }
+
+ ///
+ /// Specifies the background color of the panel.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Panel Colors"),System.ComponentModel.Description("Specifies the background color of the panel.")]
+ public Color PanelBackground
+ {
+ get {return m_PanelBackground;}
+ set
+ {
+ if(m_PanelBackground!=value)
+ {
+ m_PanelBackground=value;
+ m_PanelBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializePanelBackground()
+ {
+ return m_PanelBackgroundCustom;
+ }
+ ///
+ /// Specifies the target background gradient color of the panel.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Panel Colors"),System.ComponentModel.Description("Specifies the target background gradient color of the panel.")]
+ public Color PanelBackground2
+ {
+ get {return m_PanelBackground2;}
+ set
+ {
+ if(m_PanelBackground2!=value)
+ {
+ m_PanelBackground2=value;
+ m_PanelBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializePanelBackground2()
+ {
+ return m_PanelBackground2Custom;
+ }
+ ///
+ /// Specifies the angle of the gradient fill for the panel background.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Panel Colors"),System.ComponentModel.Description("Specifies the angle of the gradient fill for the panel background."),DefaultValue(90)]
+ public int PanelBackgroundGradientAngle
+ {
+ get {return m_PanelBackgroundGradientAngle;}
+ set
+ {
+ if(m_PanelBackgroundGradientAngle!=value)
+ {
+ m_PanelBackgroundGradientAngle=value;
+ }
+ }
+ }
+ ///
+ /// Specifies border color of the panel.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Panel Colors"),System.ComponentModel.Description("Specifies border color of the panel.")]
+ public Color PanelBorder
+ {
+ get {return m_PanelBorder;}
+ set
+ {
+ if(m_PanelBorder!=value)
+ {
+ m_PanelBorder=value;
+ m_PanelBorderCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializePanelBorder()
+ {
+ return m_PanelBorderCustom;
+ }
+ ///
+ /// Specifies color of the text on the panel.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Panel Colors"),System.ComponentModel.Description("Specifies color of the text on the panel.")]
+ public Color PanelText
+ {
+ get {return m_PanelText;}
+ set
+ {
+ if(m_PanelText!=value)
+ {
+ m_PanelText=value;
+ m_PanelTextCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializePanelText()
+ {
+ return m_PanelTextCustom;
+ }
+
+ ///
+ /// Specifies the background color of the explorer bar.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Explorer Bar Colors"),System.ComponentModel.Description("Specifies the background color of the explorer bar.")]
+ public Color ExplorerBarBackground
+ {
+ get {return m_ExplorerBarBackground;}
+ set
+ {
+ if(m_ExplorerBarBackground!=value)
+ {
+ m_ExplorerBarBackground=value;
+ m_ExplorerBarBackgroundCustom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeExplorerBarBackground()
+ {
+ return m_ExplorerBarBackgroundCustom;
+ }
+ ///
+ /// Specifies the target gradient background color of the explorer bar.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Explorer Bar Colors"),System.ComponentModel.Description("Specifies target gradient background color of the explorer bar.")]
+ public Color ExplorerBarBackground2
+ {
+ get {return m_ExplorerBarBackground2;}
+ set
+ {
+ if(m_ExplorerBarBackground2!=value)
+ {
+ m_ExplorerBarBackground2=value;
+ m_ExplorerBarBackground2Custom=true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeExplorerBarBackground2()
+ {
+ return m_ExplorerBarBackground2Custom;
+ }
+ ///
+ /// Specifies the angle of the gradient fill for the explorer bar background.
+ ///
+ [Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Explorer Bar Colors"),System.ComponentModel.Description("Specifies the angle of the gradient fill for the explorer bar background."),DefaultValue(90)]
+ public int ExplorerBarBackgroundGradientAngle
+ {
+ get {return m_ExplorerBarBackgroundGradientAngle;}
+ set
+ {
+ if(m_ExplorerBarBackgroundGradientAngle!=value)
+ {
+ m_ExplorerBarBackgroundGradientAngle=value;
+ }
+ }
+ }
+
+ ///
+ /// Specifies the foreground color of MDI System Item buttons.
+ ///
+ [Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Item Colors"), System.ComponentModel.Description("Specifies the foreground color of MDI System Item buttons.")]
+ public Color MdiSystemItemForeground
+ {
+ get { return m_MdiSystemItemForeground; }
+ set
+ {
+ m_MdiSystemItemForeground = value;
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeMdiSystemItemForeground()
+ {
+ return !m_MdiSystemItemForeground.IsEmpty;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetMdiSystemItemForeground()
+ {
+ MdiSystemItemForeground = Color.Empty;
+ }
+
+
+ ///
+ /// Specifies the background color of the Splitter.
+ ///
+ [Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Splitter Colors"), System.ComponentModel.Description("Specifies the background color of the Splitter.")]
+ public Color SplitterBackground
+ {
+ get { return m_SplitterBackground; }
+ set
+ {
+ if (m_SplitterBackground != value)
+ {
+ m_SplitterBackground = value;
+ m_SplitterBackgroundCustom = true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSplitterBackground()
+ {
+ return m_SplitterBackgroundCustom;
+ }
+ ///
+ /// Specifies the target background gradient color of the Splitter.
+ ///
+ [Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Splitter Colors"), System.ComponentModel.Description("Specifies the target background gradient color of the Splitter.")]
+ public Color SplitterBackground2
+ {
+ get { return m_SplitterBackground2; }
+ set
+ {
+ if (m_SplitterBackground2 != value)
+ {
+ m_SplitterBackground2 = value;
+ m_SplitterBackground2Custom = true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSplitterBackground2()
+ {
+ return m_SplitterBackground2Custom;
+ }
+ ///
+ /// Specifies the angle of the gradient fill for the Splitter background.
+ ///
+ [Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Splitter Colors"), System.ComponentModel.Description("Specifies the angle of the gradient fill for the Splitter background."), DefaultValue(90)]
+ public int SplitterBackgroundGradientAngle
+ {
+ get { return m_SplitterBackgroundGradientAngle; }
+ set
+ {
+ if (m_SplitterBackgroundGradientAngle != value)
+ {
+ m_SplitterBackgroundGradientAngle = value;
+ }
+ }
+ }
+ ///
+ /// Specifies border color of the Splitter.
+ ///
+ [Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Splitter Colors"), System.ComponentModel.Description("Specifies border color of the Splitter.")]
+ public Color SplitterBorder
+ {
+ get { return m_SplitterBorder; }
+ set
+ {
+ if (m_SplitterBorder != value)
+ {
+ m_SplitterBorder = value;
+ m_SplitterBorderCustom = true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSplitterBorder()
+ {
+ return m_SplitterBorderCustom;
+ }
+ ///
+ /// Specifies color of the text on the Splitter.
+ ///
+ [Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Splitter Colors"), System.ComponentModel.Description("Specifies color of the text on the Splitter.")]
+ public Color SplitterText
+ {
+ get { return m_SplitterText; }
+ set
+ {
+ if (m_SplitterText != value)
+ {
+ m_SplitterText = value;
+ m_SplitterTextCustom = true;
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSplitterText()
+ {
+ return m_SplitterTextCustom;
+ }
+
+ public void Refresh()
+ {
+ this.Refresh(null,false);
+ }
+ public void ResetChangedFlag()
+ {
+ m_BarCaptionBackgroundCustom=false;
+ m_BarCaptionBackground2Custom=false;
+ m_BarStripeColorCustom=false;
+ m_BarCaptionInactiveBackgroundCustom=false;
+ m_BarCaptionInactiveBackground2Custom=false;
+ m_BarCaptionInactiveTextCustom=false;
+ m_BarCaptionTextCustom=false;
+ m_BarFloatingBorderCustom=false;
+ m_BarPopupBackgroundCustom=false;
+ m_BarPopupBorderCustom=false;
+ m_BarDockedBorderCustom=false;
+ m_BarBackgroundCustom=false;
+ m_BarBackground2Custom=false;
+ m_ItemBackgroundCustom=false;
+ m_ItemBackground2Custom=false;
+ m_ItemCheckedBackgroundCustom=false;
+ m_ItemCheckedBackground2Custom=false;
+ m_ItemCheckedBorderCustom=false;
+ m_ItemCheckedTextCustom=false;
+ m_ItemDisabledBackgroundCustom=false;
+ m_ItemDisabledTextCustom=false;
+ m_ItemExpandedShadowCustom=false;
+ m_ItemExpandedBackgroundCustom=false;
+ m_ItemExpandedBackground2Custom=false;
+ m_ItemExpandedTextCustom=false;
+ m_ItemExpandedBorderCustom=false;
+ m_ItemHotBackgroundCustom=false;
+ m_ItemHotBackground2Custom=false;
+ m_ItemHotBorderCustom=false;
+ m_ItemHotTextCustom=false;
+ m_ItemPressedBackgroundCustom=false;
+ m_ItemPressedBackground2Custom=false;
+ m_ItemPressedBorderCustom=false;
+ m_ItemPressedTextCustom=false;
+ m_ItemSeparatorCustom=false;
+ m_ItemSeparatorShadeCustom=false;
+ m_ItemTextCustom=false;
+ m_MenuBackgroundCustom=false;
+ m_MenuBackground2Custom=false;
+ m_MenuBarBackgroundCustom=false;
+ m_MenuBarBackground2Custom=false;
+ m_MenuBorderCustom=false;
+ m_MenuSideCustom=false;
+ m_MenuSide2Custom=false;
+ m_MenuUnusedBackgroundCustom=false;
+ m_MenuUnusedSideCustom=false;
+ m_MenuUnusedSide2Custom=false;
+ m_ItemDesignTimeBorderCustom=false;
+ m_CustomizeBackgroundCustom=false;
+ m_CustomizeBackground2Custom=false;
+ m_CustomizeTextCustom=false;
+ m_PanelBackgroundCustom=false;
+ m_PanelBackground2Custom=false;
+ m_PanelBorderCustom=false;
+ m_PanelTextCustom=false;
+ m_SplitterBackgroundCustom = false;
+ m_SplitterBackground2Custom = false;
+ m_SplitterBorderCustom = false;
+ m_SplitterTextCustom = false;
+ m_ExplorerBarBackgroundCustom=false;
+ m_ExplorerBarBackground2Custom=false;
+ m_MdiSystemItemForeground = Color.Empty;
+ }
+
+ [Browsable(false),DevCoBrowsable(false)]
+ public bool SchemeChanged
+ {
+ get
+ {
+ return m_BarCaptionBackgroundCustom ||
+ m_BarCaptionBackground2Custom ||
+ m_BarStripeColorCustom ||
+ m_BarCaptionInactiveBackgroundCustom ||
+ m_BarCaptionInactiveBackground2Custom ||
+ m_BarCaptionInactiveTextCustom ||
+ m_BarCaptionTextCustom ||
+ m_BarFloatingBorderCustom ||
+ m_BarPopupBackgroundCustom ||
+ m_BarDockedBorderCustom ||
+ m_BarPopupBorderCustom ||
+ m_BarBackgroundCustom ||
+ m_BarBackground2Custom ||
+ m_ItemBackgroundCustom ||
+ m_ItemCheckedBackgroundCustom ||
+ m_ItemCheckedBackground2Custom ||
+ m_ItemCheckedBorderCustom ||
+ m_ItemCheckedTextCustom ||
+ m_ItemDisabledBackgroundCustom ||
+ m_ItemDisabledTextCustom ||
+ m_ItemExpandedShadowCustom ||
+ m_ItemExpandedBackgroundCustom ||
+ m_ItemExpandedBackground2Custom ||
+ m_ItemExpandedTextCustom ||
+ m_ItemExpandedBorderCustom ||
+ m_ItemHotBackgroundCustom ||
+ m_ItemHotBackground2Custom ||
+ m_ItemHotBorderCustom ||
+ m_ItemHotTextCustom ||
+ m_ItemPressedBackgroundCustom ||
+ m_ItemPressedBackground2Custom ||
+ m_ItemPressedBorderCustom ||
+ m_ItemPressedTextCustom ||
+ m_ItemSeparatorCustom ||
+ m_ItemTextCustom ||
+ m_MenuBackgroundCustom ||
+ m_MenuBackground2Custom ||
+ m_MenuBarBackgroundCustom ||
+ m_MenuBarBackground2Custom ||
+ m_MenuBorderCustom ||
+ m_MenuSideCustom ||
+ m_MenuSide2Custom ||
+ m_MenuUnusedBackgroundCustom ||
+ m_MenuUnusedSideCustom ||
+ m_MenuUnusedSide2Custom ||
+ m_ItemDesignTimeBorderCustom ||
+ m_CustomizeBackgroundCustom ||
+ m_CustomizeBackground2Custom ||
+ m_DockSiteBackColorCustom ||
+ m_DockSiteBackColor2Custom ||
+ !m_MdiSystemItemForeground.IsEmpty ||
+ (m_PredefinedColorScheme != ePredefinedColorScheme.AutoGenerated);
+ }
+ }
+
+ private Image _AutoHidePanelBackgroundImage = null;
+ ///
+ /// Indicates auto-hide panel background image if any.
+ ///
+ [DefaultValue(null), Description("Indicates auto-hide panel background image if any."), Category("Auto-Hide Panel")]
+ public Image AutoHidePanelBackgroundImage
+ {
+ get { return _AutoHidePanelBackgroundImage; }
+ set { _AutoHidePanelBackgroundImage = value; }
+ }
+ private Color _AutoHidePanelBackground = Color.Empty;
+ ///
+ /// Gets or sets the color of the auto-hide panel background.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of auto-hide panel background.")]
+ public Color AutoHidePanelBackground
+ {
+ get { return _AutoHidePanelBackground; }
+ set { _AutoHidePanelBackground = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHidePanelBackground()
+ {
+ return !_AutoHidePanelBackground.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHidePanelBackground()
+ {
+ this.AutoHidePanelBackground = Color.Empty;
+ }
+ private Color _AutoHidePanelBackground2 = Color.Empty;
+ ///
+ /// Gets or sets the color of the auto-hide panel background.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of auto-hide panel background.")]
+ public Color AutoHidePanelBackground2
+ {
+ get { return _AutoHidePanelBackground2; }
+ set { _AutoHidePanelBackground2 = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHidePanelBackground2()
+ {
+ return !_AutoHidePanelBackground2.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHidePanelBackground2()
+ {
+ this.AutoHidePanelBackground2 = Color.Empty;
+ }
+
+ private Color _AutoHideTabBackground = Color.Empty;
+ ///
+ /// Gets or sets the color of the auto-hide tab.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of the auto-hide tab.")]
+ public Color AutoHideTabBackground
+ {
+ get { return _AutoHideTabBackground; }
+ set { _AutoHideTabBackground = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHideTabBackground()
+ {
+ return !_AutoHideTabBackground.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHideTabBackground()
+ {
+ this.AutoHideTabBackground = Color.Empty;
+ }
+
+ private Color _AutoHideTabBackground2 = Color.Empty;
+ ///
+ /// Gets or sets the color of the auto-hide tab.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of auto-hide tab.")]
+ public Color AutoHideTabBackground2
+ {
+ get { return _AutoHideTabBackground2; }
+ set { _AutoHideTabBackground2 = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHideTabBackground2()
+ {
+ return !_AutoHideTabBackground2.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHideTabBackground2()
+ {
+ this.AutoHideTabBackground2 = Color.Empty;
+ }
+ private int _AutoHideTabBackgroundGradientAngle = 90;
+ ///
+ /// Gets or sets the auto-hide tab background gradient angle.
+ ///
+ [DefaultValue(90), Category("Auto-Hide Panel"), Description("Gets or sets the auto-hide tab background gradient angle.")]
+ public int AutoHideTabBackgroundGradientAngle
+ {
+ get { return _AutoHideTabBackgroundGradientAngle; }
+ set { _AutoHideTabBackgroundGradientAngle = value; }
+ }
+ private Color _AutoHideTabText = Color.Empty;
+ ///
+ /// Gets or sets the color of the auto-hide tab text.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of auto-hide tab text.")]
+ public Color AutoHideTabText
+ {
+ get { return _AutoHideTabText; }
+ set { _AutoHideTabText = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHideTabText()
+ {
+ return !_AutoHideTabText.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHideTabText()
+ {
+ this.AutoHideTabText = Color.Empty;
+ }
+ private Color _AutoHideTabBorder = Color.Empty;
+ ///
+ /// Gets or sets the color of the auto-hide tab border.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of auto-hide tab border.")]
+ public Color AutoHideTabBorder
+ {
+ get { return _AutoHideTabBorder; }
+ set { _AutoHideTabBorder = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHideTabBorder()
+ {
+ return !_AutoHideTabBorder.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHideTabBorder()
+ {
+ this.AutoHideTabBorder = Color.Empty;
+ }
+
+ private Color _AutoHideSelectedTabBackground = Color.Empty;
+ ///
+ /// Gets or sets the color of the auto-hide tab.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of the auto-hide tab.")]
+ public Color AutoHideSelectedTabBackground
+ {
+ get { return _AutoHideSelectedTabBackground; }
+ set { _AutoHideSelectedTabBackground = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHideSelectedTabBackground()
+ {
+ return !_AutoHideSelectedTabBackground.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHideSelectedTabBackground()
+ {
+ this.AutoHideSelectedTabBackground = Color.Empty;
+ }
+
+ private Color _AutoHideSelectedTabBackground2 = Color.Empty;
+ ///
+ /// Gets or sets the color of the auto-hide tab.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of auto-hide tab.")]
+ public Color AutoHideSelectedTabBackground2
+ {
+ get { return _AutoHideSelectedTabBackground2; }
+ set { _AutoHideSelectedTabBackground2 = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHideSelectedTabBackground2()
+ {
+ return !_AutoHideSelectedTabBackground2.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHideSelectedTabBackground2()
+ {
+ this.AutoHideSelectedTabBackground2 = Color.Empty;
+ }
+
+ private Color _AutoHideSelectedTabText = Color.Empty;
+ ///
+ /// Gets or sets the color of the auto-hide tab text.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of auto-hide tab text.")]
+ public Color AutoHideSelectedTabText
+ {
+ get { return _AutoHideSelectedTabText; }
+ set { _AutoHideSelectedTabText = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHideSelectedTabText()
+ {
+ return !_AutoHideSelectedTabText.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHideSelectedTabText()
+ {
+ this.AutoHideSelectedTabText = Color.Empty;
+ }
+
+ private Color _AutoHideSelectedTabBorder = Color.Empty;
+ ///
+ /// Gets or sets the color of the tab border.
+ ///
+ [Category("Auto-Hide Panel"), Description("Indicates color of tab border.")]
+ public Color AutoHideSelectedTabBorder
+ {
+ get { return _AutoHideSelectedTabBorder; }
+ set { _AutoHideSelectedTabBorder = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeAutoHideSelectedTabBorder()
+ {
+ return !_AutoHideSelectedTabBorder.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetAutoHideSelectedTabBorder()
+ {
+ this.AutoHideSelectedTabBorder = Color.Empty;
+ }
+ #endregion
+
+ #region Color Scheme Generation
+ public void Refresh(System.Drawing.Graphics graphics, bool bSystemColorEvent)
+ {
+ if(!bSystemColorEvent)
+ {
+ ResetChangedFlag();
+ }
+
+ if (m_PredefinedColorScheme == ePredefinedColorScheme.Blue2003)
+ SchemeXpBlue2003();
+ else if (m_PredefinedColorScheme == ePredefinedColorScheme.OliveGreen2003)
+ SchemeXpOliveGreen2003();
+ else if (m_PredefinedColorScheme == ePredefinedColorScheme.Silver2003)
+ SchemeXpSilver2003();
+ else if (m_PredefinedColorScheme == ePredefinedColorScheme.SystemColors)
+ GenerateScheme();
+ else
+ {
+ if (Style == eDotNetBarStyle.Office2007)
+ SchemeOffice2007();
+ else
+ {
+ eWinXPColorScheme xpc = BarFunctions.WinXPColorScheme;
+ if (xpc != eWinXPColorScheme.Undetermined)
+ {
+ if (xpc == eWinXPColorScheme.Blue)
+ {
+ if (Style == eDotNetBarStyle.Office2003)
+ SchemeXpBlue2003();
+ else if (Style == eDotNetBarStyle.VS2005)
+ SchemeXpBlueVS2005();
+ else
+ SchemeXpBlue();
+ }
+ else if (xpc == eWinXPColorScheme.Silver)
+ {
+ if (Style == eDotNetBarStyle.Office2003)
+ SchemeXpSilver2003();
+ else if (Style == eDotNetBarStyle.VS2005)
+ SchemeXpSilverVS2005();
+ else
+ SchemeXpSilver();
+ }
+ else if (xpc == eWinXPColorScheme.OliveGreen)
+ {
+ if (Style == eDotNetBarStyle.Office2003)
+ SchemeXpOliveGreen2003();
+ else if (Style == eDotNetBarStyle.VS2005)
+ SchemeXpOliveGreenVS2005();
+ else
+ SchemeXpOliveGreen();
+ }
+ else
+ GenerateScheme();
+ }
+ else
+ GenerateScheme();
+ }
+ }
+
+ bool bDisposeGraphics=false;
+ if(graphics==null)
+ {
+ IntPtr wnd=NativeFunctions.GetDesktopWindow();
+ if(wnd!=IntPtr.Zero)
+ {
+ graphics=System.Drawing.Graphics.FromHwnd(wnd);
+ bDisposeGraphics=true;
+ }
+ }
+ try
+ {
+ if(graphics!=null)
+ {
+ if(!m_BarCaptionBackground.IsSystemColor && !m_BarCaptionBackground.IsEmpty)
+ m_BarCaptionBackground=graphics.GetNearestColor(m_BarCaptionBackground);
+ if(!m_BarCaptionBackground2.IsSystemColor && !m_BarCaptionBackground2.IsEmpty)
+ m_BarCaptionBackground2=graphics.GetNearestColor(m_BarCaptionBackground2);
+ if(!m_BarStripeColor.IsSystemColor && !m_BarStripeColor.IsEmpty)
+ m_BarStripeColor=graphics.GetNearestColor(m_BarStripeColor);
+ if(!m_BarCaptionInactiveBackground.IsSystemColor && !m_BarCaptionInactiveBackground.IsEmpty)
+ m_BarCaptionInactiveBackground=graphics.GetNearestColor(m_BarCaptionInactiveBackground);
+ if(!m_BarCaptionInactiveBackground2.IsSystemColor && !m_BarCaptionInactiveBackground2.IsEmpty)
+ m_BarCaptionInactiveBackground2=graphics.GetNearestColor(m_BarCaptionInactiveBackground2);
+ if(!m_BarCaptionInactiveText.IsSystemColor && !m_BarCaptionInactiveText.IsEmpty)
+ m_BarCaptionInactiveText=graphics.GetNearestColor(m_BarCaptionInactiveText);
+ if(!m_BarCaptionText.IsSystemColor && !m_BarCaptionText.IsEmpty)
+ m_BarCaptionText=graphics.GetNearestColor(m_BarCaptionText);
+ if(!m_BarFloatingBorder.IsSystemColor && !m_BarFloatingBorder.IsEmpty)
+ m_BarFloatingBorder=graphics.GetNearestColor(m_BarFloatingBorder);
+ if(!m_BarPopupBackground.IsSystemColor && !m_BarPopupBackground.IsEmpty)
+ m_BarPopupBackground=graphics.GetNearestColor(m_BarPopupBackground);
+ if(!m_BarPopupBorder.IsSystemColor && !m_BarPopupBorder.IsEmpty)
+ m_BarPopupBorder=graphics.GetNearestColor(m_BarPopupBorder);
+ if(!m_BarDockedBorder.IsSystemColor && !m_BarDockedBorder.IsEmpty)
+ m_BarDockedBorder=graphics.GetNearestColor(m_BarDockedBorder);
+ if(!m_BarBackground.IsSystemColor && !m_BarBackground.IsEmpty)
+ m_BarBackground=graphics.GetNearestColor(m_BarBackground);
+ if(!m_BarBackground2.IsEmpty && !m_BarBackground2.IsSystemColor)
+ m_BarBackground2=graphics.GetNearestColor(m_BarBackground2);
+ if(!m_ItemBackground.IsEmpty)
+ m_ItemBackground=graphics.GetNearestColor(m_ItemBackground);
+ if(!m_ItemBackground2.IsEmpty)
+ m_ItemBackground2=graphics.GetNearestColor(m_ItemBackground2);
+ if(!m_ItemCheckedBackground.IsSystemColor)
+ m_ItemCheckedBackground=graphics.GetNearestColor(m_ItemCheckedBackground);
+ if(!m_ItemCheckedBackground2.IsEmpty && !m_ItemCheckedBackground2.IsSystemColor)
+ m_ItemCheckedBackground2=graphics.GetNearestColor(m_ItemCheckedBackground2);
+ if(!m_ItemCheckedBorder.IsSystemColor)
+ m_ItemCheckedBorder=graphics.GetNearestColor(m_ItemCheckedBorder);
+ if(!m_ItemCheckedText.IsSystemColor)
+ m_ItemCheckedText=graphics.GetNearestColor(m_ItemCheckedText);
+ if(!m_ItemDisabledBackground.IsEmpty && !m_ItemDisabledBackground.IsSystemColor)
+ m_ItemDisabledBackground=graphics.GetNearestColor(m_ItemDisabledBackground);
+ if(!m_ItemDisabledText.IsSystemColor)
+ m_ItemDisabledText=graphics.GetNearestColor(m_ItemDisabledText);
+ if(!m_ItemExpandedShadow.IsSystemColor && !m_ItemExpandedShadow.IsEmpty)
+ m_ItemExpandedShadow=graphics.GetNearestColor(m_ItemExpandedShadow);
+ if(!m_ItemExpandedBackground.IsSystemColor)
+ m_ItemExpandedBackground=graphics.GetNearestColor(m_ItemExpandedBackground);
+ if(!m_ItemExpandedText.IsSystemColor)
+ m_ItemExpandedText=graphics.GetNearestColor(m_ItemExpandedText);
+ if(!m_ItemExpandedBorder.IsSystemColor)
+ m_ItemExpandedBorder=graphics.GetNearestColor(m_ItemExpandedBorder);
+ if(!m_ItemHotBackground.IsSystemColor)
+ m_ItemHotBackground=graphics.GetNearestColor(m_ItemHotBackground);
+ if(!m_ItemHotBackground2.IsEmpty && !m_ItemHotBackground2.IsSystemColor)
+ m_ItemHotBackground2=graphics.GetNearestColor(m_ItemHotBackground2);
+ if(!m_ItemHotBorder.IsSystemColor)
+ m_ItemHotBorder=graphics.GetNearestColor(m_ItemHotBorder);
+ if(!m_ItemHotText.IsSystemColor)
+ m_ItemHotText=graphics.GetNearestColor(m_ItemHotText);
+ if(!m_ItemPressedBackground.IsSystemColor)
+ m_ItemPressedBackground=graphics.GetNearestColor(m_ItemPressedBackground);
+ if(!m_ItemPressedBackground2.IsEmpty && !m_ItemPressedBackground2.IsSystemColor)
+ m_ItemPressedBackground2=graphics.GetNearestColor(m_ItemPressedBackground2);
+ if(!m_ItemPressedBorder.IsSystemColor)
+ m_ItemPressedBorder=graphics.GetNearestColor(m_ItemPressedBorder);
+ if(!m_ItemPressedText.IsSystemColor)
+ m_ItemPressedText=graphics.GetNearestColor(m_ItemPressedText);
+ if(!m_ItemSeparator.IsSystemColor)
+ m_ItemSeparator=graphics.GetNearestColor(m_ItemSeparator);
+ if(!m_ItemSeparatorShade.IsSystemColor && !m_ItemSeparatorShade.IsEmpty)
+ m_ItemSeparatorShade=graphics.GetNearestColor(m_ItemSeparatorShade);
+ if(!m_ItemText.IsSystemColor)
+ m_ItemText=graphics.GetNearestColor(m_ItemText);
+ if(!m_MenuBackground.IsSystemColor)
+ m_MenuBackground=graphics.GetNearestColor(m_MenuBackground);
+ if(!m_MenuBarBackground.IsSystemColor)
+ m_MenuBarBackground=graphics.GetNearestColor(m_MenuBarBackground);
+ if(!m_MenuBarBackground2.IsEmpty && !m_MenuBarBackground2.IsSystemColor)
+ m_MenuBarBackground2=graphics.GetNearestColor(m_MenuBarBackground2);
+ if(!m_MenuBorder.IsSystemColor)
+ m_MenuBorder=graphics.GetNearestColor(m_MenuBorder);
+ if(!m_MenuSide.IsSystemColor)
+ m_MenuSide=graphics.GetNearestColor(m_MenuSide);
+ if(!m_MenuUnusedBackground.IsSystemColor)
+ m_MenuUnusedBackground=graphics.GetNearestColor(m_MenuUnusedBackground);
+ if(!m_MenuUnusedSide.IsSystemColor)
+ m_MenuUnusedSide=graphics.GetNearestColor(m_MenuUnusedSide);
+ if(!m_ItemDesignTimeBorder.IsSystemColor)
+ m_ItemDesignTimeBorder=graphics.GetNearestColor(m_ItemDesignTimeBorder);
+ if(!m_CustomizeBackground.IsEmpty && !m_CustomizeBackground.IsSystemColor)
+ m_CustomizeBackground=graphics.GetNearestColor(m_CustomizeBackground);
+ if(!m_CustomizeBackground2.IsEmpty && !m_CustomizeBackground2.IsSystemColor)
+ m_CustomizeBackground2=graphics.GetNearestColor(m_CustomizeBackground2);
+ if(!m_CustomizeText.IsEmpty && !m_CustomizeText.IsSystemColor)
+ m_CustomizeText=graphics.GetNearestColor(m_CustomizeText);
+ }
+ }
+ finally
+ {
+ if(bDisposeGraphics)
+ graphics.Dispose();
+ }
+ }
+ private void GenerateScheme()
+ {
+ if(m_Style==eDotNetBarStyle.Office2003 || m_Style==eDotNetBarStyle.VS2005)
+ GenerateScheme2003();
+ else
+ GenerateSchemeDefault();
+ }
+ private void GenerateSchemeDefault()
+ {
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground=ColorFunctions.MenuFocusBorderColor();
+ m_BarCaptionBackground2=Color.Empty;
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=SystemColors.ControlDark;
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground=SystemColors.Control;
+ m_BarCaptionInactiveBackground2=Color.Empty;
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=SystemColors.ControlText;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=SystemColors.ActiveCaptionText;
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=ColorFunctions.MenuFocusBorderColor();
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=SystemColors.Control;
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=ColorFunctions.MenuFocusBorderColor();
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=ColorFunctions.ToolMenuFocusBackColor();
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=ColorFunctions.CheckBoxBackColor();
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=SystemColors.Highlight;
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=SystemColors.ControlDark;
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=SystemColors.ControlDark;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=ColorFunctions.ToolMenuFocusBackColor();
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=ColorFunctions.HoverBackColor();
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=SystemColors.Highlight;
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=ColorFunctions.PressedBackColor();
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=SystemColors.Highlight;
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=SystemColors.ControlDarkDark;
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=SystemColors.ControlDark;
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=ColorFunctions.MenuBackColor();
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=SystemColors.Control;
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=SystemColors.ControlDark;
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=ColorFunctions.ToolMenuFocusBackColor();
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=ColorFunctions.SideRecentlyBackColor();
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=SystemColors.Highlight;
+
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=Color.Empty;
+ if(!m_MenuBarBackground2Custom)
+ m_MenuBarBackground2=Color.Empty;
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=Color.Empty;
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=Color.Empty;
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.Empty;
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.Empty;
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=Color.Empty;
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=Color.Empty;
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=Color.Empty;
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.Empty;
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=Color.Empty;
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=Color.Empty;
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=Color.Empty;
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=Color.Empty;
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=Color.Empty;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=System.Windows.Forms.ControlPaint.Dark(m_BarBackground);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=System.Windows.Forms.ControlPaint.DarkDark(m_BarBackground);
+ if(!m_PanelTextCustom)
+ m_PanelText=System.Windows.Forms.ControlPaint.LightLight(m_BarBackground);
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=System.Windows.Forms.ControlPaint.DarkDark(m_BarBackground);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = System.Windows.Forms.ControlPaint.Dark(m_BarBackground);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = System.Windows.Forms.ControlPaint.DarkDark(m_BarBackground);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = System.Windows.Forms.ControlPaint.LightLight(m_BarBackground);
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = System.Windows.Forms.ControlPaint.DarkDark(m_BarBackground);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=m_MenuBarBackground;
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=m_ItemSeparator;
+
+ }
+
+ private void GenerateScheme2003()
+ {
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground=ColorFunctions.MenuFocusBorderColor();
+ if (!m_BarCaptionBackground2Custom)
+ m_BarCaptionBackground2 = System.Windows.Forms.ControlPaint.Light(m_BarCaptionBackground);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=SystemColors.ControlDark;
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground=SystemColors.Control;
+ m_BarCaptionInactiveBackground2=Color.Empty;
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=SystemColors.ControlText;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=SystemColors.ActiveCaptionText;
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=ColorFunctions.MenuFocusBorderColor();
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=SystemColors.Control;
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=ColorFunctions.MenuFocusBorderColor();
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=ColorFunctions.MenuBackColor();
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=ColorFunctions.CheckBoxBackColor();
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.Empty;
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=SystemColors.Highlight;
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=SystemColors.ControlDark;
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=Color.Empty;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=ColorFunctions.ToolMenuFocusBackColor();
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=ColorFunctions.HoverBackColor3();
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=SystemColors.Highlight;
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=ColorFunctions.HoverBackColor2();
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=SystemColors.Highlight;
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=SystemColors.ControlDarkDark;
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=SystemColors.ControlDark;
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=ColorFunctions.MenuBackColor();
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=SystemColors.Control;
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=SystemColors.ControlDark;
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=ColorFunctions.MenuBackColor();
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=ColorFunctions.SideRecentlyBackColor();
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=SystemColors.Highlight;
+
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=SystemColors.Control;
+ if(!m_MenuBarBackground2Custom)
+ m_MenuBarBackground2=Color.Empty;
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=ColorFunctions.HoverBackColor2();
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=ColorFunctions.HoverBackColor3();
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.Empty;
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.Empty;
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=ColorFunctions.ToolMenuFocusBackColor();
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=Color.Empty;
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=SystemColors.Control;
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=SystemColors.ControlLightLight;
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=SystemColors.Control;
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=ColorFunctions.MenuBackColor();
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=SystemColors.ControlDark;
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=ColorFunctions.MenuFocusBorderColor();
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=SystemColors.ControlText;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=(m_BarBackground2);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=System.Windows.Forms.ControlPaint.Dark(m_BarBackground2);
+ if(!m_PanelTextCustom)
+ m_PanelText=System.Windows.Forms.ControlPaint.LightLight(m_BarBackground);
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=System.Windows.Forms.ControlPaint.DarkDark(m_BarBackground2);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = (m_BarBackground2);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = System.Windows.Forms.ControlPaint.Dark(m_BarBackground2);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = System.Windows.Forms.ControlPaint.LightLight(m_BarBackground);
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = System.Windows.Forms.ControlPaint.DarkDark(m_BarBackground2);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=m_MenuBarBackground;
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=m_ItemSeparator;
+ }
+
+ private void SchemeXpBlue()
+ {
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=Color.FromArgb(239,237,222);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=Color.FromArgb(191,188,177);
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground=Color.FromArgb(172,168,153);
+ m_BarCaptionBackground2=Color.Empty;
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground=SystemColors.Control;
+ m_BarCaptionInactiveBackground2=Color.Empty;
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=SystemColors.ControlText;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=Color.FromArgb(64,64,64);
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=Color.FromArgb(172,168,153);
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=Color.FromArgb(252,252,249);
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=Color.FromArgb(138,134,122);
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=Color.FromArgb(225,230,232);
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=SystemColors.Highlight;
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=SystemColors.ControlDark;
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=SystemColors.ControlDark;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=Color.FromArgb(239,237,222);
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=Color.FromArgb(193,210,238);
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=SystemColors.Highlight;
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=Color.FromArgb(152,181,226);
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=SystemColors.Highlight;
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=Color.FromArgb(73,73,73);
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=Color.FromArgb(197,194,184);
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=Color.FromArgb(252,252,249);
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=SystemColors.Control;
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=SystemColors.ControlDark;
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=Color.FromArgb(239,237,222);
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=Color.FromArgb(230,227,210);
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=SystemColors.Highlight;
+
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=Color.Empty;
+ if(!m_MenuBarBackground2Custom)
+ m_MenuBarBackground2=Color.Empty;
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=Color.Empty;
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=Color.Empty;
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.Empty;
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.Empty;
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=Color.Empty;
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=Color.Empty;
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=Color.Empty;
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.Empty;
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=Color.Empty;
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=Color.Empty;
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=Color.Empty;
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=Color.Empty;
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=Color.Empty;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=Color.FromArgb(89,135,214);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=Color.FromArgb(3,56,148);
+ if(!m_PanelTextCustom)
+ m_PanelText=Color.White;
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=Color.FromArgb(0,45,150);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = Color.FromArgb(89, 135, 214);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = Color.FromArgb(3, 56, 148);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = Color.White;
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = Color.FromArgb(0, 45, 150);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=Color.FromArgb(123,162,231);
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=Color.FromArgb(99,117,214);
+ }
+ private void SchemeXpOliveGreen()
+ {
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=Color.FromArgb(239,237,222);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=Color.FromArgb(191,188,177);
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground=Color.FromArgb(153,153,153);
+ m_BarCaptionBackground2=Color.Empty;
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground=SystemColors.Control;
+ m_BarCaptionInactiveBackground2=Color.Empty;
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=SystemColors.ControlText;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=Color.FromArgb(64,64,64);
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=Color.FromArgb(153,153,153);
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=Color.FromArgb(252,252,249);
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=Color.FromArgb(138,134,122);
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=Color.FromArgb(234,235,223);
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=SystemColors.Highlight;
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=SystemColors.ControlDark;
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=SystemColors.ControlDark;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=Color.FromArgb(239,237,222);
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=Color.FromArgb(206,209,195);
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=SystemColors.Highlight;
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=Color.FromArgb(201,208,184);
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=SystemColors.Highlight;
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=Color.FromArgb(102,102,102);
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=Color.FromArgb(197,194,184);
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=Color.FromArgb(252,252,249);
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=SystemColors.Control;
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=SystemColors.ControlDark;
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=Color.FromArgb(239,237,222);
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=Color.FromArgb(230,227,210);
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=SystemColors.Highlight;
+
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=Color.Empty;
+ if(!m_MenuBarBackground2Custom)
+ m_MenuBarBackground2=Color.Empty;
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=Color.Empty;
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=Color.Empty;
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.Empty;
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.Empty;
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=Color.Empty;
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=Color.Empty;
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=Color.Empty;
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.Empty;
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=Color.Empty;
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=Color.Empty;
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=Color.Empty;
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=Color.Empty;
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=Color.Empty;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=Color.FromArgb(175,192,130);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=Color.FromArgb(99,122,68);
+ if(!m_PanelTextCustom)
+ m_PanelText=Color.White;
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=Color.FromArgb(96,128,88);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = Color.FromArgb(175, 192, 130);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = Color.FromArgb(99, 122, 68);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = Color.White;
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = Color.FromArgb(96, 128, 88);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=Color.FromArgb(204,217,173);
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=Color.FromArgb(165,189,132);
+ }
+ private void SchemeXpSilver()
+ {
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=Color.FromArgb(229,228,232);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=Color.FromArgb(179,179,182);
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground=Color.FromArgb(157,157,161);
+ m_BarCaptionBackground2=Color.Empty;
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground=SystemColors.Control;
+ m_BarCaptionInactiveBackground2=Color.Empty;
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=SystemColors.ControlText;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=Color.FromArgb(53,53,53);
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=Color.FromArgb(157,157,161);
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=Color.FromArgb(251,250,251);
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=Color.FromArgb(126,126,129);
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=Color.FromArgb(233,234,237);
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=SystemColors.Highlight;
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=SystemColors.ControlDark;
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=SystemColors.ControlDark;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=Color.FromArgb(229,228,232);
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=Color.FromArgb(199,199,202);
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=Color.FromArgb(169,171,181);
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=Color.FromArgb(210,211,216);
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=SystemColors.Highlight;
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=SystemColors.ControlText;
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=Color.FromArgb(186,186,189);
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=Color.FromArgb(251,250,251);
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=SystemColors.Control;
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=SystemColors.ControlDark;
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=Color.FromArgb(229,228,232);
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=Color.FromArgb(217,216,220);
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=SystemColors.Highlight;
+
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=Color.Empty;
+ if(!m_MenuBarBackground2Custom)
+ m_MenuBarBackground2=Color.Empty;
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=Color.Empty;
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=Color.Empty;
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.Empty;
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.Empty;
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=Color.Empty;
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=Color.Empty;
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=Color.Empty;
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.Empty;
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=Color.Empty;
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=Color.Empty;
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=Color.Empty;
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=Color.Empty;
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=Color.Empty;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=Color.FromArgb(168,167,191);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=Color.FromArgb(112,111,145);
+ if(!m_PanelTextCustom)
+ m_PanelText=Color.White;
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=Color.FromArgb(124,124,148);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = Color.FromArgb(168, 167, 191);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = Color.FromArgb(112, 111, 145);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = Color.White;
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = Color.FromArgb(124, 124, 148);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=Color.FromArgb(196,200,212);
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=Color.FromArgb(177,179,200);
+ }
+
+ private void SchemeXpBlue2003()
+ {
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=Color.FromArgb(223,237,254);
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=Color.FromArgb(142,179,231);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=Color.FromArgb(39,65,118);
+ if (!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground = GetColor(0x6690E0);
+ if (!m_BarCaptionBackground2Custom)
+ m_BarCaptionBackground2 = Color.FromArgb(42, 102, 201);
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground = GetColor(0x6699FF);
+ if (!m_BarCaptionInactiveBackground2Custom)
+ m_BarCaptionInactiveBackground2 = GetColor(0x557BC2);
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=Color.White;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=Color.White;
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=Color.FromArgb(42,102,201);
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=Color.FromArgb(246,246,246);
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=Color.FromArgb(0,45,150);
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=Color.FromArgb(255,213,140);
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.FromArgb(255,173,85);
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=Color.FromArgb(0,0,128);
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=Color.FromArgb(141,141,141);
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=Color.Empty;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=Color.FromArgb(227,239,255);
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.FromArgb(147,181,231);
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=Color.FromArgb(255,244,204);
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=Color.FromArgb(255,208,145);
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=Color.FromArgb(0,0,128);
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=Color.FromArgb(254,142,75);
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=Color.FromArgb(255,207,139);
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=Color.FromArgb(0,0,128);
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=SystemColors.ControlText;
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=Color.FromArgb(106,140,203);
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.FromArgb(241,249,255);
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=Color.FromArgb(246,246,246);
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;// Color.FromArgb(246,246,246);
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=Color.FromArgb(158,190,245);
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=Color.FromArgb(0,45,150);
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=Color.FromArgb(227,239,255);
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=Color.FromArgb(135,173,228);
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=Color.FromArgb(203,221,246);
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=Color.FromArgb(121,161,220);
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=Color.FromArgb(0,0,128);
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=Color.FromArgb(59,97,156);
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=Color.FromArgb(158,190,245);
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=Color.FromArgb(195,218,249);
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=Color.FromArgb(117,166,241);
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=Color.FromArgb(0,53,145);
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=SystemColors.ControlText;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=Color.FromArgb(89,135,214);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=Color.FromArgb(3,56,148);
+ if(!m_PanelTextCustom)
+ m_PanelText=Color.White;
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=Color.FromArgb(0,45,150);
+
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = Color.FromArgb(89, 135, 214);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = Color.FromArgb(3, 56, 148);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = Color.White;
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = Color.FromArgb(0, 45, 150);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=Color.FromArgb(123,162,231);
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=Color.FromArgb(99,117,214);
+ }
+
+ private void SchemeXpOliveGreen2003()
+ {
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=Color.FromArgb(244,247,222);
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=Color.FromArgb(183,198,145);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=Color.FromArgb(81,94,51);
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground = Color.FromArgb(183, 198, 145); //Color.FromArgb(116, 134, 94);
+ if (!m_BarCaptionBackground2Custom)
+ m_BarCaptionBackground2 = Color.FromArgb(116, 134, 94);
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground = GetColor(0xD1DBB6); // Color.FromArgb(183, 198, 145);
+ if (!m_BarCaptionInactiveBackground2Custom)
+ m_BarCaptionInactiveBackground2 = Color.FromArgb(116, 134, 94);
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=Color.White;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=Color.White;
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=Color.FromArgb(116,134,94);
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=Color.FromArgb(244,244,238);
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=Color.FromArgb(117,141,94);
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=Color.FromArgb(255,213,140);
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.FromArgb(255,173,85);
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=Color.FromArgb(63,93,56);
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=Color.FromArgb(141,141,141);
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=Color.Empty;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=Color.FromArgb(236,240,213);
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.FromArgb(194,206,159);
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=Color.FromArgb(255,244,204);
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=Color.FromArgb(255,208,145);
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=Color.FromArgb(63,93,56);
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=Color.FromArgb(254,142,75);
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=Color.FromArgb(255,207,139);
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=Color.FromArgb(63,93,56);
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=SystemColors.ControlText;
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=Color.FromArgb(96,128,88);
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.FromArgb(244,247,222);
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=Color.FromArgb(244,244,238);
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=Color.FromArgb(217,217,168);
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=Color.FromArgb(117,141,94);
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=Color.FromArgb(255,255,237);
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=Color.FromArgb(184,199,146);
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=Color.FromArgb(230,230,239);
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=Color.FromArgb(164,180,120);
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=Color.FromArgb(63,93,56);
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=Color.FromArgb(96,128,88);
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=Color.FromArgb(217,217,167);
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=Color.FromArgb(242,240,228);
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=Color.FromArgb(176,194,140);
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=Color.FromArgb(96,119,107);
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=SystemColors.ControlText;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=Color.FromArgb(175,192,130);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=Color.FromArgb(99,122,68);
+ if(!m_PanelTextCustom)
+ m_PanelText=Color.White;
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=Color.FromArgb(96,128,88);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = Color.FromArgb(175, 192, 130);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = Color.FromArgb(99, 122, 68);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = Color.White;
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = Color.FromArgb(96, 128, 88);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=Color.FromArgb(204,217,173);
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=Color.FromArgb(165,189,132);
+ }
+
+ private void SchemeXpSilver2003()
+ {
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=Color.FromArgb(243,244,250);
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=Color.FromArgb(153,151,181);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=Color.FromArgb(84,84,117);
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground = Color.FromArgb(153, 151, 181); //Color.FromArgb(122, 121, 153);
+ if (!m_BarCaptionBackground2Custom)
+ m_BarCaptionBackground2 = Color.FromArgb(122, 121, 153);
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground = GetColor(0xA6A6B7); // Color.FromArgb(243, 244, 250); //Color.FromArgb(122, 121, 153);
+ if (!m_BarCaptionInactiveBackground2Custom)
+ m_BarCaptionInactiveBackground2 = Color.FromArgb(122, 121, 153);
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=Color.White;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=Color.White;
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=Color.FromArgb(122,121,153);
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=Color.FromArgb(253,250,255);
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=Color.FromArgb(124,124,148);
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=Color.FromArgb(255,213,140);
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.FromArgb(255,173,85);
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=Color.FromArgb(75,75,111);
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=Color.FromArgb(141,141,141);
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=Color.Empty;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=Color.FromArgb(232,233,241);
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.FromArgb(177,176,198);
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=Color.FromArgb(255,244,204);
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=Color.FromArgb(255,208,145);
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=Color.FromArgb(75,75,111);
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=Color.FromArgb(254,142,75);
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=Color.FromArgb(255,207,139);
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=Color.FromArgb(75,75,111);
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=SystemColors.ControlText;
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=Color.FromArgb(110,109,143);
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.White;
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=Color.FromArgb(253,250,255);
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=Color.FromArgb(215,215,229);
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=Color.FromArgb(124,124,148);
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=Color.FromArgb(249,249,255);
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=Color.FromArgb(159,157,185);
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=Color.FromArgb(215,215,226);
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=Color.FromArgb(128,126,158);
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=Color.FromArgb(84,84,117);
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=Color.FromArgb(124,124,148);
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=Color.FromArgb(215,215,229);
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=Color.FromArgb(243,243,247);
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=Color.FromArgb(179,178,200);
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=Color.FromArgb(118,116,146);
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=SystemColors.ControlText;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=Color.FromArgb(168,167,191);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=Color.FromArgb(112,111,145);
+ if(!m_PanelTextCustom)
+ m_PanelText=Color.White;
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=Color.FromArgb(124,124,148);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = Color.FromArgb(168, 167, 191);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = Color.FromArgb(112, 111, 145);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = Color.White;
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = Color.FromArgb(124, 124, 148);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=Color.FromArgb(196,200,212);
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=Color.FromArgb(177,179,200);
+ }
+
+ ///
+ /// VS.NET 2005 Blue Color Scheme
+ ///
+ private void SchemeXpBlueVS2005()
+ {
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=Color.FromArgb(251,250,247);
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=Color.FromArgb(181,181,154);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=Color.FromArgb(193,190,179);
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground=Color.FromArgb(0,84,227);
+ if(!m_BarCaptionBackground2Custom)
+ m_BarCaptionBackground2=Color.FromArgb(60,148,254);
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground=GetColor(0xCCC7BA);
+ if(!m_BarCaptionInactiveBackground2Custom)
+ m_BarCaptionInactiveBackground2=Color.Empty;
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=Color.Black;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=Color.White;
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=Color.FromArgb(146,143,130);
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=Color.FromArgb(252,252,249);
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=Color.FromArgb(138,134,122);
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=Color.FromArgb(225,230,232);
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.Empty;
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=Color.FromArgb(49,106,197);
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=Color.FromArgb(180,177,163);
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=Color.Empty;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=Color.FromArgb(251,250,247);
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.Empty;
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=Color.FromArgb(193,210,238);
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=Color.Empty;
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=Color.FromArgb(49,106,197);
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=Color.FromArgb(152,181,226);
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=Color.Empty;
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=Color.FromArgb(75,75,111);
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=SystemColors.ControlText;
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=Color.FromArgb(197,194,184);
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.Empty;
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=Color.FromArgb(252,252,249);
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=Color.FromArgb(229,229,215);
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=Color.FromArgb(138,134,122);
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=m_MenuBackground;
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=Color.FromArgb(186,186,160);
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=m_MenuBackground;
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=System.Windows.Forms.ControlPaint.Light(Color.FromArgb(186,186,160));
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=Color.Black;
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=Color.FromArgb(146,146,118);
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=Color.FromArgb(229,229,215);
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=Color.FromArgb(250,250,247);
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=Color.FromArgb(239,238,235);
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=Color.FromArgb(152,152,126);
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=SystemColors.ControlText;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=GetColor(0xBFBFA2);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=Color.FromArgb(152,152,126);
+ if(!m_PanelTextCustom)
+ m_PanelText=Color.Black;
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=Color.FromArgb(82,82,79);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = GetColor(0xBFBFA2);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = Color.FromArgb(152, 152, 126);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = Color.Black;
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = Color.FromArgb(82, 82, 79);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=Color.FromArgb(123,162,231);
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=Color.FromArgb(99,117,214);
+ }
+
+ private void SchemeXpOliveGreenVS2005()
+ {
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=GetColor(0xFAFAF6);
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=GetColor(0xEDEADB);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=GetColor(0xC1BEB3);
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground=GetColor(0x8BA169);
+ if(!m_BarCaptionBackground2Custom)
+ m_BarCaptionBackground2=GetColor(0xC5D1A1);
+ if (!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground = GetColor(0xCCC7BA);
+ if (!m_BarCaptionInactiveBackground2Custom)
+ m_BarCaptionInactiveBackground2 = Color.Empty;
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=Color.Black;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=Color.White;
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=GetColor(0x928F82);
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=GetColor(0xFCFCF9);
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=GetColor(0x8A867A);
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=GetColor(0xB6C68D);
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=Color.Empty;
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=GetColor(0x93A070);
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=GetColor(0xB4B1A3);
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=Color.Empty;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=GetColor(0xF9F9F4);
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=Color.Empty;
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=GetColor(0xB6C68D);
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=Color.Empty;
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=GetColor(0x93A070);
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=GetColor(0x93A070);
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=Color.Empty;
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=GetColor(0x93A070);
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=Color.White;
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=GetColor(0xC5C2B8);
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.Empty;
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=GetColor(0xFCFCF9);
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=GetColor(0xECE9D8);
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=GetColor(0x8A867A);
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=GetColor(0xFCFCF9);
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=GetColor(0xEDEADB);
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=m_MenuSide;
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=System.Windows.Forms.ControlPaint.Light(m_MenuSide2);
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=Color.Black;
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=GetColor(0xEFEDDE);
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=GetColor(0xECE9D8);
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=GetColor(0xFAF9F6);
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=GetColor(0xEFEEEB);
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=GetColor(0xACA899);
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=SystemColors.ControlText;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=GetColor(0xF3F2EA);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=GetColor(0xE4E2D5);
+ if(!m_PanelTextCustom)
+ m_PanelText=Color.Black;
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=GetColor(0xACA899);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = GetColor(0xF3F2EA);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = GetColor(0xE4E2D5);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = Color.Black;
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = GetColor(0xACA899);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=Color.FromArgb(204,217,173);
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=Color.FromArgb(165,189,132);
+ }
+
+ private void SchemeXpSilverVS2005()
+ {
+ if(!m_BarBackgroundCustom)
+ m_BarBackground=GetColor(0xF3F4FA);
+ if(!m_BarBackground2Custom)
+ m_BarBackground2=GetColor(0x9997B5);
+ if(!m_BarStripeColorCustom)
+ m_BarStripeColor=GetColor(0x545475);
+ if(!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground=GetColor(0xA09EBA);
+ if(!m_BarCaptionBackground2Custom)
+ m_BarCaptionBackground2=GetColor(0xE1E2EC);
+ if(!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground = GetColor(0xCECECE);
+ if(!m_BarCaptionInactiveBackground2Custom)
+ m_BarCaptionInactiveBackground2=GetColor(0xF2F2F6);
+ if(!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText=Color.Black;
+ if(!m_BarCaptionTextCustom)
+ m_BarCaptionText=Color.Black;
+ if(!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder=GetColor(0x7A7999);
+ if(!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground=GetColor(0xFDFAFF);
+ if(!m_BarPopupBorderCustom)
+ m_BarPopupBorder=GetColor(0x7C7C94);
+ if(!m_ItemBackgroundCustom)
+ m_ItemBackground=Color.Empty;
+ if(!m_ItemBackground2Custom)
+ m_ItemBackground2=Color.Empty;
+ if(!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground=GetColor(0xFFD58C);
+ if(!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2=GetColor(0xFFAD55);
+ if(!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder=GetColor(0x4B4B6F);
+ if(!m_ItemCheckedTextCustom)
+ m_ItemCheckedText=SystemColors.ControlText;
+ if(!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground=Color.Empty;
+ if(!m_ItemDisabledTextCustom)
+ m_ItemDisabledText=GetColor(0x8D8D8D);
+ if(!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow=Color.Empty;
+ if(!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground=GetColor(0xE8E9F1);
+ if(!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2=GetColor(0xBAB9CD);
+ if(!m_ItemExpandedTextCustom)
+ m_ItemExpandedText=SystemColors.ControlText;
+ if(!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground=GetColor(0xFFF4CC);
+ if(!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2=GetColor(0xFFD091);
+ if(!m_ItemHotBorderCustom)
+ m_ItemHotBorder=GetColor(0x4B4B6F);
+ if(!m_ItemHotTextCustom)
+ m_ItemHotText=SystemColors.ControlText;
+ if(!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground=GetColor(0xFE914E);
+ if(!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2=GetColor(0xFFD38E);
+ if(!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder=GetColor(0x4B4B6F);
+ if(!m_ItemPressedTextCustom)
+ m_ItemPressedText=Color.Black;
+ if(!m_ItemSeparatorCustom)
+ m_ItemSeparator=GetColor(0x6E6D8F);
+ if(!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade=Color.Empty;
+ if(!m_ItemTextCustom)
+ m_ItemText=SystemColors.ControlText;
+ if(!m_MenuBackgroundCustom)
+ m_MenuBackground=GetColor(0xFDFAFF);
+ if(!m_MenuBackground2Custom)
+ m_MenuBackground2=Color.Empty;
+ if(!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground=GetColor(0xD7D7E5);
+ if(!m_MenuBorderCustom)
+ m_MenuBorder=GetColor(0x7C7C94);
+ if(!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder=m_MenuBorder;
+ if(!m_MenuSideCustom)
+ m_MenuSide=GetColor(0xF9F9FF);
+ if(!m_MenuSide2Custom)
+ m_MenuSide2=GetColor(0x9F9DB9);
+ if(!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground=m_MenuBackground;
+ if(!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide=m_MenuSide;
+ if(!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2=System.Windows.Forms.ControlPaint.Light(m_MenuSide2);
+ if(!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder=Color.Black;
+ if(!m_BarDockedBorderCustom)
+ m_BarDockedBorder=GetColor(0x7C7C94);
+
+ if(!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor=GetColor(0xD7D7E5);
+ if(!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2=GetColor(0xF3F3F7);
+
+ if(!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground=GetColor(0xB3B2C8);
+ if(!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2=GetColor(0x797794);
+ if(!m_CustomizeTextCustom)
+ m_CustomizeText=SystemColors.ControlText;
+
+ if(!m_PanelBackgroundCustom)
+ m_PanelBackground=GetColor(0xEEEEEE);
+ if(!m_PanelBackground2Custom)
+ m_PanelBackground2=GetColor(0xFFFFFF);
+ if(!m_PanelTextCustom)
+ m_PanelText=Color.Black;
+ if(!m_PanelBorderCustom)
+ m_PanelBorder=GetColor(0x9D9DA1);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = GetColor(0xEEEEEE);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = GetColor(0xFFFFFF);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = Color.Black;
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = GetColor(0x9D9DA1);
+
+ if(!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground=Color.FromArgb(196,200,212);
+ if(!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2=Color.FromArgb(177,179,200);
+ }
+
+ private void SchemeOffice2007()
+ {
+ if (!m_BarBackgroundCustom)
+ m_BarBackground = GetColor(0xE3EFFF);
+ if (!m_BarBackground2Custom)
+ m_BarBackground2 = GetColor(0xA9CEFE);
+ if (!m_BarStripeColorCustom)
+ m_BarStripeColor = GetColor(0x6F9DD9);
+ if (!m_BarCaptionBackgroundCustom)
+ m_BarCaptionBackground = GetColor(0x6593CF);
+ if (!m_BarCaptionBackground2Custom)
+ m_BarCaptionBackground2 = GetColor(0x3764A0);
+ if (!m_BarCaptionInactiveBackgroundCustom)
+ m_BarCaptionInactiveBackground = GetColor(0xE3EFFF);
+ if (!m_BarCaptionInactiveBackground2Custom)
+ m_BarCaptionInactiveBackground2 = GetColor(0xAFD2FF);
+ if (!m_BarCaptionInactiveTextCustom)
+ m_BarCaptionInactiveText = GetColor(0x083772);
+ if (!m_BarCaptionTextCustom)
+ m_BarCaptionText = GetColor(0xFFFFFF);
+ if (!m_BarFloatingBorderCustom)
+ m_BarFloatingBorder = GetColor(0x3764A0);
+ if (!m_BarPopupBackgroundCustom)
+ m_BarPopupBackground = GetColor(0xF6F6F6);
+ if (!m_BarPopupBorderCustom)
+ m_BarPopupBorder = GetColor(0x6593CF);
+ if (!m_ItemBackgroundCustom)
+ m_ItemBackground = Color.Empty;
+ if (!m_ItemBackground2Custom)
+ m_ItemBackground2 = Color.Empty;
+ if (!m_ItemCheckedBackgroundCustom)
+ m_ItemCheckedBackground = GetColor(0xFCD578);
+ if (!m_ItemCheckedBackground2Custom)
+ m_ItemCheckedBackground2 = GetColor(0xFBC84F);
+ if (!m_ItemCheckedBorderCustom)
+ m_ItemCheckedBorder = GetColor(0xBB5503);
+ if (!m_ItemCheckedTextCustom)
+ m_ItemCheckedText = GetColor(0x000000);
+ if (!m_ItemDisabledBackgroundCustom)
+ m_ItemDisabledBackground = Color.Empty;
+ if (!m_ItemDisabledTextCustom)
+ m_ItemDisabledText = GetColor(0x8D8D8D);
+ if (!m_ItemExpandedShadowCustom)
+ m_ItemExpandedShadow = Color.Empty;
+ if (!m_ItemExpandedBackgroundCustom)
+ m_ItemExpandedBackground = GetColor(0xE3EFFE);
+ if (!m_ItemExpandedBackground2Custom)
+ m_ItemExpandedBackground2 = GetColor(0x99BFF0);
+ if (!m_ItemExpandedTextCustom)
+ m_ItemExpandedText = GetColor(0x000000);
+ if (!m_ItemHotBackgroundCustom)
+ m_ItemHotBackground = GetColor(0xFFF5CC);
+ if (!m_ItemHotBackground2Custom)
+ m_ItemHotBackground2 = GetColor(0xFFDB75);
+ if (!m_ItemHotBorderCustom)
+ m_ItemHotBorder = GetColor(0xFFBD69);
+ if (!m_ItemHotTextCustom)
+ m_ItemHotText = GetColor(0x000000);
+ if (!m_ItemPressedBackgroundCustom)
+ m_ItemPressedBackground = GetColor(0xFC973D);
+ if (!m_ItemPressedBackground2Custom)
+ m_ItemPressedBackground2 = GetColor(0xFFB85E);
+ if (!m_ItemPressedBorderCustom)
+ m_ItemPressedBorder = GetColor(0xFB8C3C);
+ if (!m_ItemPressedTextCustom)
+ m_ItemPressedText = GetColor(0x000000);
+ if (!m_ItemSeparatorCustom)
+ m_ItemSeparator = Color.FromArgb(80, GetColor(0x9AC6FF));
+ if (!m_ItemSeparatorShadeCustom)
+ m_ItemSeparatorShade = Color.FromArgb(250, GetColor(0xFFFFFF));
+ if (!m_ItemTextCustom)
+ m_ItemText = GetColor(0x000000); // SystemColors.ControlTet;
+ if (!m_MenuBackgroundCustom)
+ m_MenuBackground = GetColor(0xF6F6F6);
+ if (!m_MenuBackground2Custom)
+ m_MenuBackground2 = Color.Empty; // Color.White;
+ if (!m_MenuBarBackgroundCustom)
+ m_MenuBarBackground = GetColor(0xBFDBFF);
+ if (!m_MenuBorderCustom)
+ m_MenuBorder = GetColor(0x6593CF);
+ if (!m_ItemExpandedBorderCustom)
+ m_ItemExpandedBorder = m_MenuBorder;
+ if (!m_MenuSideCustom)
+ m_MenuSide = GetColor(0xE9EEEE);
+ if (!m_MenuSide2Custom)
+ m_MenuSide2 = Color.Empty; // GetColor(0xDDE0E8);
+ if (!m_MenuUnusedBackgroundCustom)
+ m_MenuUnusedBackground = m_MenuBackground;
+ if (!m_MenuUnusedSideCustom)
+ m_MenuUnusedSide = GetColor(0xDADADA);
+ if (!m_MenuUnusedSide2Custom)
+ m_MenuUnusedSide2 = Color.Empty;// System.Windows.Forms.ControlPaint.Light(m_MenuSide2);
+ if (!m_ItemDesignTimeBorderCustom)
+ m_ItemDesignTimeBorder = Color.Black;
+ if (!m_BarDockedBorderCustom)
+ m_BarDockedBorder = GetColor(0x6F9DD9);
+
+ if (!m_DockSiteBackColorCustom)
+ m_DockSiteBackColor = GetColor(0xBFDBFF);
+ if (!m_DockSiteBackColor2Custom)
+ m_DockSiteBackColor2 = Color.Empty;
+
+ if (!m_CustomizeBackgroundCustom)
+ m_CustomizeBackground = GetColor(0xD7E8FF);
+ if (!m_CustomizeBackground2Custom)
+ m_CustomizeBackground2 = GetColor(0x6F9DD9);
+ if (!m_CustomizeTextCustom)
+ m_CustomizeText = GetColor(0x000000);
+
+ if (!m_PanelBackgroundCustom)
+ m_PanelBackground = GetColor(0xE3EFFF);
+ if (!m_PanelBackground2Custom)
+ m_PanelBackground2 = GetColor(0xAFD2FF);
+ if (!m_PanelTextCustom)
+ m_PanelText = GetColor(0x083772);
+ if (!m_PanelBorderCustom)
+ m_PanelBorder = GetColor(0x6593CF);
+
+ if (!m_SplitterBackgroundCustom)
+ m_SplitterBackground = GetColor(0xE3EFFF);
+ if (!m_SplitterBackground2Custom)
+ m_SplitterBackground2 = GetColor(0xAFD2FF);
+ if (!m_SplitterTextCustom)
+ m_SplitterText = GetColor(0x083772);
+ if (!m_SplitterBorderCustom)
+ m_SplitterBorder = GetColor(0x6593CF);
+
+ if (!m_ExplorerBarBackgroundCustom) m_ExplorerBarBackground = Color.FromArgb(196, 200, 212);
+ if (!m_ExplorerBarBackground2Custom) m_ExplorerBarBackground2 = Color.FromArgb(177, 179, 200);
+ }
+
+ ///
+ /// Converts hex string to Color type.
+ ///
+ /// Hexadecimal color representation.
+ /// Reference to Color object.
+ public static Color GetColor(string rgbHex)
+ {
+ if(string.IsNullOrEmpty(rgbHex))
+ return Color.Empty;
+ if(rgbHex.Length == 8)
+ return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
+ Convert.ToInt32(rgbHex.Substring(2, 2), 16),
+ Convert.ToInt32(rgbHex.Substring(4, 2), 16),
+ Convert.ToInt32(rgbHex.Substring(6, 2), 16));
+
+ return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0,2),16),
+ Convert.ToInt32(rgbHex.Substring(2,2),16),
+ Convert.ToInt32(rgbHex.Substring(4,2),16));
+ }
+
+ ///
+ /// Converts hex string to Color type.
+ ///
+ /// Color representation as 32-bit RGB value.
+ /// Reference to Color object.
+ public static Color GetColor(int rgb)
+ {
+ if (rgb == -1) return Color.Empty;
+ return Color.FromArgb((rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
+ }
+
+ ///
+ /// Converts hex string to Color type.
+ ///
+ /// Color representation as 32-bit RGB value.
+ /// Reference to Color object.
+ public static Color GetColor(int alpha, int rgb)
+ {
+ if (rgb == -1) return Color.Empty;
+ return Color.FromArgb(alpha, (rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
+ }
+ #endregion
+
+ #region Serialization
+ public void Serialize(System.Xml.XmlElement xmlElem)
+ {
+ if(m_BarBackgroundCustom)
+ xmlElem.SetAttribute("barback",BarFunctions.ColorToString(m_BarBackground));
+ if(m_BarBackground2Custom)
+ xmlElem.SetAttribute("barback2",BarFunctions.ColorToString(m_BarBackground2));
+ if(m_BarBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("barbackga",m_BarBackgroundGradientAngle.ToString());
+ if(m_BarStripeColorCustom)
+ xmlElem.SetAttribute("barstripeclr",BarFunctions.ColorToString(m_BarStripeColor));
+ if(m_BarCaptionBackgroundCustom)
+ xmlElem.SetAttribute("barcapback",BarFunctions.ColorToString(m_BarCaptionBackground));
+ if(m_BarCaptionBackground2Custom)
+ xmlElem.SetAttribute("barcapback2",BarFunctions.ColorToString(m_BarCaptionBackground2));
+ if(m_BarCaptionBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("barcapbackga",m_BarCaptionBackgroundGradientAngle.ToString());
+ if(m_BarCaptionInactiveBackgroundCustom)
+ xmlElem.SetAttribute("barcapiback",BarFunctions.ColorToString(m_BarCaptionInactiveBackground));
+ if(m_BarCaptionInactiveBackground2Custom)
+ xmlElem.SetAttribute("barcapiback2",BarFunctions.ColorToString(m_BarCaptionInactiveBackground2));
+ if(m_BarCaptionInactiveBackgroundGAngle!=90)
+ xmlElem.SetAttribute("barcapibackga",m_BarCaptionInactiveBackgroundGAngle.ToString());
+ if(m_BarDockedBorderCustom)
+ xmlElem.SetAttribute("bardockborder",BarFunctions.ColorToString(m_BarDockedBorder));
+ if(m_BarCaptionInactiveTextCustom)
+ xmlElem.SetAttribute("barcapitext",BarFunctions.ColorToString(m_BarCaptionInactiveText));
+ if(m_BarCaptionTextCustom)
+ xmlElem.SetAttribute("barcaptext",BarFunctions.ColorToString(m_BarCaptionText));
+ if(m_BarFloatingBorderCustom)
+ xmlElem.SetAttribute("barfloatb",BarFunctions.ColorToString(m_BarFloatingBorder));
+ if(m_BarPopupBackgroundCustom)
+ xmlElem.SetAttribute("barpopupback",BarFunctions.ColorToString(m_BarPopupBackground));
+ if(m_BarPopupBorderCustom)
+ xmlElem.SetAttribute("barpopupb",BarFunctions.ColorToString(m_BarPopupBorder));
+ if(m_ItemBackgroundCustom)
+ xmlElem.SetAttribute("itemback",BarFunctions.ColorToString(m_ItemBackground));
+ if(m_ItemBackground2Custom)
+ xmlElem.SetAttribute("itemback2",BarFunctions.ColorToString(m_ItemBackground2));
+ if(m_ItemBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("itembackga",m_ItemBackgroundGradientAngle.ToString());
+ if(m_ItemCheckedBackgroundCustom)
+ xmlElem.SetAttribute("itemchkback",BarFunctions.ColorToString(m_ItemCheckedBackground));
+ if(m_ItemCheckedBackground2Custom)
+ xmlElem.SetAttribute("itemchkback2",BarFunctions.ColorToString(m_ItemCheckedBackground2));
+ if(m_ItemCheckedBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("itemchkbackga",m_ItemCheckedBackgroundGradientAngle.ToString());
+ if(m_ItemCheckedBorderCustom)
+ xmlElem.SetAttribute("itemchkb",BarFunctions.ColorToString(m_ItemCheckedBorder));
+ if(m_ItemCheckedTextCustom)
+ xmlElem.SetAttribute("itemchktext",BarFunctions.ColorToString(m_ItemCheckedText));
+ if(m_ItemDisabledBackgroundCustom && !m_ItemDisabledBackground.IsEmpty)
+ xmlElem.SetAttribute("itemdisback",BarFunctions.ColorToString(m_ItemDisabledBackground));
+ if(m_ItemDisabledTextCustom)
+ xmlElem.SetAttribute("itemdistext",BarFunctions.ColorToString(m_ItemDisabledText));
+ if(m_ItemExpandedShadowCustom)
+ xmlElem.SetAttribute("itemexpshadow",BarFunctions.ColorToString(m_ItemExpandedShadow));
+ if(m_ItemExpandedBackgroundCustom)
+ xmlElem.SetAttribute("itemexpback",BarFunctions.ColorToString(m_ItemExpandedBackground));
+ if(m_ItemExpandedBackground2Custom)
+ xmlElem.SetAttribute("itemexpback2",BarFunctions.ColorToString(m_ItemExpandedBackground2));
+ if(m_ItemExpandedBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("itemexpbackga",m_ItemExpandedBackgroundGradientAngle.ToString());
+ if(m_ItemExpandedTextCustom)
+ xmlElem.SetAttribute("itemexptext",BarFunctions.ColorToString(m_ItemExpandedText));
+ if(m_ItemExpandedBorderCustom)
+ xmlElem.SetAttribute("itemexpborder",BarFunctions.ColorToString(m_ItemExpandedBorder));
+ if(m_ItemHotBackgroundCustom)
+ xmlElem.SetAttribute("itemhotback",BarFunctions.ColorToString(m_ItemHotBackground));
+ if(m_ItemHotBackground2Custom)
+ xmlElem.SetAttribute("itemhotback2",BarFunctions.ColorToString(m_ItemHotBackground2));
+ if(m_ItemHotBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("itemhotbackga",m_ItemHotBackgroundGradientAngle.ToString());
+ if(m_ItemHotBorderCustom)
+ xmlElem.SetAttribute("itemhotb",BarFunctions.ColorToString(m_ItemHotBorder));
+ if(m_ItemHotTextCustom)
+ xmlElem.SetAttribute("itemhottext",BarFunctions.ColorToString(m_ItemHotText));
+ if(m_ItemPressedBackgroundCustom)
+ xmlElem.SetAttribute("itempressback",BarFunctions.ColorToString(m_ItemPressedBackground));
+ if(m_ItemPressedBackground2Custom)
+ xmlElem.SetAttribute("itempressback2",BarFunctions.ColorToString(m_ItemPressedBackground2));
+ if(m_ItemPressedBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("itempressbackga",m_ItemPressedBackgroundGradientAngle.ToString());
+ if(m_ItemPressedBorderCustom)
+ xmlElem.SetAttribute("itempressb",BarFunctions.ColorToString(m_ItemPressedBorder));
+ if(m_ItemPressedTextCustom)
+ xmlElem.SetAttribute("itempresstext",BarFunctions.ColorToString(m_ItemPressedText));
+ if(m_ItemSeparatorCustom)
+ xmlElem.SetAttribute("itemsep",BarFunctions.ColorToString(m_ItemSeparator));
+ if(m_ItemTextCustom)
+ xmlElem.SetAttribute("itemtext",BarFunctions.ColorToString(m_ItemText));
+ if(m_MenuBackgroundCustom)
+ xmlElem.SetAttribute("menuback",BarFunctions.ColorToString(m_MenuBackground));
+ if(m_MenuBackground2Custom)
+ xmlElem.SetAttribute("menuback2",BarFunctions.ColorToString(m_MenuBackground2));
+ if(m_MenuBackgroundGradientAngle!=0)
+ xmlElem.SetAttribute("menubackga",m_MenuBackgroundGradientAngle.ToString());
+ if(m_MenuBarBackgroundCustom)
+ xmlElem.SetAttribute("menubarback",BarFunctions.ColorToString(m_MenuBarBackground));
+ if(m_MenuBarBackground2Custom)
+ xmlElem.SetAttribute("menubarback2",BarFunctions.ColorToString(m_MenuBarBackground2));
+ if(m_MenuBarBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("menubarbackga",m_MenuBarBackgroundGradientAngle.ToString());
+ if(m_MenuBorderCustom)
+ xmlElem.SetAttribute("menub",BarFunctions.ColorToString(m_MenuBorder));
+ if(m_MenuSideCustom)
+ xmlElem.SetAttribute("menuside",BarFunctions.ColorToString(m_MenuSide));
+ if(m_MenuSide2Custom)
+ xmlElem.SetAttribute("menuside2",BarFunctions.ColorToString(m_MenuSide2));
+ if(m_MenuSideGradientAngle!=0)
+ xmlElem.SetAttribute("menusidega",m_MenuSideGradientAngle.ToString());
+ if(m_MenuUnusedBackgroundCustom)
+ xmlElem.SetAttribute("menuuback",BarFunctions.ColorToString(m_MenuUnusedBackground));
+ if(m_MenuUnusedSideCustom)
+ xmlElem.SetAttribute("menuuside",BarFunctions.ColorToString(m_MenuUnusedSide));
+ if(m_MenuUnusedSide2Custom)
+ xmlElem.SetAttribute("menuuside2",BarFunctions.ColorToString(m_MenuUnusedSide2));
+ if(m_MenuSideGradientAngle!=0)
+ xmlElem.SetAttribute("menuusidega",m_MenuSideGradientAngle.ToString());
+ if(m_ItemDesignTimeBorderCustom)
+ xmlElem.SetAttribute("menudtb",BarFunctions.ColorToString(m_ItemDesignTimeBorder));
+ if(m_CustomizeBackgroundCustom)
+ xmlElem.SetAttribute("customback",BarFunctions.ColorToString(m_CustomizeBackground));
+ if(m_CustomizeBackground2Custom)
+ xmlElem.SetAttribute("customback2",BarFunctions.ColorToString(m_CustomizeBackground2));
+ if(m_CustomizeTextCustom)
+ xmlElem.SetAttribute("customtext",BarFunctions.ColorToString(m_CustomizeText));
+ if(m_CustomizeBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("custombackga",m_CustomizeBackgroundGradientAngle.ToString());
+
+ // Panel Colors
+ if(m_PanelBackgroundCustom)
+ xmlElem.SetAttribute("panelback",BarFunctions.ColorToString(m_PanelBackground));
+ if(m_PanelBackground2Custom)
+ xmlElem.SetAttribute("panelback2",BarFunctions.ColorToString(m_PanelBackground2));
+ if(m_PanelBorderCustom)
+ xmlElem.SetAttribute("panelborder",BarFunctions.ColorToString(m_PanelBorder));
+ if(m_PanelTextCustom)
+ xmlElem.SetAttribute("paneltext",BarFunctions.ColorToString(m_PanelText));
+ if(m_PanelBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("panelbackga",m_PanelBackgroundGradientAngle.ToString());
+
+ // Splitter Colors
+ if (m_SplitterBackgroundCustom)
+ xmlElem.SetAttribute("splitterback", BarFunctions.ColorToString(m_SplitterBackground));
+ if (m_SplitterBackground2Custom)
+ xmlElem.SetAttribute("splitterback2", BarFunctions.ColorToString(m_SplitterBackground2));
+ if (m_SplitterBorderCustom)
+ xmlElem.SetAttribute("splitterborder", BarFunctions.ColorToString(m_SplitterBorder));
+ if (m_SplitterTextCustom)
+ xmlElem.SetAttribute("splittertext", BarFunctions.ColorToString(m_SplitterText));
+ if (m_SplitterBackgroundGradientAngle != 90)
+ xmlElem.SetAttribute("splitterbackga", m_SplitterBackgroundGradientAngle.ToString());
+
+ // Explorer Bar
+ if(m_ExplorerBarBackgroundCustom)
+ xmlElem.SetAttribute("exbarback",BarFunctions.ColorToString(m_ExplorerBarBackground));
+ if(m_ExplorerBarBackground2Custom)
+ xmlElem.SetAttribute("exbarback2",BarFunctions.ColorToString(m_ExplorerBarBackground2));
+ if(m_ExplorerBarBackgroundGradientAngle!=90)
+ xmlElem.SetAttribute("exbarbackga",m_ExplorerBarBackgroundGradientAngle.ToString());
+
+ // Dock Site colors
+ if(m_DockSiteBackColorCustom)
+ xmlElem.SetAttribute("dsback",BarFunctions.ColorToString(m_DockSiteBackColor));
+ if(m_DockSiteBackColor2Custom)
+ xmlElem.SetAttribute("dsback2",BarFunctions.ColorToString(m_DockSiteBackColor2));
+ if(m_DockSiteBackColorGradientAngle!=0)
+ xmlElem.SetAttribute("dsbackga",m_DockSiteBackColorGradientAngle.ToString());
+
+ if (!m_MdiSystemItemForeground.IsEmpty)
+ xmlElem.SetAttribute("mdisystemitemforeground", BarFunctions.ColorToString(m_MdiSystemItemForeground));
+
+ if(m_PredefinedColorScheme!=ePredefinedColorScheme.AutoGenerated)
+ xmlElem.SetAttribute("predefcolorscheme",System.Xml.XmlConvert.ToString(((int)m_PredefinedColorScheme)));
+ }
+
+ public void Deserialize(System.Xml.XmlElement xmlElem)
+ {
+ if(xmlElem.HasAttribute("predefcolorscheme"))
+ m_PredefinedColorScheme=(ePredefinedColorScheme)System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("predefcolorscheme"));
+
+ this.Refresh();
+
+ if(xmlElem.HasAttribute("barback"))
+ {
+ m_BarBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("barback"));
+ m_BarBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("barback2"))
+ {
+ m_BarBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("barback2"));
+ m_BarBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("barbackga"))
+ {
+ m_BarBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("barbackga"));
+ }
+ if(xmlElem.HasAttribute("barstripeclr"))
+ {
+ m_BarStripeColor=BarFunctions.ColorFromString(xmlElem.GetAttribute("barstripeclr"));
+ m_BarStripeColorCustom=true;
+ }
+ if(xmlElem.HasAttribute("barcapback"))
+ {
+ m_BarCaptionBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("barcapback"));
+ m_BarCaptionBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("barcapback2"))
+ {
+ m_BarCaptionBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("barcapback2"));
+ m_BarCaptionBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("barcapbackga"))
+ {
+ m_BarCaptionBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("barcapbackga"));
+ }
+ if(xmlElem.HasAttribute("barcapiback"))
+ {
+ m_BarCaptionInactiveBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("barcapiback"));
+ m_BarCaptionInactiveBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("barcapiback2"))
+ {
+ m_BarCaptionInactiveBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("barcapiback2"));
+ m_BarCaptionInactiveBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("barcapibackga"))
+ {
+ m_BarCaptionInactiveBackgroundGAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("barcapibackga"));
+ }
+ if(xmlElem.HasAttribute("barcapitext"))
+ {
+ m_BarCaptionInactiveText=BarFunctions.ColorFromString(xmlElem.GetAttribute("barcapitext"));
+ m_BarCaptionInactiveTextCustom=true;
+ }
+ if(xmlElem.HasAttribute("barcaptext"))
+ {
+ m_BarCaptionText=BarFunctions.ColorFromString(xmlElem.GetAttribute("barcaptext"));
+ m_BarCaptionTextCustom=true;
+ }
+ if(xmlElem.HasAttribute("barfloatb"))
+ {
+ m_BarFloatingBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("barfloatb"));
+ m_BarFloatingBorderCustom=true;
+ }
+ if(xmlElem.HasAttribute("bardockborder"))
+ {
+ m_BarDockedBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("bardockborder"));
+ m_BarDockedBorderCustom=true;
+ }
+ if(xmlElem.HasAttribute("barpopupback"))
+ {
+ m_BarPopupBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("barpopupback"));
+ m_BarPopupBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("barpopupb"))
+ {
+ m_BarPopupBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("barpopupb"));
+ m_BarPopupBorderCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemback"))
+ {
+ m_ItemBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemback"));
+ m_ItemBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemback2"))
+ {
+ m_ItemBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemback2"));
+ m_ItemBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("itembackga"))
+ {
+ m_ItemBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("itembackga"));
+ }
+
+ if(xmlElem.HasAttribute("itemchkback"))
+ {
+ m_ItemCheckedBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemchkback"));
+ m_ItemCheckedBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemchkback2"))
+ {
+ m_ItemCheckedBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemchkback2"));
+ m_ItemCheckedBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("itemchkbackga"))
+ {
+ m_ItemCheckedBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("itemchkbackga"));
+ }
+ if(xmlElem.HasAttribute("itemchkb"))
+ {
+ m_ItemCheckedBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemchkb"));
+ m_ItemCheckedBorderCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemchktext"))
+ {
+ m_ItemCheckedText=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemchktext"));
+ m_ItemCheckedTextCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemdisback"))
+ {
+ m_ItemDisabledBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemdisback"));
+ m_ItemDisabledBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemdistext"))
+ {
+ m_ItemDisabledText=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemdistext"));
+ m_ItemDisabledTextCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemexpshadow"))
+ {
+ m_ItemExpandedShadow=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemexpshadow"));
+ m_ItemExpandedShadowCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemexpback"))
+ {
+ m_ItemExpandedBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemexpback"));
+ m_ItemExpandedBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemexpback2"))
+ {
+ m_ItemExpandedBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemexpback2"));
+ m_ItemExpandedBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("itemexpbackga"))
+ {
+ m_ItemExpandedBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("itemexpbackga"));
+ }
+ if(xmlElem.HasAttribute("itemexptext"))
+ {
+ m_ItemExpandedText=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemexptext"));
+ m_ItemExpandedTextCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemexpborder"))
+ {
+ m_ItemExpandedBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemexpborder"));
+ m_ItemExpandedBorderCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemhotback"))
+ {
+ m_ItemHotBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemhotback"));
+ m_ItemHotBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemhotback2"))
+ {
+ m_ItemHotBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemhotback2"));
+ m_ItemHotBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("itemhotbackga"))
+ {
+ m_ItemHotBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("itemhotbackga"));
+ }
+ if(xmlElem.HasAttribute("itemhotb"))
+ {
+ m_ItemHotBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemhotb"));
+ m_ItemHotBorderCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemhottext"))
+ {
+ m_ItemHotText=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemhottext"));
+ m_ItemHotTextCustom=true;
+ }
+ if(xmlElem.HasAttribute("itempressback"))
+ {
+ m_ItemPressedBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("itempressback"));
+ m_ItemPressedBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("itempressback2"))
+ {
+ m_ItemPressedBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("itempressback2"));
+ m_ItemPressedBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("itempressbackga"))
+ {
+ m_ItemPressedBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("itempressbackga"));
+ }
+ if(xmlElem.HasAttribute("itempressb"))
+ {
+ m_ItemPressedBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("itempressb"));
+ m_ItemPressedBorderCustom=true;
+ }
+ if(xmlElem.HasAttribute("itempresstext"))
+ {
+ m_ItemPressedText=BarFunctions.ColorFromString(xmlElem.GetAttribute("itempresstext"));
+ m_ItemPressedTextCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemsep"))
+ {
+ m_ItemSeparator=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemsep"));
+ m_ItemSeparatorCustom=true;
+ }
+ if(xmlElem.HasAttribute("itemtext"))
+ {
+ m_ItemText=BarFunctions.ColorFromString(xmlElem.GetAttribute("itemtext"));
+ m_ItemTextCustom=true;
+ }
+ if(xmlElem.HasAttribute("menuback"))
+ {
+ m_MenuBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("menuback"));
+ m_MenuBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("menuback2"))
+ {
+ m_MenuBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("menuback2"));
+ m_MenuBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("menubackga"))
+ {
+ m_MenuBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("menubackga"));
+ }
+ if(xmlElem.HasAttribute("menubarback"))
+ {
+ m_MenuBarBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("menubarback"));
+ m_MenuBarBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("menubarback2"))
+ {
+ m_MenuBarBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("menubarback2"));
+ m_MenuBarBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("menubarbackga"))
+ {
+ m_MenuBarBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("menubarbackga"));
+ }
+ else m_MenuBarBackgroundGradientAngle=90;
+ if(xmlElem.HasAttribute("menub"))
+ {
+ m_MenuBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("menub"));
+ m_MenuBorderCustom=true;
+ }
+ if(xmlElem.HasAttribute("menuside"))
+ {
+ m_MenuSide=BarFunctions.ColorFromString(xmlElem.GetAttribute("menuside"));
+ m_MenuSideCustom=true;
+ }
+ if(xmlElem.HasAttribute("menuside2"))
+ {
+ m_MenuSide2=BarFunctions.ColorFromString(xmlElem.GetAttribute("menuside2"));
+ m_MenuSide2Custom=true;
+ }
+ if(xmlElem.HasAttribute("menusidega"))
+ {
+ m_MenuSideGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("menusidega"));
+ }
+ if(xmlElem.HasAttribute("menuuback"))
+ {
+ m_MenuUnusedBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("menuuback"));
+ m_MenuUnusedBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("menuuside"))
+ {
+ m_MenuUnusedSide=BarFunctions.ColorFromString(xmlElem.GetAttribute("menuuside"));
+ m_MenuUnusedSideCustom=true;
+ }
+ if(xmlElem.HasAttribute("menuuside2"))
+ {
+ m_MenuUnusedSide2=BarFunctions.ColorFromString(xmlElem.GetAttribute("menuuside2"));
+ m_MenuUnusedSide2Custom=true;
+ }
+ if(xmlElem.HasAttribute("menuusidega"))
+ {
+ m_MenuUnusedSideGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("menuusidega"));
+ }
+ if(xmlElem.HasAttribute("menudtb"))
+ {
+ m_ItemDesignTimeBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("menudtb"));
+ m_ItemDesignTimeBorderCustom=true;
+ }
+ if(xmlElem.HasAttribute("customback"))
+ {
+ m_CustomizeBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("customback"));
+ m_CustomizeBackgroundCustom=true;
+ }
+ if(xmlElem.HasAttribute("customback2"))
+ {
+ m_CustomizeBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("customback2"));
+ m_CustomizeBackground2Custom=true;
+ }
+ if(xmlElem.HasAttribute("customtext"))
+ {
+ m_CustomizeText=BarFunctions.ColorFromString(xmlElem.GetAttribute("customtext"));
+ m_CustomizeTextCustom=true;
+ }
+ if(xmlElem.HasAttribute("custombackga"))
+ {
+ m_CustomizeBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("custombackga"));
+ }
+
+ // Panel Colors
+ if(xmlElem.HasAttribute("panelback"))
+ {
+ m_PanelBackgroundCustom=true;
+ m_PanelBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("panelback"));
+ }
+ if(xmlElem.HasAttribute("panelback2"))
+ {
+ m_PanelBackground2Custom=true;
+ m_PanelBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("panelback2"));
+ }
+ if(xmlElem.HasAttribute("panelborder"))
+ {
+ m_PanelBorderCustom=true;
+ m_PanelBorder=BarFunctions.ColorFromString(xmlElem.GetAttribute("panelborder"));
+ }
+ if(xmlElem.HasAttribute("paneltext"))
+ {
+ m_PanelTextCustom=true;
+ m_PanelText=BarFunctions.ColorFromString(xmlElem.GetAttribute("paneltext"));
+ }
+ if(xmlElem.HasAttribute("panelbackga"))
+ {
+ m_PanelBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("panelbackga"));
+ }
+
+ // Splitter Colors
+ if (xmlElem.HasAttribute("splitterback"))
+ {
+ m_SplitterBackgroundCustom = true;
+ m_SplitterBackground = BarFunctions.ColorFromString(xmlElem.GetAttribute("Splitterback"));
+ }
+ if (xmlElem.HasAttribute("splitterback2"))
+ {
+ m_SplitterBackground2Custom = true;
+ m_SplitterBackground2 = BarFunctions.ColorFromString(xmlElem.GetAttribute("Splitterback2"));
+ }
+ if (xmlElem.HasAttribute("splitterborder"))
+ {
+ m_SplitterBorderCustom = true;
+ m_SplitterBorder = BarFunctions.ColorFromString(xmlElem.GetAttribute("Splitterborder"));
+ }
+ if (xmlElem.HasAttribute("splittertext"))
+ {
+ m_SplitterTextCustom = true;
+ m_SplitterText = BarFunctions.ColorFromString(xmlElem.GetAttribute("Splittertext"));
+ }
+ if (xmlElem.HasAttribute("splitterbackga"))
+ {
+ m_SplitterBackgroundGradientAngle = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("Splitterbackga"));
+ }
+
+ // Explorer Bar Colors
+ if(xmlElem.HasAttribute("exbarback"))
+ {
+ m_ExplorerBarBackgroundCustom=true;
+ m_ExplorerBarBackground=BarFunctions.ColorFromString(xmlElem.GetAttribute("exbarback"));
+ }
+ if(xmlElem.HasAttribute("exbarback2"))
+ {
+ m_ExplorerBarBackground2Custom=true;
+ m_ExplorerBarBackground2=BarFunctions.ColorFromString(xmlElem.GetAttribute("exbarback2"));
+ }
+ if(xmlElem.HasAttribute("exbarbackga"))
+ {
+ m_ExplorerBarBackgroundGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("exbarbackga"));
+ }
+
+ // Dock Site colors
+ // Explorer Bar Colors
+ if(xmlElem.HasAttribute("dsback"))
+ {
+ m_DockSiteBackColorCustom=true;
+ m_DockSiteBackColor=BarFunctions.ColorFromString(xmlElem.GetAttribute("dsback"));
+ }
+ if(xmlElem.HasAttribute("dsback2"))
+ {
+ m_DockSiteBackColor2Custom=true;
+ m_DockSiteBackColor2=BarFunctions.ColorFromString(xmlElem.GetAttribute("dsback2"));
+ }
+ if(xmlElem.HasAttribute("dsbackga"))
+ m_DockSiteBackColorGradientAngle=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("dsbackga"));
+
+ if (xmlElem.HasAttribute("mdisystemitemforeground"))
+ {
+ m_MdiSystemItemForeground = BarFunctions.ColorFromString(xmlElem.GetAttribute("mdisystemitemforeground"));
+ }
+ else
+ m_MdiSystemItemForeground = Color.Empty;
+ }
+ #endregion
+ }
+
+ #region Enums
+ ///
+ /// Specifies the type of predefined color scheme in ColorScheme object.
+ ///
+ public enum ePredefinedColorScheme
+ {
+ ///
+ /// Default value. DotNetBar will automatically change and generate color scheme depending on system colors.
+ ///
+ AutoGenerated=0,
+ ///
+ /// Blue Office 2003 Color Scheme. This setting specifies that this color scheme will be used regardless of system color setting on user machine.
+ ///
+ Blue2003=1,
+ ///
+ /// Olive Green Office 2003 Color Scheme. This setting specifies that this color scheme will be used regardless of system color setting on user machine.
+ ///
+ OliveGreen2003=2,
+ ///
+ /// Silver Office 2003 Color Scheme. This setting specifies that this color scheme will be used regardless of system color setting on user machine.
+ ///
+ Silver2003=3,
+ ///
+ /// Always use system colors to auto-generate color scheme.
+ ///
+ SystemColors
+ }
+
+ ///
+ /// Specifies a color scheme member.
+ ///
+ public enum eColorSchemePart
+ {
+ BarBackground,
+ BarBackground2,
+ BarCaptionBackground,
+ BarCaptionBackground2,
+ BarCaptionInactiveBackground,
+ BarCaptionInactiveBackground2,
+ BarCaptionInactiveText,
+ BarCaptionText,
+ BarDockedBorder,
+ BarFloatingBorder,
+ BarPopupBackground,
+ BarPopupBorder,
+ BarStripeColor,
+ CustomizeBackground,
+ CustomizeBackground2,
+ CustomizeText,
+ ItemBackground,
+ ItemBackground2,
+ ItemCheckedBackground,
+ ItemCheckedBackground2,
+ ItemCheckedBorder,
+ ItemCheckedText,
+ ItemDesignTimeBorder,
+ ItemDisabledBackground,
+ ItemDisabledText,
+ ItemExpandedBackground,
+ ItemExpandedBackground2,
+ ItemExpandedBorder,
+ ItemExpandedShadow,
+ ItemExpandedText,
+ ItemHotBackground,
+ ItemHotBackground2,
+ ItemHotBorder,
+ ItemHotText,
+ ItemPressedBackground,
+ ItemPressedBackground2,
+ ItemPressedBorder,
+ ItemPressedText,
+ ItemSeparator,
+ ItemSeparatorShade,
+ ItemText,
+ MenuBackground,
+ MenuBackground2,
+ MenuBarBackground,
+ MenuBarBackground2,
+ MenuBorder,
+ MenuSide,
+ MenuSide2,
+ MenuUnusedBackground,
+ MenuUnusedSide,
+ MenuUnusedSide2,
+ PanelBackground,
+ PanelBackground2,
+ PanelBorder,
+ PanelText,
+ SplitterBackground,
+ SplitterBackground2,
+ SplitterBorder,
+ SplitterText,
+ ExplorerBarBackground,
+ ExplorerBarBackground2,
+ Custom,
+ None,
+ DockSiteBackColor,
+ DockSiteBackColor2
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/ColorSchemeEditor.cs b/PROMS/DotNetBar Source Code/ColorSchemeEditor.cs
new file mode 100644
index 00000000..f9d4f46b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorSchemeEditor.cs
@@ -0,0 +1,384 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Xml;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for ColorSchemeEditor.
+ ///
+ public class ColorSchemeEditor : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.PropertyGrid propertyGrid1;
+ private System.Windows.Forms.GroupBox groupBox1;
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.Container components = null;
+ private ColorScheme m_ColorScheme=null;
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Button button2;
+ private MenuPanel m_Menu=null;
+ private Bar m_SimpleBar=null;
+ private Bar m_FloatBar=null;
+ private System.Windows.Forms.Button button3;
+ private Bar m_PopupBar=null;
+ private System.Windows.Forms.Button btnSaveScheme;
+ private System.Windows.Forms.Button btnLoadScheme;
+ private System.Windows.Forms.OpenFileDialog openFileDialog1;
+ private System.Windows.Forms.SaveFileDialog saveFileDialog1;
+ public bool ColorSchemeChanged=false;
+
+ public ColorSchemeEditor()
+ {
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+ this.StartPosition=FormStartPosition.CenterScreen;
+ }
+
+ private void AddDotNetBarControls()
+ {
+ if(m_Menu!=null)
+ {
+ m_Menu.RecalcSize();
+ m_SimpleBar.Size=new Size(groupBox1.ClientRectangle.Width-12,16);
+ m_SimpleBar.RecalcSize();
+ m_FloatBar.Size=new Size(groupBox1.ClientRectangle.Width,16);
+ m_FloatBar.RecalcSize();
+ m_PopupBar.Size=new Size(groupBox1.ClientRectangle.Width,24);
+ m_PopupBar.RecalcSize();
+ return;
+ }
+
+ m_Menu=new MenuPanel();
+ m_Menu.PopupMenu=false;
+ m_Menu.Location=new Point(8,135);
+
+ // Create Simple Toolbar
+ m_SimpleBar=new Bar();
+ m_SimpleBar.PassiveBar=true;
+ m_SimpleBar.Location=new Point(4,16);
+ m_SimpleBar.ThemeAware=false;
+
+ m_FloatBar=new Bar();
+ m_FloatBar.PassiveBar=true;
+ m_FloatBar.Location=new Point(4,46);
+ m_FloatBar.ThemeAware=false;
+
+ m_PopupBar=new Bar();
+ m_PopupBar.PassiveBar=true;
+ m_PopupBar.Location=new Point(4,96);
+ m_PopupBar.ThemeAware=false;
+
+ ButtonItem menuItem=new ButtonItem();
+ ButtonItem item, item2;
+ Bitmap bmp=null;
+
+ item=new ButtonItem("new","&New...");
+ bmp=BarFunctions.LoadBitmap("BarEditorImages.FileNew.bmp");
+ bmp.MakeTransparent(Color.Magenta);
+ item.Image=bmp;
+ m_SimpleBar.Items.Add(item.Copy());
+ m_FloatBar.Items.Add(item.Copy());
+ m_PopupBar.Items.Add(item.Copy());
+ menuItem.SubItems.Add(item);
+ item=new ButtonItem("open","&Open");
+ bmp=BarFunctions.LoadBitmap("BarEditorImages.FileOpen.bmp");
+ bmp.MakeTransparent(Color.Magenta);
+ item.Image=bmp;
+ item2=(ButtonItem)item.Copy();
+ item2.ButtonStyle=eButtonStyle.ImageAndText;
+ m_SimpleBar.Items.Add(item2);
+ m_FloatBar.Items.Add(item2.Copy());
+ m_PopupBar.Items.Add(item2.Copy());
+ menuItem.SubItems.Add(item);
+ item=new ButtonItem("close","&Close");
+ bmp=BarFunctions.LoadBitmap("BarEditorImages.FileClose.bmp");
+ bmp.MakeTransparent(Color.Magenta);
+ item.Image=bmp;
+ item2=(ButtonItem)item.Copy();
+ item2.Checked=true;
+ item2.ButtonStyle=eButtonStyle.ImageAndText;
+ m_SimpleBar.Items.Add(item2);
+ m_PopupBar.Items.Add(item2.Copy());
+ item2=(ButtonItem)item2.Copy();
+ item2.Enabled=false;
+ m_FloatBar.Items.Add(item2.Copy());
+ menuItem.SubItems.Add(item);
+ item=new ButtonItem("open","Add Ne&w Item...");
+ menuItem.SubItems.Add(item);
+ item=new ButtonItem("open","Add Existin&g Item...");
+ menuItem.SubItems.Add(item);
+ item=new ButtonItem("opensol","Open Solution...");
+ item.BeginGroup=true;
+ bmp=BarFunctions.LoadBitmap("BarEditorImages.FileOpenSol.bmp");
+ bmp.MakeTransparent(Color.Magenta);
+ item.Image=bmp;
+ item2=(ButtonItem)item.Copy();
+ item2.Enabled=false;
+ m_SimpleBar.Items.Add(item2);
+ m_FloatBar.Items.Add(item2.Copy());
+ m_PopupBar.Items.Add(item2.Copy());
+ menuItem.SubItems.Add(item);
+ item=new ButtonItem("open","Close Solution");
+ bmp=BarFunctions.LoadBitmap("BarEditorImages.FileCloseSol.bmp");
+ bmp.MakeTransparent(Color.Magenta);
+ item.Image=bmp;
+ item.Enabled=false;
+ menuItem.SubItems.Add(item);
+
+ m_Menu.ParentItem=menuItem;
+
+ groupBox1.Controls.Add(m_Menu);
+ m_Menu.RecalcSize();
+ m_Menu.Show();
+
+ //m_SimpleBar.SetBarState(eBarState.Docked);
+ m_SimpleBar.Size=new Size(groupBox1.ClientRectangle.Width,16);
+ m_SimpleBar.GrabHandleStyle=eGrabHandleStyle.StripeFlat;
+ groupBox1.Controls.Add(m_SimpleBar);
+ m_SimpleBar.RecalcSize();
+ m_SimpleBar.Show();
+
+ m_FloatBar.SetBarState(eBarState.Floating);
+ m_FloatBar.Size=new Size(groupBox1.ClientRectangle.Width,16);
+ groupBox1.Controls.Add(m_FloatBar);
+ m_FloatBar.Text="Bar Caption";
+ m_FloatBar.RecalcSize();
+ m_FloatBar.Show();
+
+ m_PopupBar.SetBarState(eBarState.Popup);
+ m_PopupBar.Size=new Size(groupBox1.ClientRectangle.Width,24);
+ m_PopupBar.PopupWidth=groupBox1.ClientRectangle.Width;
+ groupBox1.Controls.Add(m_PopupBar);
+ m_PopupBar.RecalcSize();
+ m_PopupBar.Show();
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.button1 = new System.Windows.Forms.Button();
+ this.button2 = new System.Windows.Forms.Button();
+ this.button3 = new System.Windows.Forms.Button();
+ this.btnSaveScheme = new System.Windows.Forms.Button();
+ this.btnLoadScheme = new System.Windows.Forms.Button();
+ this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
+ this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
+ this.SuspendLayout();
+ //
+ // propertyGrid1
+ //
+ this.propertyGrid1.CommandsVisibleIfAvailable = true;
+ this.propertyGrid1.LargeButtons = false;
+ this.propertyGrid1.LineColor = System.Drawing.SystemColors.ScrollBar;
+ this.propertyGrid1.Location = new System.Drawing.Point(208, 4);
+ this.propertyGrid1.Name = "propertyGrid1";
+ this.propertyGrid1.Size = new System.Drawing.Size(352, 299);
+ this.propertyGrid1.TabIndex = 0;
+ this.propertyGrid1.Text = "propertyGrid1";
+ this.propertyGrid1.ViewBackColor = System.Drawing.SystemColors.Window;
+ this.propertyGrid1.ViewForeColor = System.Drawing.SystemColors.WindowText;
+ this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged);
+ //
+ // groupBox1
+ //
+ this.groupBox1.Location = new System.Drawing.Point(10, 0);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(190, 303);
+ this.groupBox1.TabIndex = 1;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Color Scheme Preview:";
+ //
+ // button1
+ //
+ this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.button1.Location = new System.Drawing.Point(404, 307);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(76, 24);
+ this.button1.TabIndex = 2;
+ this.button1.Text = "OK";
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // button2
+ //
+ this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.button2.Location = new System.Drawing.Point(316, 307);
+ this.button2.Name = "button2";
+ this.button2.Size = new System.Drawing.Size(76, 24);
+ this.button2.TabIndex = 3;
+ this.button2.Text = "&Reset";
+ this.button2.Click += new System.EventHandler(this.button2_Click);
+ //
+ // button3
+ //
+ this.button3.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.button3.Location = new System.Drawing.Point(484, 307);
+ this.button3.Name = "button3";
+ this.button3.Size = new System.Drawing.Size(76, 24);
+ this.button3.TabIndex = 4;
+ this.button3.Text = "Cancel";
+ this.button3.Click += new System.EventHandler(this.button3_Click);
+ //
+ // btnSaveScheme
+ //
+ this.btnSaveScheme.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.btnSaveScheme.Location = new System.Drawing.Point(10, 308);
+ this.btnSaveScheme.Name = "btnSaveScheme";
+ this.btnSaveScheme.Size = new System.Drawing.Size(92, 24);
+ this.btnSaveScheme.TabIndex = 5;
+ this.btnSaveScheme.Text = "Save Scheme...";
+ this.btnSaveScheme.Click += new System.EventHandler(this.btnSaveScheme_Click);
+ //
+ // btnLoadScheme
+ //
+ this.btnLoadScheme.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.btnLoadScheme.Location = new System.Drawing.Point(107, 308);
+ this.btnLoadScheme.Name = "btnLoadScheme";
+ this.btnLoadScheme.Size = new System.Drawing.Size(92, 24);
+ this.btnLoadScheme.TabIndex = 6;
+ this.btnLoadScheme.Text = "Load Scheme...";
+ this.btnLoadScheme.Click += new System.EventHandler(this.btnLoadScheme_Click);
+ //
+ // openFileDialog1
+ //
+ this.openFileDialog1.DefaultExt = "*.dcs";
+ this.openFileDialog1.Filter = "DotNetBar Color Scheme files|*.dcs|All files|*.*";
+ this.openFileDialog1.Title = "Open DotNetBar Color Scheme File";
+ //
+ // saveFileDialog1
+ //
+ this.saveFileDialog1.DefaultExt = "dcs";
+ this.saveFileDialog1.FileName = "colorscheme1";
+ this.saveFileDialog1.Filter = "DotNetBar Color Scheme files|*.dcs|All files|*.*";
+ this.saveFileDialog1.Title = "Save DotNetBar Color Scheme File";
+ //
+ // ColorSchemeEditor
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(567, 338);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.btnLoadScheme,
+ this.btnSaveScheme,
+ this.button3,
+ this.button2,
+ this.button1,
+ this.groupBox1,
+ this.propertyGrid1});
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "ColorSchemeEditor";
+ this.Text = "ColorScheme Editor";
+ this.Load += new System.EventHandler(this.ColorSchemeEditorLoad);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ private void ColorSchemeEditorLoad(object sender, EventArgs e)
+ {
+ AddDotNetBarControls();
+ }
+
+ private void propertyGrid1_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
+ {
+ m_Menu.Refresh();
+ m_SimpleBar.Refresh();
+ m_FloatBar.Refresh();
+ m_PopupBar.Refresh();
+ ColorSchemeChanged=true;
+ }
+
+ private void button1_Click(object sender, System.EventArgs e)
+ {
+ this.Hide();
+ }
+
+ private void button2_Click(object sender, System.EventArgs e)
+ {
+ if(MessageBox.Show("Reseting the Color Scheme will destroy any changes you made. Are you sure you want to reset the Color Scheme?","Color Scheme Editor",MessageBoxButtons.YesNo)==DialogResult.Yes)
+ {
+ this.ColorScheme=new ColorScheme(this.ColorScheme.Style);
+ ColorSchemeChanged=true;
+ }
+ }
+
+ private void button3_Click(object sender, System.EventArgs e)
+ {
+ ColorSchemeChanged=false;
+ this.Hide();
+ }
+
+ private void btnSaveScheme_Click(object sender, System.EventArgs e)
+ {
+ if(saveFileDialog1.ShowDialog()==DialogResult.OK)
+ {
+ XmlDocument doc=new XmlDocument();
+ XmlElement elem1=doc.CreateElement("colorschemes");
+ doc.AppendChild(elem1);
+ XmlElement elem2=doc.CreateElement("colorscheme");
+ elem1.AppendChild(elem2);
+ m_ColorScheme.Serialize(elem2);
+ doc.Save(saveFileDialog1.FileName);
+ MessageBox.Show("Color Scheme has been saved.","DotNetBar Color Scheme Editor",MessageBoxButtons.OK,MessageBoxIcon.Information);
+ }
+ }
+
+ private void btnLoadScheme_Click(object sender, System.EventArgs e)
+ {
+ if(openFileDialog1.ShowDialog()==DialogResult.OK && System.IO.File.Exists(openFileDialog1.FileName))
+ {
+ DevComponents.DotNetBar.ColorScheme scheme=new ColorScheme();
+ XmlDocument doc=new XmlDocument();
+ doc.Load(openFileDialog1.FileName);
+ scheme.Deserialize(doc.FirstChild.FirstChild as XmlElement);
+ this.ColorScheme=scheme;
+ ColorSchemeChanged=true;
+ }
+ }
+
+ public DevComponents.DotNetBar.ColorScheme ColorScheme
+ {
+ get {return m_ColorScheme;}
+ set
+ {
+ if(m_Menu==null)
+ AddDotNetBarControls();
+ m_ColorScheme=value;
+ propertyGrid1.SelectedObject=m_ColorScheme;
+ m_Menu.ColorScheme=m_ColorScheme;
+ m_SimpleBar.ColorScheme=m_ColorScheme;
+ m_FloatBar.ColorScheme=m_ColorScheme;
+ m_PopupBar.ColorScheme=m_ColorScheme;
+ ColorSchemeChanged=false;
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorSchemeEditor.resx b/PROMS/DotNetBar Source Code/ColorSchemeEditor.resx
new file mode 100644
index 00000000..87c738c3
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorSchemeEditor.resx
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 147, 17
+
+
+ ColorSchemeEditor
+
+
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/ColorSchemeVSEditor.cs b/PROMS/DotNetBar Source Code/ColorSchemeVSEditor.cs
new file mode 100644
index 00000000..52494321
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorSchemeVSEditor.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Drawing.Design;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for ColorSchemeVSEditor.
+ ///
+ public sealed class ColorSchemeVSEditor:UITypeEditor
+ {
+ private System.Windows.Forms.Design.IWindowsFormsEditorService m_EditorService=null;
+ public ColorSchemeVSEditor()
+ {
+ }
+ public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
+ {
+ if (context != null && context.Instance != null)
+ {
+ return System.Drawing.Design.UITypeEditorEditStyle.Modal;
+ }
+ return base.GetEditStyle(context);
+ }
+ public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
+ {
+ if (context!=null && context.Instance!=null && provider!=null)
+ {
+ m_EditorService=(System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));
+
+ if(m_EditorService!=null)
+ {
+ if(context.Instance is Bar)
+ {
+ Bar bar=context.Instance as Bar;
+ if(bar.Owner is DotNetBarManager && ((DotNetBarManager)bar.Owner).UseGlobalColorScheme)
+ System.Windows.Forms.MessageBox.Show("Please note that your DotNetBarManager has its UseGlobalColorScheme set to true and any changes you make to ColorScheme object on the bar will not be used.");
+ }
+ else if(context.Instance is DotNetBarManager && !((DotNetBarManager)context.Instance).UseGlobalColorScheme)
+ {
+ System.Windows.Forms.MessageBox.Show("Please note that you need to set UseGlobalColorScheme=true in order for all bars to use ColorScheme you change on this dialog.");
+ }
+
+ if(value==null)
+ value=new ColorScheme();
+ ColorSchemeEditor editor=new ColorSchemeEditor();
+ editor.CreateControl();
+ editor.ColorScheme=(ColorScheme)value;
+ m_EditorService.ShowDialog(editor);
+ if(editor.ColorSchemeChanged)
+ {
+ value=editor.ColorScheme;
+ context.OnComponentChanged();
+ ((ColorScheme)value)._DesignTimeSchemeChanged=true;
+ if(context.Instance is Bar)
+ {
+ ((Bar)context.Instance).Refresh();
+ }
+ }
+ editor.Close();
+ }
+ }
+
+ return value;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ColorTypeEditor.cs b/PROMS/DotNetBar Source Code/ColorTypeEditor.cs
new file mode 100644
index 00000000..ef7a4ad8
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ColorTypeEditor.cs
@@ -0,0 +1,131 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Design;
+using System.Reflection;
+using System.Windows.Forms.Design;
+using DevComponents.UI;
+using System.Windows.Forms;
+
+#if AdvTree
+namespace DevComponents.Tree
+#elif DOTNETBAR
+namespace DevComponents.DotNetBar
+#endif
+{
+ ///
+ /// Represents Color type editor with support for color schemes.
+ ///
+ public class ColorTypeEditor:UITypeEditor
+ {
+ private IWindowsFormsEditorService m_EditorService=null;
+
+ ///
+ /// Edits the value of the specified object using the editor style indicated by GetEditStyle.
+ ///
+ /// An ITypeDescriptorContext that can be used to gain additional context information.
+ /// An IServiceProvider that this editor can use to obtain services.
+ /// The object to edit.
+ /// The new value of the object.
+ public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
+ {
+ if (context != null && context.Instance != null && provider != null)
+ {
+ m_EditorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
+
+ ColorScheme cs=null;
+ if(context.Instance!=null)
+ {
+ MethodInfo method = null;
+ if (context.Instance is object[])
+ {
+ method = ((object[])context.Instance)[0].GetType().GetMethod("GetColorScheme", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+ if (method != null)
+ {
+ cs = method.Invoke(((object[])context.Instance)[0], null) as ColorScheme;
+ }
+ }
+ else
+ {
+ method = context.Instance.GetType().GetMethod("GetColorScheme", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+ if (method != null)
+ {
+ cs = method.Invoke(context.Instance, null) as ColorScheme;
+ }
+ }
+
+ }
+
+ Color colorValue=(Color)value;
+
+ if(m_EditorService!=null)
+ {
+ ColorPicker colorPicker=new ColorPicker();
+ colorPicker.EditorService=m_EditorService;
+ colorPicker.BackColor=SystemColors.Control;
+ colorPicker.ColorScheme=cs;
+ colorPicker.SelectedColor=colorValue;
+
+ string propertyName=context.PropertyDescriptor.Name;
+ PropertyInfo property = null;
+ if (context.Instance is object[])
+ property = ((object[])context.Instance)[0].GetType().GetProperty(propertyName + "SchemePart", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+ else
+ property=context.Instance.GetType().GetProperty(propertyName+"SchemePart",BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+
+ if(property!=null)
+ {
+ if (context.Instance is object[])
+ colorPicker.SelectedColorSchemeName = property.GetValue(((object[])context.Instance)[0], null).ToString();
+ else
+ colorPicker.SelectedColorSchemeName=property.GetValue(context.Instance,null).ToString();
+ }
+ colorPicker.UpdateUIWithSelection();
+
+ m_EditorService.DropDownControl(colorPicker);
+ if(!colorPicker.Canceled)
+ {
+ Color returnColor=colorPicker.SelectedColor;
+ eColorSchemePart schemePart=eColorSchemePart.None;
+ if(colorPicker.SelectedColorSchemeName!="")
+ {
+ schemePart=(eColorSchemePart)Enum.Parse(typeof(eColorSchemePart),colorPicker.SelectedColorSchemeName);
+ }
+ if(property!=null)
+ {
+ if (context.Instance is object[])
+ {
+ object[] objects = (object[])context.Instance;
+ foreach (object item in objects)
+ {
+ property = item.GetType().GetProperty(propertyName + "SchemePart", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+ property.SetValue(item, schemePart, null);
+ }
+ }
+ else
+ property.SetValue(context.Instance, schemePart, null);
+ }
+ return returnColor;
+ }
+ }
+ }
+
+ return value;
+ }
+
+ ///
+ /// Gets the editor style used by the EditValue method.
+ ///
+ /// An ITypeDescriptorContext that can be used to gain additional context information.
+ /// A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None.
+ ///
+ public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
+ {
+ if (context != null && context.Instance != null)
+ {
+ return UITypeEditorEditStyle.DropDown;
+ }
+ return base.GetEditStyle(context);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ComboBoxItem.cs b/PROMS/DotNetBar Source Code/ComboBoxItem.cs
new file mode 100644
index 00000000..e629e0a2
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ComboBoxItem.cs
@@ -0,0 +1,1538 @@
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Controls;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for ComboBoxItem.
+ ///
+ [System.ComponentModel.ToolboxItem(false), DefaultEvent("Click"), System.ComponentModel.DesignTimeVisible(false), Designer("DevComponents.DotNetBar.Design.ComboBoxItemDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class ComboBoxItem:ImageItem,IPersonalizedMenuItem
+ {
+ private Controls.ComboBoxEx m_ComboBox=null;
+ private int m_ComboWidth=64;
+ private bool m_MouseOver=false;
+ //private string m_ControlText="";
+ private bool m_AlwaysShowCaption;
+ private bool m_FontCombo=false;
+
+ // IPersonalizedMenuItem Implementation
+ private eMenuVisibility m_MenuVisibility=eMenuVisibility.VisibleAlways;
+ private bool m_RecentlyUsed=false;
+ internal bool _CopyInProgress=false;
+
+ private bool m_PreventEnterBeep=false;
+
+ ///
+ /// Occurs when underlining control ComboBox.Text property has changed.
+ ///
+ public event EventHandler ComboBoxTextChanged;
+
+ ///
+ /// Occurs when selected item on combo box has changed.
+ ///
+ public event EventHandler SelectedIndexChanged;
+
+ ///
+ /// Creates new instance of ComboBoxItem.
+ ///
+ public ComboBoxItem():this("","") {}
+ ///
+ /// Creates new instance of ComboBoxItem and assigns item name.
+ ///
+ /// Item Name.
+ public ComboBoxItem(string sName):this(sName,""){}
+ ///
+ /// Creates new instance of ComboBoxItem and assigns item name and item text.
+ ///
+ /// Item Name
+ /// Item Text.
+ public ComboBoxItem(string sName, string ItemText):base(sName,ItemText)
+ {
+ CreateComboBox();
+ m_ComboWidth=64;
+ m_SupportedOrientation=eSupportedOrientation.Horizontal;
+ this.IsAccessible=true;
+ this.AccessibleRole = AccessibleRole.ComboBox;
+ }
+ private void CreateComboBox()
+ {
+ if(m_ComboBox!=null)
+ {
+ m_ComboBox.Dispose();
+ m_ComboBox=null;
+ }
+ m_ComboBox = new Controls.ComboBoxEx();
+ m_ComboBox.IsStandalone = false;
+ m_ComboBox.TabStop = false;
+ m_ComboBox.TabIndex = 9999;
+ m_ComboBox.Style = this.Style;
+ m_ComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
+ m_ComboBox.IntegralHeight = false;
+ //m_ComboBox.ItemHeight = 13;
+ m_ComboBox.ThemeAware = false;
+ m_ComboBox.Visible = false;
+ m_ComboBox.Text = this.Text;
+ m_ComboBox.SelectionStart = 0;
+ m_ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+
+ m_ComboBox.LostFocus += new EventHandler(this.ComboLostFocus);
+ m_ComboBox.GotFocus += new EventHandler(this.ComboGotFocus);
+ m_ComboBox.MouseHover += new EventHandler(this.ComboMouseHover);
+ m_ComboBox.MouseEnter += new EventHandler(this.ComboMouseEnter);
+ m_ComboBox.MouseLeave += new EventHandler(this.ComboMouseLeave);
+ m_ComboBox.VisibleChanged += new EventHandler(ComboBoxVisibleChanged);
+ m_ComboBox.DropDownChange += new Controls.ComboBoxEx.OnDropDownChangeEventHandler(this.ComboDropDownChange);
+ m_ComboBox.TextChanged += new EventHandler(this.InternalComboTextChanged);
+ m_ComboBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ComboKeyDown);
+ m_ComboBox.SelectedIndexChanged += new System.EventHandler(this.ComboSelChanged);
+ m_ComboBox.PreventEnterBeep = m_PreventEnterBeep;
+ m_ComboBox.ParentItem = this;
+ if(m_FontCombo)
+ m_ComboBox.LoadFonts();
+
+ if(this.ContainerControl!=null)
+ {
+ System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(objCtrl!=null)
+ {
+ objCtrl.Controls.Add(m_ComboBox);
+ m_ComboBox.Refresh();
+ }
+ }
+
+ if(this.Displayed)
+ {
+ m_ComboBox.Visible=true;
+ }
+ }
+
+ public override BaseItem Copy()
+ {
+ ComboBoxItem objCopy=new ComboBoxItem(this.Name);
+ this.CopyToItem(objCopy);
+ objCopy.DropDownStyle=this.DropDownStyle;
+ objCopy.AlwaysShowCaption=this.AlwaysShowCaption;
+ objCopy.FontCombo=this.FontCombo;
+ objCopy.ItemHeight=this.ItemHeight;
+ objCopy.Caption = this.Caption;
+
+ return objCopy;
+ }
+ protected override void CopyToItem(BaseItem copy)
+ {
+ ((ComboBoxItem)copy)._CopyInProgress=true;
+ try
+ {
+ ComboBoxItem objCopy=copy as ComboBoxItem;
+ base.CopyToItem(objCopy);
+
+
+ objCopy.ComboWidth=m_ComboWidth;
+ objCopy.FontCombo=m_FontCombo;
+ objCopy.PreventEnterBeep=m_PreventEnterBeep;
+ if (m_ComboBox != null)
+ {
+ objCopy.DisplayMember = m_ComboBox.DisplayMember;
+
+ Controls.ComboBoxEx cb = objCopy.ComboBoxEx;
+ if (!m_FontCombo)
+ {
+ foreach (object o in m_ComboBox.Items)
+ cb.Items.Add(o);
+ }
+ cb.SelectedIndex = m_ComboBox.SelectedIndex;
+ }
+ }
+ finally
+ {
+ ((ComboBoxItem)copy)._CopyInProgress=false;
+ }
+ }
+ protected override void Dispose(bool disposing)
+ {
+ base.Dispose(disposing);
+ // Control gets disposed by the parent control it is added to
+ //if (m_ComboBox != null)
+ //{
+ // if (m_ComboBox.Parent == null && !m_ComboBox.IsDisposed)
+ // m_ComboBox.Dispose();
+ //}
+ }
+ protected override System.Windows.Forms.AccessibleObject CreateAccessibilityInstance()
+ {
+ return m_ComboBox.AccessibilityObject;
+ }
+ ///
+ /// Gets or sets the accessible role of the item.
+ ///
+ [Browsable(true), Category("Accessibility"), Description("Gets or sets the accessible role of the item."), DefaultValue(System.Windows.Forms.AccessibleRole.ComboBox)]
+ public override System.Windows.Forms.AccessibleRole AccessibleRole
+ {
+ get { return base.AccessibleRole; }
+ set { base.AccessibleRole = value; }
+ }
+ protected internal override void Serialize(ItemSerializationContext context)
+ {
+ base.Serialize(context);
+ System.Xml.XmlElement ThisItem = context.ItemXmlElement;
+ ThisItem.SetAttribute("ComboWidth",System.Xml.XmlConvert.ToString(m_ComboWidth));
+ ThisItem.SetAttribute("FontCombo",System.Xml.XmlConvert.ToString(m_FontCombo));
+
+ ThisItem.SetAttribute("MenuVisibility",System.Xml.XmlConvert.ToString((int)m_MenuVisibility));
+ ThisItem.SetAttribute("RecentlyUsed",System.Xml.XmlConvert.ToString(m_RecentlyUsed));
+ ThisItem.SetAttribute("DropDownStyle",System.Xml.XmlConvert.ToString((int)m_ComboBox.DropDownStyle));
+ //ThisItem.SetAttribute("CText",m_ControlText);
+ ThisItem.SetAttribute("ThemeAware",System.Xml.XmlConvert.ToString(m_ComboBox.ThemeAware));
+
+ ThisItem.SetAttribute("AlwaysShowCaption",System.Xml.XmlConvert.ToString(m_AlwaysShowCaption));
+ ThisItem.SetAttribute("ItemHeight",System.Xml.XmlConvert.ToString(m_ComboBox.ItemHeight));
+
+ if(m_ComboBox.DisplayMember!="")
+ ThisItem.SetAttribute("DisplayMembers", m_ComboBox.DisplayMember);
+
+ if(m_PreventEnterBeep)
+ ThisItem.SetAttribute("nobeep",System.Xml.XmlConvert.ToString(m_PreventEnterBeep));
+
+ if(!m_FontCombo && m_ComboBox.Items.Count>0)
+ {
+ System.Xml.XmlElement xmlItems=ThisItem.OwnerDocument.CreateElement("cbitems");
+ ThisItem.AppendChild(xmlItems);
+ foreach(object item in m_ComboBox.Items)
+ {
+ DevComponents.Editors.ComboItem ci=item as DevComponents.Editors.ComboItem;
+ if(ci!=null)
+ {
+ System.Xml.XmlElement xmlChild=ThisItem.OwnerDocument.CreateElement("ci");
+
+ if(!ci.BackColor.IsEmpty)
+ xmlChild.SetAttribute("bc",BarFunctions.ColorToString(ci.BackColor));
+ if(ci.FontName!="")
+ xmlChild.SetAttribute("fn",ci.FontName);
+ if(ci.FontSize!=8)
+ xmlChild.SetAttribute("fs",System.Xml.XmlConvert.ToString(ci.FontSize));
+
+ xmlChild.SetAttribute("fy",System.Xml.XmlConvert.ToString((int)ci.FontStyle));
+
+ if(!ci.ForeColor.IsEmpty)
+ xmlChild.SetAttribute("fc",BarFunctions.ColorToString(ci.ForeColor));
+
+ BarFunctions.SerializeImage(ci.Image,xmlChild);
+
+ if(ci.ImageIndex>=0)
+ xmlChild.SetAttribute("img",System.Xml.XmlConvert.ToString(ci.ImageIndex));
+
+ if(ci.ImagePosition!=System.Windows.Forms.HorizontalAlignment.Left)
+ xmlChild.SetAttribute("ip",System.Xml.XmlConvert.ToString((int)ci.ImagePosition));
+
+ xmlChild.SetAttribute("text",ci.Text);
+
+ xmlChild.SetAttribute("ta",System.Xml.XmlConvert.ToString((int)ci.TextAlignment));
+ xmlChild.SetAttribute("tla",System.Xml.XmlConvert.ToString((int)ci.TextLineAlignment));
+
+ if(m_ComboBox.SelectedItem==item)
+ xmlChild.SetAttribute("selected","1");
+
+ xmlItems.AppendChild(xmlChild);
+ }
+ else
+ {
+ System.Xml.XmlElement xmlChild=ThisItem.OwnerDocument.CreateElement("co");
+ xmlChild.InnerText=item.ToString();
+ xmlItems.AppendChild(xmlChild);
+
+ if(m_ComboBox.SelectedItem==item)
+ xmlChild.SetAttribute("selected","1");
+ }
+ }
+ }
+ }
+
+ public override void Deserialize(ItemSerializationContext context)
+ {
+ base.Deserialize(context);
+ System.Xml.XmlElement ItemXmlSource = context.ItemXmlElement;
+ m_ComboWidth=System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("ComboWidth"));
+ m_FontCombo=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("FontCombo"));
+
+ m_MenuVisibility=(eMenuVisibility)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("MenuVisibility"));
+ m_RecentlyUsed=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("RecentlyUsed"));
+ if(ItemXmlSource.HasAttribute("DropDownStyle"))
+ m_ComboBox.DropDownStyle=(System.Windows.Forms.ComboBoxStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("DropDownStyle"));
+
+ if(ItemXmlSource.HasAttribute("CText"))
+ this.Text=ItemXmlSource.GetAttribute("CText");
+
+ if(ItemXmlSource.HasAttribute("ThemeAware"))
+ m_ComboBox.ThemeAware=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("ThemeAware"));
+ else
+ m_ComboBox.ThemeAware=true;
+
+ if(ItemXmlSource.HasAttribute("AlwaysShowCaption"))
+ m_AlwaysShowCaption=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("AlwaysShowCaption"));
+
+ if(ItemXmlSource.HasAttribute("nobeep"))
+ this.PreventEnterBeep=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("nobeep"));
+
+ System.Xml.XmlNodeList list=ItemXmlSource.GetElementsByTagName("cbitems");
+ if(!m_FontCombo && list.Count>0)
+ {
+ foreach(System.Xml.XmlElement xmlChild in list[0].ChildNodes)
+ {
+ if(xmlChild.Name=="ci")
+ {
+ DevComponents.Editors.ComboItem ci=new DevComponents.Editors.ComboItem();
+ if(xmlChild.HasAttribute("bc"))
+ ci.BackColor=BarFunctions.ColorFromString(xmlChild.GetAttribute("bk"));
+ if(xmlChild.HasAttribute("fn"))
+ ci.FontName=xmlChild.GetAttribute("fn");
+ if(xmlChild.HasAttribute("fs"))
+ ci.FontSize=System.Xml.XmlConvert.ToSingle(xmlChild.GetAttribute("fs"));
+ if(xmlChild.HasAttribute("fy"))
+ ci.FontStyle=(FontStyle)System.Xml.XmlConvert.ToInt32(xmlChild.GetAttribute("fy"));
+ if(xmlChild.HasAttribute("fc"))
+ ci.ForeColor=BarFunctions.ColorFromString(xmlChild.GetAttribute("fc"));
+
+ ci.Image=BarFunctions.DeserializeImage(xmlChild);
+
+ if(xmlChild.HasAttribute("img"))
+ ci.ImageIndex=System.Xml.XmlConvert.ToInt32(xmlChild.GetAttribute("img"));
+
+ if(xmlChild.HasAttribute("ip"))
+ ci.ImagePosition=(System.Windows.Forms.HorizontalAlignment)System.Xml.XmlConvert.ToInt32(xmlChild.GetAttribute("ip"));
+
+ if(xmlChild.HasAttribute("ItemHeight"))
+ m_ComboBox.ItemHeight=System.Xml.XmlConvert.ToInt32(xmlChild.GetAttribute("ItemHeight"));
+
+ ci.Text=xmlChild.GetAttribute("text");
+
+ ci.TextAlignment=(StringAlignment)System.Xml.XmlConvert.ToInt32(xmlChild.GetAttribute("ta"));
+ ci.TextLineAlignment=(StringAlignment)System.Xml.XmlConvert.ToInt32(xmlChild.GetAttribute("tla"));
+
+ m_ComboBox.Items.Add(ci);
+
+ if(xmlChild.HasAttribute("selected") && xmlChild.GetAttribute("selected")=="1")
+ m_ComboBox.SelectedItem=ci;
+ }
+ else if(xmlChild.Name=="co")
+ {
+ m_ComboBox.Items.Add(xmlChild.InnerText);
+ if(xmlChild.HasAttribute("selected") && xmlChild.GetAttribute("selected")=="1")
+ m_ComboBox.SelectedItem=m_ComboBox.Items[m_ComboBox.Items.Count-1];
+ }
+ }
+ }
+ if(m_FontCombo)
+ m_ComboBox.LoadFonts();
+
+ if(m_ComboBox!=null)
+ m_ComboBox.Enabled=this.Enabled;
+
+ if (ItemXmlSource.HasAttribute("DisplayMembers") && m_ComboBox!=null)
+ m_ComboBox.DisplayMember = ItemXmlSource.GetAttribute("DisplayMembers");
+ }
+
+ ///
+ /// Gets or sets whether combo box generates the audible alert when Enter key is pressed.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates whether combo box generates the audible alert when Enter key is pressed."),System.ComponentModel.DefaultValue(false)]
+ public bool PreventEnterBeep
+ {
+ get
+ {
+ return m_PreventEnterBeep;
+ }
+ set
+ {
+ m_PreventEnterBeep=value;
+ if(m_ComboBox!=null)
+ m_ComboBox.PreventEnterBeep=value;
+ }
+ }
+
+ private Color _LabelForeColor = Color.Empty;
+ ///
+ /// Gets or sets the text color of the combo box label.
+ ///
+ [Category("Columns"), Description("Indicates color of combo box label.")]
+ public Color LabelForeColor
+ {
+ get { return _LabelForeColor; }
+ set { _LabelForeColor = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeLabelForeColor()
+ {
+ return !_LabelForeColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetLabelForeColor()
+ {
+ this.LabelForeColor = Color.Empty;
+ }
+
+ public override void Paint(ItemPaintArgs pa)
+ {
+ if(this.SuspendLayout)
+ return;
+ System.Drawing.Graphics g=pa.Graphics;
+ Rectangle r=this.DisplayRectangle;
+ Size objImageSize=GetMaxImageSize();
+ bool bOnMenu = this.IsOnMenu && !(this.Parent is ItemContainer);
+ bool enabled = GetEnabled(pa.ContainerControl);
+ Color textColor = enabled ? SystemColors.ControlText : SystemColors.ControlDark;
+ if (BarFunctions.IsOffice2007Style(this.EffectiveStyle) && pa.Renderer is Rendering.Office2007Renderer &&
+ ((Rendering.Office2007Renderer)pa.Renderer).ColorTable.ButtonItemColors.Count > 0)
+ {
+ textColor = enabled ? ((Rendering.Office2007Renderer)pa.Renderer).ColorTable.ButtonItemColors[0].Default.Text : pa.Colors.ItemDisabledText;
+ }
+ if (!_LabelForeColor.IsEmpty)
+ textColor = _LabelForeColor;
+
+ if(this.Orientation==eOrientation.Horizontal)
+ {
+ if (bOnMenu && (EffectiveStyle == eDotNetBarStyle.OfficeXP || EffectiveStyle == eDotNetBarStyle.Office2003 || EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(EffectiveStyle)))
+ {
+ objImageSize.Width+=7;
+ r.Width-=objImageSize.Width;
+ r.X+=objImageSize.Width;
+ if(this.IsOnCustomizeMenu)
+ objImageSize.Width+=objImageSize.Height+8;
+ // Draw side bar
+ Rectangle sideRect = new Rectangle(m_Rect.Left, m_Rect.Top, objImageSize.Width, m_Rect.Height);
+ if(this.MenuVisibility==eMenuVisibility.VisibleIfRecentlyUsed && !this.RecentlyUsed)
+ {
+ if(!pa.Colors.MenuUnusedSide2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(sideRect,pa.Colors.MenuUnusedSide,pa.Colors.MenuUnusedSide2,pa.Colors.MenuUnusedSideGradientAngle);
+ g.FillRectangle(gradient,sideRect);
+ gradient.Dispose();
+ }
+ else
+ g.FillRectangle(new SolidBrush(pa.Colors.MenuUnusedSide), sideRect);
+ }
+ else
+ {
+ if(!pa.Colors.MenuSide2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(sideRect, pa.Colors.MenuSide, pa.Colors.MenuSide2, pa.Colors.MenuSideGradientAngle);
+ g.FillRectangle(gradient, sideRect);
+ gradient.Dispose();
+ }
+ else
+ g.FillRectangle(new SolidBrush(pa.Colors.MenuSide), sideRect);
+ }
+ if (BarFunctions.IsOffice2007Style(EffectiveStyle) && GlobalManager.Renderer is Office2007Renderer)
+ {
+ Office2007MenuColorTable mt = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.Menu;
+ if (mt != null && !mt.SideBorder.IsEmpty)
+ {
+ if (pa.RightToLeft)
+ DisplayHelp.DrawGradientLine(g, sideRect.X + 1, sideRect.Y, sideRect.X + 1, sideRect.Bottom - 1, mt.SideBorder, 1);
+ else
+ DisplayHelp.DrawGradientLine(g, sideRect.Right - 2, sideRect.Y, sideRect.Right - 2, sideRect.Bottom - 1, mt.SideBorder, 1);
+ }
+ if (mt != null && !mt.SideBorderLight.IsEmpty)
+ {
+ if (pa.RightToLeft)
+ DisplayHelp.DrawGradientLine(g, sideRect.X, sideRect.Y, sideRect.X, sideRect.Bottom - 1, mt.SideBorder, 1);
+ else
+ DisplayHelp.DrawGradientLine(g, sideRect.Right - 1, sideRect.Y, sideRect.Right - 1, sideRect.Bottom - 1, mt.SideBorderLight, 1);
+ }
+ }
+ }
+
+ if(this.IsOnCustomizeMenu)
+ {
+ if (this.EffectiveStyle == eDotNetBarStyle.OfficeXP || this.EffectiveStyle == eDotNetBarStyle.Office2003 || EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(EffectiveStyle))
+ {
+ r.X+=(objImageSize.Height+8);
+ r.Width-=(objImageSize.Height+8);
+ }
+ else
+ {
+ r.X+=(objImageSize.Height+4);
+ r.Width-=(objImageSize.Height+4);
+ }
+ }
+
+ if (bOnMenu && (this.EffectiveStyle == eDotNetBarStyle.OfficeXP || this.EffectiveStyle == eDotNetBarStyle.Office2003 || EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(EffectiveStyle)))
+ {
+ if(m_MouseOver)
+ {
+ Rectangle rHover=this.DisplayRectangle;
+ rHover.Inflate(-1,0);
+ if (BarFunctions.IsOffice2007Style(EffectiveStyle) && !(pa.Owner is DotNetBarManager) && GlobalManager.Renderer is Office2007Renderer)
+ {
+ Office2007ButtonItemStateColorTable bt = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.ButtonItemColors[0].MouseOver;
+ Office2007ButtonItemPainter.PaintBackground(g, bt, rHover, RoundRectangleShapeDescriptor.RoundCorner3);
+ }
+ else
+ {
+ if (!pa.Colors.ItemHotBackground2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(rHover, pa.Colors.ItemHotBackground, pa.Colors.ItemHotBackground2, pa.Colors.ItemHotBackgroundGradientAngle);
+ g.FillRectangle(gradient, rHover);
+ gradient.Dispose();
+ }
+ else
+ g.FillRectangle(new SolidBrush(pa.Colors.ItemHotBackground), rHover);
+ NativeFunctions.DrawRectangle(g, new Pen(pa.Colors.ItemHotBorder), rHover);
+ }
+ }
+ }
+
+ // Draw text if needed
+ if (Caption != "" && (m_AlwaysShowCaption || bOnMenu))
+ {
+ eTextFormat objStringFormat=GetStringFormat();
+ Font objFont=this.GetFont();
+ Rectangle rText=new Rectangle(r.X+8,r.Y,r.Width,r.Height);
+
+ if (pa.GlassEnabled && this.Parent is CaptionItemContainer && !(this.ContainerControl is Ribbon.QatToolbar))
+ {
+ if (!pa.CachedPaint)
+ Office2007RibbonControlPainter.PaintTextOnGlass(g, Caption, objFont,
+ rText, TextDrawing.GetTextFormat(objStringFormat), textColor, true, true, 7);
+ }
+ else
+ {
+ TextDrawing.DrawString(g, Caption, objFont, textColor, rText, objStringFormat);
+ }
+
+ Size textSize = TextDrawing.MeasureString(g, Caption, objFont, 0, objStringFormat);
+ r.X+=(int)textSize.Width+8;
+ r.Width-=((int)textSize.Width+8);
+ }
+
+ if(m_ComboBox==null || this.IsOnCustomizeMenu || this.IsOnCustomizeDialog || this.DesignMode)
+ {
+ r.Inflate(-3,-2);
+ g.FillRectangle(SystemBrushes.Window,r);
+ NativeFunctions.DrawRectangle(g,SystemPens.ControlDark,r);
+ r.X=r.Right-(System.Windows.Forms.SystemInformation.HorizontalScrollBarThumbWidth-2);
+ r.Width=System.Windows.Forms.SystemInformation.HorizontalScrollBarThumbWidth-2;
+ System.Windows.Forms.ControlPaint.DrawComboButton(g,r,System.Windows.Forms.ButtonState.Flat);
+ }
+ else
+ {
+ int selLength = m_ComboBox.SelectionLength;
+ r.Inflate(-2,-2);
+ if(m_ComboBox.Width!=r.Width)
+ m_ComboBox.Width=r.Width;
+ Point loc=r.Location;
+ loc.Offset((r.Width-m_ComboBox.Width)/2,(r.Height-m_ComboBox.Height)/2);
+
+ ScrollableControl scc = pa.ContainerControl as ScrollableControl;
+ if (scc != null && scc.AutoScroll)
+ loc.Offset(scc.AutoScrollPosition.X, scc.AutoScrollPosition.Y);
+ if (m_ComboBox.Location != loc)
+ m_ComboBox.Location = loc;
+
+ if (selLength > 0 && selLength < 1000 && m_ComboBox.SelectionLength != selLength && m_ComboBox.Text.Length > selLength && m_ComboBox.DropDownStyle == ComboBoxStyle.DropDown)
+ {
+ m_ComboBox.SelectionLength = selLength;
+ }
+ }
+
+ if(this.IsOnCustomizeMenu && this.Visible)
+ {
+ // Draw check box if this item is visible
+ Rectangle rBox=new Rectangle(m_Rect.Left,m_Rect.Top,m_Rect.Height,m_Rect.Height);
+ if (EffectiveStyle == eDotNetBarStyle.OfficeXP || EffectiveStyle == eDotNetBarStyle.Office2003 || EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(EffectiveStyle))
+ rBox.Inflate(-1,-1);
+ BarFunctions.DrawMenuCheckBox(pa, rBox, EffectiveStyle, m_MouseOver);
+ }
+ }
+ else
+ {
+ string Caption=this.Text;
+ if(Caption=="")
+ Caption="...";
+ else
+ Caption+=" ";
+
+ if (EffectiveStyle == eDotNetBarStyle.OfficeXP || EffectiveStyle == eDotNetBarStyle.Office2003 || EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(EffectiveStyle))
+ g.FillRectangle(new SolidBrush(ColorFunctions.ToolMenuFocusBackColor(g)),this.DisplayRectangle);
+ else
+ g.FillRectangle(SystemBrushes.Control,this.DisplayRectangle);
+
+ if(m_MouseOver && !this.DesignMode)
+ {
+ if (EffectiveStyle == eDotNetBarStyle.Office2000)
+ {
+ //r.Inflate(-1,-1);
+ System.Windows.Forms.ControlPaint.DrawBorder3D(g,r,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.All);
+ }
+ else if (EffectiveStyle == eDotNetBarStyle.OfficeXP || EffectiveStyle == eDotNetBarStyle.Office2003 || EffectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(EffectiveStyle))
+ {
+ r.Inflate(-1,-1);
+ g.FillRectangle(new SolidBrush(ColorFunctions.HoverBackColor(g)),r);
+ NativeFunctions.DrawRectangle(g,SystemPens.Highlight,r);
+ }
+ }
+
+ r=new Rectangle(m_Rect.Top,-m_Rect.Right,m_Rect.Height,m_Rect.Width);
+ g.RotateTransform(90);
+ eTextFormat sf=GetStringFormat();
+ sf |= eTextFormat.HorizontalCenter;
+ TextDrawing.DrawStringLegacy(g, Caption, GetFont(), textColor, r, sf);
+ g.ResetTransform();
+ }
+
+ if(this.Focused && this.DesignMode)
+ {
+ r=this.DisplayRectangle;
+ r.Inflate(-1,-1);
+ DesignTime.DrawDesignTimeSelection(g,r,pa.Colors.ItemDesignTimeBorder);
+ }
+
+ //if(this.DesignMode)
+ this.DrawInsertMarker(g);
+ }
+
+ ///
+ /// IBlock member implementation
+ ///
+ [Browsable(false), DevCoBrowsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
+ public override System.Drawing.Rectangle Bounds
+ {
+ get { return base.Bounds; }
+ set
+ {
+ if (base.Bounds != value)
+ {
+ bool topLocationChanged = base.Bounds.Top != value.Top;
+ bool leftLocationChanged = base.Bounds.Left != value.Left;
+ base.Bounds = value;
+ if ((topLocationChanged || leftLocationChanged) && (this.ContainerControl is ItemPanel || this.ContainerControl is ExplorerBar))
+ UpdateControlLocation();
+ }
+ }
+ }
+
+ private void UpdateControlLocation()
+ {
+ if (m_ComboBox == null) return;
+ Rectangle r = this.DisplayRectangle;
+ r.Inflate(-2, -2);
+ m_ComboBox.Location = r.Location;
+ }
+
+ public override void RecalcSize()
+ {
+ if (this.SuspendLayout)
+ return;
+
+ bool bOnMenu = this.IsOnMenu;
+
+ if (this.Orientation == eOrientation.Horizontal)
+ {
+ // Default Height
+ if (this.Parent != null && this.Parent is ImageItem)
+ m_Rect.Height = ((ImageItem)this.Parent).SubItemsImageSize.Height + Dpi.Height(4);
+ else
+ m_Rect.Height = this.SubItemsImageSize.Height + Dpi.Height(4);
+
+ eDotNetBarStyle effectiveStyle = EffectiveStyle;
+ if (effectiveStyle == eDotNetBarStyle.OfficeXP || effectiveStyle == eDotNetBarStyle.Office2003 || effectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(effectiveStyle))
+ {
+ if (m_ComboBox != null && m_Rect.Height < (m_ComboBox.Height + 2))
+ m_Rect.Height = m_ComboBox.Height + 2;
+ }
+ else
+ {
+ if (m_ComboBox != null && m_Rect.Height < (m_ComboBox.Height + 2))
+ m_Rect.Height = m_ComboBox.Height + 2;
+ }
+
+ // Default width
+ m_Rect.Width = Dpi.Width(m_ComboWidth + 4);
+
+ // Calculate Item Height
+ if (Caption != "" && (m_AlwaysShowCaption || bOnMenu))
+ {
+ System.Windows.Forms.Control objCtrl = this.ContainerControl as System.Windows.Forms.Control;
+ if (objCtrl != null && IsHandleValid(objCtrl))
+ {
+ Graphics g = BarFunctions.CreateGraphics(objCtrl);
+ try
+ {
+ Size textSize = Size.Empty;
+ if (m_Orientation == eOrientation.Vertical && !bOnMenu)
+ textSize = TextDrawing.MeasureStringLegacy(g, Caption, GetFont(), Size.Empty, GetStringFormat());
+ else
+ textSize = TextDrawing.MeasureString(g, Caption, GetFont(), 0, GetStringFormat());
+ if (textSize.Height > this.SubItemsImageSize.Height && textSize.Height > m_Rect.Height)
+ m_Rect.Height = (int)textSize.Height + 4;
+ m_Rect.Width = Dpi.Width(m_ComboWidth + 4) + (int)textSize.Width + 8;
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ }
+ }
+
+ Size objImageSize = GetMaxImageSize();
+ if (this.IsOnMenu && (effectiveStyle == eDotNetBarStyle.OfficeXP || effectiveStyle == eDotNetBarStyle.Office2003 || effectiveStyle == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(effectiveStyle)))
+ {
+ // THis is side bar that will need to be drawn for DotNet style
+ m_Rect.Width += (objImageSize.Width + 7);
+ }
+
+ if (this.IsOnCustomizeMenu)
+ m_Rect.Width += (objImageSize.Height + 2);
+ }
+ else
+ {
+ // Default width
+ m_Rect.Width = Dpi.Width(this.SubItemsImageSize.Width + 4);
+ string caption = this.Caption;
+ if (caption == "")
+ caption = "...";
+ else
+ caption += " ";
+ System.Windows.Forms.Control objCtrl = this.ContainerControl as System.Windows.Forms.Control;
+ if (objCtrl != null && IsHandleValid(objCtrl))
+ {
+ Graphics g = BarFunctions.CreateGraphics(objCtrl);
+ try
+ {
+ SizeF textSize = TextDrawing.MeasureString(g, caption, GetFont(), 0, GetStringFormat());
+ if (textSize.Height > this.SubItemsImageSize.Height)
+ m_Rect.Width = (int)textSize.Height + 4;
+ m_Rect.Height = (int)textSize.Width + 8;
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ }
+
+ }
+
+ // Always call base implementation to reset resize flag
+ base.RecalcSize();
+ }
+ protected internal override void OnContainerChanged(object objOldContainer)
+ {
+ base.OnContainerChanged(objOldContainer);
+ if(m_ComboBox!=null)
+ {
+ if(m_ComboBox.Parent!=null)
+ {
+ //bool bVisible=false;
+ if(m_ComboBox.Visible)
+ {
+ m_ComboBox.Visible=false;
+ //bVisible=true;
+ }
+ System.Windows.Forms.Control parent=m_ComboBox.Parent;
+ parent.Controls.Remove(m_ComboBox);
+ //if(bVisible)
+ //m_ComboBox.Visible=true;
+ }
+
+ System.Windows.Forms.Control objCtrl=null;
+ if(this.ContainerControl!=null)
+ {
+ objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(objCtrl!=null)
+ {
+ objCtrl.Controls.Add(m_ComboBox);
+ OnDisplayedChanged();
+ m_ComboBox.Refresh();
+ }
+ }
+ }
+ }
+ protected internal override void OnAfterItemRemoved(BaseItem item, int itemIndex)
+ {
+ base.OnAfterItemRemoved(item, itemIndex);
+ this.ContainerControl=null;
+ }
+ protected internal override void OnVisibleChanged(bool newValue)
+ {
+ if(m_ComboBox!=null && !newValue)
+ m_ComboBox.Visible=newValue;
+ base.OnVisibleChanged(newValue);
+ }
+ protected override void OnDisplayedChanged()
+ {
+ if(m_ComboBox!=null && !(this.IsOnCustomizeMenu || this.IsOnCustomizeDialog || this.DesignMode))
+ {
+ m_ComboBox.Visible=this.Displayed;
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnGotFocus()
+ {
+ base.OnGotFocus();
+ if(m_ComboBox==null)
+ return;
+ if(m_ComboBox.Focused || this.IsOnCustomizeMenu || this.IsOnCustomizeDialog || this.DesignMode)
+ return;
+ m_ComboBox.Focus();
+ }
+
+ private void ComboLostFocus(object sender, EventArgs e)
+ {
+ this.HideToolTip();
+ this.Text=m_ComboBox.Text;
+ this.ReleaseFocus();
+ if(!m_MouseOver)
+ return;
+ m_MouseOver=false;
+ this.Refresh();
+ }
+
+ private void ComboMouseHover(object sender, EventArgs e)
+ {
+ if(this.DesignMode)
+ return;
+ if(System.Windows.Forms.Control.MouseButtons==System.Windows.Forms.MouseButtons.None)
+ ShowToolTip();
+ }
+
+ private void ComboMouseEnter(object sender, EventArgs e)
+ {
+ if(!m_MouseOver)
+ {
+ m_MouseOver=true;
+ this.Refresh();
+ }
+ }
+
+ private void ComboMouseLeave(object sender, EventArgs e)
+ {
+ this.HideToolTip();
+ if(m_ComboBox.Focused)
+ return;
+ if(m_MouseOver)
+ {
+ m_MouseOver=false;
+ this.Refresh();
+ }
+ }
+ private void ComboBoxVisibleChanged(object sender, EventArgs e)
+ {
+ this.HideToolTip();
+ }
+
+ private void ComboGotFocus(object sender, EventArgs e)
+ {
+ this.HideToolTip();
+ this.Focus();
+
+ if (GetEnabled() && !this.DesignMode)
+ {
+ if(m_MenuVisibility==eMenuVisibility.VisibleIfRecentlyUsed && !m_RecentlyUsed && this.IsOnMenu)
+ {
+ // Propagate to the top
+ m_RecentlyUsed=true;
+ BaseItem objItem=this.Parent;
+ while(objItem!=null)
+ {
+ IPersonalizedMenuItem ipm=objItem as IPersonalizedMenuItem;
+ if(ipm!=null)
+ ipm.RecentlyUsed=true;
+ objItem=objItem.Parent;
+ }
+ }
+ }
+ }
+
+ private void ComboSelChanged(object sender, EventArgs e)
+ {
+ if (!_CopyInProgress)
+ {
+ this.RaiseClick();
+ if (SelectedIndexChanged != null)
+ SelectedIndexChanged(this, e);
+ if (ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "SelectedIndex");
+ ExecuteCommand();
+ }
+
+ }
+
+ private void ComboKeyDown(object sender,System.Windows.Forms.KeyEventArgs e)
+ {
+ this.HideToolTip();
+ if(e.KeyCode==System.Windows.Forms.Keys.Enter && this.Parent is PopupItem)
+ {
+ ((PopupItem)this.Parent).ClosePopup();
+ }
+ }
+ private void ComboDropDownChange(object sender,bool bExpanded)
+ {
+ this.Expanded=bExpanded;
+ if(!bExpanded)
+ this.ReleaseFocus();
+ }
+ protected override void OnIsOnCustomizeDialogChanged()
+ {
+ base.OnIsOnCustomizeDialogChanged();
+ CustomizeChanged();
+ }
+
+ protected override void OnDesignModeChanged()
+ {
+ base.OnDesignModeChanged();
+ CustomizeChanged();
+ }
+
+ protected override void OnIsOnCustomizeMenuChanged()
+ {
+ base.OnIsOnCustomizeMenuChanged();
+ CustomizeChanged();
+ }
+
+ private void CustomizeChanged()
+ {
+ if(this.IsOnCustomizeMenu || this.IsOnCustomizeDialog || this.DesignMode)
+ {
+ m_ComboBox.Visible=false;
+ }
+ else
+ {
+ m_ComboBox.Visible=this.Displayed;
+ }
+ }
+
+ ///
+ /// Gets or sets the width of the of the drop-down portion of a combo box.
+ ///
+ [Category("Layout"), Browsable(true), Description("Indicates width of the of the drop-down portion of a combo box.")]
+ public int DropDownWidth
+ {
+ get { return m_ComboBox.DropDownWidth; }
+ set { m_ComboBox.DropDownWidth = value; }
+ }
+
+ ///
+ /// Returns whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeDropDownWidth()
+ {
+ return m_ComboBox.Width != m_ComboBox.DropDownWidth;
+ }
+
+ ///
+ /// Gets or sets the height of the of the drop-down portion of a combo box.
+ ///
+ [Category("Layout"), Browsable(true), DefaultValue(0), Description("Indicates height of the of the drop-down portion of a combo box.")]
+ public int DropDownHeight
+ {
+ get { return m_ComboBox.DropDownHeight; }
+ set { m_ComboBox.DropDownHeight = value; }
+ }
+
+ ///
+ /// Indicates the Width of the combo box part of the item.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Layout"),System.ComponentModel.Description("Indicates the Width of the combo box part of the item."),System.ComponentModel.DefaultValue(64)]
+ public int ComboWidth
+ {
+ get
+ {
+ return m_ComboWidth;
+ }
+ set
+ {
+ if(m_ComboWidth!=value)
+ {
+ m_ComboWidth=value;
+ if(this.Name!="" && this.GlobalItem)
+ {
+ BarFunctions.SetProperty(this.GetOwner(),this.GetType(),m_Name,System.ComponentModel.TypeDescriptor.GetProperties(this)["ComboWidth"],m_ComboWidth);
+ }
+ NeedRecalcSize=true;
+ this.Refresh();
+ }
+ OnAppearanceChanged();
+ }
+ }
+
+ ///
+ /// Overridden. Releases the input focus.
+ ///
+ public override void ReleaseFocus()
+ {
+ if(m_ComboBox!=null && m_ComboBox.Focused)
+ m_ComboBox.ReleaseFocus();
+ base.ReleaseFocus();
+ }
+
+ ///
+ /// Indicates whether control automatically releases its input focus when selection is made using keyboard.
+ ///
+ [DefaultValue(true), Browsable(true), Category("Behavior"), Description("Indicates whether control automatically releases its input focus when selection is made using keyboard.")]
+ public bool AutoReleaseFocus
+ {
+ get
+ {
+ return m_ComboBox.AutoReleaseFocus;
+ }
+ set
+ {
+ m_ComboBox.AutoReleaseFocus = value;
+ }
+ }
+
+ ///
+ /// Returns the reference to the inner combo box control.
+ ///
+ [Browsable(false)]
+ public ComboBoxEx ComboBoxEx
+ {
+ get
+ {
+ return m_ComboBox;
+ }
+ }
+
+// [System.ComponentModel.Browsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("The caption of the item.")]
+// public string Caption
+// {
+// get
+// {
+// return m_Caption;
+// }
+// set
+// {
+// if(m_Caption!=value)
+// {
+// m_Caption=value;
+// if(this.Name!="" && this.GlobalItem)
+// {
+// BarFunctions.SetProperty(this.GetOwner(),this.GetType(),m_Name,System.ComponentModel.TypeDescriptor.GetProperties(this)["Caption"],m_Caption);
+// }
+// m_NeedRecalcSize=true;
+// this.Refresh();
+// }
+// }
+// }
+
+ ///
+ /// Indicates whether item caption is always shown.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates whether item caption is always shown."), System.ComponentModel.DefaultValue(false)]
+ public bool AlwaysShowCaption
+ {
+ get
+ {
+ return m_AlwaysShowCaption;
+ }
+ set
+ {
+ if(m_AlwaysShowCaption!=value)
+ {
+ m_AlwaysShowCaption=value;
+ }
+ NeedRecalcSize=true;
+ }
+ }
+ private Size GetMaxImageSize()
+ {
+ if(m_Parent!=null)
+ {
+ ImageItem objParentImageItem=m_Parent as ImageItem;
+ if(objParentImageItem!=null)
+ return objParentImageItem.SubItemsImageSize;
+ else
+ return this.ImageSize;
+ }
+ else
+ return this.ImageSize;
+ }
+ private eTextFormat GetStringFormat()
+ {
+ eTextFormat format = eTextFormat.Default;
+ format |= eTextFormat.SingleLine;
+ format |= eTextFormat.EndEllipsis;
+ format |= eTextFormat.VerticalCenter;
+ return format;
+ //sfmt.HotkeyPrefix=System.Drawing.Text.HotkeyPrefix.Show;
+ //sfmt.FormatFlags=sfmt.FormatFlags | StringFormatFlags.NoWrap;
+ //sfmt.Trimming=StringTrimming.EllipsisCharacter;
+ //sfmt.Alignment=System.Drawing.StringAlignment.Near;
+ //sfmt.LineAlignment=System.Drawing.StringAlignment.Center;
+
+ //return sfmt;
+ }
+ protected virtual Font GetFont()
+ {
+ System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(objCtrl!=null)
+ return (Font)objCtrl.Font;
+ return SystemFonts.DefaultFont;
+ }
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseEnter()
+ {
+ base.InternalMouseEnter();
+ //if(this.DesignMode || this.IsOnCustomizeMenu || this.IsOnCustomizeDialog || this.Orientation==eOrientation.Vertical)
+ if(!m_MouseOver)
+ {
+ m_MouseOver=true;
+ this.Refresh();
+ }
+ }
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseLeave()
+ {
+ base.InternalMouseLeave();
+ if(m_MouseOver)
+ {
+ m_MouseOver=false;
+ this.Refresh();
+ }
+ }
+ protected internal override bool IsAnyOnHandle(IntPtr iHandle)
+ {
+ bool bRet=base.IsAnyOnHandle(iHandle);
+ if(!bRet && m_ComboBox!=null && m_ComboBox.DroppedDown && m_ComboBox.DropDownHandle!=IntPtr.Zero && m_ComboBox.DropDownHandle==iHandle)
+ bRet=true;
+ return bRet;
+ }
+ protected override void OnStyleChanged()
+ {
+ base.OnStyleChanged();
+ m_ComboBox.Style=this.Style;
+ }
+
+ ///
+ /// Gets an object representing the collection of the items contained in inner ComboBoxEx.
+ ///
+ [System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ComboItemsEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.Category("Data"), DevCoBrowsable(true), Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public System.Windows.Forms.ComboBox.ObjectCollection Items
+ {
+ get
+ {
+ return m_ComboBox.Items;
+
+ }
+ }
+
+ ///
+ /// Gets or sets a value specifying the style of the combo box.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),DefaultValue(System.Windows.Forms.ComboBoxStyle.DropDownList),System.ComponentModel.Description("Gets or sets a value specifying the style of the combo box.")]
+ public System.Windows.Forms.ComboBoxStyle DropDownStyle
+ {
+ get
+ {
+ return m_ComboBox.DropDownStyle;
+ }
+ set
+ {
+ m_ComboBox.DropDownStyle=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the starting index of text selected in the combo box.
+ ///
+ [Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden),System.ComponentModel.DefaultValue(0)]
+ public int SelectionStart
+ {
+ get
+ {
+ return m_ComboBox.SelectionStart;
+ }
+ set
+ {
+ m_ComboBox.SelectionStart=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the number of characters selected in the editable portion of the combo box.
+ ///
+ [Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden),System.ComponentModel.DefaultValue(0)]
+ public int SelectionLength
+ {
+ get
+ {
+ return m_ComboBox.SelectionLength;
+ }
+ set
+ {
+ m_ComboBox.SelectionLength=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the text that is selected in the editable portion of a combo box.
+ ///
+ [Browsable(false),System.ComponentModel.DefaultValue(""),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public string SelectedText
+ {
+ get
+ {
+ return m_ComboBox.SelectedText;
+ }
+ set
+ {
+ m_ComboBox.SelectedText=value;
+ }
+ }
+
+ ///
+ /// Gets or sets currently selected item in the combo box.
+ ///
+ [Browsable(false),System.ComponentModel.DefaultValue(null),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public object SelectedItem
+ {
+ get
+ {
+ return m_ComboBox.SelectedItem;
+ }
+ set
+ {
+ m_ComboBox.SelectedItem=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the index specifying the currently selected item.
+ ///
+ [Browsable(false),System.ComponentModel.DefaultValue(-1),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public int SelectedIndex
+ {
+ get
+ {
+ return m_ComboBox.SelectedIndex;
+ }
+ set
+ {
+ m_ComboBox.SelectedIndex=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the value indicating whether the item automatically loads all the fonts available into the combo box.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Automatically loads all the fonts available into the combo box."),System.ComponentModel.DefaultValue(false)]
+ public bool FontCombo
+ {
+ get
+ {
+ return m_FontCombo;
+ }
+ set
+ {
+ if(m_FontCombo!=value)
+ {
+ m_FontCombo=value;
+ if(m_FontCombo)
+ {
+ m_ComboBox.LoadFonts();
+ m_ComboBox.DropDownStyle=System.Windows.Forms.ComboBoxStyle.DropDownList;
+ //m_ComboBox.DrawMode=System.Windows.Forms.DrawMode.OwnerDrawVariable;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the height of an item in the combo box.
+ ///
+ [DefaultValue(15), System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Indicates the height of an item in the combo box.")]
+ public int ItemHeight
+ {
+ get
+ {
+ return m_ComboBox.ItemHeight;
+ }
+ set
+ {
+ m_ComboBox.ItemHeight=value;
+ }
+ }
+
+ // IPersonalizedMenuItem Implementation
+ ///
+ /// Indicates item's visibility when on pop-up menu.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates item's visiblity when on pop-up menu."),System.ComponentModel.DefaultValue(eMenuVisibility.VisibleAlways)]
+ public eMenuVisibility MenuVisibility
+ {
+ get
+ {
+ return m_MenuVisibility;
+ }
+ set
+ {
+ if(m_MenuVisibility!=value)
+ {
+ m_MenuVisibility=value;
+ if(m_Name!="" && this.GlobalItem)
+ {
+ BarFunctions.SetProperty(this.GetOwner(),this.GetType(),m_Name,System.ComponentModel.TypeDescriptor.GetProperties(this)["MenuVisibility"],m_MenuVisibility);
+ }
+ }
+ }
+ }
+ ///
+ /// Gets or sets the value that indicates whether the item was recently used.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DefaultValue(false)]
+ public bool RecentlyUsed
+ {
+ get
+ {
+ return m_RecentlyUsed;
+ }
+ set
+ {
+ if(m_RecentlyUsed!=value)
+ {
+ m_RecentlyUsed=value;
+ if(m_Name!="" && this.GlobalItem)
+ {
+ BarFunctions.SetProperty(this.GetOwner(),this.GetType(),m_Name,System.ComponentModel.TypeDescriptor.GetProperties(this)["RecentlyUsed"],m_RecentlyUsed);
+ }
+ }
+ }
+ }
+
+ protected override void OnEnabledChanged()
+ {
+ base.OnEnabledChanged();
+ if(m_ComboBox!=null)
+ m_ComboBox.Enabled=this.Enabled;
+ }
+
+ private void InternalComboTextChanged(object sender, EventArgs e)
+ {
+ if(!_SettingText)
+ this.Text = m_ComboBox.Text;
+ OnComboBoxTextChanged(e);
+ }
+
+ ///
+ /// Raises the ComboBoxTextChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnComboBoxTextChanged(EventArgs e)
+ {
+ if (ComboBoxTextChanged != null)
+ ComboBoxTextChanged(this, e);
+ }
+
+ ///
+ /// Overridden. Gets or sets the text associated with this item.
+ ///
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false), Obsolete("Please use Text property instead to access ComboBox text.")]
+ public virtual string ControlText
+ {
+ get
+ {
+ return this.Text;
+ }
+ set
+ {
+ this.Text = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the text associated with this item.
+ ///
+ [Browsable(true), Category("Appearance"), Description("The text contained in the underlining Control portion of the item."), DefaultValue("")]
+ public override string Text
+ {
+ get
+ {
+ return base.Text;
+ }
+ set
+ {
+ base.Text = value;
+ }
+ }
+ private bool _SettingText = false;
+ protected override void OnTextChanged()
+ {
+ if (m_ComboBox != null && m_ComboBox.Text != this.Text)
+ {
+ try
+ {
+ _SettingText = true;
+ m_ComboBox.Text = this.Text;
+ }
+ finally
+ {
+ _SettingText = false;
+ }
+ }
+ base.OnTextChanged();
+ }
+
+ private string _Caption = "";
+ ///
+ /// Gets or sets the item caption text displayed next to the combo box.
+ ///
+ [DefaultValue(""), System.ComponentModel.Category("Appearance"), Description("Indicates the item Caption displayed next to the combo box."), Localizable(true)]
+ public string Caption
+ {
+ get { return _Caption; }
+ set
+ {
+ if (value == null) value = "";
+ _Caption = value;
+ }
+ }
+
+ ///
+ /// Gets or sets a string that specifies the property of the data source whose contents you want to display. When ComboBoxItem is used in DropDown mode
+ /// and objects like ComboItem are added to ComboBoxItems.Items collection DisplayMembers should be set to the name of the property you would
+ /// like to use as text representation in editable portion of ComboBox. For example in case of ComboItem objects property should be set to Text.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Data"), System.ComponentModel.Description("Indicates string that specifies the property of the data source whose contents you want to display."), System.ComponentModel.DefaultValue("")]
+ public virtual string DisplayMember
+ {
+ get
+ {
+ if(m_ComboBox!=null)
+ return m_ComboBox.DisplayMember;
+ return "";
+ }
+ set
+ {
+ if (m_ComboBox != null)
+ m_ComboBox.DisplayMember = value;
+ }
+ }
+
+ ///
+ /// Specifies whether combo box is drawn using themes when running on OS that supports themes like Windows XP
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Specifies whether combo box is drawn using themes when running on OS that supports themes like Windows XP.")]
+ public override bool ThemeAware
+ {
+ get
+ {
+ return m_ComboBox.ThemeAware;
+ }
+ set
+ {
+ m_ComboBox.ThemeAware=value;
+ }
+ }
+
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override bool IsWindowed
+ {
+ get {return true;}
+ }
+
+ ///
+ /// Gets or sets the watermark font.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates watermark font."), DefaultValue(null)]
+ public Font WatermarkFont
+ {
+ get { return m_ComboBox.WatermarkFont; }
+ set { m_ComboBox.WatermarkFont = value; }
+ }
+
+ ///
+ /// Gets or sets the watermark text color.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates watermark text color.")]
+ public Color WatermarkColor
+ {
+ get { return m_ComboBox.WatermarkColor; }
+ set { m_ComboBox.WatermarkColor = value; }
+ }
+ ///
+ /// Indicates whether property should be serialized by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeWatermarkColor()
+ {
+ return m_ComboBox.WatermarkColor != SystemColors.GrayText;
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetWatermarkColor()
+ {
+ this.WatermarkColor = SystemColors.GrayText;
+ }
+
+ ///
+ /// Gets or sets whether watermark text is displayed when control is empty. Default value is true.
+ ///
+ [DefaultValue(true), Description("Indicates whether watermark text is displayed when control is empty.")]
+ public virtual bool WatermarkEnabled
+ {
+ get { return m_ComboBox.WatermarkEnabled; }
+ set { m_ComboBox.WatermarkEnabled = value; }
+ }
+
+ ///
+ /// Gets or sets the watermark (tip) text displayed inside of the control when Text is not set and control does not have input focus. This property supports text-markup.
+ /// Note that WatermarkText is not compatible with the auto-complete feature of .NET Framework 2.0.
+ ///
+ [Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance"), Description("Indicates watermark text displayed inside of the control when Text is not set and control does not have input focus."), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ public string WatermarkText
+ {
+ get { return m_ComboBox.WatermarkText; }
+ set
+ {
+ m_ComboBox.WatermarkText = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the watermark hiding behaviour. Default value indicates that watermark is hidden when control receives input focus.
+ ///
+ [DefaultValue(eWatermarkBehavior.HideOnFocus), Category("Behavior"), Description("Indicates watermark hiding behaviour.")]
+ public eWatermarkBehavior WatermarkBehavior
+ {
+ get { return m_ComboBox.WatermarkBehavior; }
+ set { m_ComboBox.WatermarkBehavior = value; }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), RefreshProperties(RefreshProperties.All), ParenthesizePropertyName(true)]
+ public ControlBindingsCollection DataBindings
+ {
+ get { return m_ComboBox.DataBindings; }
+ }
+
+ ///
+ /// Gets or sets whether control is stand-alone control. Stand-alone flag affects the appearance of the control in Office 2007 style.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance"), Description("Indicates the appearance of the control.")]
+ public bool IsStandalone
+ {
+ get { return m_ComboBox.IsStandalone; }
+ set
+ {
+ m_ComboBox.IsStandalone = value;
+ }
+ }
+
+ public override string ToString()
+ {
+ return m_Text;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ComboItem.cs b/PROMS/DotNetBar Source Code/ComboItem.cs
new file mode 100644
index 00000000..a05145da
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ComboItem.cs
@@ -0,0 +1,354 @@
+using System;
+using System.Windows.Forms;
+using System.Drawing.Drawing2D;
+using System.Drawing;
+using System.ComponentModel;
+using DevComponents.DotNetBar.Controls;
+using DevComponents.DotNetBar;
+
+namespace DevComponents.Editors
+{
+ ///
+ /// Summary description for ComboItem.
+ ///
+ [System.ComponentModel.ToolboxItem(false),System.ComponentModel.DesignTimeVisible(false)]
+ public class ComboItem:Component
+ {
+ private string m_Text="";
+ private int m_ImageIndex=-1;
+ private Image m_Image;
+ private StringFormat m_TextFormat;
+ private HorizontalAlignment m_ImagePosition=HorizontalAlignment.Left;
+
+ private string m_FontName="";
+ private FontStyle m_FontStyle=FontStyle.Regular;
+ private float m_FontSize=8;
+
+ private Color m_ForeColor=Color.Empty;
+ private Color m_BackColor=Color.Empty;
+
+ private object m_Tag;
+
+ internal ComboBoxEx m_ComboBox=null;
+ internal bool IsFontItem=false;
+
+ ///
+ /// Creates new instance of ComboItem.
+ ///
+ public ComboItem()
+ {
+ m_TextFormat=DevComponents.DotNetBar.BarFunctions.CreateStringFormat(); //new StringFormat(StringFormat.GenericDefault);
+ m_TextFormat.Alignment=StringAlignment.Near;
+ }
+
+ ///
+ /// Initializes a new instance of the ComboItem class.
+ ///
+ ///
+ public ComboItem(string text) : this()
+ {
+ this.m_Text = text;
+ }
+
+ ///
+ /// Initializes a new instance of the ComboItem class.
+ ///
+ ///
+ ///
+ public ComboItem(string text, Color foreColor) : this()
+ {
+ this.m_Text = text;
+ this.m_ForeColor = foreColor;
+ }
+
+ ///
+ /// Initializes a new instance of the ComboItem class.
+ ///
+ ///
+ ///
+ ///
+ public ComboItem(string text, Color foreColor, Color backColor)
+ : this()
+ {
+ this.m_Text = text;
+ this.m_ForeColor = foreColor;
+ this.m_BackColor = backColor;
+ }
+
+ ///
+ /// Initializes a new instance of the ComboItem class.
+ ///
+ ///
+ ///
+ public ComboItem(string text, Image image)
+ : this()
+ {
+ this.m_Text = text;
+ this.m_Image = image;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (BarUtilities.DisposeItemImages && !this.DesignMode)
+ {
+ BarUtilities.DisposeImage(ref m_Image);
+ }
+ base.Dispose(disposing);
+ }
+
+ ///
+ /// Gets or sets the text associated with this item.
+ ///
+ [DefaultValue(""),Browsable(true), Localizable(true)]
+ public string Text
+ {
+ get
+ {
+ return m_Text;
+ }
+ set
+ {
+ m_Text=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the index value of the image assigned to the item.
+ ///
+ [DefaultValue(-1), System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), TypeConverter(typeof(System.Windows.Forms.ImageIndexConverter)), Localizable(true)]
+ public int ImageIndex
+ {
+ get
+ {
+ return m_ImageIndex;
+ }
+ set
+ {
+ m_ImageIndex=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the text alignment..
+ ///
+ [DefaultValue(StringAlignment.Near)]
+ public StringAlignment TextAlignment
+ {
+ get
+ {
+ return m_TextFormat.Alignment;
+ }
+ set
+ {
+ m_TextFormat.Alignment=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the line alignment for the item.
+ ///
+ [DefaultValue(StringAlignment.Near)]
+ public StringAlignment TextLineAlignment
+ {
+ get
+ {
+ return m_TextFormat.LineAlignment;
+ }
+ set
+ {
+ m_TextFormat.LineAlignment=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the value that encapsulates text layout information (such as alignment, orientation, tab stops, and clipping) and display manipulations.
+ ///
+ [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public StringFormat TextFormat
+ {
+ get
+ {
+ return m_TextFormat;
+ }
+ set
+ {
+ m_TextFormat=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the image horizontal image position.
+ ///
+ [DefaultValue(HorizontalAlignment.Left)]
+ public HorizontalAlignment ImagePosition
+ {
+ get
+ {
+ return m_ImagePosition;
+ }
+ set
+ {
+ m_ImagePosition=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the font name used to draw the item text.
+ ///
+ [DefaultValue("")]
+ public String FontName
+ {
+ get
+ {
+ return m_FontName;
+ }
+ set
+ {
+ m_FontName=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the text color.
+ ///
+ public Color ForeColor
+ {
+ get
+ {
+ return m_ForeColor;
+ }
+ set
+ {
+ m_ForeColor=value;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeForeColor()
+ {
+ return !m_ForeColor.IsEmpty;
+ }
+
+ ///
+ /// Gets or sets the background color of the item.
+ ///
+ public Color BackColor
+ {
+ get
+ {
+ return m_BackColor;
+ }
+ set
+ {
+ m_BackColor=value;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBackColor()
+ {
+ return !m_BackColor.IsEmpty;
+ }
+
+ ///
+ /// Specifies style information applied to text.
+ ///
+ [DefaultValue(FontStyle.Regular)]
+ public System.Drawing.FontStyle FontStyle
+ {
+ get
+ {
+ return m_FontStyle;
+ }
+ set
+ {
+ m_FontStyle=value;
+ }
+ }
+
+ ///
+ /// Gets the em-size of this Font object in design units.
+ ///
+ [DefaultValue(8f)]
+ public float FontSize
+ {
+ get
+ {
+ return m_FontSize;
+ }
+ set
+ {
+ m_FontSize=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the image assigned to this item.
+ ///
+ [DefaultValue(null), Localizable(true)]
+ public System.Drawing.Image Image
+ {
+ get
+ {
+ return m_Image;
+ }
+ set
+ {
+ m_Image=value;
+ }
+ }
+
+ ///
+ /// Overridden. Returns a human-readable string representation of this object.
+ ///
+ /// A string that represents this object.
+ public override string ToString()
+ {
+ return m_Text;
+ }
+
+ ///
+ /// Gets or sets an object that contains data to associate with the item.
+ ///
+ [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public object Tag
+ {
+ get
+ {
+ return m_Tag;
+ }
+ set
+ {
+ m_Tag=value;
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public System.Windows.Forms.ImageList ImageList
+ {
+ get
+ {
+ if(m_ComboBox!=null)
+ {
+ return m_ComboBox.Images;
+ }
+ return null;
+ }
+ }
+ [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
+ public ComboBoxEx Parent
+ {
+ get
+ {
+ return m_ComboBox;
+ }
+ }
+
+ private object _Value = null;
+ [DefaultValue(null), Category("Data"), TypeConverter(typeof(StringConverter)), Localizable(true)]
+ public object Value
+ {
+ get { return _Value; }
+ set { _Value = value; }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Command.ico b/PROMS/DotNetBar Source Code/Command.ico
new file mode 100644
index 00000000..236756d7
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Command.ico differ
diff --git a/PROMS/DotNetBar Source Code/CommandLink.cs b/PROMS/DotNetBar Source Code/CommandLink.cs
new file mode 100644
index 00000000..25b62cf3
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandLink.cs
@@ -0,0 +1,144 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the base class that provides link between DotNetBar BaseItem commands and typed code representation for them.
+ ///
+ [ToolboxItem(false), DesignTimeVisible(false), DefaultEvent("Click")]
+ public class CommandLink : Component
+ {
+ #region Private Variables
+ private string m_Name = "";
+ private DotNetBarManager m_Manager = null;
+ private static string CommandPrefix = "cmd";
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs when item connected to the command link is clicked.
+ ///
+ public event EventHandler Click;
+ #endregion
+
+ ///
+ /// Returns name of the item that can be used to identify item from the code. You should not set this property directly since it is populated by DotNetBar designer.
+ ///
+ [Browsable(false), Category("Design"), Description("Indicates the name used to identify item command link is connected to.")]
+ public string Name
+ {
+ get
+ {
+ if (this.Site != null)
+ m_Name = this.Site.Name;
+ return m_Name;
+ }
+ set
+ {
+ if (this.Site != null)
+ this.Site.Name = value;
+ if (value == null)
+ m_Name = "";
+ else
+ m_Name = value;
+ }
+ }
+
+ protected virtual BaseItem GetItem(Type expectedItemType)
+ {
+ if (this.Manager == null)
+ throw new InvalidOperationException("Manager property is not assigned to the instance of DotNetBarManager this CommandLink is linking to.");
+
+ string itemName = GetItemName(this.Name);
+ if (itemName == "")
+ {
+ throw new InvalidOperationException("Command link name is not in expected format. Could not retrive item.");
+ }
+
+ BaseItem item = this.Manager.GetItem(itemName, true);
+
+ if (item == null)
+ throw new InvalidOperationException("Item '" + itemName + "' cannot be found. DotNetBarManager definition might not be loaded. Try moving your code to Load event.");
+
+ if (item.GetType() != expectedItemType)
+ throw new InvalidOperationException("This CommandLink type can only by connected to " + expectedItemType.Name + " type. Currently link is connecting to " + item.GetType().ToString());
+
+ return item;
+ }
+
+ ///
+ /// Disconnects the CommandLink object to the DotNetBarManager.
+ ///
+ protected virtual void DisconnectManager()
+ {
+ if (m_Manager == null)
+ return;
+ m_Manager.ItemClick -= new EventHandler(ItemClick);
+ m_Manager.CommandLinks.Remove(this);
+ }
+
+ ///
+ /// Connects the CommandLink object to the DotNetBarManager.
+ ///
+ protected virtual void ConnectManager()
+ {
+ if (m_Manager == null)
+ return;
+ m_Manager.ItemClick += new EventHandler(ItemClick);
+ m_Manager.CommandLinks.Add(this);
+ }
+
+ private void ItemClick(object sender, EventArgs e)
+ {
+ if(sender is BaseItem)
+ {
+ BaseItem item = sender as BaseItem;
+ if(item.Name == GetItemName(this.Name))
+ {
+ if (Click != null)
+ Click(sender, e);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the instance of DotNetBarManager associated with the command link.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public DotNetBarManager Manager
+ {
+ get { return m_Manager; }
+ set
+ {
+ if (m_Manager != null)
+ DisconnectManager();
+ m_Manager = value;
+
+ if (m_Manager != null)
+ ConnectManager();
+ }
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ this.Manager = null;
+ base.Dispose(disposing);
+ }
+
+ internal static string GetCommandLinkName(string itemName)
+ {
+ return CommandPrefix + itemName;
+ }
+
+ internal static string GetItemName(string commandLinkName)
+ {
+ if (commandLinkName.StartsWith(CommandPrefix))
+ return commandLinkName.Substring(CommandPrefix.Length);
+
+ return "";
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CommandLinkButtonItem.cs b/PROMS/DotNetBar Source Code/CommandLinkButtonItem.cs
new file mode 100644
index 00000000..8eeb0456
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandLinkButtonItem.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the typed command link for ButtonItem type.
+ ///
+ public class CommandLinkButtonItem : CommandLink
+ {
+ ///
+ /// Gets reference to the ButtonItem this CommandLink is linked to. Note that this is the first ButtonItem object found by DotNetBarManager.
+ /// It is possible that multiple buttons have same name see Global Items under DotNetBar Fundamentals in help file for more details.
+ ///
+ [Browsable(false)]
+ public ButtonItem Item
+ {
+ get
+ {
+ return this.GetItem(typeof(ButtonItem)) as ButtonItem;
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CommandLinkColorPickerDropDown.cs b/PROMS/DotNetBar Source Code/CommandLinkColorPickerDropDown.cs
new file mode 100644
index 00000000..3598430e
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandLinkColorPickerDropDown.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the typed command link for ColorPickerDropDown type.
+ ///
+ public class CommandLinkColorPickerDropDown : CommandLink
+ {
+ #region Events
+ ///
+ /// Occurs when color is choosen from drop-down color picker or from Custom Colors dialog box. Selected color can be accessed through SelectedColor property.
+ ///
+ [Description("Occurs when color is choosen from drop-down color picker or from Custom Colors dialog box.")]
+ public event EventHandler SelectedColorChanged;
+ #endregion
+
+ ///
+ /// Gets reference to the ColorPickerDropDown this CommandLink is linked to. Note that this is the first ColorPickerDropDown object found by DotNetBarManager.
+ /// It is possible that multiple buttons have same name see Global Items under DotNetBar Fundamentals in help file for more details.
+ ///
+ [Browsable(false)]
+ public ColorPickerDropDown Item
+ {
+ get
+ {
+ return this.GetItem(typeof(ColorPickerDropDown)) as ColorPickerDropDown;
+ }
+ }
+
+ protected override void ConnectManager()
+ {
+ base.ConnectManager();
+ if(this.Manager!=null)
+ this.Manager.ColorPickerSelectedColorChanged += new EventHandler(ManagerColorPickerSelectedColorChanged);
+ }
+
+ private void ManagerColorPickerSelectedColorChanged(object sender, EventArgs e)
+ {
+ if (SelectedColorChanged != null)
+ SelectedColorChanged(sender, e);
+ }
+
+ protected override void DisconnectManager()
+ {
+ base.DisconnectManager();
+ if(this.Manager!=null)
+ this.Manager.ColorPickerSelectedColorChanged -= new EventHandler(ManagerColorPickerSelectedColorChanged);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CommandLinkComboBoxItem.cs b/PROMS/DotNetBar Source Code/CommandLinkComboBoxItem.cs
new file mode 100644
index 00000000..9c6d9491
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandLinkComboBoxItem.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the command link for a combo box item
+ ///
+ public class CommandLinkComboBoxItem : CommandLink
+ {
+ ///
+ /// Gets reference to the ComboBoxItem this CommandLink is linked to. Note that this is the first ComboBoxItem object found by DotNetBarManager.
+ /// It is possible that multiple buttons have same name see Global Items under DotNetBar Fundamentals in help file for more details.
+ ///
+ [Browsable(false)]
+ public ComboBoxItem Item
+ {
+ get
+ {
+ return this.GetItem(typeof(ComboBoxItem)) as ComboBoxItem;
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CommandLinkControlContainerItem.cs b/PROMS/DotNetBar Source Code/CommandLinkControlContainerItem.cs
new file mode 100644
index 00000000..0807ec6d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandLinkControlContainerItem.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the typed command link for ControlContainerItem type.
+ ///
+ public class CommandLinkControlContainerItem : CommandLink
+ {
+ ///
+ /// Gets reference to the ControlContainerItem this CommandLink is linked to. Note that this is the first ControlContainerItem object found by DotNetBarManager.
+ /// It is possible that multiple buttons have same name see Global Items under DotNetBar Fundamentals in help file for more details.
+ ///
+ [Browsable(false)]
+ public ControlContainerItem Item
+ {
+ get
+ {
+ return this.GetItem(typeof(ControlContainerItem)) as ControlContainerItem;
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CommandLinkDockContainerItem.cs b/PROMS/DotNetBar Source Code/CommandLinkDockContainerItem.cs
new file mode 100644
index 00000000..326e8210
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandLinkDockContainerItem.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the typed command link for DockContainerItem type.
+ ///
+ public class CommandLinkDockContainerItem : CommandLink
+ {
+ ///
+ /// Gets reference to the ControlContainerItem this CommandLink is linked to. Note that this is the first ControlContainerItem object found by DotNetBarManager.
+ /// It is possible that multiple buttons have same name see Global Items under DotNetBar Fundamentals in help file for more details.
+ ///
+ [Browsable(false)]
+ public DockContainerItem Item
+ {
+ get
+ {
+ return this.GetItem(typeof(DockContainerItem)) as DockContainerItem;
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CommandLinkLabelItem.cs b/PROMS/DotNetBar Source Code/CommandLinkLabelItem.cs
new file mode 100644
index 00000000..a09e3fde
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandLinkLabelItem.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the command link for a label item
+ ///
+ public class CommandLinkLabelItem : CommandLink
+ {
+ ///
+ /// Gets reference to the LabelItem this CommandLink is linked to. Note that this is the first LabelItem object found by DotNetBarManager.
+ /// It is possible that multiple buttons have same name see Global Items under DotNetBar Fundamentals in help file for more details.
+ ///
+ [Browsable(false)]
+ public LabelItem Item
+ {
+ get
+ {
+ return this.GetItem(typeof(LabelItem)) as LabelItem;
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CommandLinkProgressBarItem.cs b/PROMS/DotNetBar Source Code/CommandLinkProgressBarItem.cs
new file mode 100644
index 00000000..f280b2c2
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandLinkProgressBarItem.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the typed command link for ProgressBarItem type.
+ ///
+ public class CommandLinkProgressBarItem : CommandLink
+ {
+ ///
+ /// Gets reference to the ControlContainerItem this CommandLink is linked to. Note that this is the first ControlContainerItem object found by DotNetBarManager.
+ /// It is possible that multiple buttons have same name see Global Items under DotNetBar Fundamentals in help file for more details.
+ ///
+ [Browsable(false)]
+ public ProgressBarItem Item
+ {
+ get
+ {
+ return this.GetItem(typeof(ProgressBarItem)) as ProgressBarItem;
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CommandLinkTextBoxItem.cs b/PROMS/DotNetBar Source Code/CommandLinkTextBoxItem.cs
new file mode 100644
index 00000000..8b14f9e6
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandLinkTextBoxItem.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the command link for a text box item
+ ///
+ public class CommandLinkTextBoxItem : CommandLink
+ {
+ #region Events
+ ///
+ /// Occurs when text in text box item has changed.
+ ///
+ public event EventHandler InputTextChanged;
+ #endregion
+
+ ///
+ /// Gets reference to the TextBoxItem this CommandLink is linked to. Note that this is the first TextBoxItem object found by DotNetBarManager.
+ /// It is possible that multiple buttons have same name see Global Items under DotNetBar Fundamentals in help file for more details.
+ ///
+ [Browsable(false)]
+ public TextBoxItem Item
+ {
+ get
+ {
+ return this.GetItem(typeof(TextBoxItem)) as TextBoxItem;
+ }
+ }
+
+ protected override void ConnectManager()
+ {
+ base.ConnectManager();
+
+ if (this.Manager != null)
+ {
+ this.Manager.TextBoxItemTextChanged += new EventHandler(this.ItemInputTextChanged);
+ }
+ }
+
+ protected override void DisconnectManager()
+ {
+ base.DisconnectManager();
+ if(this.Manager!=null)
+ this.Manager.TextBoxItemTextChanged -= new EventHandler(this.ItemInputTextChanged);
+ }
+
+ private void ItemInputTextChanged(object sender, EventArgs e)
+ {
+ if (InputTextChanged != null)
+ InputTextChanged(sender, e);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CommandManager.cs b/PROMS/DotNetBar Source Code/CommandManager.cs
new file mode 100644
index 00000000..2c244bfb
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CommandManager.cs
@@ -0,0 +1,148 @@
+using System;
+using System.Text;
+using System.Collections;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Provides command related utility methods that register and unregister commands.
+ ///
+ public class CommandManager
+ {
+ private static Hashtable _CommandBindings = new Hashtable();
+ private static bool _UseReflection = true;
+
+ ///
+ /// Gets or sets whether commands use Reflection to find the property names when applying value to the unknown types. Default value is true.
+ /// Setting this value to false will increase performance if Unknown types are used but it will at same time disable the
+ /// command setting value for these types.
+ ///
+ public static bool UseReflection
+ {
+ get
+ {
+ return _UseReflection;
+ }
+ set
+ {
+ _UseReflection = value;
+ }
+ }
+
+ private static bool _AutoUpdateLayout = true;
+ ///
+ /// Gets or sets whether layout on the items of type BaseItem is automatically updated when command text or other property changes which requires layout updated. Default value is true.
+ ///
+ public static bool AutoUpdateLayout
+ {
+ get { return _AutoUpdateLayout; }
+ set
+ {
+ if (_AutoUpdateLayout != value)
+ {
+ _AutoUpdateLayout = value;
+ }
+ }
+ }
+
+ ///
+ /// Connects the Command Source to the Command.
+ ///
+ /// Command source to connect to the command.
+ /// Reference to the command.
+ public static void RegisterCommand(ICommandSource commandSource, ICommand command)
+ {
+ if (commandSource == null)
+ throw new NullReferenceException("commandSource cannot be null");
+ if (command == null)
+ throw new NullReferenceException("command cannot be null");
+
+ ArrayList subscribers = null;
+ if (_CommandBindings.Contains(command))
+ {
+ subscribers = (ArrayList)_CommandBindings[command];
+ if (!subscribers.Contains(commandSource))
+ subscribers.Add(commandSource);
+ }
+ else
+ {
+ subscribers = new ArrayList();
+ subscribers.Add(commandSource);
+ _CommandBindings.Add(command, subscribers);
+ }
+ command.CommandSourceRegistered(commandSource);
+ }
+
+ ///
+ /// Disconnects command source from the command.
+ ///
+ /// Reference to command source.
+ /// Reference to the command.
+ public static void UnRegisterCommandSource(ICommandSource commandSource, ICommand command)
+ {
+ if (commandSource == null)
+ throw new NullReferenceException("commandSource cannot be null");
+ if (command == null)
+ throw new NullReferenceException("command cannot be null");
+ if (_CommandBindings.Contains(command))
+ {
+ ArrayList subscribers = (ArrayList)_CommandBindings[command];
+ if (subscribers.Contains(commandSource))
+ subscribers.Remove(commandSource);
+ }
+ command.CommandSourceUnregistered(commandSource);
+ }
+
+ ///
+ /// Unregister command from all subscribers. Called when command is disposed.
+ ///
+ /// Command to unregister.
+ public static void UnRegisterCommand(ICommand command)
+ {
+ if (command == null)
+ throw new NullReferenceException("command cannot be null");
+
+ if (_CommandBindings.Contains(command))
+ _CommandBindings.Remove(command);
+ }
+
+ ///
+ /// Gets an array of Command Sources that are connected with the command.
+ ///
+ /// Reference to command
+ /// An array of command sources.
+ public static ArrayList GetSubscribers(ICommand command)
+ {
+ if (command == null)
+ throw new NullReferenceException("command cannot be null");
+ ArrayList subscribers = null;
+ if (_CommandBindings.Contains(command))
+ subscribers = (ArrayList)((ArrayList)_CommandBindings[command]).Clone();
+ else
+ subscribers = new ArrayList();
+
+ return subscribers;
+ }
+
+ internal static void ExecuteCommand(ICommandSource commandSource)
+ {
+ if (commandSource == null)
+ throw new NullReferenceException("commandSource cannot be null");
+ ICommand command=commandSource.Command;
+ if(command == null)
+ throw new NullReferenceException("commandSource.Command cannot be null");
+
+ command.Execute(commandSource);
+ }
+
+ internal static void ExecuteCommand(ICommandSource commandSource, ICommand command)
+ {
+ if (commandSource == null)
+ throw new NullReferenceException("commandSource cannot be null");
+ if (command == null)
+ throw new NullReferenceException("commandSource.Command cannot be null");
+
+ command.Execute(commandSource);
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/CompositeImage.cs b/PROMS/DotNetBar Source Code/CompositeImage.cs
new file mode 100644
index 00000000..12969cdc
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/CompositeImage.cs
@@ -0,0 +1,262 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Serves as integration of regular Image class and Icon class
+ ///
+ internal class CompositeImage : IDisposable
+ {
+ private bool m_DisposeImage = false;
+
+ private Image m_Image = null;
+ private Icon m_Icon = null;
+ private Size m_ImageSizeOverride = Size.Empty;
+ private ImageList m_ImageList = null;
+ private int m_ImageIndex = -1;
+
+ public CompositeImage(int imageIndex, ImageList imageList)
+ {
+ m_ImageIndex = imageIndex;
+ m_ImageList = imageList;
+ }
+
+ public CompositeImage(Image image, bool dispose)
+ {
+ m_Image = image;
+ m_DisposeImage = dispose;
+ }
+ public CompositeImage(Icon icon, bool dispose)
+ {
+ m_Icon = icon;
+ m_DisposeImage = dispose;
+ }
+ public CompositeImage(Image image, bool dispose, Size overrideSize)
+ {
+ m_Image = image;
+ m_DisposeImage = dispose;
+ m_ImageSizeOverride = overrideSize;
+ }
+ public CompositeImage(Icon icon, bool dispose, Size overrideSize)
+ {
+ m_Icon = icon;
+ m_DisposeImage = dispose;
+ m_ImageSizeOverride = overrideSize;
+ }
+ ~CompositeImage() // destructor
+ {
+ if (m_DisposeImage && (m_Image != null || m_Icon != null))
+ {
+ Dispose();
+ }
+ }
+
+ public void Dispose()
+ {
+ if (m_DisposeImage)
+ {
+ if (m_Image != null)
+ m_Image.Dispose();
+ if (m_Icon != null)
+ m_Icon.Dispose();
+ }
+
+ m_Image = null;
+ m_Icon = null;
+ }
+
+ public void DrawImage(Graphics g, Rectangle rect)
+ {
+ if (m_Image != null)
+ g.DrawImage(m_Image, rect);
+ else if (m_Icon != null)
+ DrawIcon(g, rect);
+ else if (m_ImageIndex >= 0 && m_ImageList != null && m_ImageIndex < m_ImageList.Images.Count)
+ m_ImageList.Draw(g, rect.X, rect.Y, rect.Width, rect.Height, m_ImageIndex);
+ }
+
+ private void DrawIcon(Graphics g, Rectangle rect)
+ {
+ if (System.Environment.Version.Build <= 3705 && System.Environment.Version.Revision == 288 && System.Environment.Version.Major == 1 && System.Environment.Version.Minor == 0)
+ {
+ if (g.ClipBounds.IntersectsWith(rect) && rect.Width > 0 && rect.Height > 0 && m_Icon.Handle != IntPtr.Zero)
+ {
+ IntPtr hdc = g.GetHdc();
+ try
+ {
+ NativeFunctions.DrawIconEx(hdc, rect.X, rect.Y, m_Icon.Handle, rect.Width, rect.Height, 0, IntPtr.Zero, 3);
+ }
+ finally
+ {
+ g.ReleaseHdc(hdc);
+ }
+ }
+ }
+ else if (rect.Width > 0 && rect.Height > 0 && m_Icon.Handle != IntPtr.Zero)
+ {
+ try
+ {
+ g.DrawIcon(m_Icon, rect);
+ }
+ catch { }
+ }
+ }
+
+ public void DrawImage(Graphics g, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttrs)
+ {
+ if (m_Image != null)
+ {
+ g.DrawImage(m_Image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttrs);
+ }
+ else if (m_Icon != null)
+ {
+ // Attempt to solve issues with icon drawing...
+ //DrawIcon(g,destRect);
+ Bitmap bmp = new Bitmap(this.Width, this.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ bmp.MakeTransparent();
+ Graphics gBmp = Graphics.FromImage(bmp);
+ gBmp.DrawIcon(m_Icon, 0, 0);
+ gBmp.Dispose();
+ g.DrawImage(bmp, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttrs);
+ bmp.Dispose();
+ }
+ else if (m_ImageIndex >= 0 && m_ImageList != null && m_ImageIndex < m_ImageList.Images.Count)
+ m_ImageList.Draw(g, srcX, srcY, srcWidth, srcHeight, m_ImageIndex);
+ }
+
+ public bool IsIcon
+ {
+ get { return (m_Icon != null); }
+ }
+
+ public int Width
+ {
+ get
+ {
+ if (!m_ImageSizeOverride.IsEmpty)
+ return GetSize(m_ImageSizeOverride.Width);
+ if (m_Image != null)
+ return GetSize(m_Image.Width);
+ if (m_Icon != null)
+ return GetSize(m_Icon.Width);
+ if (m_ImageIndex >= 0 && m_ImageList != null)
+ return GetSize(m_ImageList.ImageSize.Width);
+ return 0;
+ }
+ }
+
+ public int Height
+ {
+ get
+ {
+ if (!m_ImageSizeOverride.IsEmpty)
+ return GetSize(m_ImageSizeOverride.Height);
+ if (m_Image != null)
+ return GetSize(m_Image.Height);
+ if (m_Icon != null)
+ return GetSize(m_Icon.Height);
+ if (m_ImageIndex >= 0 && m_ImageList != null)
+ return GetSize(m_ImageList.ImageSize.Height);
+ return 0;
+ }
+ }
+
+ private int GetSize(int height)
+ {
+ return (Dpi.AutoScaleImages ? Dpi.Height(height) : height);
+ }
+ private Size GetSize(Size size)
+ {
+ return (Dpi.AutoScaleImages ? Dpi.Size(size) : size);
+ }
+
+ public System.Drawing.Size Size
+ {
+ get
+ {
+ if (!m_ImageSizeOverride.IsEmpty)
+ return GetSize(m_ImageSizeOverride);
+ if (m_Image != null)
+ return GetSize(m_Image.Size);
+ if (m_Icon != null)
+ return GetSize(m_Icon.Size);
+ if (m_ImageIndex >= 0 && m_ImageList != null)
+ return GetSize(m_ImageList.ImageSize);
+ return System.Drawing.Size.Empty;
+ }
+ }
+
+ public System.Drawing.Image Image
+ {
+ get
+ {
+ if (m_ImageIndex >= 0 && m_ImageList != null)
+ return m_ImageList.Images[m_ImageIndex];
+ return m_Image;
+ }
+ }
+
+ public System.Drawing.Icon Icon
+ {
+ get { return m_Icon; }
+ }
+
+ internal int RealHeight
+ {
+ get
+ {
+ if (m_Image != null)
+ return GetSize(m_Image.Height);
+ if (m_Icon != null)
+ return GetSize(m_Icon.Height);
+ if (m_ImageIndex >= 0 && m_ImageList != null)
+ return GetSize(m_ImageList.ImageSize.Height);
+ return 0;
+ }
+ }
+
+ internal int RealWidth
+ {
+ get
+ {
+ if (m_Image != null)
+ return GetSize(m_Image.Width);
+ if (m_Icon != null)
+ return GetSize(m_Icon.Width);
+ if (m_ImageIndex >= 0 && m_ImageList != null)
+ return GetSize(m_ImageList.ImageSize.Width);
+ return 0;
+ }
+ }
+
+ internal int ActualHeight
+ {
+ get
+ {
+ if (m_Image != null)
+ return m_Image.Height;
+ if (m_Icon != null)
+ return m_Icon.Height;
+ if (m_ImageIndex >= 0 && m_ImageList != null)
+ return m_ImageList.ImageSize.Height;
+ return 0;
+ }
+ }
+
+ internal int ActualWidth
+ {
+ get
+ {
+ if (m_Image != null)
+ return (m_Image.Width);
+ if (m_Icon != null)
+ return (m_Icon.Width);
+ if (m_ImageIndex >= 0 && m_ImageList != null)
+ return (m_ImageList.ImageSize.Width);
+ return 0;
+ }
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ContainerKeyboardNavigation.cs b/PROMS/DotNetBar Source Code/ContainerKeyboardNavigation.cs
new file mode 100644
index 00000000..1f89a151
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContainerKeyboardNavigation.cs
@@ -0,0 +1,206 @@
+using System;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar
+{
+ internal class ContainerKeyboardNavigation
+ {
+ internal static void ProcessKeyDown(BaseItem container, System.Windows.Forms.KeyEventArgs objArg)
+ {
+ if (container.SubItems.Count == 0 || objArg.Handled)
+ return;
+
+ BaseItem objExpanded = container.ExpandedItem();
+
+ if (objExpanded != null)
+ {
+ objExpanded.InternalKeyDown(objArg);
+ if (objArg.Handled)
+ return;
+ }
+
+ eOrientation containerOrientation = container.Orientation;
+ if (container is ItemContainer)
+ containerOrientation = ((ItemContainer)container).LayoutOrientation;
+
+ if (containerOrientation == eOrientation.Horizontal && (objArg.KeyCode == Keys.Left || objArg.KeyCode == Keys.Right || container.HotSubItem == null && (objArg.KeyCode == Keys.Down || objArg.KeyCode == Keys.Up)) ||
+ (containerOrientation == eOrientation.Vertical && (objArg.KeyCode == Keys.Up || objArg.KeyCode == Keys.Down || container.HotSubItem == null && (objArg.KeyCode == Keys.Right || objArg.KeyCode == Keys.Left))))
+ {
+ // Select next object
+ if (container.HotSubItem != null)
+ {
+ container.HotSubItem.InternalMouseLeave();
+ if (container.AutoExpand && container.HotSubItem.Expanded)
+ {
+ container.HotSubItem.Expanded = false;
+ }
+ }
+ if (objArg.KeyCode == System.Windows.Forms.Keys.Left || objArg.KeyCode == Keys.Up)
+ {
+ int iIndex = 0;
+ if (container.HotSubItem != null)
+ iIndex = container.SubItems.IndexOf(container.HotSubItem) - 1;
+ if (iIndex < 0)
+ iIndex = container.SubItems.Count - 1;
+ BaseItem objNew = null;
+ bool bRepeat = false;
+ do
+ {
+ for (int i = iIndex; i >= 0; i--)
+ {
+ objNew = container.SubItems[i];
+ if (CanFocus(objNew))
+ {
+ iIndex = i;
+ break;
+ }
+ }
+ if (!CanFocus(container.SubItems[iIndex]))
+ {
+ if (!bRepeat)
+ {
+ iIndex = container.SubItems.Count - 1;
+ bRepeat = true;
+ }
+ else
+ bRepeat = false;
+ }
+ else
+ bRepeat = false;
+ } while (bRepeat);
+ container.HotSubItem = container.SubItems[iIndex];
+ }
+ else
+ {
+ int iIndex = 0;
+ if (container.HotSubItem != null)
+ iIndex = container.SubItems.IndexOf(container.HotSubItem) + 1;
+
+ while (iIndex < container.SubItems.Count && !CanFocus(container.SubItems[iIndex]))
+ iIndex++;
+ if (iIndex >= container.SubItems.Count)
+ iIndex = 0;
+ BaseItem objNew = null;
+ for (int i = iIndex; i < container.SubItems.Count; i++)
+ {
+ objNew = container.SubItems[i];
+ if (CanFocus(objNew))
+ {
+ iIndex = i;
+ break;
+ }
+ }
+ container.HotSubItem = container.SubItems[iIndex];
+ }
+
+ if (container.HotSubItem != null)
+ {
+ if (container.HotSubItem is ItemContainer)
+ {
+ ((ItemContainer)container.HotSubItem).SelectFirstItem();
+ }
+ else
+ {
+ container.HotSubItem.InternalMouseEnter();
+ container.HotSubItem.InternalMouseMove(new MouseEventArgs(MouseButtons.None, 0, container.HotSubItem.LeftInternal + 1, container.HotSubItem.TopInternal + 1, 0));
+ IScrollableItemControl isc = container.ContainerControl as IScrollableItemControl;
+ if (isc != null)
+ isc.KeyboardItemSelected(container.HotSubItem);
+ }
+ }
+
+ objArg.Handled = true;
+ }
+ else if (objArg.KeyCode == System.Windows.Forms.Keys.Escape)
+ {
+ if (objExpanded != null)
+ {
+ objExpanded.Expanded = false;
+ objArg.Handled = true;
+ }
+ else
+ {
+ Control cc = container.ContainerControl as Control;
+ if (cc is Bar)
+ {
+ Bar bar = cc as Bar;
+ if (bar.BarState == eBarState.Popup)
+ {
+ bar.ParentItem.Expanded = false;
+ }
+ else
+ {
+ if (container.AutoExpand)
+ container.AutoExpand = false;
+ else if (bar.Focused || bar.MenuFocus)
+ {
+ bar.MenuFocus = false;
+ bar.ReleaseFocus();
+ }
+ }
+ objArg.Handled = true;
+ }
+ else if (cc is ItemControl)
+ {
+ ItemControl ic = cc as ItemControl;
+ if (container.AutoExpand)
+ container.AutoExpand = false;
+ else if (ic.Focused || ic.MenuFocus)
+ {
+ ic.MenuFocus = false;
+ ic.ReleaseFocus();
+ }
+ }
+ }
+ }
+ else
+ {
+ BaseItem objItem = container.ExpandedItem();
+ if (objItem != null)
+ objItem.InternalKeyDown(objArg);
+ else
+ {
+ int key = 0;
+ if (objArg.Shift)
+ {
+ try
+ {
+ byte[] keyState = new byte[256];
+ if (NativeFunctions.GetKeyboardState(keyState))
+ {
+ byte[] chars = new byte[2];
+ if (NativeFunctions.ToAscii((uint)objArg.KeyValue, 0, keyState, chars, 0) != 0)
+ {
+ key = chars[0];
+ }
+ }
+ }
+ catch (Exception)
+ {
+ key = 0;
+ }
+ }
+
+ if (key == 0)
+ key = (int)NativeFunctions.MapVirtualKey((uint)objArg.KeyValue, 2);
+
+ if (container.HotSubItem != null)
+ container.HotSubItem.InternalKeyDown(objArg);
+ }
+ }
+ }
+
+ private static bool CanFocus(BaseItem objNew)
+ {
+ if (objNew == null) return false;
+ if (!objNew.Visible || !objNew.GetEnabled() || objNew is ListBoxItem && ((ListBoxItem)objNew).IsSelected)
+ return false;
+
+ if (objNew is LabelItem)
+ return false;
+
+ return true;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ContentManager/BlockLayoutManager.cs b/PROMS/DotNetBar Source Code/ContentManager/BlockLayoutManager.cs
new file mode 100644
index 00000000..c828e842
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContentManager/BlockLayoutManager.cs
@@ -0,0 +1,46 @@
+using System.Collections;
+using System.Drawing;
+
+#if AdvTree
+namespace DevComponents.Tree.TextMarkup
+#elif DOTNETBAR
+namespace DevComponents.UI.ContentManager
+#elif SUPERGRID
+namespace DevComponents.SuperGrid.TextMarkup
+#elif LAYOUT
+namespace DevComponents.DotNetBar.Layout.TextMarkup
+#endif
+{
+ ///
+ /// Represents block layout manager responsible for sizing the content blocks.
+ ///
+ public abstract class BlockLayoutManager
+ {
+ private Graphics m_Graphics;
+
+ ///
+ /// Resizes the content block and sets it's Bounds property to reflect new size.
+ ///
+ /// Content block to resize.
+ /// Content size available for the block in the given line.
+ public abstract void Layout(IBlock block, Size availableSize);
+
+ ///
+ /// Performs layout finalization
+ ///
+ ///
+ ///
+ ///
+ ///
+ public abstract Rectangle FinalizeLayout(Rectangle containerBounds, Rectangle blocksBounds, ArrayList lines);
+
+ ///
+ /// Gets or sets the graphics object used by layout manager.
+ ///
+ public System.Drawing.Graphics Graphics
+ {
+ get {return m_Graphics;}
+ set {m_Graphics=value;}
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ContentManager/Enums.cs b/PROMS/DotNetBar Source Code/ContentManager/Enums.cs
new file mode 100644
index 00000000..e61ff8a7
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContentManager/Enums.cs
@@ -0,0 +1,66 @@
+using System;
+
+#if AdvTree
+namespace DevComponents.Tree.TextMarkup
+#elif DOTNETBAR
+namespace DevComponents.UI.ContentManager
+#elif SUPERGRID
+namespace DevComponents.SuperGrid.TextMarkup
+#elif LAYOUT
+namespace DevComponents.DotNetBar.Layout.TextMarkup
+#endif
+
+{
+ ///
+ /// Specifies orientation of content.
+ ///
+ public enum eContentOrientation
+ {
+ ///
+ /// Indicates Horizontal orientation of the content.
+ ///
+ Horizontal,
+ ///
+ /// Indicates Vertical orientation of the content.
+ ///
+ Vertical
+ }
+
+ ///
+ /// Specifies content horizontal alignment.
+ ///
+ public enum eContentAlignment
+ {
+ ///
+ /// Content is left aligned.UI
+ ///
+ Left,
+ ///
+ /// Content is right aligned.
+ ///
+ Right,
+ ///
+ /// Content is centered.
+ ///
+ Center
+ }
+
+ ///
+ /// Specifies content vertical alignment.
+ ///
+ public enum eContentVerticalAlignment
+ {
+ ///
+ /// Content is top aligned.
+ ///
+ Top,
+ ///
+ /// Content is bottom aligned.
+ ///
+ Bottom,
+ ///
+ /// Content is in the middle.
+ ///
+ Middle
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ContentManager/IBlock.cs b/PROMS/DotNetBar Source Code/ContentManager/IBlock.cs
new file mode 100644
index 00000000..a321c68d
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContentManager/IBlock.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Drawing;
+using DevComponents.DotNetBar;
+
+#if AdvTree
+namespace DevComponents.Tree.TextMarkup
+#elif DOTNETBAR
+namespace DevComponents.UI.ContentManager
+#elif SUPERGRID
+namespace DevComponents.SuperGrid.TextMarkup
+#elif LAYOUT
+namespace DevComponents.DotNetBar.Layout.TextMarkup
+#endif
+
+{
+ ///
+ /// Represents a content block interface.
+ ///
+ public interface IBlock
+ {
+ ///
+ /// Gets or sets the bounds of the content block.
+ ///
+ Rectangle Bounds {get;set;}
+ ///
+ /// Gets or sets whether content block is visible.
+ ///
+ bool Visible {get;set;}
+ ///
+ /// Gets or sets the block margins.
+ ///
+ DevComponents.DotNetBar.Padding Margin { get;set;}
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ContentManager/IBlockExtended.cs b/PROMS/DotNetBar Source Code/ContentManager/IBlockExtended.cs
new file mode 100644
index 00000000..a263b22b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContentManager/IBlockExtended.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Text;
+
+#if AdvTree
+namespace DevComponents.Tree.TextMarkup
+#elif DOTNETBAR
+namespace DevComponents.UI.ContentManager
+#elif SUPERGRID
+namespace DevComponents.SuperGrid.TextMarkup
+#elif LAYOUT
+namespace DevComponents.DotNetBar.Layout.TextMarkup
+#endif
+
+{
+ ///
+ /// Represents a extended content block interface for advanced layout information.
+ ///
+ public interface IBlockExtended : IBlock
+ {
+ bool IsBlockElement { get;}
+ bool IsNewLineAfterElement { get;}
+ bool CanStartNewLine { get; }
+ ///
+ /// Returns whether element is an container so it receives full available size of parent control for layout.
+ ///
+ bool IsBlockContainer { get; }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ContentManager/IContentLayoutManager.cs b/PROMS/DotNetBar Source Code/ContentManager/IContentLayoutManager.cs
new file mode 100644
index 00000000..d9426e1b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContentManager/IContentLayoutManager.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Drawing;
+
+#if AdvTree
+namespace DevComponents.Tree.TextMarkup
+#elif DOTNETBAR
+namespace DevComponents.UI.ContentManager
+#elif SUPERGRID
+namespace DevComponents.SuperGrid.TextMarkup
+#elif LAYOUT
+namespace DevComponents.DotNetBar.Layout.TextMarkup
+#endif
+
+{
+ ///
+ /// Represents interface for block layout.
+ ///
+ public interface IContentLayout
+ {
+ ///
+ /// Performs layout of the content block.
+ ///
+ /// Container bounds to layout content blocks in.
+ /// Content blocks to layout.
+ /// Block layout manager that resizes the content blocks.
+ /// The bounds of the content blocks within the container bounds.
+ Rectangle Layout(Rectangle containerBounds, IBlock[] contentBlocks, BlockLayoutManager blockLayout);
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ContentManager/SerialContentLayoutManager.cs b/PROMS/DotNetBar Source Code/ContentManager/SerialContentLayoutManager.cs
new file mode 100644
index 00000000..31bb509f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContentManager/SerialContentLayoutManager.cs
@@ -0,0 +1,742 @@
+using System;
+using System.Collections;
+using System.Drawing;
+
+#if AdvTree
+namespace DevComponents.Tree.TextMarkup
+#elif DOTNETBAR
+namespace DevComponents.UI.ContentManager
+#elif SUPERGRID
+namespace DevComponents.SuperGrid.TextMarkup
+#elif LAYOUT
+namespace DevComponents.DotNetBar.Layout.TextMarkup
+#endif
+
+{
+ ///
+ /// Represents the serial content layout manager that arranges content blocks in series next to each other.
+ ///
+ public class SerialContentLayoutManager:IContentLayout
+ {
+ #region Events
+ ///
+ /// Occurs when X, Y position of next block is calcualted.
+ ///
+ public event LayoutManagerPositionEventHandler NextPosition;
+
+ ///
+ /// Occurs before new block is layed out.
+ ///
+ public event LayoutManagerLayoutEventHandler BeforeNewBlockLayout;
+ #endregion
+
+ #region Private Variables
+ private int m_BlockSpacing=0;
+ private bool m_FitContainerOversize=false;
+ private bool m_FitContainer = false;
+ private bool m_VerticalFitContainerWidth = false;
+ private bool m_HorizontalFitContainerHeight = false;
+ private eContentOrientation m_ContentOrientation=eContentOrientation.Horizontal;
+ private eContentAlignment m_ContentAlignment=eContentAlignment.Left;
+ private eContentVerticalAlignment m_ContentVerticalAlignment=eContentVerticalAlignment.Middle;
+ private eContentVerticalAlignment m_BlockLineAlignment = eContentVerticalAlignment.Middle;
+ private bool m_EvenHeight=false;
+ private bool m_MultiLine=false;
+ private bool m_RightToLeft = false;
+ private bool m_OversizeDistribute = false;
+ #endregion
+
+ ///
+ /// Creates new instance of the class.
+ ///
+ public SerialContentLayoutManager()
+ {
+ }
+
+ #region IContentLayout Members
+ ///
+ /// Performs layout of the content block.
+ ///
+ /// Container bounds to layout content blocks in.
+ /// Content blocks to layout.
+ /// Block layout manager that resizes the content blocks.
+ /// The bounds of the content blocks within the container bounds.
+ public virtual Rectangle Layout(Rectangle containerBounds, IBlock[] contentBlocks, BlockLayoutManager blockLayout)
+ {
+ Rectangle blocksBounds=Rectangle.Empty;
+ Point position=containerBounds.Location;
+ ArrayList lines=new ArrayList();
+ lines.Add(new BlockLineInfo());
+ BlockLineInfo currentLine=lines[0] as BlockLineInfo;
+ bool switchToNewLine = false;
+ bool canStartOnNewLine = true;
+ int visibleIndex = 0;
+ bool callLayout = true;
+
+ if (_EqualItemSize)
+ {
+ Size largestItemSize = Size.Empty;
+ foreach (IBlock block in contentBlocks)
+ {
+ if (!block.Visible)
+ {
+ block.Bounds = Rectangle.Empty;
+ continue;
+ }
+
+ if (BeforeNewBlockLayout != null)
+ {
+ LayoutManagerLayoutEventArgs e = new LayoutManagerLayoutEventArgs(block, position, visibleIndex);
+ BeforeNewBlockLayout(this, e);
+ position = e.CurrentPosition;
+ if (e.CancelLayout)
+ continue;
+ }
+ visibleIndex++;
+
+ Size availableSize = containerBounds.Size;
+ blockLayout.Layout(block, availableSize);
+ if (block.Bounds.Width > largestItemSize.Width)
+ largestItemSize.Width = block.Bounds.Width;
+ if (block.Bounds.Height > largestItemSize.Height)
+ largestItemSize.Height = block.Bounds.Height;
+ }
+
+ foreach (IBlock block in contentBlocks)
+ {
+ if (!block.Visible)
+ continue;
+ block.Bounds=new Rectangle(block.Bounds.Location, largestItemSize);
+
+ }
+ callLayout = false;
+ }
+
+ foreach(IBlock block in contentBlocks)
+ {
+ if(!block.Visible)
+ {
+ block.Bounds = Rectangle.Empty;
+ continue;
+ }
+
+ if (BeforeNewBlockLayout != null)
+ {
+ LayoutManagerLayoutEventArgs e = new LayoutManagerLayoutEventArgs(block, position, visibleIndex);
+ BeforeNewBlockLayout(this, e);
+ position = e.CurrentPosition;
+ if (e.CancelLayout)
+ continue;
+ }
+ visibleIndex++;
+
+ Size availableSize = containerBounds.Size;
+ bool isBlockElement = false;
+ bool isNewLineTriggger = false;
+ bool isContainer = false;
+ if (block is IBlockExtended)
+ {
+ IBlockExtended ex = block as IBlockExtended;
+ isBlockElement = ex.IsBlockElement;
+ isNewLineTriggger = ex.IsNewLineAfterElement;
+ canStartOnNewLine = ex.CanStartNewLine;
+ isContainer = ex.IsBlockContainer;
+ }
+ else
+ canStartOnNewLine = true;
+
+ if (!isBlockElement && !isContainer)
+ {
+ if (m_ContentOrientation == eContentOrientation.Horizontal)
+ availableSize.Width = (containerBounds.Right - position.X);
+ else
+ availableSize.Height = (containerBounds.Bottom - position.Y);
+ }
+
+ // Resize the content block
+ if(callLayout)
+ blockLayout.Layout(block, availableSize);
+
+ if(m_MultiLine && currentLine.Blocks.Count > 0)
+ {
+ if (m_ContentOrientation == eContentOrientation.Horizontal && (position.X + block.Bounds.Width > containerBounds.Right && canStartOnNewLine || isBlockElement || switchToNewLine))
+ {
+ position.X=containerBounds.X;
+ position.Y+=(currentLine.LineSize.Height+m_BlockSpacing);
+ currentLine=new BlockLineInfo();
+ currentLine.Line=lines.Count;
+ lines.Add(currentLine);
+ }
+ else if (m_ContentOrientation == eContentOrientation.Vertical && (position.Y + block.Bounds.Height > containerBounds.Bottom && canStartOnNewLine || isBlockElement || switchToNewLine))
+ {
+ position.Y=containerBounds.Y;
+ position.X+=(currentLine.LineSize.Width+m_BlockSpacing);
+ currentLine=new BlockLineInfo();
+ currentLine.Line=lines.Count;
+ lines.Add(currentLine);
+ }
+ }
+
+ if(m_ContentOrientation==eContentOrientation.Horizontal)
+ {
+ if(block.Bounds.Height>currentLine.LineSize.Height)
+ currentLine.LineSize.Height=block.Bounds.Height;
+ currentLine.LineSize.Width=position.X+block.Bounds.Width-containerBounds.X;
+ }
+ else if(m_ContentOrientation==eContentOrientation.Vertical)
+ {
+ if(block.Bounds.Width>currentLine.LineSize.Width)
+ currentLine.LineSize.Width=block.Bounds.Width;
+ currentLine.LineSize.Height=position.Y+block.Bounds.Height-containerBounds.Y;
+ }
+
+ currentLine.Blocks.Add(block);
+ if (block.Visible) currentLine.VisibleItemsCount++;
+ Rectangle r = new Rectangle(position, block.Bounds.Size);
+ r.X += block.Margin.Left;
+ r.Y += block.Margin.Top;
+ block.Bounds = r;
+
+ if (blocksBounds.IsEmpty)
+ {
+ r = block.Bounds; // Make sure that blocks bounds take in account any margin
+ r.X -= block.Margin.Left;
+ r.Y -= block.Margin.Top;
+ r.Width += block.Margin.Horizontal;
+ r.Height += block.Margin.Vertical;
+ blocksBounds = r;
+ }
+ else
+ blocksBounds = Rectangle.Union(blocksBounds, block.Bounds);
+
+ switchToNewLine = isBlockElement | isNewLineTriggger;
+
+ position = GetNextPosition(block, position, ref switchToNewLine);
+ }
+
+ blocksBounds=AlignResizeBlocks(containerBounds, blocksBounds, lines);
+
+ if (m_RightToLeft)
+ blocksBounds = MirrorContent(containerBounds, blocksBounds, contentBlocks);
+
+ blocksBounds = blockLayout.FinalizeLayout(containerBounds, blocksBounds, lines);
+
+ return blocksBounds;
+ }
+
+ #endregion
+
+ #region Internals
+ private struct SizeExtended
+ {
+ public int Width;
+ public int Height;
+ public float WidthReduction;
+ public float HeightReduction;
+ public bool UseAbsoluteWidth;
+ }
+
+ private Rectangle AlignResizeBlocks(Rectangle containerBounds,Rectangle blocksBounds,ArrayList lines)
+ {
+ Rectangle newBounds=Rectangle.Empty;
+ if(containerBounds.IsEmpty || blocksBounds.IsEmpty || ((BlockLineInfo)lines[0]).Blocks.Count==0)
+ return newBounds;
+
+ //Reverting to EventHeight property check so the buttons on RibbonBar are properly stretched so they consume same height.
+ // Be very careful when changing this code!
+ if (m_ContentAlignment == eContentAlignment.Left && m_ContentVerticalAlignment == eContentVerticalAlignment.Top &&
+ !m_FitContainer && !m_FitContainerOversize && !m_EvenHeight && m_BlockLineAlignment == eContentVerticalAlignment.Top &&
+ (!(m_ContentOrientation == eContentOrientation.Vertical && (m_VerticalFitContainerWidth || m_EvenHeight)) || m_MultiLine))
+ return blocksBounds;
+
+ Point[] offset=new Point[lines.Count];
+ SizeExtended[] sizeOffset = new SizeExtended[lines.Count];
+ foreach(BlockLineInfo lineInfo in lines)
+ {
+ if(m_ContentOrientation==eContentOrientation.Horizontal)
+ {
+ if(m_FitContainer && containerBounds.Width>lineInfo.LineSize.Width ||
+ m_FitContainerOversize && lineInfo.LineSize.Width>containerBounds.Width)
+ {
+ if (m_OversizeDistribute && containerBounds.Width < lineInfo.LineSize.Width * .75)
+ {
+ sizeOffset[lineInfo.Line].Width = (int)Math.Floor((float)(containerBounds.Width - lineInfo.VisibleItemsCount * m_BlockSpacing) / (float)lineInfo.VisibleItemsCount);
+ sizeOffset[lineInfo.Line].UseAbsoluteWidth = true;
+ }
+ else
+ sizeOffset[lineInfo.Line].Width = ((containerBounds.Width - lineInfo.VisibleItemsCount * m_BlockSpacing) - lineInfo.LineSize.Width) / lineInfo.VisibleItemsCount;
+ sizeOffset[lineInfo.Line].WidthReduction = (float)(containerBounds.Width - lineInfo.VisibleItemsCount * m_BlockSpacing) / (float)lineInfo.LineSize.Width;
+ blocksBounds.Width=containerBounds.Width;
+ }
+
+ if (m_HorizontalFitContainerHeight && containerBounds.Height > blocksBounds.Height && lines.Count == 1)
+ sizeOffset[lineInfo.Line].Height = (containerBounds.Height - lineInfo.LineSize.Height) / lines.Count;
+ }
+ else
+ {
+ if(m_FitContainer && containerBounds.Height>lineInfo.LineSize.Height ||
+ m_FitContainerOversize && lineInfo.LineSize.Height>containerBounds.Height)
+ {
+ if (m_OversizeDistribute && containerBounds.Width < lineInfo.LineSize.Width * .75)
+ {
+ sizeOffset[lineInfo.Line].Height = (int)Math.Floor((float)(containerBounds.Height - lineInfo.VisibleItemsCount * m_BlockSpacing) / (float)lineInfo.VisibleItemsCount);
+ sizeOffset[lineInfo.Line].UseAbsoluteWidth = true;
+ }
+ else
+ sizeOffset[lineInfo.Line].Height = ((containerBounds.Height - lineInfo.VisibleItemsCount * m_BlockSpacing) - lineInfo.LineSize.Height) / lineInfo.VisibleItemsCount;
+ sizeOffset[lineInfo.Line].HeightReduction = (float)(containerBounds.Height - lineInfo.VisibleItemsCount * m_BlockSpacing) / (float)lineInfo.LineSize.Height;
+ blocksBounds.Height=containerBounds.Height;
+ }
+
+ if (m_VerticalFitContainerWidth && containerBounds.Width > blocksBounds.Width && lines.Count==1)
+ sizeOffset[lineInfo.Line].Width = (containerBounds.Width - lineInfo.LineSize.Width) / lines.Count;
+ }
+
+
+ if(m_ContentOrientation==eContentOrientation.Horizontal && !m_FitContainer)
+ {
+ if(containerBounds.Width>blocksBounds.Width && m_FitContainerOversize || !m_FitContainerOversize)
+ {
+ switch(m_ContentAlignment)
+ {
+ case eContentAlignment.Right:
+ if (containerBounds.Width > lineInfo.LineSize.Width)
+ offset[lineInfo.Line].X = containerBounds.Width - lineInfo.LineSize.Width;
+ break;
+ case eContentAlignment.Center:
+ if (containerBounds.Width > lineInfo.LineSize.Width)
+ offset[lineInfo.Line].X = (containerBounds.Width - lineInfo.LineSize.Width) / 2;
+ break;
+ }
+ }
+ }
+
+ if(m_ContentOrientation==eContentOrientation.Vertical && !m_FitContainer)
+ {
+ if(containerBounds.Height>blocksBounds.Height && m_FitContainerOversize || !m_FitContainerOversize)
+ {
+ switch(m_ContentVerticalAlignment)
+ {
+ case eContentVerticalAlignment.Bottom:
+ if (containerBounds.Height > lineInfo.LineSize.Height)
+ offset[lineInfo.Line].Y = containerBounds.Height - lineInfo.LineSize.Height;
+ break;
+ case eContentVerticalAlignment.Middle:
+ if (containerBounds.Height > lineInfo.LineSize.Height)
+ offset[lineInfo.Line].Y = (containerBounds.Height - lineInfo.LineSize.Height) / 2;
+ break;
+ }
+ }
+ }
+ }
+
+ if (m_VerticalFitContainerWidth && containerBounds.Width > blocksBounds.Width && m_ContentOrientation==eContentOrientation.Vertical)
+ blocksBounds.Width = containerBounds.Width;
+ else if(m_HorizontalFitContainerHeight && containerBounds.Height>blocksBounds.Height && m_ContentOrientation==eContentOrientation.Horizontal)
+ blocksBounds.Height = containerBounds.Height;
+
+ if(m_ContentOrientation==eContentOrientation.Horizontal)
+ {
+ foreach(BlockLineInfo lineInfo in lines)
+ {
+ foreach(IBlock block in lineInfo.Blocks)
+ {
+ if(!block.Visible)
+ continue;
+ Rectangle r=block.Bounds;
+ if(m_EvenHeight && lineInfo.LineSize.Height>0)
+ r.Height=lineInfo.LineSize.Height;
+ r.Offset(offset[lineInfo.Line]);
+
+ if(m_ContentVerticalAlignment==eContentVerticalAlignment.Middle)
+ {
+ // Takes care of offset rounding error when both content is vertically centered and blocks in line are centered
+ if (m_BlockLineAlignment == eContentVerticalAlignment.Middle)
+ r.Offset(0,((containerBounds.Height-blocksBounds.Height)+(lineInfo.LineSize.Height-r.Height))/2);
+ else
+ r.Offset(0,(containerBounds.Height-blocksBounds.Height)/2);
+
+ // Line alignment of the block
+ if (m_BlockLineAlignment == eContentVerticalAlignment.Bottom)
+ r.Offset(0, lineInfo.LineSize.Height - r.Height);
+ }
+ else if(m_ContentVerticalAlignment==eContentVerticalAlignment.Bottom)
+ r.Offset(0,containerBounds.Height-blocksBounds.Height);
+
+ // To avoid rounding offset errors when dividing this is split see upper part
+ if(m_ContentVerticalAlignment!=eContentVerticalAlignment.Middle)
+ {
+ // Line alignment of the block
+ if (m_BlockLineAlignment == eContentVerticalAlignment.Middle)
+ r.Offset(0, (lineInfo.LineSize.Height - r.Height) / 2);
+ else if (m_BlockLineAlignment == eContentVerticalAlignment.Bottom)
+ r.Offset(0, lineInfo.LineSize.Height - r.Height);
+ }
+
+ if(sizeOffset[lineInfo.Line].Width!=0)
+ {
+ if (m_OversizeDistribute)
+ {
+ int nw = sizeOffset[lineInfo.Line].UseAbsoluteWidth ? sizeOffset[lineInfo.Line].Width : (int)Math.Floor(r.Width * sizeOffset[lineInfo.Line].WidthReduction);
+ offset[lineInfo.Line].X += nw - r.Width;
+ r.Width = nw;
+ }
+ else
+ {
+ r.Width += sizeOffset[lineInfo.Line].Width;
+ offset[lineInfo.Line].X += sizeOffset[lineInfo.Line].Width;
+ }
+ }
+ r.Height+=sizeOffset[lineInfo.Line].Height;
+ block.Bounds=r;
+ if(newBounds.IsEmpty)
+ newBounds=block.Bounds;
+ else
+ newBounds=Rectangle.Union(newBounds,block.Bounds);
+ }
+ // Adjust for left-over size adjustment for odd difference between container width and the total block width
+ if (!m_OversizeDistribute && sizeOffset[lineInfo.Line].Width != 0 && containerBounds.Width - (lineInfo.LineSize.Width + sizeOffset[lineInfo.Line].Width * lineInfo.Blocks.Count) != 0)
+ {
+ Rectangle r=((IBlock)lineInfo.Blocks[lineInfo.Blocks.Count-1]).Bounds;
+ r.Width+=containerBounds.Width-(lineInfo.LineSize.Width+sizeOffset[lineInfo.Line].Width*lineInfo.Blocks.Count);
+ ((IBlock)lineInfo.Blocks[lineInfo.Blocks.Count-1]).Bounds=r;
+ }
+ if (!m_FitContainer && m_ContentAlignment != eContentAlignment.Left && _ReserveLeftSpace)
+ {
+ // For block elements they should consume the space available to the left otherwise
+ // the parent is not aware that the space has been consumed
+ newBounds.Width += (newBounds.X - containerBounds.X);
+ newBounds.X = containerBounds.X;
+ }
+ }
+ }
+ else
+ {
+ foreach(BlockLineInfo lineInfo in lines)
+ {
+ foreach(IBlock block in lineInfo.Blocks)
+ {
+ if(!block.Visible)
+ continue;
+ Rectangle r=block.Bounds;
+ if(m_EvenHeight && lineInfo.LineSize.Width>0)
+ r.Width=lineInfo.LineSize.Width - block.Margin.Horizontal;
+ r.Offset(offset[lineInfo.Line]);
+ if(m_ContentAlignment==eContentAlignment.Center)
+ r.Offset(((containerBounds.Width-blocksBounds.Width)+(lineInfo.LineSize.Width-r.Width))/2,0); //r.Offset((containerBounds.Width-blocksBounds.Width)/2+(lineInfo.LineSize.Width-r.Width)/2,0);
+ else if(m_ContentAlignment==eContentAlignment.Right)
+ r.Offset((containerBounds.Width-blocksBounds.Width)+lineInfo.LineSize.Width-r.Width,0);
+ r.Width+=sizeOffset[lineInfo.Line].Width;
+ if(sizeOffset[lineInfo.Line].Height!=0)
+ {
+ if (m_OversizeDistribute)
+ {
+ int nw = sizeOffset[lineInfo.Line].UseAbsoluteWidth ? sizeOffset[lineInfo.Line].Height : (int)Math.Floor(r.Height * sizeOffset[lineInfo.Line].HeightReduction);
+ offset[lineInfo.Line].Y += nw - r.Height;
+ r.Height = nw;
+ }
+ else
+ {
+ r.Height += sizeOffset[lineInfo.Line].Height;
+ offset[lineInfo.Line].Y += sizeOffset[lineInfo.Line].Height;
+ }
+ }
+ block.Bounds=r;
+ if (newBounds.IsEmpty)
+ {
+ r.Y -= block.Margin.Top; // Account for any margin set on first element
+ r.X -= block.Margin.Left;
+ r.Width += block.Margin.Horizontal;
+ r.Height += block.Margin.Vertical;
+ newBounds = r;
+ }
+ else
+ newBounds = Rectangle.Union(newBounds, block.Bounds);
+ }
+ if (!m_OversizeDistribute && sizeOffset[lineInfo.Line].Height != 0 && containerBounds.Height - (lineInfo.LineSize.Height + sizeOffset[lineInfo.Line].Height * lineInfo.Blocks.Count) != 0)
+ {
+ Rectangle r=((IBlock)lineInfo.Blocks[lineInfo.Blocks.Count-1]).Bounds;
+ r.Height+=containerBounds.Height-(lineInfo.LineSize.Height+sizeOffset[lineInfo.Line].Height*lineInfo.Blocks.Count);
+ ((IBlock)lineInfo.Blocks[lineInfo.Blocks.Count-1]).Bounds=r;
+ }
+ }
+ }
+ return newBounds;
+ }
+
+ private Point GetNextPosition(IBlock block, Point position, ref bool switchToNewLine)
+ {
+ if (NextPosition != null)
+ {
+ LayoutManagerPositionEventArgs e = new LayoutManagerPositionEventArgs();
+
+ e.Block = block;
+ e.CurrentPosition = position;
+ e.SwitchToNewLine = switchToNewLine;
+
+ NextPosition(this, e);
+
+ switchToNewLine = e.SwitchToNewLine;
+
+ if (e.Cancel)
+ return e.NextPosition;
+ }
+
+ if (m_ContentOrientation == eContentOrientation.Horizontal)
+ position.X += block.Bounds.Width + m_BlockSpacing + block.Margin.Horizontal;
+ else
+ position.Y += block.Bounds.Height + m_BlockSpacing + block.Margin.Vertical;
+
+ return position;
+ }
+
+ internal class BlockLineInfo
+ {
+ public BlockLineInfo() {}
+ public ArrayList Blocks=new ArrayList();
+ public Size LineSize=Size.Empty;
+ public int Line=0;
+ public int VisibleItemsCount = 0;
+ }
+
+ private Rectangle MirrorContent(Rectangle containerBounds, Rectangle blockBounds, IBlock[] contentBlocks)
+ {
+ int xOffset = (blockBounds.X - containerBounds.X);
+
+ if (blockBounds.Width < containerBounds.Width)
+ blockBounds.X = containerBounds.Right - ((blockBounds.X - containerBounds.X) + blockBounds.Width);
+ else if (blockBounds.Width > containerBounds.Width)
+ containerBounds.Width = blockBounds.Width;
+ foreach (IBlock block in contentBlocks)
+ {
+ if (!block.Visible)
+ continue;
+ Rectangle r = block.Bounds;
+ block.Bounds = new Rectangle(containerBounds.Right - ((r.X - containerBounds.X) + r.Width), r.Y, r.Width, r.Height);
+ }
+
+ return blockBounds;
+ }
+ #endregion
+
+ #region Properties
+
+ private bool _ReserveLeftSpace = false;
+
+ ///
+ /// Indicates whether space to the left of center and right aligned blocks is blocked out by stretching the block so it consumes that space.
+ ///
+ public bool ReserveLeftSpace
+ {
+ get { return _ReserveLeftSpace; }
+ set { _ReserveLeftSpace = value; }
+ }
+
+ ///
+ /// Gets or sets the spacing in pixels between content blocks. Default value is 0.
+ ///
+ public virtual int BlockSpacing
+ {
+ get {return m_BlockSpacing;}
+ set {m_BlockSpacing=value;}
+ }
+
+ ///
+ /// Gets or sets whether content blocks are forced to fit the container bounds if they
+ /// occupy more space than it is available by container. Default value is false.
+ ///
+ public virtual bool FitContainerOversize
+ {
+ get {return m_FitContainerOversize;}
+ set {m_FitContainerOversize=value;}
+ }
+
+ ///
+ /// Gets or sets whether content blocks are resized to fit the container bound if they
+ /// occupy less space than it is available by container. Default value is false.
+ ///
+ public virtual bool FitContainer
+ {
+ get {return m_FitContainer;}
+ set {m_FitContainer=value;}
+ }
+
+ ///
+ /// Gets or sets whether content blocks are resized (Width) to fit container bounds if they
+ /// occupy less space than the actual container width. Applies to the Vertical orientation only. Default value is false.
+ ///
+ public virtual bool VerticalFitContainerWidth
+ {
+ get { return m_VerticalFitContainerWidth; }
+ set { m_VerticalFitContainerWidth = value; }
+ }
+
+ ///
+ /// Gets or sets whether content blocks are resized (Height) to fit container bounds if they
+ /// occupy less space than the actual container height. Applies to the Horizontal orientation only. Default value is false.
+ ///
+ public virtual bool HorizontalFitContainerHeight
+ {
+ get { return m_HorizontalFitContainerHeight; }
+ set { m_HorizontalFitContainerHeight = value; }
+ }
+
+ ///
+ /// Gets or sets the content orientation. Default value is Horizontal.
+ ///
+ public virtual eContentOrientation ContentOrientation
+ {
+ get {return m_ContentOrientation;}
+ set {m_ContentOrientation=value;}
+ }
+
+ ///
+ /// Gets or sets the content vertical alignment. Default value is Middle.
+ ///
+ public virtual eContentVerticalAlignment ContentVerticalAlignment
+ {
+ get {return m_ContentVerticalAlignment;}
+ set {m_ContentVerticalAlignment=value;}
+ }
+
+ ///
+ /// Gets or sets the block line vertical alignment. Default value is Middle.
+ ///
+ public virtual eContentVerticalAlignment BlockLineAlignment
+ {
+ get { return m_BlockLineAlignment; }
+ set { m_BlockLineAlignment = value; }
+ }
+
+ ///
+ /// Gets or sets the content horizontal alignment. Default value is Left.
+ ///
+ public virtual eContentAlignment ContentAlignment
+ {
+ get {return m_ContentAlignment;}
+ set {m_ContentAlignment=value;}
+ }
+
+ ///
+ /// Gets or sets whether all content blocks are resized so they have same height which is height of the tallest content block. Default value is false.
+ ///
+ public virtual bool EvenHeight
+ {
+ get {return m_EvenHeight;}
+ set {m_EvenHeight=value;}
+ }
+
+ ///
+ /// Gets or sets whether oversized blocks are resized based on the percentage reduction instead of based on equal pixel distribution. Default value is false.
+ ///
+ public virtual bool OversizeDistribute
+ {
+ get { return m_OversizeDistribute; }
+ set { m_OversizeDistribute = value; }
+ }
+
+ ///
+ /// Gets or sets whether content is wrapped into new line if it exceeds the width of the container.
+ ///
+ public bool MultiLine
+ {
+ get {return m_MultiLine;}
+ set {m_MultiLine=value;}
+ }
+
+ ///
+ /// Gets or sets whether layout is right-to-left.
+ ///
+ public bool RightToLeft
+ {
+ get { return m_RightToLeft; }
+ set { m_RightToLeft = value; }
+ }
+
+ private bool _EqualItemSize = false;
+
+ ///
+ /// Gets or sets whether all items are equaly sized based on the size of the largest item in the list.
+ ///
+ public bool EqualItemSize
+ {
+ get { return _EqualItemSize; }
+ set { _EqualItemSize = value; }
+ }
+
+ #endregion
+ }
+
+ ///
+ /// Represents event arguments for SerialContentLayoutManager.NextPosition event.
+ ///
+ public class LayoutManagerPositionEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets the block that is layed out.
+ ///
+ public IBlock Block = null;
+ ///
+ /// Gets or sets the current block position.
+ ///
+ public Point CurrentPosition = Point.Empty;
+ ///
+ /// Gets or sets the calculated next block position.
+ ///
+ public Point NextPosition = Point.Empty;
+ ///
+ /// Cancels default position calculation.
+ ///
+ public bool Cancel = false;
+
+ public bool SwitchToNewLine;
+ }
+
+ ///
+ /// Represents event arguments for the SerialContentLayoutManager layout events.
+ ///
+ public class LayoutManagerLayoutEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets the reference block object.
+ ///
+ public IBlock Block = null;
+
+ ///
+ /// Gets or sets the position block will assume.
+ ///
+ public Point CurrentPosition = Point.Empty;
+
+ ///
+ /// Cancel the layout of the block, applies only to BeforeXXX layout event.
+ ///
+ public bool CancelLayout = false;
+
+ ///
+ /// Gets or sets the visibility index of the block.
+ ///
+ public int BlockVisibleIndex = 0;
+
+ ///
+ /// Creates new instance of the class and initializes it with default values.
+ ///
+ public LayoutManagerLayoutEventArgs(IBlock block, Point currentPosition, int visibleIndex)
+ {
+ this.Block = block;
+ this.CurrentPosition = currentPosition;
+ this.BlockVisibleIndex = visibleIndex;
+ }
+ }
+
+ ///
+ /// Delegate for SerialContentLayoutManager.NextPosition event.
+ ///
+ public delegate void LayoutManagerPositionEventHandler(object sender, LayoutManagerPositionEventArgs e);
+
+ ///
+ /// Delegate for the SerialContentLayoutManager layout events.
+ ///
+ public delegate void LayoutManagerLayoutEventHandler(object sender, LayoutManagerLayoutEventArgs e);
+
+
+}
diff --git a/PROMS/DotNetBar Source Code/ContextExMenuTypeEditor.cs b/PROMS/DotNetBar Source Code/ContextExMenuTypeEditor.cs
new file mode 100644
index 00000000..fe761086
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContextExMenuTypeEditor.cs
@@ -0,0 +1,89 @@
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Windows.Forms;
+using System.Windows.Forms.Design;
+using System.Drawing.Design;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for ContextExMenuTypeEditor.
+ ///
+ public class ContextExMenuTypeEditor : System.Drawing.Design.UITypeEditor
+ {
+ private IWindowsFormsEditorService edSvc = null;
+ public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
+ {
+ if (context != null
+ && context.Instance != null
+ && provider != null)
+ {
+ edSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
+
+ ContextMenuBar cb = null;
+ GridItem pg = provider as GridItem;
+ string propLabel = "";
+ if (pg != null)
+ propLabel = pg.Label;
+
+ foreach (IComponent c in context.Container.Components)
+ {
+ if (c is ContextMenuBar)
+ {
+ if(propLabel.EndsWith(((ContextMenuBar)c).Name) || propLabel=="")
+ {
+ cb = c as ContextMenuBar;
+ break;
+ }
+ }
+ }
+
+ BaseItem selectedItem=null;
+ if(value!=null && value is BaseItem)
+ selectedItem = (BaseItem)value;
+ if(cb!=null && edSvc!=null)
+ {
+ ListBox lb=new ListBox();
+ lb.SelectedIndexChanged+=new EventHandler(this.SelectedChanged);
+ foreach(BaseItem item in cb.Items)
+ {
+ if(item.Name!="")
+ {
+ int i=lb.Items.Add(item.Name);
+ if (item == selectedItem)
+ lb.SelectedIndex=i;
+ }
+ }
+ edSvc.DropDownControl(lb);
+ if(lb.SelectedItem!=null)
+ return cb.Items[lb.SelectedItem.ToString()];
+ }
+ }
+
+ return value;
+ }
+
+ private void SelectedChanged(object sender, EventArgs e)
+ {
+ if(edSvc!=null)
+ edSvc.CloseDropDown();
+ }
+
+ ///
+ /// Gets the editor style used by the EditValue method.
+ ///
+ /// An ITypeDescriptorContext that can be used to gain additional context information.
+ /// A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None
+ public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
+ {
+ if (context != null && context.Instance != null)
+ {
+ return UITypeEditorEditStyle.DropDown;
+ }
+ return base.GetEditStyle(context);
+ }
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ContextMenuBar.cs b/PROMS/DotNetBar Source Code/ContextMenuBar.cs
new file mode 100644
index 00000000..889f5673
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContextMenuBar.cs
@@ -0,0 +1,387 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+using System.Collections;
+using System.Windows.Forms;
+using System.Drawing;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the context menu bar that provides the context menus for the System.Windows.Forms.Control inherited controls on the form.
+ ///
+ [ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.ContextMenuBarDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), ProvideProperty("ContextMenuEx", typeof(Control)), System.Runtime.InteropServices.ComVisible(false), DefaultEvent("ItemClick")]
+ public class ContextMenuBar : Bar, System.ComponentModel.IExtenderProvider
+ {
+ #region Private Variables
+ private Hashtable m_ContextExMenus = new Hashtable();
+ private Hashtable m_ContextExHandlers = new Hashtable();
+ private bool m_ContextMenuSubclass = true;
+ #endregion
+
+ #region Internal Implementation
+ public ContextMenuBar() : base()
+ {
+ this.Visible = false;
+ this.WrapItemsDock = true;
+ this.WrapItemsFloat = true;
+ }
+
+ protected override bool IsContextPopup(BaseItem popup)
+ {
+ if (this.Items.Contains(popup)) return true;
+ return base.IsContextPopup(popup);
+ }
+ #endregion
+
+ #region Property Hiding
+ ///
+ /// Gets/Sets whether Bar is visible or not.
+ ///
+ [DevCoBrowsable(false), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new bool Visible
+ {
+ get { return base.Visible; }
+ set { base.Visible = value; }
+ }
+ #endregion
+
+ #region Extender Implementation
+ // *********************************************************************
+ //
+ // Extended Property ContextMenuEx implementation code
+ //
+ // *********************************************************************
+ bool IExtenderProvider.CanExtend(object target)
+ {
+ if (target is Control)
+ return true;
+ return false;
+ }
+
+ private delegate void WmContextEventHandler(object sender, WmContextEventArgs e);
+ ///
+ /// Returns the instance of the BaseItem that is assigned as context menu to the control.
+ ///
+ /// Control to return context menu for.
+ /// Instance of the BaseItem used as context menu for the control.
+ [DefaultValue(null), Editor(typeof(ContextExMenuTypeEditor), typeof(System.Drawing.Design.UITypeEditor))]
+ public BaseItem GetContextMenuEx(Control control)
+ {
+ if (control is DevComponents.DotNetBar.Controls.RichTextBoxEx)
+ control = ((DevComponents.DotNetBar.Controls.RichTextBoxEx)control).RichTextBox;
+
+ BaseItem item = (BaseItem)m_ContextExMenus[control];
+ return item;
+ }
+ ///
+ /// Assigns the context menu to a control.
+ ///
+ /// Control to assign the context menu to.
+ /// Instance of PopupItem derived class usually ButtonItem to act as context menu for a control. The SubItems collection of the item specified here actually defines the visible context menu items.
+ public void SetContextMenuEx(Control control, BaseItem value)
+ {
+ if (control is DevComponents.DotNetBar.Controls.RichTextBoxEx)
+ control = ((DevComponents.DotNetBar.Controls.RichTextBoxEx)control).RichTextBox;
+ if (value == null)
+ {
+ if (m_ContextExMenus.Contains(control))
+ {
+ if (m_ContextExHandlers.Contains(control))
+ {
+ ContextMessageHandler h = m_ContextExHandlers[control] as ContextMessageHandler;
+ if (h != null)
+ {
+ h.ContextMenu -= new WmContextEventHandler(this.OnContextMenu);
+ h.ReleaseHandle();
+ h = null;
+ }
+ m_ContextExHandlers.Remove(control);
+ }
+
+ m_ContextExMenus.Remove(control);
+ control.MouseUp -= new MouseEventHandler(this.ContextExMouseUp);
+ try
+ {
+ control.HandleDestroyed -= new EventHandler(this.ContextExHandleDestroy);
+ }
+ catch { }
+ try
+ {
+ control.HandleCreated -= new EventHandler(this.ContextExHandleCreate);
+ }
+ catch { }
+ try { control.MouseUp -= new MouseEventHandler(this.ContextExMouseUp); }
+ catch { }
+ }
+ }
+ else
+ {
+ if (m_ContextExMenus.Contains(control))
+ {
+ m_ContextExMenus[control] = value;
+ }
+ else
+ {
+ m_ContextExMenus[control] = value;
+ if (!m_ContextExHandlers.Contains(control) && !this.DesignMode)
+ {
+ if (!(control is System.Windows.Forms.TreeView) && !(control is System.Windows.Forms.Form) &&
+ !(control is System.Windows.Forms.Panel
+#if FRAMEWORK20
+ || control is System.Windows.Forms.DataGridView
+#endif
+ ) &&
+ m_ContextMenuSubclass)
+ {
+ if (control.IsHandleCreated)
+ {
+ ContextMessageHandler h = new ContextMessageHandler();
+ h.ContextMenu += new WmContextEventHandler(this.OnContextMenu);
+ h.ParentControl = control;
+ h.AssignHandle(control.Handle);
+ m_ContextExHandlers[control] = h;
+ }
+ control.HandleDestroyed += new EventHandler(this.ContextExHandleDestroy);
+ control.HandleCreated += new EventHandler(this.ContextExHandleCreate);
+ }
+ if (control is ComboBox)
+ {
+ ComboBox cbo = control as ComboBox;
+ cbo.ContextMenu = new ContextMenu();
+ }
+ }
+ try { control.MouseUp += new MouseEventHandler(this.ContextExMouseUp); }
+ catch { }
+ }
+ }
+ }
+
+ internal bool HasContextMenu(Control ctrl)
+ {
+ return m_ContextExMenus.Contains(ctrl);
+ }
+
+ private void ContextExHandleDestroy(object sender, EventArgs e)
+ {
+ Control control = sender as Control;
+ if (control == null)
+ return;
+ ContextMessageHandler h = m_ContextExHandlers[control] as ContextMessageHandler;
+ if (h != null)
+ {
+ h.ContextMenu -= new WmContextEventHandler(this.OnContextMenu);
+ h.ReleaseHandle();
+ h = null;
+ }
+ m_ContextExHandlers.Remove(control);
+ }
+
+ private void ContextExHandleCreate(object sender, EventArgs e)
+ {
+ Control control = sender as Control;
+ if (control == null)
+ return;
+ if (m_ContextExHandlers.Contains(control))
+ return;
+
+ ContextMessageHandler h = new ContextMessageHandler();
+ h.ContextMenu += new WmContextEventHandler(this.OnContextMenu);
+ h.ParentControl = control;
+ h.AssignHandle(control.Handle);
+ m_ContextExHandlers[control] = h;
+ }
+
+ private void ContextExMouseUp(object sender, MouseEventArgs e)
+ {
+ if (e.Button != MouseButtons.Right)
+ return;
+ Control ctrl = sender as Control;
+ if (ctrl == null)
+ return;
+ // Find it in pop-ups
+ PopupItem popup = GetContextExItem(ctrl) as PopupItem;
+ if (popup == null) return;
+
+ if (!popup.Expanded)
+ {
+ popup.Style = this.Style;
+ popup.SetSourceControl(ctrl);
+ popup.Popup(ctrl.PointToScreen(new Point(e.X, e.Y)));
+ }
+ }
+
+ private Control FindControl(Control parent, IntPtr handle)
+ {
+ foreach (Control ctrl in parent.Controls)
+ {
+ if (ctrl.Handle == handle)
+ return ctrl;
+ if (ctrl.Controls.Count > 0)
+ {
+ Control ret = FindControl(ctrl, handle);
+ if (ret != null)
+ return ret;
+ }
+ }
+ return parent;
+ }
+
+ private BaseItem GetContextExItem(Control ctrl)
+ {
+ BaseItem item = (BaseItem)m_ContextExMenus[ctrl];
+ return item;
+ }
+ private void OnContextMenu(object sender, WmContextEventArgs e)
+ {
+ ContextMessageHandler h = sender as ContextMessageHandler;
+ if (h == null)
+ return;
+
+ BaseItem contextItem = GetContextExItem(h.ParentControl);
+ if (contextItem == null)
+ return;
+
+ // Check whether context menu originated elsewhere in particular a Panel which handles MouseUp
+ if (e.Handle != e.SourceHandle && e.SourceHandle != IntPtr.Zero)
+ {
+ Control ctrl = Control.FromChildHandle(e.Handle);
+ if (ctrl != null && ctrl is Panel && this.GetContextExItem(ctrl) != null) return; // WM_CONTEXT bubbles up and Panel handles MouseUp
+ }
+
+ // Find it in pop-ups
+ PopupItem popup = contextItem as PopupItem;
+ popup.Style = this.Style;
+
+ if (e.Button == MouseButtons.None)
+ {
+ // Get the control with focus
+ Control ctrl = Control.FromChildHandle(e.Handle);
+ if (ctrl != null && ctrl.Handle != e.Handle)
+ {
+ ctrl = FindControl(ctrl, e.Handle);
+ }
+ popup.SetSourceControl(h.ParentControl);
+ if (ctrl != null)
+ {
+ if (ctrl.ClientRectangle.Contains(ctrl.PointToClient(Control.MousePosition)))
+ popup.Popup(Control.MousePosition);
+ else
+ popup.Popup(ctrl.PointToScreen(Point.Empty));
+ }
+ else
+ popup.Popup(Control.MousePosition);
+
+ // We need to eat the message in OnSysKeyUp for Shift+F10 case
+ if (this.IgnoreSysKeyUp)
+ {
+ this.IgnoreSysKeyUp = false;
+ this.EatSysKeyUp = true;
+ }
+ }
+ else
+ {
+ // This is handled by the WM_RBUTTONUP just eat it
+ if (!e.WmContext)
+ {
+ popup.SetSourceControl(h.ParentControl);
+ popup.Popup(e.X, e.Y);
+ }
+ }
+ e.Handled = true;
+ }
+ private class ContextMessageHandler : NativeWindow
+ {
+ public event WmContextEventHandler ContextMenu;
+ private const int WM_CONTEXTMENU = 0x007B;
+ private const int WM_RBUTTONUP = 0x0205;
+ private const int WM_NCRBUTTONUP = 0x00A5;
+ private const int WM_RBUTTONDOWN = 0x0204;
+ public Control ParentControl = null;
+ protected override void WndProc(ref Message m)
+ {
+ if (m.Msg == WM_CONTEXTMENU)
+ {
+ if (ContextMenu != null)
+ {
+ int ilParam = WinApi.ToInt(m.LParam);
+ int y = ilParam >> 16;
+ int x = (short)(ilParam & 0xFFFF);
+ IntPtr hWnd = m.WParam;
+ if (hWnd == IntPtr.Zero)
+ hWnd = m.HWnd;
+ bool context = true;
+ if (m.HWnd != m.WParam)
+ context = false;
+ WmContextEventArgs e = new WmContextEventArgs(hWnd, x, y, ((x == -1 && y == -1) ? MouseButtons.None : MouseButtons.Right), context, m.HWnd);
+ ContextMenu(this, e);
+ if (e.Handled)
+ return;
+ }
+ }
+ // This case was taken out becouse the message was not generated for the listview control and possibly for
+ // treview control so this code was moved to the MouseUp event of the Control see ContextExMouseUp
+ // else if(m.Msg==WM_RBUTTONUP || m.Msg==WM_NCRBUTTONUP)
+ // {
+ // if(ContextMenu!=null)
+ // {
+ // int ilParam=m.LParam.ToInt32();
+ // int y=ilParam>>16;
+ // int x=ilParam & 0xFFFF;
+ // Point p=ParentControl.PointToScreen(new Point(x,y));
+ // WmContextEventArgs e=new WmContextEventArgs(m.HWnd,p.X,p.Y,MouseButtons.Right,false);
+ // ContextMenu(this,e);
+ // }
+ // }
+ base.WndProc(ref m);
+ }
+ }
+ private class WmContextEventArgs : EventArgs
+ {
+ private readonly int x;
+ private readonly int y;
+ private readonly MouseButtons button = 0;
+ private readonly IntPtr hwnd;
+ private readonly bool wmcontext;
+ public bool Handled = false;
+ private IntPtr sourceHandle;
+ public WmContextEventArgs(IntPtr phwnd, int ix, int iy, MouseButtons eButton, bool WmContextMessage, IntPtr sourceHandle)
+ {
+ this.x = ix;
+ this.y = iy;
+ this.button = eButton;
+ this.hwnd = phwnd;
+ this.wmcontext = WmContextMessage;
+ this.sourceHandle = sourceHandle;
+ }
+ public int X
+ {
+ get { return this.x; }
+ }
+ public int Y
+ {
+ get { return this.y; }
+ }
+ public MouseButtons Button
+ {
+ get { return this.button; }
+ }
+ public IntPtr Handle
+ {
+ get { return this.hwnd; }
+ }
+ public bool WmContext
+ {
+ get { return this.wmcontext; }
+ }
+ public IntPtr SourceHandle
+ {
+ get
+ {
+ return this.sourceHandle;
+ }
+ }
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ContextMenusCollection.cs b/PROMS/DotNetBar Source Code/ContextMenusCollection.cs
new file mode 100644
index 00000000..1a45552b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ContextMenusCollection.cs
@@ -0,0 +1,101 @@
+using System;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for Popups.
+ ///
+ public class ContextMenusCollection:System.Collections.CollectionBase
+ {
+ private DotNetBarManager m_Owner;
+ public ContextMenusCollection(DotNetBarManager owner)
+ {
+ m_Owner=owner;
+ }
+ public int Add(BaseItem item)
+ {
+ item.SetOwner(m_Owner);
+ item.Visible=false;
+ item.Displayed=false;
+ return List.Add(item);
+ }
+ public BaseItem this[int index]
+ {
+ get {return (BaseItem)(List[index]);}
+ set {List[index] = value;}
+ }
+ public BaseItem this[string name]
+ {
+ get {return (BaseItem)(List[this.IndexOf(name)]);}
+ set {List[this.IndexOf(name)] = value;}
+ }
+
+ public void Insert(int index, BaseItem value)
+ {
+ value.Visible=false;
+ value.Displayed=false;
+ List.Insert(index, value);
+ }
+
+ public int IndexOf(BaseItem value)
+ {
+ return List.IndexOf(value);
+ }
+
+ public int IndexOf(string name)
+ {
+ int i=-1;
+ foreach(BaseItem item in List)
+ {
+ i++;
+ if(item.Name==name)
+ return i;
+ }
+ return -1;
+ }
+
+ public bool Contains(BaseItem value)
+ {
+ return List.Contains(value);
+ }
+
+ public bool Contains(string name)
+ {
+ foreach(BaseItem item in List)
+ {
+ if(item.Name==name)
+ return true;
+ }
+ return false;
+ }
+
+ public void Remove(BaseItem value)
+ {
+ List.Remove(value);
+ }
+
+ public void CopyTo(BaseItem[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ protected override void OnClear()
+ {
+ IOwner owner=m_Owner as IOwner;
+ if(List.Count>0 && owner!=null)
+ {
+ foreach(BaseItem objSub in this)
+ {
+ if(owner!=null)
+ owner.RemoveShortcutsFromItem(objSub);
+ }
+ }
+ base.OnClear();
+ }
+
+ internal void SetOwner(DotNetBarManager owner)
+ {
+ m_Owner=owner;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/ControlContainerItem.cs b/PROMS/DotNetBar Source Code/ControlContainerItem.cs
new file mode 100644
index 00000000..5bae8deb
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/ControlContainerItem.cs
@@ -0,0 +1,746 @@
+using System;
+using System.Drawing;
+using System.ComponentModel;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Summary description for ControlContainerItem.
+ ///
+ [System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false), Designer("DevComponents.DotNetBar.Design.SimpleBaseItemDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class ControlContainerItem:ImageItem,IPersonalizedMenuItem
+ {
+ ///
+ /// Occurs when container control needs to be assigned to the item.
+ ///
+ public event EventHandler ContainerLoadControl;
+ public delegate void ControlContainerSerializationEventHandler(object sender, ControlContainerSerializationEventArgs e);
+ public event ControlContainerSerializationEventHandler ContainerControlSerialize;
+ public event ControlContainerSerializationEventHandler ContainerControlDeserialize;
+
+ // IPersonalizedMenuItem Implementation
+ private eMenuVisibility m_MenuVisibility=eMenuVisibility.VisibleAlways;
+ private bool m_RecentlyUsed=false;
+ private System.Windows.Forms.Control m_Control=null;
+ private bool m_MouseOver=false;
+ private bool m_AllowItemResize=true;
+
+ ///
+ /// Creates new instance of ControlContainerItem and assigns item name.
+ ///
+ public ControlContainerItem():this("","") {}
+ ///
+ /// Creates new instance of ControlContainerItem and assigns item name.
+ ///
+ /// Item name.
+ public ControlContainerItem(string sName):this(sName,""){}
+ ///
+ /// Creates new instance of ControlContainerItem and assigns item name and item text.
+ ///
+ /// Item name.
+ /// Item text.
+ public ControlContainerItem(string sName, string ItemText):base(sName,ItemText)
+ {
+ m_SupportedOrientation=eSupportedOrientation.Horizontal;
+ }
+
+ internal void InitControl()
+ {
+ EventArgs e=new EventArgs();
+ if(ContainerLoadControl!=null)
+ ContainerLoadControl(this,e);
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null)
+ owner.InvokeContainerLoadControl(this,e);
+ CustomizeChanged();
+ }
+
+ ///
+ /// Overridden. Returns the copy of the ControlContainerItem.
+ ///
+ /// Copy of the ControlContainerItem.
+ public override BaseItem Copy()
+ {
+ ControlContainerItem objCopy=new ControlContainerItem(this.Name);
+ objCopy.AllowItemResize = this.AllowItemResize;
+ this.CopyToItem(objCopy);
+ return objCopy;
+ }
+ protected override void CopyToItem(BaseItem copy)
+ {
+ ControlContainerItem objCopy=copy as ControlContainerItem;
+ base.CopyToItem(objCopy);
+ objCopy.ContainerLoadControl=this.ContainerLoadControl;
+ objCopy.InitControl();
+ }
+ protected override void Dispose(bool disposing)
+ {
+ if(m_Control!=null)
+ {
+ m_Control.Enter -= new EventHandler(HostedControlEnter);
+ m_Control.GotFocus -= new EventHandler(HostedControlGotFocus);
+ m_Control.Resize -= new EventHandler(HostedControlResized);
+// if(m_Control.Parent!=null && (!m_Control.Parent.Disposing && !(m_Control.Parent is Bar && ((Bar)m_Control.Parent).IsDisposing)))
+// {
+// m_Control.Parent.Controls.Remove(m_Control);
+// }
+ m_Control=null;
+ }
+ base.Dispose(disposing);
+ }
+ protected internal override void Serialize(ItemSerializationContext context)
+ {
+ base.Serialize(context);
+ System.Xml.XmlElement ThisItem = context.ItemXmlElement;
+ ThisItem.SetAttribute("AllowResize",System.Xml.XmlConvert.ToString(m_AllowItemResize));
+
+ if(ContainerControlSerialize!=null)
+ this.ContainerControlSerialize(this,new ControlContainerSerializationEventArgs(ThisItem));
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null)
+ owner.InvokeContainerControlSerialize(this,new ControlContainerSerializationEventArgs(ThisItem));
+
+ }
+ public override void Deserialize(ItemSerializationContext context)
+ {
+ base.Deserialize(context);
+ System.Xml.XmlElement ItemXmlSource = context.ItemXmlElement;
+ m_AllowItemResize=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("AllowResize"));
+ InitControl();
+
+ if(ContainerControlDeserialize!=null)
+ this.ContainerControlDeserialize(this,new ControlContainerSerializationEventArgs(ItemXmlSource));
+ IOwnerItemEvents owner=this.GetIOwnerItemEvents();
+ if(owner!=null)
+ owner.InvokeContainerControlDeserialize(this,new ControlContainerSerializationEventArgs(ItemXmlSource));
+ }
+
+ // IPersonalizedMenuItem Impementation
+ ///
+ /// Indicates item's visiblity when on pop-up menu.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates item's visiblity when on pop-up menu.")]
+ public eMenuVisibility MenuVisibility
+ {
+ get
+ {
+ return m_MenuVisibility;
+ }
+ set
+ {
+ if(m_MenuVisibility!=value)
+ {
+ m_MenuVisibility=value;
+ if(ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "MenuVisibility");
+ }
+ }
+ }
+ ///
+ /// Indicates whether item was recently used.
+ ///
+ [System.ComponentModel.Browsable(false),System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
+ public bool RecentlyUsed
+ {
+ get
+ {
+ return m_RecentlyUsed;
+ }
+ set
+ {
+ if(m_RecentlyUsed!=value)
+ {
+ m_RecentlyUsed=value;
+ if(ShouldSyncProperties)
+ BarFunctions.SyncProperty(this, "RecentlyUsed");
+ }
+ }
+ }
+
+ ///
+ /// Gets/Sets informational text (tooltip) for the item.
+ ///
+ [System.ComponentModel.Browsable(false),DevCoBrowsable(false),System.ComponentModel.DefaultValue(""),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("Indicates the text that is displayed when mouse hovers over the item."),System.ComponentModel.Localizable(true)]
+ public override string Tooltip
+ {
+ get
+ {
+
+ return base.Tooltip;
+ }
+ set
+ {
+ base.Tooltip=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the reference to the control that is managed by the item.
+ ///
+ [Category("Data"), DefaultValue(null), Description("Indicates the control that is managed by the item.")]
+ public System.Windows.Forms.Control Control
+ {
+ get
+ {
+ return m_Control;
+ }
+ set
+ {
+ if(m_Control!=null)
+ {
+ if(m_Control.Parent!=null)
+ m_Control.Parent.Controls.Remove(m_Control);
+ m_Control.Enter -= new EventHandler(HostedControlEnter);
+ m_Control.GotFocus -= new EventHandler(HostedControlGotFocus);
+ m_Control.Resize -= new EventHandler(HostedControlResized);
+ }
+ m_Control=value;
+ if(m_Control!=null)
+ {
+ m_Control.Enter += new EventHandler(HostedControlEnter);
+ m_Control.GotFocus += new EventHandler(HostedControlGotFocus);
+ m_Control.Resize += new EventHandler(HostedControlResized);
+ if(m_Control.Parent!=null)
+ m_Control.Parent.Controls.Remove(m_Control);
+ m_Control.Dock=System.Windows.Forms.DockStyle.None;
+
+ //if (m_Control is System.Windows.Forms.ListBox)
+ //{
+ // TypeDescriptor.GetProperties(m_Control)["IntegralHeight"].SetValue(m_Control, false);
+ //}
+ //if (!(m_Control is ItemControl) && TypeDescriptor.GetProperties(m_Control).Find("AutoSize", true) != null)
+ // TypeDescriptor.GetProperties(m_Control)["AutoSize"].SetValue(m_Control, false);
+
+ System.Windows.Forms.Control objCtrl=null;
+ if(this.ContainerControl!=null)
+ {
+ objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(objCtrl!=null)
+ {
+ objCtrl.Controls.Add(m_Control);
+ m_Control.Refresh();
+ }
+ }
+ if(!this.Displayed)
+ m_Control.Visible=false;
+ }
+ }
+ }
+
+ void HostedControlResized(object sender, EventArgs e)
+ {
+ NeedRecalcSize = true;
+ if (this.ContainerControl is MenuPanel)
+ ((MenuPanel)this.ContainerControl).RecalcLayout();
+ }
+
+ private void HostedControlGotFocus(object sender, EventArgs e)
+ {
+ SetMenuHotSubItem();
+ }
+
+ private void SetMenuHotSubItem()
+ {
+ if (this.IsOnMenu)
+ {
+ MenuPanel panel = this.ContainerControl as MenuPanel;
+ if (panel != null && panel.HotSubItem != this)
+ panel.HotSubItem = this;
+ }
+ }
+ private void HostedControlEnter(object sender, EventArgs e)
+ {
+ SetMenuHotSubItem();
+ }
+
+ ///
+ /// Overridden. Draws the item.
+ ///
+ /// Target Graphics object.
+ public override void Paint(ItemPaintArgs pa)
+ {
+ if(this.SuspendLayout)
+ return;
+
+ System.Drawing.Graphics g = pa.Graphics;
+
+ if (m_Control != null && m_Control.Visible != this.Displayed && !m_Control.Visible)
+ CustomizeChanged(); // Determine based on customize status
+
+ Rectangle r = this.DisplayRectangle;
+
+ Size objImageSize = GetMaxImageSize();
+ bool bOnMenu = this.IsOnMenu;
+ if (bOnMenu && this.Parent is ItemContainer)
+ bOnMenu = false;
+
+ if (this.Orientation == eOrientation.Horizontal)
+ {
+ if (bOnMenu && !this.Stretch)
+ {
+ objImageSize.Width += 7;
+ r.Width -= objImageSize.Width;
+ r.X += objImageSize.Width;
+ if (this.IsOnCustomizeMenu)
+ objImageSize.Width += objImageSize.Height + 8;
+
+ // Draw side bar
+ Rectangle sideRect = new Rectangle(m_Rect.Left, m_Rect.Top, objImageSize.Width, m_Rect.Height);
+ if (this.MenuVisibility == eMenuVisibility.VisibleIfRecentlyUsed && !this.RecentlyUsed)
+ {
+ if (!pa.Colors.MenuUnusedSide2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(sideRect, pa.Colors.MenuUnusedSide, pa.Colors.MenuUnusedSide2, pa.Colors.MenuUnusedSideGradientAngle);
+ g.FillRectangle(gradient, sideRect);
+ gradient.Dispose();
+ }
+ else
+ g.FillRectangle(new SolidBrush(pa.Colors.MenuUnusedSide), sideRect);
+ }
+ else
+ {
+ if (!pa.Colors.MenuSide2.IsEmpty)
+ {
+ System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(sideRect, pa.Colors.MenuSide, pa.Colors.MenuSide2, pa.Colors.MenuSideGradientAngle);
+ g.FillRectangle(gradient, sideRect);
+ gradient.Dispose();
+ }
+ else
+ g.FillRectangle(new SolidBrush(pa.Colors.MenuSide), sideRect);
+ }
+ if (BarFunctions.IsOffice2007Style(EffectiveStyle) && GlobalManager.Renderer is Office2007Renderer)
+ {
+ Office2007MenuColorTable mt = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.Menu;
+ if (mt != null && !mt.SideBorder.IsEmpty)
+ {
+ if (pa.RightToLeft)
+ DisplayHelp.DrawGradientLine(g, sideRect.X + 1, sideRect.Y, sideRect.X + 1, sideRect.Bottom - 1, mt.SideBorder, 1);
+ else
+ DisplayHelp.DrawGradientLine(g, sideRect.Right - 2, sideRect.Y, sideRect.Right - 2, sideRect.Bottom - 1, mt.SideBorder, 1);
+ }
+ if (mt != null && !mt.SideBorderLight.IsEmpty)
+ {
+ if (pa.RightToLeft)
+ DisplayHelp.DrawGradientLine(g, sideRect.X, sideRect.Y, sideRect.X, sideRect.Bottom - 1, mt.SideBorder, 1);
+ else
+ DisplayHelp.DrawGradientLine(g, sideRect.Right - 1, sideRect.Y, sideRect.Right - 1, sideRect.Bottom - 1, mt.SideBorderLight, 1);
+ }
+ }
+ }
+
+ if(this.IsOnCustomizeMenu)
+ {
+ if (EffectiveStyle != eDotNetBarStyle.Office2000)
+ {
+ r.X+=(objImageSize.Height+8);
+ r.Width-=(objImageSize.Height+8);
+ }
+ else
+ {
+ r.X+=(objImageSize.Height+4);
+ r.Width-=(objImageSize.Height+4);
+ }
+ }
+
+ if (bOnMenu && EffectiveStyle != eDotNetBarStyle.Office2000)
+ {
+ //g.FillRectangle(new SolidBrush(pa.Colors.MenuBackground),r);
+ }
+ //else if(this.Style==eDotNetBarStyle.OfficeXP && !this.IsOnMenuBar)
+ // g.FillRectangle(new SolidBrush(ColorFunctions.ToolMenuFocusBackColor(g)),this.DisplayRectangle);
+ //else
+ // g.FillRectangle(SystemBrushes.Control,this.DisplayRectangle);
+
+ // Draw text if needed
+ if (m_Control == null || this.GetDesignMode() || this.IsOnCustomizeMenu)
+ {
+ string text=m_Text;
+ if(text=="")
+ text="Container";
+ eTextFormat objStringFormat=GetStringFormat();
+ Font objFont=this.GetFont();
+ Rectangle rText=new Rectangle(r.X+8,r.Y,r.Width,r.Height);
+ if (EffectiveStyle == eDotNetBarStyle.Office2000)
+ {
+ TextDrawing.DrawString(g, text, objFont, SystemColors.ControlText, rText, objStringFormat);
+ }
+ else
+ {
+ TextDrawing.DrawString(g, text, objFont, SystemColors.ControlText, rText, objStringFormat);
+ }
+ Size textSize = TextDrawing.MeasureString(g, text, objFont, 0, objStringFormat);
+ r.X += (int)textSize.Width + 8;
+ r.Width -= ((int)textSize.Width + 8);
+ }
+ else if (m_Control != null)
+ {
+ r.Inflate(-2, -2);
+ if (m_AllowItemResize)
+ {
+ m_Control.Width = r.Width;
+ }
+ Point loc = r.Location;
+ loc.Offset((r.Width - m_Control.Width) / 2, (r.Height - m_Control.Height) / 2);
+
+ ScrollableControl scc = pa.ContainerControl as ScrollableControl;
+ if (scc != null && scc.AutoScroll /*&& !(scc is ItemPanel)*/)
+ loc.Offset(scc.AutoScrollPosition.X, scc.AutoScrollPosition.Y);
+
+ if (m_Control.Location != loc &&
+ (!(m_Control is Controls.ComboBoxEx && ContainerControl is RibbonBar) || IsOnPopup(this)) || _ControlLocationUpdatePending)
+ {
+ m_Control.Location = loc;
+ _ControlLocationUpdatePending = false;
+ }
+ }
+
+ if(this.IsOnCustomizeMenu && this.Visible)
+ {
+ // Draw check box if this item is visible
+ Rectangle rBox=new Rectangle(m_Rect.Left,m_Rect.Top,m_Rect.Height,m_Rect.Height);
+ if (EffectiveStyle != eDotNetBarStyle.Office2000)
+ rBox.Inflate(-1,-1);
+ BarFunctions.DrawMenuCheckBox(pa, rBox, EffectiveStyle, m_MouseOver);
+ }
+ }
+
+ if (this.Focused && (this.GetDesignMode() || m_Control == null && this.DesignMode))
+ {
+ r = this.DisplayRectangle;
+ r.Inflate(-1, -1);
+ DesignTime.DrawDesignTimeSelection(g, r, pa.Colors.ItemDesignTimeBorder);
+ }
+ }
+
+ ///
+ /// IBlock member implementation
+ ///
+ [Browsable(false), DevCoBrowsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
+ public override System.Drawing.Rectangle Bounds
+ {
+ get { return base.Bounds; }
+ set
+ {
+ if (base.Bounds != value)
+ {
+ bool topLocationChanged = base.Bounds.Top != value.Top;
+ bool leftLocationChanged = base.Bounds.Left != value.Left;
+ base.Bounds = value;
+ if (topLocationChanged || leftLocationChanged)
+ UpdateControlLocation();
+ }
+ }
+ }
+
+ private bool _ControlLocationUpdatePending = false;
+ private void UpdateControlLocation()
+ {
+ if (m_Control == null) return;
+ if (this.IsLayoutPassInProgress)
+ {
+ _ControlLocationUpdatePending = true;
+ return;
+ }
+ Rectangle r = this.DisplayRectangle;
+ r.Inflate(-2, -2);
+ m_Control.Location = r.Location;
+ _ControlLocationUpdatePending = false;
+ }
+
+ ///
+ /// Overridden. Recalculates the size of the item.
+ ///
+ public override void RecalcSize()
+ {
+ if(this.SuspendLayout)
+ return;
+
+ bool bOnMenu=this.IsOnMenu;
+
+ if(m_Control==null && !this.DesignMode)
+ InitControl();
+
+ // Default Height
+ if(this.Parent!=null && this.Parent is ImageItem)
+ m_Rect.Height=((ImageItem)this.Parent).SubItemsImageSize.Height+4;
+ else
+ m_Rect.Height=this.SubItemsImageSize.Height+4;
+
+ if (EffectiveStyle == eDotNetBarStyle.OfficeXP || EffectiveStyle == eDotNetBarStyle.Office2003 || EffectiveStyle == eDotNetBarStyle.VS2005)
+ {
+ if(m_Control!=null && m_Rect.Height<(m_Control.Height+2))
+ m_Rect.Height=m_Control.Height+2;
+ }
+ else
+ {
+ if(m_Control!=null && m_Rect.Height<(m_Control.Height+2))
+ m_Rect.Height=m_Control.Height+2;
+ }
+
+ // Default width
+ if(m_Control!=null)
+ {
+ if (this.Stretch)
+ m_Rect.Width = 32;
+ else
+ {
+ m_Rect.Width = m_Control.Width + 4;
+ }
+ }
+ else
+ m_Rect.Width=64+4;
+
+ // Calculate Item Height
+ if(m_Control==null)
+ {
+ string text=m_Text;
+ if(text=="")
+ text="Container";
+ System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(objCtrl!=null && IsHandleValid(objCtrl))
+ {
+ Graphics g=BarFunctions.CreateGraphics(objCtrl);
+ try
+ {
+ Size textSize = TextDrawing.MeasureString(g, text, GetFont(), 0, GetStringFormat());
+ if (textSize.Height > this.SubItemsImageSize.Height && textSize.Height > m_Rect.Height)
+ m_Rect.Height = (int)textSize.Height + 4;
+ m_Rect.Width = (int)textSize.Width + 8;
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ }
+ }
+
+ Size objImageSize=GetMaxImageSize();
+ if (this.IsOnMenu && EffectiveStyle != eDotNetBarStyle.Office2000 && !this.Stretch && !(this.Parent is ItemContainer))
+ {
+ // THis is side bar that will need to be drawn for DotNet style
+ m_Rect.Width+=(objImageSize.Width+7);
+ }
+
+ if(this.IsOnCustomizeMenu)
+ m_Rect.Width+=(objImageSize.Height+2);
+
+ // Always call base implementation to reset resize flag
+ base.RecalcSize();
+ }
+
+ ///
+ /// Called when size of the item is changed externally.
+ ///
+ protected override void OnExternalSizeChange()
+ {
+ base.OnExternalSizeChange();
+ if(m_AllowItemResize)
+ NeedRecalcSize=true;
+ }
+
+ protected internal override void OnContainerChanged(object objOldContainer)
+ {
+ base.OnContainerChanged(objOldContainer);
+ if(m_Control!=null)
+ {
+ System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(m_Control.Parent!=null && objCtrl!=m_Control.Parent)
+ m_Control.Parent.Controls.Remove(m_Control);
+
+ if(objCtrl!=null && m_Control.Parent==null)
+ {
+ objCtrl.Controls.Add(m_Control);
+ m_Control.Refresh();
+ }
+ }
+ }
+
+ protected internal override void OnVisibleChanged(bool newValue)
+ {
+ if(m_Control!=null && !newValue)
+ m_Control.Visible=newValue;
+ base.OnVisibleChanged(newValue);
+ }
+ protected override void OnDisplayedChanged()
+ {
+ if (!this.Displayed && m_Control != null && !(this.IsOnCustomizeMenu || this.IsOnCustomizeDialog || this.GetDesignMode()))
+ {
+ m_Control.Visible=this.Displayed;
+ }
+ }
+
+ protected override void OnIsOnCustomizeDialogChanged()
+ {
+ base.OnIsOnCustomizeDialogChanged();
+ CustomizeChanged();
+ }
+
+ protected override void OnDesignModeChanged()
+ {
+ base.OnDesignModeChanged();
+ CustomizeChanged();
+ }
+
+ protected override void OnIsOnCustomizeMenuChanged()
+ {
+ base.OnIsOnCustomizeMenuChanged();
+ CustomizeChanged();
+ }
+
+ private bool m_CustomizeChangedExecuting = false;
+ private void CustomizeChanged()
+ {
+ if(m_Control!=null)
+ {
+ if (m_CustomizeChangedExecuting) return;
+ m_CustomizeChangedExecuting = true;
+ try
+ {
+ if (this.IsOnCustomizeMenu || this.IsOnCustomizeDialog || this.GetDesignMode())
+ {
+ m_Control.Visible = false;
+ }
+ else
+ {
+ m_Control.Visible = this.Displayed;
+ }
+ }
+ finally
+ {
+ m_CustomizeChangedExecuting = false;
+ }
+ }
+ }
+
+ private Size GetMaxImageSize()
+ {
+ if(m_Parent!=null)
+ {
+ ImageItem objParentImageItem=m_Parent as ImageItem;
+ if(objParentImageItem!=null)
+ return objParentImageItem.SubItemsImageSize;
+ else
+ return this.ImageSize;
+ }
+ else
+ return this.ImageSize;
+ }
+ private eTextFormat GetStringFormat()
+ {
+ eTextFormat format = eTextFormat.Default;
+ format |= eTextFormat.SingleLine;
+ format |= eTextFormat.EndEllipsis;
+ format |= eTextFormat.VerticalCenter;
+ return format;
+
+
+ //StringFormat sfmt=BarFunctions.CreateStringFormat(); //new StringFormat(StringFormat.GenericDefault);
+ //sfmt.HotkeyPrefix=System.Drawing.Text.HotkeyPrefix.Show;
+ ////sfmt.FormatFlags=sfmt.FormatFlags & ~(sfmt.FormatFlags & StringFormatFlags.DisableKerning);
+ //sfmt.FormatFlags=sfmt.FormatFlags | StringFormatFlags.NoWrap;
+ //sfmt.Trimming=StringTrimming.EllipsisCharacter;
+ //sfmt.Alignment=System.Drawing.StringAlignment.Near;
+ //sfmt.LineAlignment=System.Drawing.StringAlignment.Center;
+
+ //return sfmt;
+ }
+
+ ///
+ /// Returns the Font object to be used for drawing the item text.
+ ///
+ /// Font object.
+ protected virtual Font GetFont()
+ {
+ System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;
+ if(objCtrl!=null)
+ return (Font)objCtrl.Font;
+ return SystemFonts.DefaultFont;
+ }
+ protected internal override bool IsAnyOnHandle(IntPtr iHandle)
+ {
+ bool bRet=base.IsAnyOnHandle(iHandle);
+ if(!bRet && m_Control!=null && m_Control.Handle==iHandle)
+ bRet=true;
+ return bRet;
+ }
+ protected override void OnEnabledChanged()
+ {
+ base.OnEnabledChanged();
+ if(m_Control!=null)
+ m_Control.Enabled=this.Enabled;
+ }
+
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseEnter()
+ {
+ base.InternalMouseEnter();
+ if(!m_MouseOver)
+ {
+ m_MouseOver=true;
+ if(this.IsOnCustomizeMenu && this.Visible)
+ this.Refresh();
+ }
+ }
+
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override void InternalMouseLeave()
+ {
+ base.InternalMouseLeave();
+ if(m_MouseOver)
+ {
+ m_MouseOver=false;
+ if (this.IsOnCustomizeMenu && this.Visible)
+ this.Refresh();
+ }
+ }
+
+ ///
+ /// Specifies whether contained control can be automatically resized to fill the item container.
+ ///
+ [System.ComponentModel.Browsable(true),DevCoBrowsable(true),System.ComponentModel.Category("Behavior"),System.ComponentModel.Description("Specifies whether contained control can be automatically resized to fill the item container.")]
+ public bool AllowItemResize
+ {
+ get {return m_AllowItemResize;}
+ set {m_AllowItemResize=value;}
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnGotFocus()
+ {
+ base.OnGotFocus();
+ if(m_Control==null)
+ return;
+ if (m_Control.Focused || this.IsOnCustomizeMenu || this.IsOnCustomizeDialog || this.GetDesignMode())
+ return;
+ m_Control.Focus();
+ }
+
+ [System.ComponentModel.Browsable(false),System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ public override bool IsWindowed
+ {
+ get {return true;}
+ }
+
+ private bool GetDesignMode()
+ {
+ if (this.ContainerControl is IBarDesignerServices && ((IBarDesignerServices)this.ContainerControl).Designer != null)
+ return false;
+ return base.DesignMode;
+ }
+ }
+
+ public class ControlContainerSerializationEventArgs : EventArgs
+ {
+ private readonly System.Xml.XmlElement xmlstore;
+ public ControlContainerSerializationEventArgs(System.Xml.XmlElement xmlstorage)
+ {
+ this.xmlstore=xmlstorage;
+ }
+ public System.Xml.XmlElement XmlStorage
+ {
+ get{return this.xmlstore;}
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/AnalogClockControl.bmp b/PROMS/DotNetBar Source Code/Controls/AnalogClockControl.bmp
new file mode 100644
index 00000000..783bb5c9
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/AnalogClockControl.bmp differ
diff --git a/PROMS/DotNetBar Source Code/Controls/BaseItemControl.cs b/PROMS/DotNetBar Source Code/Controls/BaseItemControl.cs
new file mode 100644
index 00000000..61796360
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/BaseItemControl.cs
@@ -0,0 +1,667 @@
+using System;
+using System.Text;
+using System.Windows.Forms;
+using System.Drawing;
+using System.ComponentModel;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+using DevComponents.DotNetBar.Rendering;
+using System.Reflection;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the class for the BaseItem non-popup based control host.
+ ///
+ [ToolboxItem(false)]
+ public abstract class BaseItemControl : Control
+ {
+ #region Private Variables
+ private BaseItem m_Item = null;
+ private ElementStyle m_BackgroundStyle = null;
+ private ColorScheme m_ColorScheme = null;
+ private bool m_DesignModeInternal = false;
+ private bool m_AntiAlias = true;
+ #endregion
+
+ #region Constructor Dispose
+ ///
+ /// Creates new instance of the object.
+ ///
+ public BaseItemControl()
+ {
+ if (!ColorFunctions.ColorsLoaded)
+ {
+ NativeFunctions.RefreshSettings();
+ NativeFunctions.OnDisplayChange();
+ ColorFunctions.LoadColors();
+ }
+
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(ControlStyles.StandardDoubleClick, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
+
+ m_ColorScheme = new ColorScheme(eDotNetBarStyle.Office2007);
+ m_BackgroundStyle = new ElementStyle();
+ m_BackgroundStyle.SetColorScheme(m_ColorScheme);
+ m_BackgroundStyle.StyleChanged += new EventHandler(this.VisualPropertyChanged);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && m_Item != null)
+ m_Item.Dispose();
+ base.Dispose(disposing);
+ }
+ #endregion
+
+ #region Internal Implementation
+
+ protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
+ {
+ if (Dpi.RecordScalePerControl)
+ Dpi.SetScaling(factor);
+ if (m_Item != null)
+ {
+ m_Item.NotifyScaleItem(factor);
+ RecalcLayout();
+ }
+ base.ScaleControl(factor, specified);
+ }
+
+ internal bool IsValidationCancelled
+ {
+ get
+ {
+ PropertyInfo pi=this.GetType().GetProperty("ValidationCancelled", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
+ if (pi != null)
+ return (bool)pi.GetValue(this, null);
+ return false;
+ }
+ }
+
+
+#if FRAMEWORK20
+ protected override void OnBindingContextChanged(EventArgs e)
+ {
+ base.OnBindingContextChanged(e);
+ if (m_Item != null)
+ m_Item.UpdateBindings();
+ }
+#endif
+
+ protected bool GetDesignMode()
+ {
+ if (!m_DesignModeInternal)
+ return this.DesignMode;
+ return m_DesignModeInternal;
+ }
+
+ protected virtual ElementStyle GetBackgroundStyle()
+ {
+ return m_BackgroundStyle;
+ }
+
+ internal void SetDesignMode(bool mode)
+ {
+ m_DesignModeInternal = mode;
+ if(m_Item!=null)
+ m_Item.SetDesignMode(mode);
+ }
+
+ ///
+ /// Gets or sets the instance of BaseItem object hosted by this control.
+ ///
+ protected virtual BaseItem HostItem
+ {
+ get { return m_Item; }
+ set
+ {
+ m_Item = value;
+ if (m_Item != null)
+ {
+ m_Item.Displayed = true;
+ m_Item.ContainerControl = this;
+ }
+ }
+ }
+
+ ///
+ /// Returns the color scheme used by control. Color scheme for Office2007 style will be retrieved from the current renderer instead of
+ /// local color scheme referenced by ColorScheme property.
+ ///
+ /// An instance of ColorScheme object.
+ protected virtual ColorScheme GetColorScheme()
+ {
+ if (m_Item != null && BarFunctions.IsOffice2007Style(m_Item.EffectiveStyle))
+ {
+ BaseRenderer r = GetRenderer();
+ if (r is Office2007Renderer)
+ return ((Office2007Renderer)r).ColorTable.LegacyColors;
+ }
+ return m_ColorScheme;
+ }
+
+ private bool _CallBasePaintBackground = true;
+ ///
+ /// Gets or sets whether during painting OnPaintBackground on base control is called when BackColor=Transparent.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool CallBasePaintBackground
+ {
+ get { return _CallBasePaintBackground; }
+ set
+ {
+ _CallBasePaintBackground = value;
+ }
+ }
+
+ internal void InternalPaint(PaintEventArgs e)
+ {
+ OnPaint(e);
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if ((this.BackColor.IsEmpty || this.BackColor == Color.Transparent) && _CallBasePaintBackground)
+ {
+ base.OnPaintBackground(e);
+ }
+
+ if (m_BackgroundStyle != null)
+ m_BackgroundStyle.SetColorScheme(this.GetColorScheme());
+
+ PaintBackground(e);
+ PaintControl(e);
+
+ if (this.Focused && /*this.ShowFocusCues &&*/ this.FocusCuesEnabled)
+ {
+ PaintFocusCues(e);
+ }
+
+ base.OnPaint(e);
+ }
+
+ private bool _FocusCuesEnabled = true;
+ ///
+ /// Gets or sets whether control displays focus cues when focused.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether control displays focus cues when focused.")]
+ public virtual bool FocusCuesEnabled
+ {
+ get { return _FocusCuesEnabled; }
+ set
+ {
+ _FocusCuesEnabled = value;
+ if (this.Focused) this.Invalidate();
+ }
+ }
+
+ ///
+ /// Paints the control focus cues.
+ ///
+ /// Paint event information.
+ protected virtual void PaintFocusCues(PaintEventArgs e)
+ {
+ ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
+ }
+
+ protected virtual void PaintBackground(PaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+ Rectangle r = this.ClientRectangle;
+ ElementStyle style = this.GetBackgroundStyle();
+
+ if (!this.BackColor.IsEmpty && this.BackColor != Color.Transparent)
+ {
+ DisplayHelp.FillRectangle(g, r, this.BackColor);
+ }
+
+ if (this.BackgroundImage != null)
+ base.OnPaintBackground(e);
+
+ if (style.Custom)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ if (m_AntiAlias)
+ g.SmoothingMode = SmoothingMode.HighQuality;
+ ElementStyleDisplayInfo displayInfo = new ElementStyleDisplayInfo(style, e.Graphics, r);
+ ElementStyleDisplay.Paint(displayInfo);
+ if (m_AntiAlias)
+ g.SmoothingMode = sm;
+ }
+ }
+
+ protected virtual void PaintControl(PaintEventArgs e)
+ {
+ SmoothingMode sm = e.Graphics.SmoothingMode;
+ TextRenderingHint th = e.Graphics.TextRenderingHint;
+ Graphics g = e.Graphics;
+
+ if (m_AntiAlias)
+ {
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+
+ ItemPaintArgs pa = GetItemPaintArgs(g);
+ pa.ClipRectangle = e.ClipRectangle;
+
+ if (m_Item != null) m_Item.Paint(pa);
+
+ if (m_AntiAlias)
+ {
+ g.SmoothingMode = sm;
+ g.TextRenderingHint = th;
+ }
+ }
+
+ ///
+ /// Creates the Graphics object for the control.
+ ///
+ /// The Graphics object for the control.
+ public new Graphics CreateGraphics()
+ {
+ Graphics g = base.CreateGraphics();
+ if (m_AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ #if FRAMEWORK20
+ if (!SystemInformation.IsFontSmoothingEnabled)
+ #endif
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+ return g;
+ }
+
+ protected virtual ItemPaintArgs GetItemPaintArgs(Graphics g)
+ {
+ ItemPaintArgs pa = new ItemPaintArgs(this as IOwner, this, g, GetColorScheme());
+ pa.Renderer = this.GetRenderer();
+ pa.DesignerSelection = false;
+ pa.GlassEnabled = !this.DesignMode && WinApi.IsGlassEnabled;
+ return pa;
+ }
+
+ private Rendering.BaseRenderer m_DefaultRenderer = null;
+ private Rendering.BaseRenderer m_Renderer = null;
+ private eRenderMode m_RenderMode = eRenderMode.Global;
+ ///
+ /// Returns the renderer control will be rendered with.
+ ///
+ /// The current renderer.
+ public virtual Rendering.BaseRenderer GetRenderer()
+ {
+ if (m_RenderMode == eRenderMode.Global && Rendering.GlobalManager.Renderer != null)
+ return Rendering.GlobalManager.Renderer;
+ else if (m_RenderMode == eRenderMode.Custom && m_Renderer != null)
+ return m_Renderer;
+
+ if (m_DefaultRenderer == null)
+ m_DefaultRenderer = new Rendering.Office2007Renderer();
+
+ return m_Renderer;
+ }
+
+ ///
+ /// Gets or sets the redering mode used by control. Default value is eRenderMode.Global which means that static GlobalManager.Renderer is used. If set to Custom then Renderer property must
+ /// also be set to the custom renderer that will be used.
+ ///
+ [Browsable(false), DefaultValue(eRenderMode.Global)]
+ public eRenderMode RenderMode
+ {
+ get { return m_RenderMode; }
+ set
+ {
+ if (m_RenderMode != value)
+ {
+ m_RenderMode = value;
+ this.Invalidate(true);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the custom renderer used by the items on this control. RenderMode property must also be set to eRenderMode.Custom in order renderer
+ /// specified here to be used.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public DevComponents.DotNetBar.Rendering.BaseRenderer Renderer
+ {
+ get
+ {
+ return m_Renderer;
+ }
+ set { m_Renderer = value; }
+ }
+
+ ///
+ /// Specifies the background style of the control.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Style"), Description("Gets or sets bar background style."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return m_BackgroundStyle; }
+ }
+
+ ///
+ /// Resets style to default value. Used by windows forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackgroundStyle()
+ {
+ m_BackgroundStyle.StyleChanged -= new EventHandler(this.VisualPropertyChanged);
+ m_BackgroundStyle = new ElementStyle();
+ m_BackgroundStyle.StyleChanged += new EventHandler(this.VisualPropertyChanged);
+ OnBackgroundStyleChanged();
+ this.Invalidate();
+ }
+
+ protected virtual void OnBackgroundStyleChanged()
+ {
+ }
+
+ private void VisualPropertyChanged(object sender, EventArgs e)
+ {
+ OnVisualPropertyChanged();
+ }
+
+ ///
+ /// Called when visual property of the control has changed so the control can be updated.
+ ///
+ protected virtual void OnVisualPropertyChanged()
+ {
+ if (this.GetDesignMode() ||
+ this.Parent != null && this.Parent.Site != null && this.Parent.Site.DesignMode)
+ {
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets Bar Color Scheme.
+ ///
+ [Browsable(false), DevCoBrowsable(false), Category("Appearance"), Description("Gets or sets Bar Color Scheme."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ColorScheme ColorScheme
+ {
+ get { return m_ColorScheme; }
+ set
+ {
+ if (value == null)
+ throw new ArgumentException("NULL is not a valid value for this property.");
+ m_ColorScheme = value;
+ if (this.Visible)
+ this.Refresh();
+ }
+ }
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeColorScheme()
+ {
+ return m_ColorScheme.SchemeChanged;
+ }
+
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting. Default value is false.
+ ///
+ [DefaultValue(true), Browsable(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting.")]
+ public bool AntiAlias
+ {
+ get { return m_AntiAlias; }
+ set
+ {
+ if (m_AntiAlias != value)
+ {
+ m_AntiAlias = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ protected override void OnParentChanged(EventArgs e)
+ {
+ base.OnParentChanged(e);
+ //if (this.Parent != null && (this.Images != null || this.ImagesLarge != null || this.ImagesMedium != null))
+ //{
+ // foreach (BaseItem panel in m_BaseItemContainer.SubItems)
+ // {
+ // foreach (BaseItem item in panel.SubItems)
+ // {
+ // if (item is ImageItem)
+ // ((ImageItem)item).OnImageChanged();
+ // }
+ // }
+ //}
+
+ if (this.DesignMode && m_Item!=null)
+ m_Item.SetDesignMode(this.DesignMode);
+ }
+
+ ///
+ /// Forces the button to perform internal layout.
+ ///
+ public virtual void RecalcLayout()
+ {
+ if (m_Item == null) return;
+
+ Rectangle r = GetItemBounds();
+ m_Item.Bounds = r;
+ this.RecalcSize();
+ m_Item.Bounds = r;
+ this.Invalidate();
+ }
+
+ ///
+ /// Recalculates the size of the internal item.
+ ///
+ protected virtual void RecalcSize()
+ {
+ m_Item.RecalcSize();
+ }
+
+ protected virtual Rectangle GetItemBounds()
+ {
+ Rectangle r = this.ClientRectangle;
+ r.X += ElementStyleLayout.LeftWhiteSpace(this.BackgroundStyle);
+ r.Width -= ElementStyleLayout.HorizontalStyleWhiteSpace(this.BackgroundStyle);
+ r.Y += ElementStyleLayout.TopWhiteSpace(this.BackgroundStyle);
+ r.Height -= ElementStyleLayout.VerticalStyleWhiteSpace(this.BackgroundStyle);
+
+ return r;
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ RecalcLayout();
+ base.OnResize(e);
+ }
+
+ protected override void OnTextChanged(EventArgs e)
+ {
+ m_Item.Text = this.Text;
+ this.RecalcLayout();
+ base.OnTextChanged(e);
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ base.OnFontChanged(e);
+ BarUtilities.InvalidateFontChange(m_Item);
+ this.RecalcLayout();
+ }
+
+ protected override void OnEnabledChanged(EventArgs e)
+ {
+ m_Item.Enabled = this.Enabled;
+ base.OnEnabledChanged(e);
+ }
+
+ private bool m_MouseFocus = false;
+ protected override void OnGotFocus(EventArgs e)
+ {
+ if (!m_MouseFocus)
+ m_Item.OnGotFocus();
+ m_MouseFocus = false;
+ base.OnGotFocus(e);
+ }
+
+ protected override void OnLostFocus(EventArgs e)
+ {
+ m_Item.OnLostFocus();
+ base.OnLostFocus(e);
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ m_Item.InternalMouseEnter();
+ base.OnMouseEnter(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ m_Item.InternalMouseMove(e);
+ base.OnMouseMove(e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ m_Item.InternalMouseLeave();
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseHover(EventArgs e)
+ {
+ m_Item.InternalMouseHover();
+ base.OnMouseHover(e);
+ }
+
+ protected virtual MouseButtons MouseDownFocusButtons
+ {
+ get { return MouseButtons.Left; }
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ if ((e.Button & MouseDownFocusButtons) != 0)
+ {
+ if (!this.Focused && this.GetStyle(ControlStyles.Selectable))
+ {
+ m_MouseFocus = true;
+ this.Select();
+ }
+ }
+
+ m_Item.InternalMouseDown(e);
+ base.OnMouseDown(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ m_Item.InternalMouseUp(e);
+ base.OnMouseUp(e);
+ }
+
+ protected override void OnClick(EventArgs e)
+ {
+ m_Item.InternalClick(Control.MouseButtons, this.PointToClient(Control.MousePosition));
+ base.OnClick(e);
+ }
+
+ protected override void OnDoubleClick(EventArgs e)
+ {
+ m_Item.InternalDoubleClick(Control.MouseButtons, this.PointToClient(Control.MousePosition));
+ base.OnDoubleClick(e);
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ m_Item.InternalKeyDown(e);
+ base.OnKeyDown(e);
+ }
+
+ ///
+ /// Gets/Sets the visual style for the control.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Specifies the visual style of the control."), DefaultValue(eDotNetBarStyle.Office2007)]
+ public virtual eDotNetBarStyle Style
+ {
+ get
+ {
+ return m_Item.Style;
+ }
+ set
+ {
+ m_Item.Style = value;
+ if(!BarFunctions.IsOffice2007Style(value))
+ this.GetColorScheme().Style = value;
+ this.RecalcLayout();
+ }
+ }
+
+ protected override bool ProcessMnemonic(char charCode)
+ {
+ if (IsMnemonic(charCode, m_Item.Text))
+ {
+ if (ProcessAccelerator())
+ return true;
+ }
+ return base.ProcessMnemonic(charCode);
+ }
+
+ protected virtual bool ProcessAccelerator()
+ {
+ m_Item.RaiseClick(eEventSource.Keyboard);
+ return true;
+ }
+ #endregion
+
+ #region Layout Support
+ private int m_UpdateSuspendCount = 0;
+ ///
+ /// Indicates to control that all further update operations should not result in layout and refresh of control content.
+ /// Use this method to optimize the addition of new items to the control. This method supports nested calls meaning
+ /// that multiple calls are allowed but they must be ended with appropriate number of EndUpdate calls.
+ /// IsUpdateSuspended property returns whether update is suspended.
+ ///
+ public void BeginUpdate()
+ {
+ m_UpdateSuspendCount++;
+ }
+
+ ///
+ /// Indicates that update operation is complete and that control should perform layout and refresh to show changes. See BeginUpdate
+ /// for more details.
+ ///
+ public void EndUpdate()
+ {
+ EndUpdate(true);
+ }
+
+ ///
+ /// Indicates that update operation is complete and that control should perform layout and refresh to show changes. See BeginUpdate
+ /// for more details.
+ ///
+ public void EndUpdate(bool callRecalcLayout)
+ {
+ if (m_UpdateSuspendCount > 0)
+ {
+ m_UpdateSuspendCount--;
+ if (m_UpdateSuspendCount == 0 && callRecalcLayout)
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets whether control layout is suspended becouse of the call to BeginUpdate method.
+ ///
+ [Browsable(false)]
+ public bool IsUpdateSuspended
+ {
+ get { return m_UpdateSuspendCount > 0; }
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/BindingNavigatorEx.cs b/PROMS/DotNetBar Source Code/Controls/BindingNavigatorEx.cs
new file mode 100644
index 00000000..c8f04a89
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/BindingNavigatorEx.cs
@@ -0,0 +1,671 @@
+using System.ComponentModel;
+
+using System.Globalization;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using DevComponents.DotNetBar;
+using System.Windows.Forms;
+using System;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Represents the bound data navigator in current DotNetBar style.
+ ///
+ [DefaultEvent("RefreshItems"), Description("DotNetBar Binding Navigator Control"), ClassInterface(ClassInterfaceType.AutoDispatch), DefaultProperty("BindingSource")]
+ [Designer("DevComponents.DotNetBar.Design.BindingNavigatorExDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ [ToolboxBitmap(typeof(BindingNavigatorEx), "Controls.BindingNavigatorEx.ico"), ToolboxItem(true)]
+ public class BindingNavigatorEx : Bar, ISupportInitialize
+ {
+ #region Private Variables
+ private ButtonItem _AddNewButton;
+ private bool _AddNewItemUserEnabled;
+ private BindingSource _BindingSource;
+ private LabelItem _CountLabel;
+ private string _CountLabelFormat;
+ private ButtonItem _DeleteButton;
+ private bool _DeleteButtonUserEnabled;
+ private bool _Initializing;
+ private ButtonItem _MoveFirstButton;
+ private ButtonItem _MoveLastButton;
+ private ButtonItem _MoveNextButton;
+ private ButtonItem _MovePreviousButton;
+ private TextBoxItem _PositionTextBox;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Creates new instance of BindingNavigatorEx
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public BindingNavigatorEx()
+ : this(false)
+ {
+ }
+ ///
+ /// Creates new instance of BindingNavigatorEx
+ ///
+ public BindingNavigatorEx(bool addStandardItems)
+ {
+ _CountLabelFormat = "of {0}";
+ _AddNewItemUserEnabled = true;
+ _DeleteButtonUserEnabled = true;
+ if (addStandardItems)
+ {
+ this.AddDefaultItems();
+ }
+ }
+ ///
+ /// Creates new instance of BindingNavigatorEx
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public BindingNavigatorEx(IContainer container)
+ : this(false)
+ {
+ if (container == null)
+ {
+ throw new ArgumentNullException("container");
+ }
+ container.Add(this);
+
+ }
+ ///
+ /// Creates new instance of BindingNavigatorEx
+ ///
+ public BindingNavigatorEx(BindingSource bindingSource)
+ : this(true)
+ {
+ this.BindingSource = bindingSource;
+ }
+ #endregion
+
+ #region Internal Implementation
+
+ private void AcceptNewPosition()
+ {
+ if (_PositionTextBox != null && _BindingSource != null)
+ {
+ int position = this._BindingSource.Position;
+ try
+ {
+ position = Convert.ToInt32(this._PositionTextBox.Text, CultureInfo.CurrentCulture) - 1;
+ }
+ catch (FormatException)
+ {
+ }
+ catch (OverflowException)
+ {
+ }
+ if (position != this._BindingSource.Position)
+ {
+ this._BindingSource.Position = position;
+ }
+ this.RefreshStateInternal();
+ }
+ }
+ ///
+ /// Adds default items that make up the binding navigation control.
+ ///
+ public virtual void AddDefaultItems()
+ {
+ this.MoveFirstButton = new ButtonItem();
+ this.MovePreviousButton = new ButtonItem();
+ this.MoveNextButton = new ButtonItem();
+ this.MoveLastButton = new ButtonItem();
+ this.PositionTextBox = new TextBoxItem();
+ this.CountLabel = new LabelItem();
+ this.AddNewRecordButton = new ButtonItem();
+ this.DeleteButton = new ButtonItem();
+ char ch = (string.IsNullOrEmpty(base.Name) || char.IsLower(base.Name[0])) ? 'b' : 'B';
+ this.MoveFirstButton.Name = ch + "indingNavigatorMoveFirstItem";
+ this.MovePreviousButton.Name = ch + "indingNavigatorMovePreviousItem";
+ this.MoveNextButton.Name = ch + "indingNavigatorMoveNextItem";
+ this.MoveLastButton.Name = ch + "indingNavigatorMoveLastItem";
+ this.PositionTextBox.Name = ch + "indingNavigatorPositionItem";
+ this.CountLabel.Name = ch + "indingNavigatorCountItem";
+ this.AddNewRecordButton.Name = ch + "indingNavigatorAddNewItem";
+ this.DeleteButton.Name = ch + "indingNavigatorDeleteItem";
+ this.MoveFirstButton.Text = "Move first";
+ this.MovePreviousButton.Text = "Move previous";
+ this.MoveNextButton.Text = "Move next";
+ this.MoveLastButton.Text = "Move last";
+ this.AddNewRecordButton.Text = "Add new";
+ this.DeleteButton.Text = "Delete";
+ this.PositionTextBox.AccessibleName = "Position";
+
+ _PositionTextBox.BeginGroup = true;
+ _MoveNextButton.BeginGroup = true;
+ _MoveFirstButton.Image = BarFunctions.LoadBitmap("SystemImages.FirstRecord.png");
+ _MovePreviousButton.Image = BarFunctions.LoadBitmap("SystemImages.PreviousRecord.png");
+ _MoveNextButton.Image = BarFunctions.LoadBitmap("SystemImages.NextRecord.png"); ;
+ _MoveLastButton.Image = BarFunctions.LoadBitmap("SystemImages.LastRecord.png"); ;
+ _AddNewButton.Image = BarFunctions.LoadBitmap("SystemImages.NewRecord.png"); ;
+ _DeleteButton.Image = BarFunctions.LoadBitmap("SystemImages.Delete.png"); ;
+
+ _PositionTextBox.TextBoxWidth = 54;
+ this.Items.AddRange(new BaseItem[] { this.MoveFirstButton, this.MovePreviousButton, this.PositionTextBox, this.CountLabel, this.MoveNextButton, this.MoveLastButton, this.AddNewRecordButton, this.DeleteButton });
+ }
+
+
+ private void CancelNewPosition()
+ {
+ this.RefreshStateInternal();
+ }
+
+ private bool _IsDisposing = false;
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ _IsDisposing = true;
+ try
+ {
+ this.BindingSource = null;
+ }
+ finally
+ {
+ _IsDisposing = false;
+ }
+ }
+ base.Dispose(disposing);
+ }
+
+ private void OnAddNew(object sender, EventArgs e)
+ {
+ if (this.Validate() && _BindingSource != null)
+ {
+ _BindingSource.EndEdit();
+ _BindingSource.AddNew();
+ RefreshStateInternal();
+ }
+ }
+
+ private void OnAddNewItemEnabledChanged(object sender, EventArgs e)
+ {
+ if (AddNewRecordButton != null)
+ {
+ _AddNewItemUserEnabled = _AddNewButton.Enabled;
+ }
+ }
+
+ private void OnBindingSourceListChanged(object sender, ListChangedEventArgs e)
+ {
+ RefreshStateInternal();
+ }
+
+ private void OnBindingSourceStateChanged(object sender, EventArgs e)
+ {
+ RefreshStateInternal();
+ }
+
+ private void OnDelete(object sender, EventArgs e)
+ {
+ if (this.Validate() && _BindingSource != null)
+ {
+ _BindingSource.RemoveCurrent();
+ RefreshStateInternal();
+ }
+ }
+
+ private void OnDeleteItemEnabledChanged(object sender, EventArgs e)
+ {
+ if (DeleteButton != null)
+ {
+ _DeleteButtonUserEnabled = _DeleteButton.Enabled;
+ }
+ }
+
+ private void OnMoveFirst(object sender, EventArgs e)
+ {
+ if (Validate() && _BindingSource != null)
+ {
+ _BindingSource.MoveFirst();
+ RefreshStateInternal();
+ }
+ }
+
+ private void OnMoveLast(object sender, EventArgs e)
+ {
+ if (Validate() && _BindingSource != null)
+ {
+ _BindingSource.MoveLast();
+ RefreshStateInternal();
+ }
+ }
+
+ private void OnMoveNext(object sender, EventArgs e)
+ {
+ if (Validate() && this._BindingSource != null)
+ {
+ _BindingSource.MoveNext();
+ RefreshStateInternal();
+ }
+ }
+
+ private void OnMovePrevious(object sender, EventArgs e)
+ {
+ if (Validate() && _BindingSource != null)
+ {
+ _BindingSource.MovePrevious();
+ RefreshStateInternal();
+ }
+ }
+
+ private void OnPositionKey(object sender, KeyEventArgs e)
+ {
+ Keys keyCode = e.KeyCode;
+ if (keyCode != Keys.Return)
+ {
+ if (keyCode != Keys.Escape)
+ {
+ return;
+ }
+ }
+ else
+ {
+ AcceptNewPosition();
+ return;
+ }
+ CancelNewPosition();
+ }
+
+ private void OnPositionLostFocus(object sender, EventArgs e)
+ {
+ AcceptNewPosition();
+ }
+
+ protected virtual void OnRefreshState()
+ {
+ RefreshState();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected virtual void RefreshState()
+ {
+ int count;
+ int currentPosition;
+ bool allowNew;
+ bool allowRemove;
+ if (_BindingSource == null)
+ {
+ count = 0;
+ currentPosition = 0;
+ allowNew = false;
+ allowRemove = false;
+ }
+ else if (_BindingSource.Position == -1)
+ {
+ count = -1;
+ currentPosition = -1;
+ allowNew = true;
+ allowRemove = false;
+ }
+ else
+ {
+ count = _BindingSource.Count;
+ currentPosition = _BindingSource.Position + 1;
+ allowNew = _BindingSource.AllowNew;
+ allowRemove = _BindingSource.AllowRemove;
+ }
+ if (!base.DesignMode)
+ {
+ if (MoveFirstButton != null)
+ {
+ _MoveFirstButton.Enabled = currentPosition > 1;
+ }
+ if (MovePreviousButton != null)
+ {
+ _MovePreviousButton.Enabled = currentPosition > 1;
+ }
+ if (MoveNextButton != null)
+ {
+ _MoveNextButton.Enabled = currentPosition < count;
+ }
+ if (MoveLastButton != null)
+ {
+ _MoveLastButton.Enabled = currentPosition < count;
+ }
+ if (AddNewRecordButton != null)
+ {
+ EventHandler handler = this.OnAddNewItemEnabledChanged;
+ _AddNewButton.EnabledChanged -= handler;
+ _AddNewButton.Enabled = _AddNewItemUserEnabled && allowNew;
+ _AddNewButton.EnabledChanged += handler;
+ }
+ if (DeleteButton != null)
+ {
+ EventHandler handler2 = OnDeleteItemEnabledChanged;
+ _DeleteButton.EnabledChanged -= handler2;
+ _DeleteButton.Enabled = (this._DeleteButtonUserEnabled && allowRemove) && (count > 0);
+ _DeleteButton.EnabledChanged += handler2;
+ }
+ if (PositionTextBox != null)
+ {
+ _PositionTextBox.Enabled = (currentPosition > 0) && (count > 0);
+ }
+ if (CountLabel != null)
+ {
+ _CountLabel.Enabled = count > 0;
+ }
+ }
+ if (_PositionTextBox != null)
+ {
+ _PositionTextBox.Text = currentPosition.ToString(CultureInfo.CurrentCulture);
+ }
+ if (_CountLabel != null)
+ {
+ _CountLabel.Text = base.DesignMode ? CountLabelFormat : string.Format(CultureInfo.CurrentCulture, CountLabelFormat, new object[] { count });
+ }
+ }
+
+ private void RefreshStateInternal()
+ {
+ if (!_Initializing && !_IsDisposing)
+ OnRefreshState();
+ }
+
+ public bool Validate()
+ {
+ bool flag = false;
+ System.Reflection.MethodInfo mi = ((Control)this).GetType().GetMethod("ValidateActiveControl", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
+ if (mi != null)
+ {
+ return (bool)mi.Invoke(this, new object[] { flag });
+ }
+ return true;
+ }
+
+ private void WireUpBindingSource(ref BindingSource oldBindingSource, BindingSource newBindingSource)
+ {
+ if (oldBindingSource != newBindingSource)
+ {
+ if (oldBindingSource != null)
+ {
+ oldBindingSource.PositionChanged -= OnBindingSourceStateChanged;
+ oldBindingSource.CurrentChanged -= OnBindingSourceStateChanged;
+ oldBindingSource.CurrentItemChanged -= OnBindingSourceStateChanged;
+ oldBindingSource.DataSourceChanged -= OnBindingSourceStateChanged;
+ oldBindingSource.DataMemberChanged -= OnBindingSourceStateChanged;
+ oldBindingSource.ListChanged -= OnBindingSourceListChanged;
+ }
+ if (newBindingSource != null)
+ {
+ newBindingSource.PositionChanged += OnBindingSourceStateChanged;
+ newBindingSource.CurrentChanged += OnBindingSourceStateChanged;
+ newBindingSource.CurrentItemChanged += OnBindingSourceStateChanged;
+ newBindingSource.DataSourceChanged += OnBindingSourceStateChanged;
+ newBindingSource.DataMemberChanged += OnBindingSourceStateChanged;
+ newBindingSource.ListChanged += OnBindingSourceListChanged;
+ }
+ oldBindingSource = newBindingSource;
+ this.RefreshStateInternal();
+ }
+ }
+
+ private void WireUpButton(ref ButtonItem oldButton, ButtonItem newButton, EventHandler clickHandler)
+ {
+ if (oldButton != newButton)
+ {
+ if (oldButton != null)
+ {
+ oldButton.Click -= clickHandler;
+ }
+ if (newButton != null)
+ {
+ newButton.Click += clickHandler;
+ }
+ oldButton = newButton;
+ this.RefreshStateInternal();
+ }
+ }
+
+ private void WireUpLabel(ref LabelItem oldLabel, LabelItem newLabel)
+ {
+ if (oldLabel != newLabel)
+ {
+ oldLabel = newLabel;
+ this.RefreshStateInternal();
+ }
+ }
+
+ private void WireUpTextBox(ref TextBoxItem oldTextBox, TextBoxItem newTextBox, KeyEventHandler keyUpHandler, EventHandler lostFocusHandler)
+ {
+ if (oldTextBox != newTextBox)
+ {
+ if (oldTextBox != null)
+ {
+ oldTextBox.KeyUp -= keyUpHandler;
+ oldTextBox.LostFocus -= lostFocusHandler;
+ }
+ if (newTextBox != null)
+ {
+ newTextBox.KeyUp += keyUpHandler;
+ newTextBox.LostFocus += lostFocusHandler;
+ }
+ oldTextBox = newTextBox;
+ this.RefreshStateInternal();
+ }
+ }
+
+ ///
+ /// Gets or sets the reference to Add New record button.
+ ///
+ [DefaultValue(null), Category("Items"), TypeConverter(typeof(ReferenceConverter)), Description("BindingNavigatorAddNewItemPropDescr")]
+ public ButtonItem AddNewRecordButton
+ {
+ get
+ {
+ if (_AddNewButton != null && _AddNewButton.IsDisposed)
+ {
+ _AddNewButton = null;
+ }
+ return _AddNewButton;
+ }
+ set
+ {
+ if ((_AddNewButton != value) && (value != null))
+ {
+ value.EnabledChanged += OnAddNewItemEnabledChanged;
+ _AddNewItemUserEnabled = value.Enabled;
+ }
+ WireUpButton(ref _AddNewButton, value, OnAddNew);
+ }
+ }
+
+ ///
+ /// Gets or sets the binding source for the navigator.
+ ///
+ [Category("Data"), Description("Gets or sets the binding source for the navigator."), DefaultValue((string)null), TypeConverter(typeof(ReferenceConverter))]
+ public BindingSource BindingSource
+ {
+ get
+ {
+ return _BindingSource;
+ }
+ set
+ {
+ WireUpBindingSource(ref _BindingSource, value);
+ }
+ }
+
+ ///
+ /// Gets or sets the label which represents the items count.
+ ///
+ [TypeConverter(typeof(ReferenceConverter)), Category("Items"), Description("Indicates label which represents the items count.")]
+ public LabelItem CountLabel
+ {
+ get
+ {
+ if (_CountLabel != null && _CountLabel.IsDisposed)
+ {
+ _CountLabel = null;
+ }
+ return _CountLabel;
+ }
+ set
+ {
+ this.WireUpLabel(ref _CountLabel, value);
+ }
+ }
+
+ ///
+ /// Indicates the format string for the label which displays the number of items bound.
+ ///
+ [Description("Indicates the format string for the label which displays the number of items bound."), Category("Appearance")]
+ public string CountLabelFormat
+ {
+ get
+ {
+ return _CountLabelFormat;
+ }
+ set
+ {
+ if (_CountLabelFormat != value)
+ {
+ _CountLabelFormat = value;
+ RefreshStateInternal();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the item which deletes current record.
+ ///
+ [DefaultValue(null), Description("Indicates item which deletes current record."), TypeConverter(typeof(ReferenceConverter)), Category("Items")]
+ public ButtonItem DeleteButton
+ {
+ get
+ {
+ if ((this._DeleteButton != null) && this._DeleteButton.IsDisposed)
+ {
+ _DeleteButton = null;
+ }
+ return _DeleteButton;
+ }
+ set
+ {
+ if ((this._DeleteButton != value) && (value != null))
+ {
+ value.EnabledChanged += new EventHandler(this.OnDeleteItemEnabledChanged);
+ _DeleteButtonUserEnabled = value.Enabled;
+ }
+ this.WireUpButton(ref _DeleteButton, value, new EventHandler(this.OnDelete));
+ }
+ }
+
+ ///
+ /// Gets or sets the item which moves to first record.
+ ///
+ [DefaultValue(null), TypeConverter(typeof(ReferenceConverter)), Category("Items"), Description("Indicates item which moves to first record.")]
+ public ButtonItem MoveFirstButton
+ {
+ get
+ {
+ if (_MoveFirstButton != null && _MoveFirstButton.IsDisposed)
+ {
+ _MoveFirstButton = null;
+ }
+ return _MoveFirstButton;
+ }
+ set
+ {
+ WireUpButton(ref _MoveFirstButton, value, this.OnMoveFirst);
+ }
+ }
+ ///
+ /// Gets or sets the item which moves to last record.
+ ///
+ [DefaultValue(null), Category("Items"), Description("Indicates item which moves to last record."), TypeConverter(typeof(ReferenceConverter))]
+ public ButtonItem MoveLastButton
+ {
+ get
+ {
+ if ((_MoveLastButton != null) && _MoveLastButton.IsDisposed)
+ {
+ _MoveLastButton = null;
+ }
+ return _MoveLastButton;
+ }
+ set
+ {
+ this.WireUpButton(ref _MoveLastButton, value, OnMoveLast);
+ }
+ }
+ ///
+ /// Gets or sets the item which moves to next record.
+ ///
+ [DefaultValue(null), TypeConverter(typeof(ReferenceConverter)), Category("Items"), Description("Indicates item which moves to next record")]
+ public ButtonItem MoveNextButton
+ {
+ get
+ {
+ if (_MoveNextButton != null && _MoveNextButton.IsDisposed)
+ {
+ _MoveNextButton = null;
+ }
+ return _MoveNextButton;
+ }
+ set
+ {
+ this.WireUpButton(ref _MoveNextButton, value, new EventHandler(this.OnMoveNext));
+ }
+ }
+ ///
+ /// Gets or sets the item which moves to previous record.
+ ///
+ [DefaultValue(null), Description("Indicates item which moves to previous record"), TypeConverter(typeof(ReferenceConverter)), Category("Items")]
+ public ButtonItem MovePreviousButton
+ {
+ get
+ {
+ if (_MovePreviousButton != null && this._MovePreviousButton.IsDisposed)
+ {
+ _MovePreviousButton = null;
+ }
+ return _MovePreviousButton;
+ }
+ set
+ {
+ this.WireUpButton(ref _MovePreviousButton, value, OnMovePrevious);
+ }
+ }
+ ///
+ /// Gets or sets the text-box which shows current position.
+ ///
+ [DefaultValue(null), Category("Items"), Description("Indicates text-box which shows current position."), TypeConverter(typeof(ReferenceConverter))]
+ public TextBoxItem PositionTextBox
+ {
+ get
+ {
+ if (_PositionTextBox != null && _PositionTextBox.IsDisposed)
+ {
+ _PositionTextBox = null;
+ }
+ return _PositionTextBox;
+ }
+ set
+ {
+ this.WireUpTextBox(ref _PositionTextBox, value, OnPositionKey, OnPositionLostFocus);
+ }
+ }
+ #endregion
+
+ #region ISupportInitialize Members
+
+ void ISupportInitialize.BeginInit()
+ {
+ _Initializing = true;
+ }
+
+ void ISupportInitialize.EndInit()
+ {
+
+ _Initializing = false;
+ this.RefreshStateInternal();
+ }
+
+
+ #endregion
+
+ }
+}
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/Controls/BindingNavigatorEx.ico b/PROMS/DotNetBar Source Code/Controls/BindingNavigatorEx.ico
new file mode 100644
index 00000000..732ac22e
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/BindingNavigatorEx.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/CheckBoxX.cs b/PROMS/DotNetBar Source Code/Controls/CheckBoxX.cs
new file mode 100644
index 00000000..4e0270de
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/CheckBoxX.cs
@@ -0,0 +1,786 @@
+using System;
+using System.Text;
+using System.Drawing;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Represents the Check Box control with extended styles.
+ ///
+ [ToolboxBitmap(typeof(CheckBoxX), "Controls.CheckBoxX.ico"), ToolboxItem(true), DefaultEvent("CheckedChanged"), System.Runtime.InteropServices.ComVisible(false), Designer("DevComponents.DotNetBar.Design.CheckBoxXDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class CheckBoxX : BaseItemControl, ICommandSource
+ {
+ #region Private Variables
+ private const string DefaultCheckValueUnchecked = "N";
+ private const string DefaultCheckValueChecked = "Y";
+ private const object DefaultCheckValueIndeterminate = null;
+
+ private CheckBoxItem m_CheckBox = null;
+ private object m_CheckValue = DefaultCheckValueUnchecked;
+
+ private object m_CheckValueUnchecked = DefaultCheckValueUnchecked;
+ private object m_CheckValueChecked = DefaultCheckValueChecked;
+ private object m_CheckValueIndeterminate = DefaultCheckValueIndeterminate;
+ private bool m_ConsiderEmptyStringAsNull = true;
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs before Checked property is changed and allows you to cancel the change.
+ ///
+ public event CheckBoxXChangeEventHandler CheckedChanging;
+
+ ///
+ /// Occurs after Checked property is changed with extended information.
+ ///
+ public event CheckBoxXChangeEventHandler CheckedChangedEx;
+
+ ///
+ /// Occurs after Checked property is changed. This event is provided for the Windows Forms data binding support. You can use CheckedChangedEx to get extended information about the changed.
+ ///
+ public event EventHandler CheckedChanged;
+
+ ///
+ /// Occurs after Checked property is changed. This event is provided for the Windows Forms data binding support. You can use CheckedChangedEx to get extended information about the changed.
+ ///
+ public event EventHandler CheckValueChanged;
+ #endregion
+
+ #region Constructor, Dispose
+ public CheckBoxX()
+ {
+ this.SetStyle(ControlStyles.Selectable, true);
+ m_CheckBox = new CheckBoxItem();
+ m_CheckBox.VerticalPadding = 0;
+ m_CheckBox.Style = eDotNetBarStyle.Office2007;
+ m_CheckBox.CheckedChanging += new CheckBoxChangeEventHandler(OnCheckedChanging);
+ m_CheckBox.CheckedChanged += new CheckBoxChangeEventHandler(OnCheckedChanged);
+ this.HostItem = m_CheckBox;
+ }
+
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Gets or sets the size of the check or radio sign. Default value is 13x13. Minimum value is 6x6.
+ ///
+ [Category("Appearance"), Description("Indicates size of the check or radio sign. Default value is 13x13.")]
+ public Size CheckSignSize
+ {
+ get { return m_CheckBox.CheckSignSize; }
+ set { m_CheckBox.CheckSignSize = value; this.RecalcLayout(); this.Invalidate(); }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeCheckSignSize()
+ {
+ return m_CheckBox.ShouldSerializeCheckSignSize();
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetCheckSignSize()
+ {
+ this.CheckSignSize = new Size(13, 13);
+ }
+
+ ///
+ /// Gets or sets whether text-markup support is enabled for controls Text property. Default value is true.
+ /// Set this property to false to display HTML or other markup in the control instead of it being parsed as text-markup.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether text-markup support is enabled for controls Text property.")]
+ public bool EnableMarkup
+ {
+ get { return m_CheckBox.EnableMarkup; }
+ set
+ {
+ m_CheckBox.EnableMarkup = value;
+ }
+ }
+ protected override MouseButtons MouseDownFocusButtons
+ {
+ get { return MouseButtons.Left | MouseButtons.Right | MouseButtons.Middle | MouseButtons.XButton1 | MouseButtons.XButton2; }
+ }
+ //protected override void OnMouseDown(MouseEventArgs e)
+ //{
+ // if (!this.Focused)
+ // this.Select();
+ // base.OnMouseDown(e);
+ //}
+
+ //protected override void OnEnter(EventArgs e)
+ //{
+ // if (this.CheckBoxStyle == eCheckBoxStyle.RadioButton && Control.MouseButtons == MouseButtons.None && WinApi.GetKeyState(9) < 0 && this.AutoCheck)
+ // {
+ // m_CheckBox.SetChecked(true, eEventSource.Keyboard);
+ // }
+ // base.OnEnter(e);
+ //}
+
+ ///
+ /// Invokes the CheckedChanged event.
+ ///
+ private void OnCheckedChanged(object sender, CheckBoxChangeEventArgs e)
+ {
+ CheckBoxX previous = null;
+ if (m_CheckBox.CheckBoxStyle == eCheckBoxStyle.RadioButton && m_CheckBox.Checked && this.Parent != null)
+ {
+ foreach (Control c in this.Parent.Controls)
+ {
+ if (c == this)
+ {
+ //c.TabStop = true;
+ continue;
+ }
+ CheckBoxX b = c as CheckBoxX;
+ if (b != null && b.Checked && b.CheckBoxStyle == eCheckBoxStyle.RadioButton)
+ {
+ b.Checked = false;
+ //b.TabStop = false;
+ previous = b;
+ }
+ }
+ }
+
+ if (this.Command != null)
+ this.Command.Checked = this.Checked;
+
+ CheckBoxXChangeEventArgs e1 = new CheckBoxXChangeEventArgs(previous, this, e.EventSource);
+
+ if (CheckedChangedEx != null)
+ CheckedChangedEx(this, e1);
+
+ if (CheckedChanged != null)
+ CheckedChanged(this, new EventArgs());
+
+ if (GetCheckState(m_CheckValue) != this.CheckState)
+ m_CheckValue = GetCheckValue(this.CheckState);
+
+ if (CheckValueChanged != null)
+ CheckValueChanged(this, new EventArgs());
+
+ ExecuteCommand();
+ }
+
+ ///
+ /// Invokes CheckedChanging event.
+ ///
+ private void OnCheckedChanging(object sender, CheckBoxChangeEventArgs e)
+ {
+ CheckBoxXChangeEventArgs e1 = new CheckBoxXChangeEventArgs(null, this, e.EventSource);
+
+ if (m_CheckBox.CheckBoxStyle == eCheckBoxStyle.RadioButton && !m_CheckBox.Checked && this.Parent != null)
+ {
+ CheckBoxX b = null;
+ foreach (Control c in this.Parent.Controls)
+ {
+ if (c == this)
+ continue;
+ b = c as CheckBoxX;
+ if (b != null && b.Checked && b.CheckBoxStyle == eCheckBoxStyle.RadioButton)
+ {
+ break;
+ }
+ }
+ e1 = new CheckBoxXChangeEventArgs(b, this, e.EventSource);
+ }
+
+ if (CheckedChanging != null)
+ {
+ CheckedChanging(this, e1);
+ e.Cancel = e1.Cancel;
+ }
+ }
+
+ ///
+ /// Gets or sets the appearance style of the item. Default value is CheckBox. Item can also assume the style of radio-button.
+ ///
+ [Browsable(true), DefaultValue(eCheckBoxStyle.CheckBox), Category("Appearance"), Description("Indicates appearance style of the item. Default value is CheckBox. Item can also assume the style of radio-button.")]
+ public eCheckBoxStyle CheckBoxStyle
+ {
+ get { return m_CheckBox.CheckBoxStyle; }
+ set
+ {
+ m_CheckBox.CheckBoxStyle = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the check box position relative to the text. Default value is Left.
+ ///
+ [Browsable(true), DefaultValue(eCheckBoxPosition.Left), Category("Appearance"), Description("Indicates the check box position relative to the text.")]
+ public eCheckBoxPosition CheckBoxPosition
+ {
+ get { return m_CheckBox.CheckBoxPosition; }
+ set
+ {
+ m_CheckBox.CheckBoxPosition = value;
+ }
+ }
+
+ ///
+ /// Gets or set a value indicating whether the button is in the checked state.
+ ///
+ [Browsable(true), Bindable(true), DevCoBrowsable(true), Category("Appearance"), Description("Indicates whether item is checked or not."), DefaultValue(false)]
+ public virtual bool Checked
+ {
+ get
+ {
+ return m_CheckBox.Checked;
+ }
+ set
+ {
+ m_CheckBox.Checked = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether text assigned to the check box is visible. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether text assigned to the check box is visible.")]
+ public bool TextVisible
+ {
+ get { return m_CheckBox.TextVisible; }
+ set
+ {
+ m_CheckBox.TextVisible = value;
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets the text color. Default value is Color.Empty which indicates that default color is used.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates text color.")]
+ public Color TextColor
+ {
+ get { return m_CheckBox.TextColor; }
+ set
+ {
+ m_CheckBox.TextColor = value;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTextColor()
+ {
+ return !m_CheckBox.TextColor.IsEmpty;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTextColor()
+ {
+ this.TextColor = Color.Empty;
+ }
+
+ [Browsable(false)]
+ public override Color ForeColor
+ {
+ get
+ {
+ return base.ForeColor;
+ }
+ set
+ {
+ base.ForeColor = value;
+ }
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Space && this.Enabled && this.AutoCheck)
+ {
+ if (this.CheckBoxStyle == eCheckBoxStyle.CheckBox)
+ SetChecked(!this.Checked, eEventSource.Keyboard);
+ else if (!this.Checked)
+ SetChecked(true, eEventSource.Keyboard);
+ }
+ base.OnKeyDown(e);
+ }
+
+ private void SetChecked(bool newValue, eEventSource source)
+ {
+ m_CheckBox.SetChecked(newValue, source);
+ }
+
+ private void SetChecked(CheckState newValue, eEventSource source)
+ {
+ m_CheckBox.SetChecked(newValue, source);
+ }
+
+ ///
+ /// Gets or sets the text associated with the control.
+ ///
+ [Browsable(true), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Category("Appearance"), Description("Indicates text associated with this button.."), Localizable(true), DefaultValue("")]
+ public override string Text
+ {
+ get { return base.Text; }
+ set { base.Text = value; }
+ }
+
+#if FRAMEWORK20
+ [Localizable(true), Browsable(false)]
+ public new System.Windows.Forms.Padding Padding
+ {
+ get { return base.Padding; }
+ set { base.Padding = value; }
+ }
+
+ public override Size GetPreferredSize(Size proposedSize)
+ {
+ if (!BarFunctions.IsHandleValid(this))
+ return base.GetPreferredSize(proposedSize);
+ if (this.Text.Length == 0)
+ return base.GetPreferredSize(proposedSize);
+
+ m_CheckBox.RecalcSize();
+ Size s = m_CheckBox.Size;
+ s.Width += 2;
+ s.Height += 2;
+ if (!this.TextVisible) s.Width += 2;
+ m_CheckBox.Bounds = GetItemBounds();
+ return s;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the control is automatically resized to display its entire contents. You can set MaximumSize.Width property to set the maximum width used by the control.
+ ///
+ [Browsable(true), DefaultValue(false), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public override bool AutoSize
+ {
+ get
+ {
+ return base.AutoSize;
+ }
+ set
+ {
+ if (this.AutoSize != value)
+ {
+ base.AutoSize = value;
+ AdjustSize();
+ }
+ }
+ }
+
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ if (this.AutoSize)
+ {
+ Size preferredSize = base.PreferredSize;
+ width = preferredSize.Width;
+ height = preferredSize.Height;
+ }
+ base.SetBoundsCore(x, y, width, height, specified);
+ }
+
+ private void AdjustSize()
+ {
+ if (this.AutoSize)
+ {
+ this.Size = base.PreferredSize;
+ }
+ }
+
+ protected override void OnTextChanged(EventArgs e)
+ {
+ base.OnTextChanged(e);
+ this.AdjustSize();
+ }
+
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ base.OnHandleCreated(e);
+ if (this.AutoSize)
+ this.AdjustSize();
+ }
+#endif
+
+ ///
+ /// Gets or sets a value indicating whether the CheckBox will allow three check states rather than two. If the ThreeState property is set to true
+ /// CheckState property should be used instead of Checked property to set the extended state of the control.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(false), Description("Indicates whether the CheckBox will allow three check states rather than two.")]
+ public bool ThreeState
+ {
+ get { return m_CheckBox.ThreeState; }
+ set { m_CheckBox.ThreeState = value; }
+ }
+
+ ///
+ /// Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(CheckState.Unchecked), Description("Specifies the state of a control, such as a check box, that can be checked, unchecked, or set to an indeterminate state")]
+ public CheckState CheckState
+ {
+ get { return m_CheckBox.CheckState; }
+ set { m_CheckBox.CheckState = value; }
+ }
+
+ ///
+ /// Gets the underlying CheckBoxItem
+ ///
+ internal CheckBoxItem CheckBoxItem
+ {
+ get { return (m_CheckBox); }
+ }
+
+ private bool _EnableMnemonicWithAltKeyOnly = false;
+ ///
+ /// Gets or sets whether mnemonic character assigned to control is processed only if Alt key is pressed. Default value is false which indicate that Alt key is not required.
+ ///
+ [DefaultValue(false), Category("Behavior"), Description("Indicates whether mnemonic character assigned to control is processed only if Alt key is pressed")]
+ public bool EnableMnemonicWithAltKeyOnly
+ {
+ get { return _EnableMnemonicWithAltKeyOnly; }
+ set
+ {
+ _EnableMnemonicWithAltKeyOnly = value;
+ }
+ }
+
+ protected override bool ProcessMnemonic(char charCode)
+ {
+ if (AutoCheck && CanSelect && IsMnemonic(charCode, this.Text) && this.Enabled &&
+ (!_EnableMnemonicWithAltKeyOnly || Control.ModifierKeys == Keys.Alt || this.Focused) && !m_CheckBox.IsUsingTextMarkup)
+ {
+ if (Focus())
+ {
+ if (this.CheckBoxStyle == eCheckBoxStyle.CheckBox)
+ SetChecked(!this.Checked, eEventSource.Keyboard);
+ else if (!this.Checked)
+ SetChecked(true, eEventSource.Keyboard);
+ return true;
+ }
+ }
+ return false;
+ }
+ #endregion
+
+ #region Data-Binding Support
+ ///
+ /// Gets or set whether the Checked values and the item appearance are automatically changed when the Check-Box is clicked. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether the Checked values and the item appearance are automatically changed when the Check-Box is clicked.")]
+ public bool AutoCheck
+ {
+ get { return m_CheckBox.AutoCheck; }
+ set
+ {
+ m_CheckBox.AutoCheck = value;
+ }
+ }
+ ///
+ /// Gets or sets the object that represents the Checked state of control.
+ ///
+ [DefaultValue("N"), Bindable(true), RefreshProperties(RefreshProperties.All), TypeConverter(typeof(StringConverter)), Description("Indicates object that represents the Checked state of control.")]
+ public object CheckValue
+ {
+ get { return m_CheckValue; }
+ set
+ {
+ m_CheckValue = value;
+ OnCheckValueChanged();
+ }
+ }
+
+ private void OnCheckValueChanged()
+ {
+ CheckState cs = GetCheckState(m_CheckValue);
+ this.CheckState = cs;
+ }
+
+ private bool IsNull(object value)
+ {
+ return value == null || value is string && (string)value == string.Empty && m_ConsiderEmptyStringAsNull ||
+ value == DBNull.Value;
+ }
+
+ private object GetCheckValue(CheckState cs)
+ {
+ if (cs == CheckState.Indeterminate)
+ return m_CheckValueIndeterminate;
+
+ if (cs == CheckState.Unchecked)
+ return m_CheckValueUnchecked;
+
+ return m_CheckValueChecked;
+ }
+
+ private CheckState GetCheckState(object value)
+ {
+ if (m_CheckValueIndeterminate == null && IsNull(value) || m_CheckValueIndeterminate!=null && m_CheckValueIndeterminate.Equals(value))
+ {
+ return CheckState.Indeterminate;
+ }
+ else if (m_CheckValueChecked == null && IsNull(value) || m_CheckValueChecked!=null && m_CheckValueChecked.Equals(value))
+ {
+ return CheckState.Checked;
+ }
+ else if (m_CheckValueUnchecked == null && IsNull(value) || m_CheckValueUnchecked!=null && m_CheckValueUnchecked.Equals(value))
+ {
+ return CheckState.Unchecked;
+ }
+ else
+ {
+ if (value is System.Data.SqlTypes.SqlBoolean)
+ {
+ System.Data.SqlTypes.SqlBoolean sqlBool = (System.Data.SqlTypes.SqlBoolean)value;
+ if (sqlBool.IsTrue)
+ return CheckState.Checked;
+ else if (sqlBool.IsNull)
+ return CheckState.Indeterminate;
+ else
+ return CheckState.Unchecked;
+ }
+ else if (value is int? && this.ThreeState)
+ {
+ if (value == null) return CheckState.Indeterminate;
+ if (((int?)value).Value == 0)
+ return CheckState.Unchecked;
+ return CheckState.Checked;
+ }
+ else if (value is int)
+ {
+ if (this.ThreeState && (int)value == -1)
+ return CheckState.Indeterminate;
+ return ((int)value) == 0 ? CheckState.Unchecked : CheckState.Checked;
+ }
+ else if (value is long)
+ {
+ if (this.ThreeState && (long)value == -1)
+ return CheckState.Indeterminate;
+ return ((long)value) == 0 ? CheckState.Unchecked : CheckState.Checked;
+ }
+ else if (value is short)
+ {
+ if (this.ThreeState && (short)value == -1)
+ return CheckState.Indeterminate;
+ return ((short)value) == 0 ? CheckState.Unchecked : CheckState.Checked;
+ }
+ else if (value is float)
+ {
+ if (this.ThreeState && (float)value == -1)
+ return CheckState.Indeterminate;
+ return ((float)value) == 0 ? CheckState.Unchecked : CheckState.Checked;
+ }
+ else if (value is double)
+ {
+ if (this.ThreeState && (double)value == -1)
+ return CheckState.Indeterminate;
+ return ((double)value) == 0 ? CheckState.Unchecked : CheckState.Checked;
+ }
+ else if (value is byte)
+ {
+ return ((byte)value) == 0 ? CheckState.Unchecked : CheckState.Checked;
+ }
+ else if (value is uint)
+ {
+ return ((uint)value) == 0 ? CheckState.Unchecked : CheckState.Checked;
+ }
+ else if (value is ulong)
+ {
+ return ((ulong)value) == 0 ? CheckState.Unchecked : CheckState.Checked;
+ }
+ else if (value is bool)
+ {
+ return ((bool)value) == false ? CheckState.Unchecked : CheckState.Checked;
+ }
+
+ return CheckState.Indeterminate;
+ }
+ }
+
+ ///
+ /// Gets or sets whether empty string is consider as null value during CheckValue value comparison. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Browsable(true), Description("Indicates whether empty string is consider as null value during CheckValue value comparison.")]
+ public bool ConsiderEmptyStringAsNull
+ {
+ get { return m_ConsiderEmptyStringAsNull; }
+ set { m_ConsiderEmptyStringAsNull = value; }
+ }
+
+ ///
+ /// Gets or sets the value that represents the Indeterminate state of check box when CheckValue property is set to that value. Default value is null.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Behavior"), TypeConverter(typeof(StringConverter)), Description("Represents the Indeterminate state value of check box when CheckValue property is set to that value")]
+ public object CheckValueIndeterminate
+ {
+ get { return m_CheckValueIndeterminate; }
+ set { m_CheckValueIndeterminate = value; OnCheckValueChanged(); }
+ }
+
+ ///
+ /// Gets or sets the value that represents the Checked state of check box when CheckValue property is set to that value. Default value is null.
+ ///
+ [Browsable(true), DefaultValue("Y"), Category("Behavior"), TypeConverter(typeof(StringConverter)), Description("Represents the Checked state value of check box when CheckValue property is set to that value")]
+ public object CheckValueChecked
+ {
+ get { return m_CheckValueChecked; }
+ set { m_CheckValueChecked = value; OnCheckValueChanged(); }
+ }
+
+ ///
+ /// Gets or sets the value that represents the Unchecked state of check box when CheckValue property is set to that value. Default value is null.
+ ///
+ [Browsable(true), DefaultValue("N"), Category("Behavior"), TypeConverter(typeof(StringConverter)), Description("Represents the Unchecked state value of check box when CheckValue property is set to that value")]
+ public object CheckValueUnchecked
+ {
+ get { return m_CheckValueUnchecked; }
+ set { m_CheckValueUnchecked = value; OnCheckValueChanged(); }
+ }
+
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box is checked.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box is checked")]
+ public Image CheckBoxImageChecked
+ {
+ get { return m_CheckBox.CheckBoxImageChecked; }
+ set
+ {
+ m_CheckBox.CheckBoxImageChecked = value;
+ }
+ }
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box is unchecked.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box is unchecked")]
+ public Image CheckBoxImageUnChecked
+ {
+ get { return m_CheckBox.CheckBoxImageUnChecked; }
+ set
+ {
+ m_CheckBox.CheckBoxImageUnChecked = value;
+ }
+ }
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box is in indeterminate state.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box is in indeterminate state")]
+ public Image CheckBoxImageIndeterminate
+ {
+ get { return m_CheckBox.CheckBoxImageIndeterminate; }
+ set
+ {
+ m_CheckBox.CheckBoxImageIndeterminate = value;
+ }
+ }
+ #endregion
+
+ #region ICommandSource Members
+ protected virtual void ExecuteCommand()
+ {
+ if (_Command == null) return;
+ CommandManager.ExecuteCommand(this);
+ }
+
+ ///
+ /// Gets or sets the command assigned to the item. Default value is null.
+ /// Note that if this property is set to null Enabled property will be set to false automatically to disable the item.
+ ///
+ [DefaultValue(null), Category("Commands"), Description("Indicates the command assigned to the item.")]
+ public Command Command
+ {
+ get { return (Command)((ICommandSource)this).Command; }
+ set
+ {
+ ((ICommandSource)this).Command = value;
+ }
+ }
+
+ private ICommand _Command = null;
+ //[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ ICommand ICommandSource.Command
+ {
+ get
+ {
+ return _Command;
+ }
+ set
+ {
+ bool changed = false;
+ if (_Command != value)
+ changed = true;
+
+ if (_Command != null)
+ CommandManager.UnRegisterCommandSource(this, _Command);
+ _Command = value;
+ if (value != null)
+ CommandManager.RegisterCommand(this, value);
+ if (changed)
+ OnCommandChanged();
+ }
+ }
+
+ ///
+ /// Called when Command property value changes.
+ ///
+ protected virtual void OnCommandChanged()
+ {
+ Command command = this.Command;
+ if (command != null && command.Checked != this.Checked)
+ {
+ SetChecked(command.Checked, eEventSource.Code);
+ }
+ }
+
+ private object _CommandParameter = null;
+ ///
+ /// Gets or sets user defined data value that can be passed to the command when it is executed.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Commands"), Description("Indicates user defined data value that can be passed to the command when it is executed."), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)), System.ComponentModel.Localizable(true)]
+ public object CommandParameter
+ {
+ get
+ {
+ return _CommandParameter;
+ }
+ set
+ {
+ _CommandParameter = value;
+ }
+ }
+
+ #endregion
+ }
+
+ ///
+ /// Delegate for OptionGroupChanging event.
+ ///
+ public delegate void CheckBoxXChangeEventHandler(object sender, CheckBoxXChangeEventArgs e);
+
+ #region CheckBoxXChangeEventArgs
+ ///
+ /// Represents event arguments for OptionGroupChanging event.
+ ///
+ public class CheckBoxXChangeEventArgs : EventArgs
+ {
+ ///
+ /// Set to true to cancel the checking on NewChecked button.
+ ///
+ public bool Cancel = false;
+ ///
+ /// Check-box that will become checked if operation is not cancelled.
+ ///
+ public readonly CheckBoxX NewChecked;
+ ///
+ /// Check-box that is currently checked and which will be unchecked if operation is not cancelled. This property will have only valid values for eCheckBoxStyle.RadioButton style CheckBoxItems.
+ ///
+ public readonly CheckBoxX OldChecked;
+ ///
+ /// Indicates the action that has caused the event.
+ ///
+ public readonly eEventSource EventSource = eEventSource.Code;
+
+ ///
+ /// Default constructor.
+ ///
+ public CheckBoxXChangeEventArgs(CheckBoxX oldchecked, CheckBoxX newchecked, eEventSource eventSource)
+ {
+ NewChecked = newchecked;
+ OldChecked = oldchecked;
+ EventSource = eventSource;
+ }
+ }
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/CheckBoxX.ico b/PROMS/DotNetBar Source Code/Controls/CheckBoxX.ico
new file mode 100644
index 00000000..4d82de2b
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/CheckBoxX.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/CircularProgress.cs b/PROMS/DotNetBar Source Code/Controls/CircularProgress.cs
new file mode 100644
index 00000000..f9e6a162
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/CircularProgress.cs
@@ -0,0 +1,474 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(CircularProgress), "Controls.CircularProgress.ico"), ToolboxItem(true), DefaultEvent("ValueChanged")]
+ public class CircularProgress : BaseItemControl
+ {
+ #region Constructor
+ private CircularProgressItem _Item = null;
+ ///
+ /// Initializes a new instance of the CircularProgress class.
+ ///
+ public CircularProgress()
+ {
+ _Item = new CircularProgressItem();
+ _Item.ValueChanged += new EventHandler(ItemValueChanged);
+ _Item.TextVisible = false;
+ this.HostItem = _Item;
+ }
+ #endregion
+
+ #region Implementation
+ protected override void Dispose(bool disposing)
+ {
+ _Item.Dispose();
+ base.Dispose(disposing);
+ }
+ protected override void RecalcSize()
+ {
+ _Item.Diameter = Math.Min(this.Width, this.Height);
+ base.RecalcSize();
+ }
+ private void ItemValueChanged(object sender, EventArgs e)
+ {
+ OnValueChanged(e);
+ }
+ ///
+ /// Occurs when Value property has changed.
+ ///
+ public event EventHandler ValueChanged;
+ ///
+ /// Raises ValueChanged event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnValueChanged(EventArgs e)
+ {
+ EventHandler handler = ValueChanged;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Gets or sets the circular progress bar type.
+ ///
+ [DefaultValue(eCircularProgressType.Line), Category("Appearance"), Description("Indicates circular progress bar type.")]
+ public eCircularProgressType ProgressBarType
+ {
+ get { return _Item.ProgressBarType; }
+ set
+ {
+ _Item.ProgressBarType = value;
+ }
+ }
+ ///
+ /// Gets or sets the maximum value of the progress bar.
+ ///
+ [Description("Indicates maximum value of the progress bar."), Category("Behavior"), DefaultValue(100)]
+ public int Maximum
+ {
+ get { return _Item.Maximum; }
+ set
+ {
+ _Item.Maximum = value;
+ }
+ }
+ ///
+ /// Gets or sets the minimum value of the progress bar.
+ ///
+ [Description("Indicates minimum value of the progress bar."), Category("Behavior"), DefaultValue(0)]
+ public int Minimum
+ {
+ get { return _Item.Minimum; }
+ set
+ {
+ _Item.Minimum = value;
+ }
+ }
+ ///
+ /// Gets or sets the color of the progress percentage text.
+ ///
+ [Category("Appearance"), Description("Indicates color of progress percentage text")]
+ public Color ProgressTextColor
+ {
+ get { return _Item.ProgressTextColor; }
+ set { _Item.ProgressTextColor = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeProgressTextColor()
+ {
+ return _Item.ShouldSerializeProgressTextColor();
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetProgressTextColor()
+ {
+ _Item.ResetProgressTextColor();
+ }
+
+ ///
+ /// Gets or sets whether text that displays the progress bar completion percentage text is visible. Default value is false.
+ ///
+ [DefaultValue(false), Category("Appearance"), Description("Indicates whether text that displays the progress bar completion percentage text is visible")]
+ public bool ProgressTextVisible
+ {
+ get { return _Item.ProgressTextVisible; }
+ set
+ {
+ _Item.ProgressTextVisible = value;
+ }
+ }
+ ///
+ /// Gets or sets the text displayed on top of the circular progress bar.
+ ///
+ [DefaultValue(""), Category("Appearance"), Description("Indicates text displayed on top of the circular progress bar.")]
+ public string ProgressText
+ {
+ get { return _Item.ProgressText; }
+ set
+ {
+ _Item.ProgressText = value;
+ }
+ }
+ ///
+ /// Gets or sets the current value of the progress bar.
+ ///
+ [Description("Indicates current value of the progress bar."), Category("Behavior"), DefaultValue(0)]
+ public int Value
+ {
+ get { return _Item.Value; }
+ set
+ {
+ _Item.Value = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether endless type progress bar is running.
+ ///
+ [Browsable(false), DefaultValue(false)]
+ public bool IsRunning
+ {
+ get { return _Item.IsRunning; }
+ set
+ {
+ _Item.IsRunning = value;
+ }
+ }
+ ///
+ /// Gets or sets the color of the color of progress indicator.
+ ///
+ [Category("Columns"), Description("Indicates color of progress indicator.")]
+ public Color ProgressColor
+ {
+ get { return _Item.ProgressColor; }
+ set { _Item.ProgressColor = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeProgressColor()
+ {
+ return _Item.ShouldSerializeProgressColor();
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetProgressColor()
+ {
+ _Item.ResetProgressColor();
+ }
+
+ /////
+ ///// Gets or sets circular progress indicator diameter in pixels.
+ /////
+ //[DefaultValue(24), Category("Appearance"), Description("Indicates circular progress indicator diameter in pixels.")]
+ //public int Diameter
+ //{
+ // get { return _Item.Diameter; }
+ // set
+ // {
+ // _Item.Diameter = value;
+ // this.RecalcLayout();
+ // }
+ //}
+ /////
+ ///// Gets or sets the text position in relation to the circular progress indicator.
+ /////
+ //[DefaultValue(eTextPosition.Left), Category("Appearance"), Description("Indicatesd text position in relation to the circular progress indicator.")]
+ //public eTextPosition TextPosition
+ //{
+ // get { return _Item.TextPosition; }
+ // set
+ // {
+ // _Item.TextPosition = value;
+ // }
+ //}
+ /////
+ ///// Gets or sets whether text/label displayed next to the item is visible.
+ /////
+ //[DefaultValue(true), Category("Appearance"), Description("Indicates whether caption/label set using Text property is visible.")]
+ //public bool TextVisible
+ //{
+ // get { return _Item.TextVisible; }
+ // set
+ // {
+ // _Item.TextVisible = value;
+ // }
+ //}
+ /////
+ ///// Gets or sets the suggested text-width. If you want to make sure that text you set wraps over multiple lines you can set suggested text-width so word break is performed.
+ /////
+ //[DefaultValue(0), Category("Appearance"), Description("Indicates suggested text-width. If you want to make sure that text you set wraps over multiple lines you can set suggested text-width so word break is performed.")]
+ //public int TextWidth
+ //{
+ // get { return _Item.TextWidth; }
+ // set
+ // {
+ // _Item.TextWidth = value;
+ // }
+ //}
+
+ /////
+ ///// Gets or sets text padding.
+ /////
+ //[Browsable(true), Category("Appearance"), Description("Gets or sets text padding."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ //public Padding TextPadding
+ //{
+ // get { return _Item.TextPadding; }
+ //}
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public bool ShouldSerializeTextPadding()
+ //{
+ // return _Item.ShouldSerializeTextPadding();
+ //}
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public void ResetTextPadding()
+ //{
+ // _Item.ResetTextPadding();
+ //}
+
+ //protected override void OnForeColorChanged(EventArgs e)
+ //{
+ // _Item.TextColor = this.ForeColor;
+ // base.OnForeColorChanged(e);
+ //}
+
+ ///
+ /// Gets or sets the color of the pie progress bar dark border.
+ ///
+ [Category("Pie"), Description("Indicates color of pie progress bar dark border.")]
+ public Color PieBorderDark
+ {
+ get { return _Item.PieBorderDark; }
+ set { _Item.PieBorderDark = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializePieBorderDark()
+ {
+ return _Item.ShouldSerializePieBorderDark();
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetPieBorderDark()
+ {
+ _Item.ResetPieBorderDark();
+ }
+ ///
+ /// Gets or sets the color of the pie progress bar light border.
+ ///
+ [Category("Pie"), Description("Indicates color of pie progress bar light border. ")]
+ public Color PieBorderLight
+ {
+ get { return _Item.PieBorderLight; }
+ set { _Item.PieBorderLight = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializePieBorderLight()
+ {
+ return _Item.ShouldSerializePieBorderLight();
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetPieBorderLight()
+ {
+ _Item.ResetPieBorderLight();
+ }
+
+ ///
+ /// Gets or sets the color of the spoke progress bar dark border.
+ ///
+ [Category("Spoke"), Description("Indicates color of spoke progress bar dark border.")]
+ public Color SpokeBorderDark
+ {
+ get { return _Item.SpokeBorderDark; }
+ set { _Item.SpokeBorderDark = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSpokeBorderDark()
+ {
+ return _Item.ShouldSerializeSpokeBorderDark();
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSpokeBorderDark()
+ {
+ _Item.ResetSpokeBorderDark();
+ }
+ ///
+ /// Gets or sets the color of the spoke progress bar light border.
+ ///
+ [Category("Spoke"), Description("Indicates color of spoke progress bar light border..")]
+ public Color SpokeBorderLight
+ {
+ get { return _Item.SpokeBorderLight; }
+ set { _Item.SpokeBorderLight = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSpokeBorderLight()
+ {
+ return _Item.ShouldSerializeSpokeBorderLight();
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSpokeBorderLight()
+ {
+ _Item.ResetSpokeBorderLight();
+ }
+
+ ///
+ /// Gets or sets format string for progress value.
+ ///
+ [DefaultValue("{0}%"), Category("Appearance"), Description("Indicates format string for progress value.")]
+ public string ProgressTextFormat
+ {
+ get { return _Item.ProgressTextFormat; }
+ set
+ {
+ _Item.ProgressTextFormat = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the animation speed for endless running progress. Lower number means faster running.
+ ///
+ [DefaultValue(100), Description("Indicates the animation speed for endless running progress. Lower number means faster running."), Category("Behavior")]
+ public int AnimationSpeed
+ {
+ get
+ {
+ return _Item.AnimationSpeed;
+ }
+ set
+ {
+ _Item.AnimationSpeed = value;
+ }
+ }
+
+ ///
+ /// Starts the progress bar loop for endless type progress bar. Progress bar will continue to run until Stop() method is called.
+ ///
+ public void Start()
+ {
+ _Item.Start();
+ }
+
+ ///
+ /// Stops the progress bar loop for endless type progress bar.
+ ///
+ public void Stop()
+ {
+ _Item.Stop(false);
+ }
+ #endregion
+
+ #region Property-Hiding
+ [Browsable(false)]
+ public override eDotNetBarStyle Style
+ {
+ get { return base.Style; }
+ set { base.Style = value;}
+ }
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override Color ForeColor
+ {
+ get { return base.ForeColor; }
+ set { base.ForeColor = value; }
+ }
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override RightToLeft RightToLeft
+ {
+ get { return base.RightToLeft; }
+ set { base.RightToLeft = value; }
+ }
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override string Text
+ {
+ get
+ {
+ return base.Text;
+ }
+ set
+ {
+ base.Text = value;
+ }
+ }
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override Image BackgroundImage
+ {
+ get
+ {
+ return base.BackgroundImage;
+ }
+ set
+ {
+ base.BackgroundImage = value;
+ }
+ }
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override ImageLayout BackgroundImageLayout
+ {
+ get
+ {
+ return base.BackgroundImageLayout;
+ }
+ set
+ {
+ base.BackgroundImageLayout = value;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/CircularProgress.ico b/PROMS/DotNetBar Source Code/Controls/CircularProgress.ico
new file mode 100644
index 00000000..83dae94e
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/CircularProgress.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/CollapsibleSplitContainer.cs b/PROMS/DotNetBar Source Code/Controls/CollapsibleSplitContainer.cs
new file mode 100644
index 00000000..2a5f91dd
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/CollapsibleSplitContainer.cs
@@ -0,0 +1,558 @@
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.Editors;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Reflection;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(CollapsibleSplitContainer), "Controls.CollapsibleSplitContainer.ico")]
+ public class CollapsibleSplitContainer : SplitContainer
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the CollapsibleSplitContainer class.
+ ///
+ public CollapsibleSplitContainer()
+ {
+ ControlStyles cs = ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer;
+ this.SetStyle(cs, true);
+ object[] objArgs = new object[] { cs, true };
+ MethodInfo mi = typeof(Control).GetMethod("SetStyle", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (mi != null)
+ {
+ mi.Invoke(this.Panel1, objArgs);
+ mi.Invoke(this.Panel2, objArgs);
+ }
+ this.SplitterWidth = 20;
+ _OverrideCursorPropInfo = typeof(SplitContainer).GetProperty("OverrideCursor", BindingFlags.NonPublic | BindingFlags.Instance);
+
+ this.SplitterMoved += SplitterMovedHandler;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ this.SplitterMoved -= SplitterMovedHandler;
+ base.Dispose(disposing);
+ }
+ #endregion
+
+ #region Implementation
+ private Rectangle _NearCollapseButton = Rectangle.Empty;
+ private Rectangle _FarCollapseButton = Rectangle.Empty;
+ private eButtonState _NearCollapseButtonState = eButtonState.Normal, _FarCollapseButtonState = eButtonState.Normal;
+ private const int ButtonSpacing = 2;
+
+ private void UpdateButtonLayout()
+ {
+ Rectangle r = this.SplitterRectangle;
+ Size buttonSize = new Size(this.SplitterWidth, this.SplitterWidth);
+ if (this.Orientation == System.Windows.Forms.Orientation.Horizontal)
+ {
+ if (_ButtonPosition == eSplitterButtonPosition.Near)
+ {
+ _NearCollapseButton = new Rectangle(r.X, r.Y, buttonSize.Width, buttonSize.Height);
+ _FarCollapseButton = new Rectangle(_NearCollapseButton.Right + ButtonSpacing, r.Y, buttonSize.Width, buttonSize.Height);
+ }
+ else if (_ButtonPosition == eSplitterButtonPosition.Center)
+ {
+ _NearCollapseButton = new Rectangle(r.X + (r.Width - (buttonSize.Width * 2 + ButtonSpacing)) / 2, r.Y, buttonSize.Width, buttonSize.Height);
+ _FarCollapseButton = new Rectangle(_NearCollapseButton.Right + ButtonSpacing, r.Y, buttonSize.Width, buttonSize.Height);
+ }
+ else if (_ButtonPosition == eSplitterButtonPosition.Far)
+ {
+ _NearCollapseButton = new Rectangle(r.Right - buttonSize.Width * 2 - ButtonSpacing, r.Y, buttonSize.Width, buttonSize.Height);
+ _FarCollapseButton = new Rectangle(_NearCollapseButton.Right + ButtonSpacing, r.Y, buttonSize.Width, buttonSize.Height);
+ }
+ }
+ else
+ {
+ if (_ButtonPosition == eSplitterButtonPosition.Near)
+ {
+ _NearCollapseButton = new Rectangle(r.X, r.Y, buttonSize.Width, buttonSize.Height);
+ _FarCollapseButton = new Rectangle(r.X, _NearCollapseButton.Bottom + ButtonSpacing, buttonSize.Width, buttonSize.Height);
+ }
+ else if (_ButtonPosition == eSplitterButtonPosition.Center)
+ {
+ _NearCollapseButton = new Rectangle(r.X, r.Y + (r.Height - (buttonSize.Height * 2 + ButtonSpacing)) / 2, buttonSize.Width, buttonSize.Height);
+ _FarCollapseButton = new Rectangle(r.X, _NearCollapseButton.Bottom + ButtonSpacing, buttonSize.Width, buttonSize.Height);
+ }
+ else if (_ButtonPosition == eSplitterButtonPosition.Far)
+ {
+ _NearCollapseButton = new Rectangle(r.X, r.Bottom - buttonSize.Height * 2 - ButtonSpacing, buttonSize.Width, buttonSize.Height);
+ _FarCollapseButton = new Rectangle(r.X, _NearCollapseButton.Bottom + ButtonSpacing, buttonSize.Width, buttonSize.Height);
+ }
+ }
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ UpdateButtonLayout();
+
+ base.OnPaint(e);
+
+ Graphics g = e.Graphics;
+ bool isHorizontal = this.Orientation == System.Windows.Forms.Orientation.Horizontal;
+
+ if (_NearCollapseButtonState != eButtonState.Hidden)
+ {
+ Office2007ButtonItemStateColorTable ct = GetOffice2007StateColorTable(_NearCollapseButtonState);
+ Office2007ButtonItemPainter.PaintBackground(g, ct, _NearCollapseButton, RoundRectangleShapeDescriptor.RectangleShape);
+ Rectangle r = _NearCollapseButton;
+ r.Inflate(-2, -2);
+ TextDrawing.DrawStringLegacy(g, isHorizontal ? "\uf077" : "\uf053", Symbols.GetFont(9f, eSymbolSet.Awesome),
+ ct.Text, r, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter);
+ }
+ if (_FarCollapseButtonState != eButtonState.Hidden)
+ {
+ Office2007ButtonItemStateColorTable ct = GetOffice2007StateColorTable(_FarCollapseButtonState);
+ Office2007ButtonItemPainter.PaintBackground(g, ct, _FarCollapseButton, RoundRectangleShapeDescriptor.RectangleShape);
+ Rectangle r = _FarCollapseButton;
+ r.Inflate(-2, -2);
+ TextDrawing.DrawStringLegacy(g, isHorizontal ? "\uf078" : "\uf054", Symbols.GetFont(9f, eSymbolSet.Awesome),
+ ct.Text, r, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter);
+ }
+
+
+ }
+
+ protected Office2007ButtonItemStateColorTable GetOffice2007StateColorTable(eButtonState state)
+ {
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ Office2007ColorTable ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
+ Office2007ButtonItemColorTable buttonColorTable = ct.ButtonItemColors[Enum.GetName(typeof(eButtonColor), eButtonColor.OrangeWithBackground)];
+ if (!this.Enabled || state == eButtonState.Disabled)
+ return buttonColorTable.Disabled;
+ else if (state == eButtonState.MouseDownLeft)
+ return buttonColorTable.Pressed;
+ else if (state == eButtonState.MouseOver)
+ return buttonColorTable.MouseOver;
+ else
+ return buttonColorTable.Default;
+ }
+
+ return null;
+ }
+
+ private Orientation _CurrentOrientation = Orientation.Vertical;
+ protected override void OnLayout(LayoutEventArgs e)
+ {
+ base.OnLayout(e);
+
+ if (_CurrentOrientation != this.Orientation)
+ {
+ _CurrentOrientation = this.Orientation;
+ UpdateButtonLayout();
+ }
+ Invalidate();
+ }
+
+ private bool IsButtonActive(eButtonState state)
+ {
+ return state != eButtonState.Hidden && state != eButtonState.Disabled;
+ }
+ private Cursor _OriginalCursor = null;
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ if (IsButtonActive(_NearCollapseButtonState))
+ {
+ if (_NearCollapseButton.Contains(e.Location))
+ {
+ if (_NearCollapseButtonState == eButtonState.Normal)
+ {
+ _NearCollapseButtonState = eButtonState.MouseOver;
+ this.Invalidate();
+ }
+ }
+ else
+ {
+ _NearCollapseButtonState = eButtonState.Normal;
+ this.Invalidate();
+ }
+ }
+ if (IsButtonActive(_FarCollapseButtonState))
+ {
+ if (_FarCollapseButton.Contains(e.Location))
+ {
+ if (_FarCollapseButtonState == eButtonState.Normal)
+ {
+ _FarCollapseButtonState = eButtonState.MouseOver;
+ this.Invalidate();
+ }
+ }
+ else
+ {
+ _FarCollapseButtonState = eButtonState.Normal;
+ this.Invalidate();
+ }
+ }
+ if (_NearCollapseButton.Contains(e.Location) || _FarCollapseButton.Contains(e.Location))
+ {
+ if (_OriginalCursor == null && _OverrideCursorPropInfo != null)
+ {
+ _OriginalCursor = (Cursor)_OverrideCursorPropInfo.GetValue(this, null);
+ _OverrideCursorPropInfo.SetValue(this, Cursors.Default, null);
+ }
+ return;
+ }
+
+ RestoreOriginalCursor();
+
+ base.OnMouseMove(e);
+ }
+
+ private PropertyInfo _OverrideCursorPropInfo = null;
+ private void RestoreOriginalCursor()
+ {
+ if (_OriginalCursor != null)
+ {
+ _OverrideCursorPropInfo.SetValue(this, _OriginalCursor, null); ;
+ _OriginalCursor = null;
+ }
+ }
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ if (IsButtonActive(_NearCollapseButtonState))
+ {
+ if (_NearCollapseButton.Contains(e.Location) && e.Button == System.Windows.Forms.MouseButtons.Left)
+ {
+ _NearCollapseButtonState = eButtonState.MouseDownLeft;
+ this.Invalidate();
+ }
+ }
+ if (IsButtonActive(_FarCollapseButtonState))
+ {
+ if (_FarCollapseButton.Contains(e.Location) && e.Button == System.Windows.Forms.MouseButtons.Left)
+ {
+ _FarCollapseButtonState = eButtonState.MouseDownLeft;
+ this.Invalidate();
+ }
+ }
+ if (_NearCollapseButton.Contains(e.Location) || _FarCollapseButton.Contains(e.Location))
+ return;
+ base.OnMouseDown(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ if (IsButtonActive(_NearCollapseButtonState))
+ {
+ if (_NearCollapseButton.Contains(e.Location))
+ {
+ if (_NearCollapseButtonState == eButtonState.MouseDownLeft)
+ {
+ _NearCollapseButtonState = eButtonState.MouseOver;
+ // Trigger button action
+ NearCollapseButtonClick();
+ }
+ this.Invalidate();
+ }
+ }
+ if (IsButtonActive(_FarCollapseButtonState))
+ {
+ if (_FarCollapseButton.Contains(e.Location))
+ {
+ if (_FarCollapseButtonState == eButtonState.MouseDownLeft)
+ {
+ _FarCollapseButtonState = eButtonState.MouseOver;
+ // Trigger button action
+ FarCollapseButtonClick();
+ }
+ this.Invalidate();
+ }
+ }
+
+ if (_NearCollapseButton.Contains(e.Location) || _FarCollapseButton.Contains(e.Location))
+ return;
+
+ base.OnMouseUp(e);
+ }
+
+ protected override void OnKeyUp(KeyEventArgs e)
+ {
+ base.OnKeyUp(e);
+ this.Invalidate();
+ }
+
+ //
+ /// Occurs before near collapse button is clicked and allows you to cancel its action.
+ ///
+ [Description("Occurs before near collapse button is clicked and allows you to cancel its action.")]
+ public event CancelEventHandler BeforeNearCollapseButtonClick;
+ ///
+ /// Raises BeforeNearCollapseButtonClick event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnBeforeNearCollapseButtonClick(CancelEventArgs e)
+ {
+ CancelEventHandler handler = BeforeNearCollapseButtonClick;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Occurs after near collapse button is clicked.
+ ///
+ [Description("Occurs after near collapse button is clicked.")]
+ public event EventHandler NearCollapseButtonClicked;
+ ///
+ /// Raises NearCollapseButtonClick event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnNearCollapseButtonClicked(EventArgs e)
+ {
+ EventHandler handler = NearCollapseButtonClicked;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ private int _OriginalSplitterDistance = 0;
+ private bool _IsPanel1Minimized = false;
+ private bool _IsPanel2Minimized = false;
+ private bool _InternalDistanceChange = false;
+ private void NearCollapseButtonClick()
+ {
+ CancelEventArgs e = new CancelEventArgs();
+ OnBeforeNearCollapseButtonClick(e);
+ if (e.Cancel) return;
+
+ if (_CollapseMode == eCollapseMode.PanelMinSize)
+ {
+ _InternalDistanceChange = true;
+ try
+ {
+ if (_IsPanel2Minimized)
+ {
+ this.SplitterDistance = _OriginalSplitterDistance;
+ _IsPanel2Minimized = false;
+ _FarCollapseButtonState = eButtonState.Normal;
+ }
+ else if (!_IsPanel1Minimized)
+ {
+ _OriginalSplitterDistance = this.SplitterDistance;
+ this.SplitterDistance = this.Panel1MinSize;
+ _IsPanel1Minimized = true;
+ _NearCollapseButtonState = eButtonState.Disabled;
+ }
+ }
+ finally
+ {
+ _InternalDistanceChange = false;
+ }
+ }
+ else
+ {
+ this.Panel1Collapsed = true;
+ }
+
+ OnNearCollapseButtonClicked(EventArgs.Empty);
+ }
+
+ ///
+ /// Occurs before far collapse button is clicked and allows you to cancel its action.
+ ///
+ [Description("Occurs before far collapse button is clicked and allows you to cancel its action.")]
+ public event CancelEventHandler BeforeFarCollapseButtonClick;
+ ///
+ /// Raises BeforeFarCollapseButtonClick event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnBeforeFarCollapseButtonClick(CancelEventArgs e)
+ {
+ CancelEventHandler handler = BeforeFarCollapseButtonClick;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Occurs after far collapse button is clicked.
+ ///
+ [Description("Occurs after far collapse button is clicked.")]
+ public event EventHandler FarCollapseButtonClicked;
+ ///
+ /// Raises FarCollapseButtonClick event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnFarCollapseButtonClicked(EventArgs e)
+ {
+ EventHandler handler = FarCollapseButtonClicked;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ private void FarCollapseButtonClick()
+ {
+ CancelEventArgs e=new CancelEventArgs();
+ OnBeforeFarCollapseButtonClick(e);
+ if (e.Cancel) return;
+
+ if (_CollapseMode == eCollapseMode.PanelMinSize)
+ {
+ _InternalDistanceChange = true;
+
+ try
+ {
+ if (_IsPanel1Minimized)
+ {
+ this.SplitterDistance = _OriginalSplitterDistance;
+ _IsPanel1Minimized = false;
+ _NearCollapseButtonState = eButtonState.Normal;
+ }
+ else if (!_IsPanel2Minimized)
+ {
+ _OriginalSplitterDistance = this.SplitterDistance;
+ if (this.Orientation == System.Windows.Forms.Orientation.Vertical)
+ this.SplitterDistance = this.Width - this.Panel2MinSize;
+ else
+ this.SplitterDistance = this.Height - this.Panel2MinSize;
+ _IsPanel2Minimized = true;
+ _FarCollapseButtonState = eButtonState.Disabled;
+ }
+ }
+ finally
+ {
+ _InternalDistanceChange = false;
+ }
+ }
+ else
+ {
+ this.Panel2Collapsed = true;
+ }
+
+ OnFarCollapseButtonClicked(EventArgs.Empty);
+ }
+
+ private void SplitterMovedHandler(object sender, SplitterEventArgs e)
+ {
+ if (_InternalDistanceChange) return;
+ if(_IsPanel1Minimized)
+ {
+ _IsPanel1Minimized = false;
+ _NearCollapseButtonState = eButtonState.Normal;
+ }
+ else if (_IsPanel2Minimized)
+ {
+ _IsPanel2Minimized = false;
+ _FarCollapseButtonState = eButtonState.Normal;
+ }
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ base.OnMouseEnter(e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ if (IsButtonActive(_NearCollapseButtonState))
+ {
+ _NearCollapseButtonState = eButtonState.Normal;
+ }
+ if (IsButtonActive(_FarCollapseButtonState))
+ {
+ _FarCollapseButtonState = eButtonState.Normal;
+ }
+ RestoreOriginalCursor();
+ Invalidate();
+ base.OnMouseLeave(e);
+ }
+
+ private eSplitterButtonPosition _ButtonPosition = eSplitterButtonPosition.Near;
+ ///
+ /// Indicates position of buttons inside container.
+ ///
+ [DefaultValue(eSplitterButtonPosition.Near), Category("Appearance"), Description("Indicates position of buttons inside container.")]
+ public eSplitterButtonPosition ButtonPosition
+ {
+ get { return _ButtonPosition; }
+ set
+ {
+ if (value != _ButtonPosition)
+ {
+ eSplitterButtonPosition oldValue = _ButtonPosition;
+ _ButtonPosition = value;
+ OnButtonPositionChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when ButtonPosition property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnButtonPositionChanged(eSplitterButtonPosition oldValue, eSplitterButtonPosition newValue)
+ {
+ UpdateButtonLayout();
+ this.Invalidate();
+ //OnPropertyChanged(new PropertyChangedEventArgs("ButtonPosition"));
+ }
+
+ private eCollapseMode _CollapseMode = eCollapseMode.PanelMinSize;
+ ///
+ /// Specifies how panels are collapsed when collapse buttons are pressed.
+ ///
+ [DefaultValue(eCollapseMode.PanelMinSize), Category("Behavior"), Description("Specifies how panels are collapsed when collapse buttons are pressed.")]
+ public eCollapseMode CollapseMode
+ {
+ get { return _CollapseMode; }
+ set
+ {
+ if (value !=_CollapseMode)
+ {
+ eCollapseMode oldValue = _CollapseMode;
+ _CollapseMode = value;
+ OnCollapseModeChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when CollapseMode property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnCollapseModeChanged(eCollapseMode oldValue, eCollapseMode newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("CollapseMode"));
+ }
+ #endregion
+ }
+
+ ///
+ /// Defines available positions for buttons inside CollapsibleSplitterContainer.
+ ///
+ public enum eSplitterButtonPosition
+ {
+ ///
+ /// Buttons are positioned on left or top side depending on orientation.
+ ///
+ Near,
+ ///
+ /// Buttons are positioned in center of container.
+ ///
+ Center,
+ ///
+ /// Buttons are positioned on right or bottom side depending on orientation.
+ ///
+ Far,
+ }
+
+ ///
+ /// Defines collapse mode for the CollapsibleSplitContainer control.
+ ///
+ public enum eCollapseMode
+ {
+ ///
+ /// When buttons are pressed the splitter is positioned at the PanelMinSize.
+ ///
+ PanelMinSize,
+ ///
+ /// When buttons are pressed associated panel is collapsed through Panel1Collapsed or Panel2Collapsed properties.
+ ///
+ PanelCollapse
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/CollapsibleSplitContainer.ico b/PROMS/DotNetBar Source Code/Controls/CollapsibleSplitContainer.ico
new file mode 100644
index 00000000..8d7682bc
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/CollapsibleSplitContainer.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/ColorPickerButton.cs b/PROMS/DotNetBar Source Code/Controls/ColorPickerButton.cs
new file mode 100644
index 00000000..4b01ea46
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/ColorPickerButton.cs
@@ -0,0 +1,240 @@
+using System;
+using System.Text;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Represents the color picker button control.
+ ///
+ [ToolboxBitmap(typeof(ColorPickerButton), "Controls.ColorPickerButton.ico"), ToolboxItem(true), DefaultEvent("SelectedColorChanged"), Designer("DevComponents.DotNetBar.Design.ColorPickerButtonDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false)]
+ public class ColorPickerButton : ButtonX
+ {
+ #region Private Variables
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs when color is chosen from drop-down color picker or from Custom Colors dialog box. Selected color can be accessed through SelectedColor property.
+ ///
+ [Description("Occurs when color is chosen from drop-down color picker or from Custom Colors dialog box.")]
+ public event EventHandler SelectedColorChanged;
+
+ ///
+ /// Occurs when mouse is moving over the colors presented by the color picker. You can use it to preview the color before it is selected.
+ ///
+ [Description("Occurs when mouse is moving over the colors presented by the color picker")]
+ public event ColorPreviewEventHandler ColorPreview;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Creates new instance of the object.
+ ///
+ public ColorPickerButton()
+ : base()
+ {
+ ColorPickerDropDown cp = GetColorPickerDropDown();
+ cp.SelectedColorChanged += new EventHandler(InternalSelectedColorChanged);
+ cp.ColorPreview += new ColorPreviewEventHandler(InternalColorPreview);
+ }
+ #endregion
+
+ #region Internal Implementation
+#if FRAMEWORK20
+ ///
+ /// Gets or sets the array of ColorItem objects that will be used as standard colors instead of built-in color palette.
+ /// See: http://www.devcomponents.com/kb2/?p=79 for instructions.
+ ///
+ [DefaultValue(null), Browsable(false), Category("Colors"), Description("Array of ColorItem objects that will be used as standard colors instead of built-in color palette.")]
+ public ColorItem[][] CustomStandardColors
+ {
+ get { return GetColorPickerDropDown().CustomStandardColors; }
+ set
+ {
+ GetColorPickerDropDown().CustomStandardColors = value;
+ }
+ }
+ ///
+ /// Gets or sets the array of ColorItem objects that will be used as theme colors instead of built-in color palette.
+ /// See: http://www.devcomponents.com/kb2/?p=79 for instructions.
+ ///
+ [DefaultValue(null), Browsable(false), Category("Colors"), Description("Array of ColorItem objects that will be used as theme colors instead of built-in color palette.")]
+ public ColorItem[][] CustomThemeColors
+ {
+ get { return GetColorPickerDropDown().CustomThemeColors; }
+ set
+ {
+ GetColorPickerDropDown().CustomThemeColors = value;
+ }
+ }
+#endif
+
+ ///
+ /// Displays the Colors dialog that allows user to choose the color or create a custom color. If new color is chosen the
+ /// SelectedColorChanged event is raised.
+ ///
+ public System.Windows.Forms.DialogResult DisplayMoreColorsDialog()
+ {
+ return GetColorPickerDropDown().DisplayMoreColorsDialog();
+ }
+
+ protected override ButtonItem CreateButtonItem()
+ {
+ return new ColorPickerDropDown();
+ }
+
+ private ColorPickerDropDown GetColorPickerDropDown()
+ {
+ return InternalItem as ColorPickerDropDown;
+ }
+
+ private void InternalColorPreview(object sender, ColorPreviewEventArgs e)
+ {
+ OnColorPreview(e);
+ }
+
+ ///
+ /// Raises the ColorPreview event.
+ ///
+ /// Provides event data.
+ protected virtual void OnColorPreview(ColorPreviewEventArgs e)
+ {
+ if (ColorPreview != null)
+ ColorPreview(this, e);
+ }
+
+ private void InternalSelectedColorChanged(object sender, EventArgs e)
+ {
+ OnSelectedColorChanged(e);
+ ExecuteCommand();
+ }
+
+ ///
+ /// Gets whether command is executed when button is clicked.
+ ///
+ protected virtual bool ExecuteCommandOnClick
+ {
+ get { return false; }
+ }
+
+ ///
+ /// Raises the SelectedColorChanged event.
+ ///
+ /// Provides event data.
+ protected virtual void OnSelectedColorChanged(EventArgs e)
+ {
+ if (SelectedColorChanged != null)
+ SelectedColorChanged(this, e);
+ }
+
+ ///
+ /// Gets or sets the Owner Window that will be used as owner for the colors modal dialog when displayed.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public System.Windows.Forms.IWin32Window OwnerWindow
+ {
+ get { return GetColorPickerDropDown().OwnerWindow; }
+ set { GetColorPickerDropDown().OwnerWindow = value; }
+ }
+
+ ///
+ /// Gets or sets more colors menu item is visible which allows user to open Custom Colors dialog box. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), DevCoSerialize(), Category("Appearance"), Description("Indicates more colors menu item is visible which allows user to open Custom Colors dialog box.")]
+ public bool DisplayMoreColors
+ {
+ get { return GetColorPickerDropDown().DisplayMoreColors; }
+ set { GetColorPickerDropDown().DisplayMoreColors = value; }
+ }
+
+ ///
+ /// Gets or sets the last selected color from either the drop-down or Custom Color dialog box. Default value is
+ /// Color.Empty. You can use SelectedColorChanged event to be notified when this property changes.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Color SelectedColor
+ {
+ get { return GetColorPickerDropDown().SelectedColor; }
+ set { GetColorPickerDropDown().SelectedColor = value; }
+ }
+
+ ///
+ /// Gets or sets whether theme colors are displayed on drop-down. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), DevCoSerialize(), Category("Appearance"), Description("Indicates whether theme colors are displayed on drop-down.")]
+ public bool DisplayThemeColors
+ {
+ get { return GetColorPickerDropDown().DisplayThemeColors; }
+ set { GetColorPickerDropDown().DisplayThemeColors = value; }
+ }
+
+ ///
+ /// Gets or sets whether standard colors are displayed on drop-down. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), DevCoSerialize(), Category("Appearance"), Description("Indicates whether standard colors are displayed on drop-down.")]
+ public bool DisplayStandardColors
+ {
+ get { return GetColorPickerDropDown().DisplayStandardColors; }
+ set { GetColorPickerDropDown().DisplayStandardColors = value; }
+ }
+
+ ///
+ /// Indicates whether SubItems collection is serialized. ColorPickerDropDown does not serialize the sub items.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSubItems()
+ {
+ return false;
+ }
+
+ ///
+ /// Gets or sets the rectangle in Image coordinates where selected color will be painted. Setting this property will
+ /// have an effect only if Image property is used to set the image. Default value is an empty rectangle which indicates
+ /// that selected color will not be painted on the image.
+ ///
+ [Browsable(true), Description("Indicates rectangle in Image coordinates where selected color will be painted. Property will have effect only if Image property is used to set the image."), Category("Behaviour")]
+ public Rectangle SelectedColorImageRectangle
+ {
+ get { return GetColorPickerDropDown().SelectedColorImageRectangle; }
+ set { GetColorPickerDropDown().SelectedColorImageRectangle = value; }
+ }
+
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSelectedColorImageRectangle()
+ {
+ return GetColorPickerDropDown().ShouldSerializeSelectedColorImageRectangle();
+ }
+
+ ///
+ /// Resets the property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSelectedColorImageRectangle()
+ {
+ GetColorPickerDropDown().ResetSelectedColorImageRectangle();
+ }
+
+ ///
+ /// Invokes the ColorPreview event.
+ ///
+ /// Provides data for the event.
+ public void InvokeColorPreview(ColorPreviewEventArgs e)
+ {
+ GetColorPickerDropDown().InvokeColorPreview(e);
+ }
+
+ ///
+ /// Update the selected color image if the SelectedColorImageRectangle has been set and button is using Image property to display the image.
+ ///
+ public void UpdateSelectedColorImage()
+ {
+ GetColorPickerDropDown().UpdateSelectedColorImage();
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/ColorPickerButton.ico b/PROMS/DotNetBar Source Code/Controls/ColorPickerButton.ico
new file mode 100644
index 00000000..ef4b5644
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/ColorPickerButton.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/ComboBoxEx.bmp b/PROMS/DotNetBar Source Code/Controls/ComboBoxEx.bmp
new file mode 100644
index 00000000..2195b5f9
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/ComboBoxEx.bmp differ
diff --git a/PROMS/DotNetBar Source Code/Controls/ComboBoxEx.cs b/PROMS/DotNetBar Source Code/Controls/ComboBoxEx.cs
new file mode 100644
index 00000000..3706d754
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/ComboBoxEx.cs
@@ -0,0 +1,2796 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.Editors;
+using DevComponents.DotNetBar.TextMarkup;
+using DevComponents.AdvTree;
+using System.Reflection;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Represents enhanced Windows combo box control.
+ ///
+ [ToolboxBitmap(typeof(ComboBoxEx), "Controls.ComboBoxEx.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.ComboBoxExDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class ComboBoxEx : System.Windows.Forms.ComboBox, ICommandSource
+ {
+ #region Constructor
+ ///
+ /// Represents the method that will handle the DropDownChange event.
+ ///
+ public delegate void OnDropDownChangeEventHandler(object sender, bool Expanded);
+ ///
+ /// Occurs when drop down portion of combo box is shown or hidden.
+ ///
+ public event OnDropDownChangeEventHandler DropDownChange;
+
+ private eDotNetBarStyle m_Style = eDotNetBarStyle.Office2007;
+ private bool m_DefaultStyle = false; // Disables our drawing in WndProc
+ private bool m_MouseOver = false;
+ private bool m_MouseOverThumb = false;
+ private bool _DroppedDown = false;
+ //private System.Windows.Forms.Timer m_Timer;
+ private bool m_WindowsXPAware = false;
+ private bool m_DisableInternalDrawing = false;
+ private ImageList m_ImageList = null;
+ private int m_DropDownHeight = 0;
+ private IntPtr m_LastFocusWindow;
+ private IntPtr m_DropDownHandle = IntPtr.Zero;
+ private ComboTextBoxMsgHandler m_TextWindowMsgHandler = null;
+ //private ComboListBoxMsgHandler m_ListBoxMsgHandler = null;
+
+ [DllImport("user32")]
+ private static extern bool ValidateRect(IntPtr hWnd, ref NativeFunctions.RECT pRect);
+
+ [DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)]
+ private static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);
+ private const uint GW_CHILD = 5;
+
+ private bool m_PreventEnterBeep = false;
+
+ private string m_WatermarkText = "";
+ private bool m_Focused = false;
+ private Font m_WatermarkFont = null;
+ private Color m_WatermarkColor = SystemColors.GrayText;
+ private bool m_IsStandalone = true;
+ private Timer m_MouseOverTimer = null;
+ private Rectangle m_ThumbRect = Rectangle.Empty;
+ private bool _FocusHighlightEnabled = false;
+ private static Color _DefaultHighlightColor = Color.FromArgb(0xFF, 0xFF, 0x88);
+ private Color _FocusHighlightColor = _DefaultHighlightColor;
+
+ ///
+ /// Creates new instance of ComboBoxEx.
+ ///
+ public ComboBoxEx()
+ : base()
+ {
+ if (!ColorFunctions.ColorsLoaded)
+ {
+ NativeFunctions.RefreshSettings();
+ NativeFunctions.OnDisplayChange();
+ ColorFunctions.LoadColors();
+ }
+ m_MouseOverTimer = new Timer();
+ m_MouseOverTimer.Interval = 10;
+ m_MouseOverTimer.Enabled = false;
+ m_MouseOverTimer.Tick += new EventHandler(MouseOverTimerTick);
+#if FRAMEWORK20
+ this.FlatStyle = FlatStyle.Flat;
+#endif
+ StyleManager.Register(this);
+ }
+ #endregion
+
+ #region Implementation
+ ///
+ /// Called by StyleManager to notify control that style on manager has changed and that control should refresh its appearance if
+ /// its style is controlled by StyleManager.
+ ///
+ /// New active style.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void StyleManagerStyleChanged(eDotNetBarStyle newStyle)
+ {
+ // Metro needs BackColor and ForeColor set
+ if (StyleManager.IsMetro(newStyle) || StyleManager.IsMetro(StyleManager.PreviousStyle) && !StyleManager.IsMetro(newStyle))
+ StyleManager.UpdateAmbientColors(this);
+ }
+
+ private bool _FocusCuesEnabled = true;
+ ///
+ /// Gets or sets whether control displays focus cues when focused.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether control displays focus cues when focused.")]
+ public virtual bool FocusCuesEnabled
+ {
+ get { return _FocusCuesEnabled; }
+ set
+ {
+ _FocusCuesEnabled = value;
+ if (this.Focused) this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets whether control is stand-alone control. Stand-alone flag affects the appearance of the control in Office 2007 style.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates the appearance of the control.")]
+ public bool IsStandalone
+ {
+ get { return m_IsStandalone; }
+ set
+ {
+ m_IsStandalone = value;
+ }
+ }
+
+ private bool _WatermarkEnabled = true;
+ ///
+ /// Gets or sets whether watermark text is displayed when control is empty. Default value is true.
+ ///
+ [DefaultValue(true), Description("Indicates whether watermark text is displayed when control is empty.")]
+ public virtual bool WatermarkEnabled
+ {
+ get { return _WatermarkEnabled; }
+ set { _WatermarkEnabled = value; this.Invalidate(); }
+ }
+
+ ///
+ /// Gets or sets the watermark (tip) text displayed inside of the control when Text is not set and control does not have input focus. This property supports text-markup.
+ /// Note that WatermarkText is not compatible with the auto-complete feature of .NET Framework 2.0.
+ ///
+ [Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance"), Description("Indicates watermark text displayed inside of the control when Text is not set and control does not have input focus."), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ public string WatermarkText
+ {
+ get { return m_WatermarkText; }
+ set
+ {
+ if (value == null) value = "";
+ m_WatermarkText = value;
+ MarkupTextChanged();
+ this.Invalidate();
+ }
+ }
+
+ private eWatermarkBehavior _WatermarkBehavior = eWatermarkBehavior.HideOnFocus;
+ ///
+ /// Gets or sets the watermark hiding behaviour. Default value indicates that watermark is hidden when control receives input focus.
+ ///
+ [DefaultValue(eWatermarkBehavior.HideOnFocus), Category("Behavior"), Description("Indicates watermark hiding behaviour.")]
+ public eWatermarkBehavior WatermarkBehavior
+ {
+ get { return _WatermarkBehavior; }
+ set { _WatermarkBehavior = value; this.Invalidate(); }
+ }
+
+ private TextMarkup.BodyElement m_TextMarkup = null;
+ private void MarkupTextChanged()
+ {
+ m_TextMarkup = null;
+
+ if (!TextMarkup.MarkupParser.IsMarkup(ref m_WatermarkText))
+ return;
+
+ m_TextMarkup = TextMarkup.MarkupParser.Parse(m_WatermarkText);
+ ResizeMarkup();
+ }
+
+ private void ResizeMarkup()
+ {
+ if (m_TextMarkup != null)
+ {
+ using (Graphics g = this.CreateGraphics())
+ {
+ MarkupDrawContext dc = GetMarkupDrawContext(g);
+ m_TextMarkup.Measure(GetWatermarkBounds().Size, dc);
+ Size sz = m_TextMarkup.Bounds.Size;
+ m_TextMarkup.Arrange(new Rectangle(GetWatermarkBounds().Location, sz), dc);
+ }
+ }
+ }
+ private MarkupDrawContext GetMarkupDrawContext(Graphics g)
+ {
+ return new MarkupDrawContext(g, (m_WatermarkFont == null ? this.Font : m_WatermarkFont), m_WatermarkColor, this.RightToLeft == RightToLeft.Yes);
+ }
+
+ ///
+ /// Gets or sets the watermark font.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates watermark font."), DefaultValue(null)]
+ public Font WatermarkFont
+ {
+ get { return m_WatermarkFont; }
+ set { m_WatermarkFont = value; this.Invalidate(true); }
+ }
+
+ ///
+ /// Gets or sets the watermark text color.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates watermark text color.")]
+ public Color WatermarkColor
+ {
+ get { return m_WatermarkColor; }
+ set { m_WatermarkColor = value; this.Invalidate(true); }
+ }
+ ///
+ /// Indicates whether property should be serialized by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeWatermarkColor()
+ {
+ return m_WatermarkColor != SystemColors.GrayText;
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetWatermarkColor()
+ {
+ this.WatermarkColor = SystemColors.GrayText;
+ }
+
+ ///
+ /// Gets or sets the combo box background color. Note that in Office 2007 style back color of the control is automatically managed.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public override Color BackColor
+ {
+ get
+ {
+ return base.BackColor;
+ }
+ set
+ {
+ base.BackColor = value;
+ }
+ }
+
+ private bool m_UseCustomBackColor = false;
+ ///
+ /// Gets or sets whether the BackColor value you set is used instead of the style back color automatically provided by the control. Default
+ /// value is false which indicates that BackColor property is automatically managed. Set this property to true and then set BackColor property
+ /// to make control use your custom back color.
+ ///
+ [Browsable(false), DefaultValue(false)]
+ public bool UseCustomBackColor
+ {
+ get { return m_UseCustomBackColor; }
+ set { m_UseCustomBackColor = value; }
+ }
+
+ ///
+ /// Gets or sets value indicating whether system combo box appearance is used. Default value is false.
+ ///
+ [Browsable(false), Category("Behavior"), Description("Makes Combo box appear the same as built-in Combo box."), DefaultValue(false)]
+ public bool DefaultStyle
+ {
+ get
+ {
+ return m_DefaultStyle;
+ }
+ set
+ {
+ if (m_DefaultStyle != value)
+ {
+ m_DefaultStyle = value;
+ this.Invalidate(true);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets value indicating whether the combo box is draw using the Windows XP Theme manager when running on Windows XP or theme aware OS.
+ ///
+ [Browsable(false), Category("Behavior"), Description("When running on WindowsXP draws control using the Windows XP Themes if theme manager is enabled."), DefaultValue(false)]
+ public bool ThemeAware
+ {
+ get
+ {
+ return m_WindowsXPAware;
+ }
+ set
+ {
+ if (m_WindowsXPAware != value)
+ {
+ m_WindowsXPAware = value;
+ if (!m_WindowsXPAware)
+ m_DefaultStyle = false;
+ else if (m_WindowsXPAware && BarFunctions.ThemedOS)
+ {
+ m_DefaultStyle = true;
+#if FRAMEWORK20
+ this.FlatStyle = FlatStyle.Standard;
+#endif
+ }
+ }
+ }
+ }
+
+ ///
+ /// Disables internal drawing support for the List-box portion of Combo-box. Default value is false which means that internal drawing code is used. If
+ /// you plan to provide your own drawing for combo box items you must set this property to True.
+ ///
+ [Browsable(true), Category("Behavior"), Description("Disables internal drawing support for the List-box portion of Combo-box."), DefaultValue(false)]
+ public bool DisableInternalDrawing
+ {
+ get
+ {
+ return m_DisableInternalDrawing;
+ }
+ set
+ {
+ if (m_DisableInternalDrawing != value)
+ m_DisableInternalDrawing = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether combo box generates the audible alert when Enter key is pressed.
+ ///
+ [System.ComponentModel.Browsable(true), DevCoBrowsable(true), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Indicates whether combo box generates the audible alert when Enter key is pressed."), System.ComponentModel.DefaultValue(false)]
+ public bool PreventEnterBeep
+ {
+ get
+ {
+ return m_PreventEnterBeep;
+ }
+ set
+ {
+ m_PreventEnterBeep = value;
+ }
+ }
+
+ ///
+ /// The ImageList control used by Combo box to draw images.
+ ///
+ [Browsable(true), Category("Behavior"), Description("The ImageList control used by Combo box to draw images."), DefaultValue(null)]
+ public System.Windows.Forms.ImageList Images
+ {
+ get
+ {
+ return m_ImageList;
+ }
+ set
+ {
+ m_ImageList = value;
+ }
+ }
+
+ ///
+ /// Determines the visual style applied to the combo box when shown. Default style is Office 2007.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(eDotNetBarStyle.Office2007), Description("Determines the display of the item when shown.")]
+ public eDotNetBarStyle Style
+ {
+ get
+ {
+ return m_Style;
+ }
+ set
+ {
+ m_Style = value;
+ UpdateBackColor();
+ this.Invalidate(true);
+ }
+ }
+
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ base.OnHandleCreated(e);
+ UpdateBackColor();
+ SetupTextBoxMessageHandler();
+ RemoveTheme(this.Handle);
+ if (_AutoItemHeight)
+ UpdateItemHeight();
+ }
+
+ /*protected override void OnHandleDestroyed(EventArgs e)
+ {
+ if(m_Timer!=null)
+ m_Timer.Enabled=false;
+ base.OnHandleDestroyed(e);
+ }*/
+
+ protected override void OnResize(EventArgs e)
+ {
+ ResizeMarkup();
+ this.Invalidate();
+ base.OnResize(e);
+ }
+
+ private void MouseOverTimerTick(object sender, EventArgs e)
+ {
+ bool over = false;
+
+ if (this.IsHandleCreated && this.Visible)
+ {
+ WinApi.RECT rw = new WinApi.RECT();
+ WinApi.GetWindowRect(this.Handle, ref rw);
+ Rectangle r = rw.ToRectangle();
+ if (r.Contains(Control.MousePosition))
+ over = true;
+ Point p = this.PointToClient(Control.MousePosition);
+ if (m_ThumbRect.Contains(p))
+ MouseOverThumb = true;
+ else
+ MouseOverThumb = false;
+ }
+
+ if (!over)
+ {
+ SetMouseOverTimerEnabled(false);
+ m_MouseOver = false;
+ UpdateBackColor();
+ this.Invalidate();
+ if (this.ParentItem != null) this.ParentItem.HideToolTip();
+ }
+ }
+ internal BaseItem ParentItem = null;
+
+ private bool MouseOverThumb
+ {
+ get { return m_MouseOverThumb; }
+ set
+ {
+ if (m_MouseOverThumb != value)
+ {
+ m_MouseOverThumb = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ protected override void OnGotFocus(EventArgs e)
+ {
+ base.OnGotFocus(e);
+ if (!m_MouseOver)
+ m_MouseOver = true;
+ UpdateBackColor();
+ this.Invalidate(true);
+ }
+
+ protected override void OnLostFocus(EventArgs e)
+ {
+ //if(!this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition)))
+ //m_MouseOver=false;
+ SetMouseOverTimerEnabled(true);
+ //Color c = GetComboColors().Background;
+ //if (this.BackColor != c)
+ //this.BackColor = c;
+ //if(!m_MouseOver)
+ // this.Refresh();
+ m_LastFocusWindow = IntPtr.Zero;
+ base.OnLostFocus(e);
+ }
+
+ private Timer m_DropDownTrackTimer = null;
+ private void StartDropDownTrackTimer()
+ {
+ if (m_DropDownTrackTimer == null)
+ {
+ m_DropDownTrackTimer = new Timer();
+ m_DropDownTrackTimer.Tick += new EventHandler(DropDownTrackTimerTick);
+ m_DropDownTrackTimer.Interval = 200;
+ }
+ m_DropDownTrackTimer.Start();
+ }
+ private void StopDropDownTrackTimer()
+ {
+ Timer t = m_DropDownTrackTimer;
+ m_DropDownTrackTimer = null;
+ if (t != null)
+ {
+ t.Stop();
+ t.Dispose();
+ }
+ }
+
+ private void DropDownTrackTimerTick(object sender, EventArgs e)
+ {
+ DroppedDownInternal = (WinApi.SendMessage(this.Handle, (int)WinApi.WindowsMessages.CB_GETDROPPEDSTATE, IntPtr.Zero, IntPtr.Zero) != 0);
+ }
+
+ private bool DroppedDownInternal
+ {
+ get
+ {
+ return _DroppedDown;
+ }
+ set
+ {
+ if (IsMultiColumnDropDown)
+ {
+ _DroppedDown = value;
+ return;
+ }
+ if (_DroppedDown != value)
+ {
+ StopDropDownTrackTimer();
+ _DroppedDown = value;
+ this.Invalidate();
+
+ if (DropDownChange != null)
+ DropDownChange(this, _DroppedDown);
+#if !FRAMEWORK20
+ if(m_DroppedDown)
+ {
+ StartDropDownTrackTimer();
+ }
+#endif
+ if (!_DroppedDown)
+ ReleasePopupHandler();
+ }
+ }
+ }
+
+#if FRAMEWORK20
+ protected override void OnDropDownClosed(EventArgs e)
+ {
+ if (!IsMultiColumnDropDown)
+ {
+ DroppedDownInternal = false;
+ m_SelectedIndexInternal = this.SelectedIndex;
+ }
+ base.OnDropDownClosed(e);
+ }
+#endif
+
+ protected override void OnDropDown(EventArgs e)
+ {
+ base.OnDropDown(e);
+ if (!IsMultiColumnDropDown)
+ {
+ DroppedDownInternal = true;
+ }
+ }
+
+ [DllImport("user32", CharSet = CharSet.Unicode)]
+ private static extern int SetWindowTheme(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] String pszSubAppName, [MarshalAs(UnmanagedType.LPWStr)] String pszSubIdList);
+
+ private void RemoveTheme(IntPtr handle)
+ {
+ bool isXp = false;
+ if (System.Environment.Version.Major > 5)
+ isXp = true;
+ else if ((System.Environment.Version.Major == 5) &&
+ (System.Environment.Version.Minor >= 1))
+ isXp = true;
+ if (isXp)
+ SetWindowTheme(handle, " ", " ");
+ }
+
+ #region Internal Combo Colors
+ private class InternalComboColors
+ {
+ public Color Background = SystemColors.Window;
+ public Color Border = SystemColors.Window;
+ public LinearGradientColorTable ThumbBackground = null;
+ public Color ThumbText = SystemColors.ControlText;
+ public LinearGradientColorTable ThumbBorderOuter = null;
+ public LinearGradientColorTable ThumbBorderInner = null;
+ }
+
+ private InternalComboColors GetComboColors()
+ {
+ InternalComboColors c = new InternalComboColors();
+
+ bool bFocus = (m_MouseOverThumb || this.Focused || this.DroppedDownInternal && this.DropDownStyle != ComboBoxStyle.Simple);
+ if (bFocus && !this.Enabled)
+ bFocus = false;
+
+ if (BarFunctions.IsOffice2007Style(this.Style) && GlobalManager.Renderer is Office2007Renderer)
+ {
+ Office2007ComboBoxColorTable colorTable = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.ComboBox;
+ Office2007ComboBoxStateColorTable stateColors = (IsToolbarStyle && !m_MouseOver ? colorTable.Default : colorTable.DefaultStandalone);
+ if (bFocus)
+ {
+ if (this.DroppedDown)
+ stateColors = colorTable.DroppedDown;
+ else if (bFocus)
+ stateColors = colorTable.MouseOver;
+ }
+
+ c.Background = stateColors.Background;
+ c.Border = stateColors.Border;
+ c.ThumbBackground = stateColors.ExpandBackground;
+ c.ThumbText = stateColors.ExpandText;
+ c.ThumbBorderOuter = stateColors.ExpandBorderOuter;
+ c.ThumbBorderInner = stateColors.ExpandBorderInner;
+ }
+ else
+ {
+ ColorScheme cs = new ColorScheme(this.Style);
+ if (bFocus)
+ {
+ if (DroppedDownInternal)
+ {
+ c.ThumbBackground = new LinearGradientColorTable(cs.ItemPressedBackground, cs.ItemPressedBackground2, cs.ItemPressedBackgroundGradientAngle);
+ c.Border = cs.ItemPressedBorder;
+ c.ThumbText = cs.ItemPressedText;
+ }
+ else
+ {
+ if (m_MouseOverThumb)
+ c.ThumbBackground = new LinearGradientColorTable(cs.ItemHotBackground, cs.ItemHotBackground2, cs.ItemHotBackgroundGradientAngle);
+ else
+ c.ThumbBackground = new LinearGradientColorTable(cs.BarBackground, cs.BarBackground2, cs.BarBackgroundGradientAngle);
+ c.Border = cs.ItemHotBorder;
+ c.ThumbText = cs.ItemHotText;
+ }
+ }
+ else
+ {
+ c.ThumbBackground = new LinearGradientColorTable(cs.BarBackground, cs.BarBackground2, cs.BarBackgroundGradientAngle);
+ if (m_MouseOver || !IsToolbarStyle)
+ {
+ c.Border = cs.ItemHotBorder;
+ }
+ }
+ }
+
+ if (_FocusHighlightEnabled && this.Enabled && this.Focused)
+ c.Background = _FocusHighlightColor;
+ else if (!this.Enabled)
+ {
+ c.Background = _DisabledBackColor.IsEmpty ? SystemColors.Control : _DisabledBackColor;
+ c.ThumbText = _DisabledForeColor.IsEmpty ? SystemColors.ControlDark : _DisabledForeColor; ;
+ }
+
+ return c;
+ }
+ #endregion
+ private ComboBoxPopupMsgHandler _PopupMsgHandler = null;
+ private void ReleasePopupHandler()
+ {
+ ComboBoxPopupMsgHandler handler = _PopupMsgHandler;
+ _PopupMsgHandler = null;
+ if (handler != null)
+ {
+ handler.ReleaseHandle();
+ }
+ }
+ private void CreatePopupHandler(IntPtr handle)
+ {
+ if (_PopupMsgHandler == null)
+ {
+ _PopupMsgHandler = new ComboBoxPopupMsgHandler();
+ _PopupMsgHandler.AssignHandle(handle);
+ }
+ }
+ protected override bool ProcessDialogKey(Keys keyData)
+ {
+ if (keyData == Keys.F4 && IsMultiColumnDropDown)
+ {
+ IsPopupOpen = !IsPopupOpen;
+ return true;
+ }
+ return base.ProcessDialogKey(keyData);
+ }
+ protected override void WndProc(ref Message m)
+ {
+ const int WM_PAINT = 0xF;
+ const int WM_PRINTCLIENT = 0x0318;
+ const int WM_CTLCOLORLISTBOX = 0x0134;
+ const int CB_ADDSTRING = 0x143;
+ const int CB_INSERTSTRING = 0x14A;
+ const int CB_DELETESTRING = 0x0144;
+
+ WinApi.RECT rect = new WinApi.RECT();
+
+ switch (m.Msg)
+ {
+ case WM_CTLCOLORLISTBOX:
+ if (IsMultiColumnDropDown && base.DroppedDown)
+ {
+ BarUtilities.InvokeDelayed(new MethodInvoker(delegate { base.DroppedDown = false; }), 10);
+ break;
+ }
+
+ if (BarFunctions.IsWindows7 && !IsMultiColumnDropDown)
+ {
+ if (m_DropDownHandle != m.LParam)
+ ReleasePopupHandler();
+
+ if (_PopupMsgHandler == null)
+ CreatePopupHandler(m.LParam);
+ }
+
+ m_DropDownHandle = m.LParam;
+
+ if (!IsMultiColumnDropDown && (m_DropDownHeight > 0 || this.Items.Count == 0)) // Reason for zero items check here is to set the height of popup in case that it was visible before with large number of items and now its deleted. The ComboBox has bug and it displays popup in last large size even though its empty.
+ {
+ WinApi.GetWindowRect(m.LParam, ref rect);
+ int height = m_DropDownHeight;
+ if (this.Items.Count == 0)
+ height = Math.Max(18, this.ItemHeight);
+ Point thisLocation = this.PointToScreen(Point.Empty);
+ if (rect.Top < thisLocation.Y)
+ rect.Top = thisLocation.Y + this.Height;
+ NativeFunctions.SetWindowPos(m.LParam, IntPtr.Zero, rect.Left, rect.Top, rect.Width,
+ height, NativeFunctions.SWP_NOACTIVATE);
+ }
+ break;
+
+ case (int)WinApi.WindowsMessages.CB_GETDROPPEDSTATE:
+
+ base.WndProc(ref m);
+
+ if (m.Result == IntPtr.Zero && DroppedDownInternal && !IsMultiColumnDropDown)
+ DroppedDownInternal = false;
+ return;
+
+ case NativeFunctions.WM_SETFOCUS:
+ if (m.WParam != this.Handle)
+ m_LastFocusWindow = m.WParam;
+
+ break;
+
+ case CB_ADDSTRING:
+ if (this.Items.Count > 0)
+ {
+ ComboItem cb = this.Items[this.Items.Count - 1] as ComboItem;
+
+ if (cb != null)
+ cb.m_ComboBox = this;
+ }
+ break;
+
+ case CB_INSERTSTRING:
+ int index = WinApi.ToInt(m.WParam);
+
+ if (index >= 0 && index < this.Items.Count)
+ {
+ ComboItem cb = this.Items[index] as ComboItem;
+
+ if (cb != null)
+ cb.m_ComboBox = this;
+ }
+
+ m_SelectedIndexInternal = -1;
+ break;
+
+ case CB_DELETESTRING:
+ m_SelectedIndexInternal = -1;
+ break;
+
+ case NativeFunctions.WM_USER + 7:
+ if (this.DropDownStyle == ComboBoxStyle.DropDown && !m_Focused)
+ this.SelectionLength = 0;
+
+ this.Invalidate(true);
+ return;
+ case (int)WinApi.WindowsMessages.WM_LBUTTONDOWN:
+ {
+ if (IsMultiColumnDropDown)
+ {
+ if (IsPopupOpen)
+ CloseMultiColumnDropDown();
+ else if (DateTime.Now.Subtract(_MultiDropDownClosedAtTime).TotalMilliseconds > 500 && (this.Focused || this.Focus()))
+ {
+ OpenMultiColumnDropDown();
+ }
+ return; // Don't call base
+ }
+ break;
+ }
+ case (int)WinApi.WindowsMessages.WM_REFLECTCOMMAND:
+ {
+ if (IsMultiColumnDropDown)
+ {
+ int wp = WinApi.HIWORD(m.WParam);
+ if (wp == CBN_DROPDOWN)
+ {
+ OpenMultiColumnDropDown();
+ return; // Don't call base
+ }
+ else if (wp == CBN_CLOSEUP)
+ {
+ if (DateTime.Now.Subtract(_MultiDropDownOpenedAtTime).TotalMilliseconds > 900)
+ {
+ CloseMultiColumnDropDown();
+ return; // Don't call base
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ if (m_DefaultStyle)
+ {
+ base.WndProc(ref m);
+ return;
+ }
+
+ if ((m.Msg == WM_PAINT || m.Msg == WM_PRINTCLIENT) && DrawMode != DrawMode.Normal)
+ {
+ WinApi.GetWindowRect(m.HWnd, ref rect);
+ Rectangle r = new Rectangle(0, 0, rect.Width, rect.Height);
+
+ if (m.Msg == WM_PAINT)
+ {
+ WinApi.PAINTSTRUCT ps = new WinApi.PAINTSTRUCT();
+
+ IntPtr hdc = WinApi.BeginPaint(m.HWnd, ref ps);
+
+ using (Graphics gHdc = Graphics.FromHdc(hdc))
+ {
+ using (BufferedBitmap bmp = new BufferedBitmap(gHdc, r))
+ {
+ PaintComboBox(bmp.Graphics, r);
+
+ bmp.Render(gHdc);
+ }
+ }
+
+ WinApi.EndPaint(m.HWnd, ref ps);
+ }
+ else
+ {
+ using (Graphics g = Graphics.FromHdc(m.WParam))
+ PaintComboBox(g, r);
+ }
+
+ if (this.Parent is ItemControl)
+ ((ItemControl)this.Parent).UpdateKeyTipsCanvas();
+ }
+ else
+ {
+ base.WndProc(ref m);
+ }
+ }
+ private const uint CBN_DROPDOWN = 7;
+ private const uint CBN_CLOSEUP = 8;
+ public override bool PreProcessMessage(ref Message m)
+ {
+ if (m.Msg == (int)WinApi.WindowsMessages.WM_REFLECTCOMMAND && IsMultiColumnDropDown)
+ {
+ if (WinApi.HIWORD(m.WParam) == CBN_DROPDOWN)
+ return false;
+ }
+ return base.PreProcessMessage(ref m);
+ }
+
+ private void PaintComboBox(Graphics g, Rectangle r)
+ {
+ InternalComboColors colors = GetComboColors();
+
+ PaintComboBackground(g, r, colors);
+ PaintComboBorder(g, r, colors);
+
+ Rectangle contentRect = PaintComboThumb(g, r, colors);
+
+ int selectedIndex = SelectedIndex == -1 ? -1 : m_SelectedIndexInternal;
+
+ if (m_SelectedIndexInternal == -1 && SelectedIndex >= 0)
+ selectedIndex = SelectedIndex;
+
+ if (DropDownStyle == ComboBoxStyle.DropDownList)
+ {
+ if (Items.Count > 0 && (uint)selectedIndex < Items.Count)
+ {
+ DrawItemState state = DrawItemState.ComboBoxEdit;
+
+ if (Enabled == false)
+ state |= DrawItemState.Disabled;
+
+ else if (Focused == true)
+ state |= (DrawItemState.Focus | DrawItemState.Selected);
+
+ g.SetClip(contentRect);
+ contentRect.Inflate(-1, -1);
+ OnDrawItem(new DrawItemEventArgs(g, Font, contentRect,
+ selectedIndex, state, ForeColor, BackColor));
+ g.ResetClip();
+ }
+
+ if (ShouldDrawWatermark() == true)
+ DrawWatermark(g);
+ }
+ }
+
+ private Rectangle PaintComboThumb(Graphics g, Rectangle r, InternalComboColors colors)
+ {
+ Rectangle contentRect = r;
+ contentRect.Inflate(-2, -2);
+
+ if (this.DropDownStyle == ComboBoxStyle.Simple || !_RenderThumb) return contentRect;
+
+ int thumbWidth = SystemInformation.HorizontalScrollBarThumbWidth;
+ Rectangle thumbRect = new Rectangle(r.Width - thumbWidth, r.Y, thumbWidth, r.Height);
+ if (RightToLeft == RightToLeft.Yes)
+ thumbRect = new Rectangle(r.X + 1, r.Y + 1, thumbWidth, r.Height - 2);
+ if (!this.IsToolbarStyle)
+ {
+ thumbRect.Y += 2;
+ thumbRect.Height -= 4;
+ thumbRect.Width -= 2; ;
+ if (RightToLeft == RightToLeft.Yes)
+ thumbRect.X += 2;
+ }
+ else if (!BarFunctions.IsOffice2007Style(this.Style))
+ thumbRect.Inflate(-1, -1);
+
+ if (RightToLeft == RightToLeft.Yes)
+ {
+ int diff = thumbRect.Right - contentRect.X + 2;
+ contentRect.Width -= diff;
+ contentRect.X += diff;
+ }
+ else
+ {
+ int diff = contentRect.Right - thumbRect.X + 2;
+ contentRect.Width -= diff;
+ }
+ //contentRect.Y++;
+ //contentRect.Height--;
+
+ if (!this.IsToolbarStyle && BarFunctions.IsOffice2007Style(this.Style))
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, GetOffice2007StateColorTable(), thumbRect, RoundRectangleShapeDescriptor.RectangleShape);
+ }
+ else
+ {
+ if (colors.ThumbBackground != null)
+ DisplayHelp.FillRectangle(g, thumbRect, colors.ThumbBackground);
+ if (colors.ThumbBorderOuter != null)
+ DisplayHelp.DrawGradientRectangle(g, thumbRect, colors.ThumbBorderOuter, 1);
+ Rectangle innerBorder = thumbRect;
+ innerBorder.Inflate(-1, -1);
+ if (colors.ThumbBorderInner != null)
+ DisplayHelp.DrawGradientRectangle(g, innerBorder, colors.ThumbBorderInner, 1);
+ }
+
+ using (SolidBrush brush = new SolidBrush(colors.ThumbText))
+ DrawArrow(thumbRect, g, brush);
+
+ m_ThumbRect = thumbRect;
+ return contentRect;
+ }
+
+ internal Rectangle GetThumbRect(Rectangle r)
+ {
+ if (this.DropDownStyle == ComboBoxStyle.Simple || !_RenderThumb)
+ return (Rectangle.Empty);
+
+ int thumbWidth = SystemInformation.HorizontalScrollBarThumbWidth;
+ Rectangle thumbRect = new Rectangle(r.Width - thumbWidth, r.Y, thumbWidth, r.Height);
+
+ if (RightToLeft == RightToLeft.Yes)
+ thumbRect = new Rectangle(r.X + 1, r.Y + 1, thumbWidth, r.Height - 2);
+
+ if (!this.IsToolbarStyle)
+ {
+ thumbRect.Y += 2;
+ thumbRect.Height -= 4;
+ thumbRect.Width -= 2;
+
+ if (RightToLeft == RightToLeft.Yes)
+ thumbRect.X += 2;
+ }
+ else if (!BarFunctions.IsOffice2007Style(this.Style))
+ thumbRect.Inflate(-1, -1);
+
+ return (thumbRect);
+ }
+
+ [Browsable(false)]
+ public bool IsToolbarStyle
+ {
+ get { return !m_IsStandalone; }
+ }
+
+ private bool _RenderThumb = true;
+ ///
+ /// Gets or sets whether ComboBoxEx thumb button that displays drop-down is rendered. Default value is true.
+ ///
+ internal bool RenderThumb
+ {
+ get { return _RenderThumb; }
+ set
+ {
+ _RenderThumb = value;
+ }
+ }
+
+
+ private bool _RenderBorder = true;
+ ///
+ /// Gets or sets whether ComboBoxEx border is rendered. Default value is true.
+ ///
+ internal bool RenderBorder
+ {
+ get { return _RenderBorder; }
+ set
+ {
+ _RenderBorder = value;
+ }
+ }
+
+
+ protected Office2007ButtonItemStateColorTable GetOffice2007StateColorTable()
+ {
+ bool bFocus = (m_MouseOverThumb || this.DroppedDownInternal && this.DropDownStyle != ComboBoxStyle.Simple);
+
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ Office2007ColorTable ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
+ Office2007ButtonItemColorTable buttonColorTable = ct.ButtonItemColors[Enum.GetName(typeof(eButtonColor), eButtonColor.OrangeWithBackground)];
+ if (!this.Enabled)
+ return buttonColorTable.Disabled;
+ else if (this.DroppedDownInternal)
+ return buttonColorTable.Checked;
+ else if (bFocus)
+ return buttonColorTable.MouseOver;
+ else
+ return buttonColorTable.Default;
+ }
+
+ return null;
+ }
+
+ private void PaintComboBorder(Graphics g, Rectangle controlBounds, InternalComboColors colors)
+ {
+ if (!_RenderBorder) return;
+ DisplayHelp.DrawRectangle(g, colors.Border, controlBounds);
+ }
+
+ private void PaintComboBackground(Graphics g, Rectangle controlBounds, InternalComboColors colors)
+ {
+ if (this.UseCustomBackColor && !BackColor.IsEmpty)
+ DisplayHelp.FillRectangle(g, controlBounds, BackColor);
+ else
+ DisplayHelp.FillRectangle(g, controlBounds, colors.Background);
+ }
+
+ private bool ShouldDrawWatermark()
+ {
+ if (_WatermarkEnabled && this.Enabled && (!this.Focused || _WatermarkBehavior == eWatermarkBehavior.HideNonEmpty) && this.Text == "" && this.SelectedIndex == -1)
+ return true;
+ return false;
+ }
+
+ private void DrawWatermark(Graphics g)
+ {
+ if (m_TextMarkup != null)
+ {
+ MarkupDrawContext dc = GetMarkupDrawContext(g);
+ m_TextMarkup.Render(dc);
+ }
+ else
+ {
+ eTextFormat tf = eTextFormat.Left | eTextFormat.VerticalCenter;
+
+ if (this.RightToLeft == RightToLeft.Yes) tf |= eTextFormat.RightToLeft;
+ //if (this.TextAlign == HorizontalAlignment.Left)
+ // tf |= eTextFormat.Left;
+ //else if (this.TextAlign == HorizontalAlignment.Right)
+ // tf |= eTextFormat.Right;
+ //else if (this.TextAlign == HorizontalAlignment.Center)
+ // tf |= eTextFormat.HorizontalCenter;
+ tf |= eTextFormat.EndEllipsis;
+ tf |= eTextFormat.WordBreak;
+ TextDrawing.DrawString(g, m_WatermarkText, (m_WatermarkFont == null ? this.Font : m_WatermarkFont),
+ m_WatermarkColor, GetWatermarkBounds(), tf);
+ }
+ }
+
+ private Rectangle GetWatermarkBounds()
+ {
+ if (this.DropDownStyle != ComboBoxStyle.DropDownList && m_TextWindowMsgHandler != null)
+ {
+ WinApi.RECT rect = new WinApi.RECT();
+ WinApi.GetWindowRect(m_TextWindowMsgHandler.Handle, ref rect);
+ return new Rectangle(0, 0, rect.Width, rect.Height);
+ }
+
+ Rectangle r = new Rectangle(2, 0, this.Width - 2, this.Height);
+ r.Inflate(-2, -1);
+ int thumbSize = SystemInformation.HorizontalScrollBarThumbWidth;
+ r.Width -= thumbSize;
+ if (this.RightToLeft == RightToLeft.Yes)
+ r.X += thumbSize;
+
+ return r;
+ }
+
+ //private void CreateListBoxMsgHandler(IntPtr m_DropDownHandle)
+ //{
+ // DisposeListBoxMsgHandler();
+ // m_ListBoxMsgHandler = new ComboListBoxMsgHandler();
+ // m_ListBoxMsgHandler.AssignHandle(m_DropDownHandle);
+ //}
+
+ //private void DisposeListBoxMsgHandler()
+ //{
+ // if (m_ListBoxMsgHandler != null)
+ // {
+ // m_ListBoxMsgHandler.ReleaseHandle();
+ // m_ListBoxMsgHandler = null;
+ // }
+ //}
+
+ private void DrawArrow(Rectangle r, Graphics g, Brush b)
+ {
+ Point[] p = new Point[3];
+ p[0].X = r.Left + (r.Width - Dpi.Width4) / 2;
+ p[0].Y = r.Top + (r.Height - Dpi.Height3) / 2 + 1;
+ p[1].X = p[0].X + Dpi.Width5;
+ p[1].Y = p[0].Y;
+ p[2].X = p[0].X + Dpi.Width2;
+ p[2].Y = p[0].Y + Dpi.Height3;
+ g.FillPolygon(b, p);
+ }
+
+ /*private void OnTimer(object sender, EventArgs e)
+ {
+ bool bRefresh=false;
+
+ if(m_DroppedDown && !this.DroppedDown)
+ {
+ m_DroppedDown=false;
+
+ if(DropDownChange!=null)
+ this.DropDownChange(this,false);
+
+ m_DropDownHandle=IntPtr.Zero;
+ bRefresh=true;
+ }
+
+ Point mousePos=this.PointToClient(Control.MousePosition);
+ if(!this.ClientRectangle.Contains(mousePos))
+ {
+ if(m_MouseOver && !m_DroppedDown)
+ {
+ m_MouseOver=false;
+ bRefresh=true;
+ }
+ }
+ else if(!m_MouseOver)
+ {
+ m_MouseOver=true;
+ bRefresh=true;
+ }
+
+ if(bRefresh)
+ this.Refresh();
+ }*/
+
+ protected override void OnVisibleChanged(EventArgs e)
+ {
+ base.OnVisibleChanged(e);
+ m_MouseOver = false;
+ if (this.DropDownStyle == ComboBoxStyle.DropDown && this.Items.Count > 0 && this.Items[0] is ComboItem && this.DisplayMember != "")
+ {
+ string s = this.DisplayMember;
+ this.DisplayMember = "";
+ this.DisplayMember = s;
+ }
+ if (this.IsHandleCreated && !this.IsDisposed)
+ {
+ UpdateBackColor();
+ }
+ if (!this.Visible && IsMultiColumnDropDown && IsPopupOpen)
+ IsPopupOpen = false;
+ }
+
+ private int m_SelectedIndexInternal = -1;
+ private bool _InSelectedIndexChanged = false;
+ protected override void OnSelectedIndexChanged(EventArgs e)
+ {
+ m_SelectedIndexInternal = this.SelectedIndex;
+
+ if (!this.DroppedDownInternal)
+ {
+ if (DroppedDownInternal)
+ {
+ DroppedDownInternal = false;
+ }
+ if (!m_MouseOver)
+ this.Invalidate(true);
+ }
+ if (this.SelectedIndex == -1 && _WatermarkBehavior == eWatermarkBehavior.HideNonEmpty && m_WatermarkText.Length > 0 && this.Text == "")
+ this.Invalidate(true);
+ else if (this.DropDownStyle == ComboBoxStyle.DropDownList)
+ this.Invalidate();
+
+ base.OnSelectedIndexChanged(e);
+
+ if (!_InSelectedIndexChanged && this.DropDownStyle != ComboBoxStyle.DropDown && !(this.SelectedItem is string))
+ {
+ try
+ {
+ _InSelectedIndexChanged = true;
+ if (this.SelectedItem == null)
+ this.Text = "";
+ else
+ {
+ this.Text = GetItemText(this.SelectedItem);
+ }
+ }
+ finally
+ {
+ _InSelectedIndexChanged = false;
+ }
+ }
+
+ ExecuteCommand();
+ }
+
+ public override string Text
+ {
+ get
+ {
+ if (this.DropDownStyle == ComboBoxStyle.DropDownList && this.SelectedItem != null && !(this.SelectedItem is string))
+ return GetItemText(this.SelectedItem);
+ return base.Text;
+ }
+ set
+ {
+ base.Text = value;
+ }
+ }
+
+ protected override void OnTextChanged(EventArgs e)
+ {
+ if (this.SelectedIndex == -1 && _WatermarkBehavior == eWatermarkBehavior.HideNonEmpty && m_WatermarkText.Length > 0 && this.Text == "")
+ this.Invalidate(true);
+ base.OnTextChanged(e);
+ }
+
+ /*protected override void OnEnabledChanged(EventArgs e)
+ {
+ base.OnEnabledChanged(e);
+ SyncTimerEnabled();
+ }*/
+
+ /*private void SyncTimerEnabled()
+ {
+ if(this.Visible)
+ {
+ if(!m_Timer.Enabled && this.Enabled && !this.DesignMode)
+ m_Timer.Enabled=true;
+ }
+ else
+ {
+ if(m_Timer.Enabled)
+ m_Timer.Enabled=false;
+ }
+ }*/
+
+ protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
+ {
+ if (Dpi.RecordScalePerControl)
+ Dpi.SetScaling(factor);
+ base.ScaleControl(factor, specified);
+
+ if (_AutoItemHeight && !this.DesignMode)
+ UpdateItemHeight();
+ }
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ /*if(m_Timer!=null)
+ {
+ if(m_Timer.Enabled)
+ m_Timer.Enabled=false;
+ m_Timer.Dispose();
+ m_Timer=null;
+ }*/
+ if (m_MouseOverTimer != null)
+ {
+ m_MouseOverTimer.Enabled = false;
+ m_MouseOverTimer.Dispose();
+ m_MouseOverTimer = null;
+ }
+ m_DisableInternalDrawing = true;
+ if (m_TextWindowMsgHandler != null)
+ {
+ m_TextWindowMsgHandler.ReleaseHandle();
+ m_TextWindowMsgHandler = null;
+ }
+ ReleasePopupHandler();
+ if (_MultiColumnDisplay != null)
+ {
+ _MultiColumnDisplay.AfterNodeSelect -= TreeAfterNodeSelect;
+ _MultiColumnDisplay.BeforeNodeSelect -= TreeBeforeNodeSelect;
+ _MultiColumnDisplay.NodeMouseDown -= TreeNodeMouseDown;
+ _MultiColumnDisplay.DataColumnCreated -= TreeDataColumnCreated;
+ _MultiColumnDisplay.KeyDown -= TreeKeyDown;
+ _MultiColumnDisplay.Dispose();
+ _MultiColumnDisplay = null;
+ }
+ if (_PopupController != null)
+ {
+ _PopupController.Closed -= PopupControllerClosed;
+ _PopupController.Dispose();
+ _PopupController = null;
+ }
+ base.Dispose(disposing);
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ base.OnFontChanged(e);
+ UpdateItemHeight();
+ }
+
+ private bool _AutoItemHeight = true;
+ ///
+ /// Indicates whether ItemHeight property is set automatically based on the current font when DrawMode=OwnerDrawFixed
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether ItemHeight property is set automatically based on the current font when DrawMode=OwnerDrawFixed")]
+ public bool AutoItemHeight
+ {
+ get
+ {
+ return _AutoItemHeight;
+ }
+ set
+ {
+ _AutoItemHeight = value;
+ if (this.IsHandleCreated && value)
+ UpdateItemHeight();
+ }
+ }
+
+ private void UpdateItemHeight()
+ {
+ if (this.Disposing || this.IsDisposed)
+ return;
+ if (!m_DisableInternalDrawing && this.DrawMode == DrawMode.OwnerDrawFixed)
+ {
+ if (this.IsHandleCreated && this.Parent != null && !this.Parent.IsDisposed)
+ {
+ this.ItemHeight = this.FontHeight + 2;
+ }
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int GetFontHeight()
+ {
+ return this.FontHeight;
+ }
+
+ protected override void OnMeasureItem(MeasureItemEventArgs e)
+ {
+ base.OnMeasureItem(e);
+ if (!m_DisableInternalDrawing)
+ {
+ if (this.DrawMode == DrawMode.OwnerDrawFixed)
+ {
+ e.ItemHeight = this.ItemHeight - 2;
+ }
+ else
+ {
+ object o = this.Items[e.Index];
+ if (o is ComboItem)
+ {
+ if (((ComboItem)o).IsFontItem)
+ MeasureFontItem(e);
+ else
+ {
+ Size sz = GetComboItemSize(o as ComboItem);
+ e.ItemHeight = sz.Height;
+ e.ItemWidth = sz.Width;
+ if (BarFunctions.IsOffice2007Style(m_Style))
+ {
+ e.ItemHeight += 6;
+ e.ItemWidth += 6;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected override void OnDrawItem(DrawItemEventArgs e)
+ {
+ base.OnDrawItem(e);
+ InternalDrawItem(e);
+ }
+
+ private void InternalDrawItem(DrawItemEventArgs e)
+ {
+ if (!m_DisableInternalDrawing && e.Index >= 0)
+ {
+ object o = this.Items[e.Index];
+ if (o is ComboItem)
+ DrawComboItem(e);
+ else
+ DrawObjectItem(e);
+ }
+ }
+
+ protected virtual Size GetComboItemSize(ComboItem item)
+ {
+ Size size = Size.Empty;
+ if (BarFunctions.IsHandleValid(this))
+ {
+ Graphics g = this.CreateGraphics();
+ try
+ {
+ size = GetComboItemSize(item, g);
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ }
+ return size;
+ }
+
+ protected virtual void DrawObjectItem(DrawItemEventArgs e)
+ {
+ Graphics g = e.Graphics;
+ string text = GetItemText(this.Items[e.Index]);
+ Color textColor = Color.Empty;
+ Office2007ButtonItemStateColorTable ct = null;
+
+ if (BarFunctions.IsOffice2007Style(m_Style))
+ {
+ Office2007ButtonItemColorTable bct = GetComboItemColor();
+ if ((e.State & DrawItemState.Selected) != 0 || (e.State & DrawItemState.HotLight) != 0)
+ {
+ ct = bct.MouseOver;
+ if (textColor.IsEmpty)
+ textColor = ct.Text;
+ }
+ else if ((e.State & DrawItemState.Disabled) != 0 || !this.Enabled)
+ ct = bct.Disabled;
+ else
+ ct = bct.Default;
+
+ //if (ct != null)
+ // textColor = ct.Text;
+ if ((e.State & DrawItemState.Disabled) != 0 || !this.Enabled)
+ textColor = _DisabledForeColor.IsEmpty ? SystemColors.ControlDark : _DisabledForeColor;
+ else if (textColor.IsEmpty)
+ textColor = this.ForeColor;
+ if ((e.State & DrawItemState.HotLight) != 0 || (e.State & DrawItemState.Selected) != 0)
+ {
+ Rectangle r = e.Bounds;
+ //r.Width--;
+ //r.Height--;
+ if ((e.State & DrawItemState.ComboBoxEdit) != 0) r.Inflate(1, 1);
+ Office2007ButtonItemPainter.PaintBackground(g, ct, r,
+ (StyleManager.IsMetro(this.Style) ? RoundRectangleShapeDescriptor.RectangleShape : RoundRectangleShapeDescriptor.RoundCorner2));
+ }
+ else
+ e.DrawBackground();
+ }
+ else
+ {
+ e.DrawBackground();
+
+ if ((e.State & DrawItemState.HotLight) != 0 || (e.State & DrawItemState.Selected) != 0)
+ {
+ g.FillRectangle(SystemBrushes.Highlight, e.Bounds);
+ textColor = SystemColors.HighlightText;
+ }
+ else if ((e.State & DrawItemState.Disabled) != 0 || (e.State & DrawItemState.Grayed) != 0)
+ textColor = _DisabledForeColor.IsEmpty ? SystemColors.ControlDark : _DisabledForeColor;
+ else if (this.ForeColor.IsEmpty)
+ textColor = SystemColors.ControlText;
+ else
+ textColor = this.ForeColor;
+ }
+
+ if ((e.State & DrawItemState.Focus) != 0)
+ DrawFocusRectangle(e);
+ Rectangle rText = e.Bounds;
+
+ if ((e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit)
+ {
+ //rText.Inflate(-1, 0);
+
+ }
+ else if (BarFunctions.IsOffice2007Style(m_Style))
+ rText.Inflate(-3, 0);
+ else
+ rText.Inflate(-2, 0);
+ TextDrawing.DrawString(g, text, this.Font, textColor, rText, eTextFormat.Default | eTextFormat.NoClipping | eTextFormat.NoPrefix);
+ }
+
+ private Office2007ButtonItemColorTable _ComboItemColors = null;
+ ///
+ /// Gets or sets the custom color table used to render combo-box items
+ ///
+ [DefaultValue(null), Browsable(false)]
+ public Office2007ButtonItemColorTable ComboItemColors
+ {
+ get { return _ComboItemColors; }
+ set { _ComboItemColors = value; }
+ }
+
+ protected virtual Office2007ButtonItemColorTable GetComboItemColor()
+ {
+ if (_ComboItemColors != null) return _ComboItemColors;
+ return ((Office2007Renderer)GlobalManager.Renderer).ColorTable.ButtonItemColors[0];
+ }
+
+ private void DrawFocusRectangle(DrawItemEventArgs e)
+ {
+ if (_FocusCuesEnabled && ((e.State & DrawItemState.Focus) == DrawItemState.Focus) && ((e.State & DrawItemState.NoFocusRect) != DrawItemState.NoFocusRect)
+ && ((e.State & DrawItemState.NoFocusRect) == DrawItemState.ComboBoxEdit))
+ {
+ Rectangle r = e.Bounds;
+ r.Inflate(2, 2);
+ //r.Width--;
+ //r.Height--;
+ ControlPaint.DrawFocusRectangle(e.Graphics, r, e.ForeColor, e.BackColor);
+ }
+ }
+
+ private Color _DisabledForeColor = Color.Empty;
+ ///
+ /// Gets or sets the text color for the text in combo-box when control Enabled property is set to false.
+ /// Setting this property is effective only for DropDownList ComboBox style.
+ ///
+ [Category("Appearance"), Description("Indicates text color for the text in combo-box when control Enabled property is set to false. Setting this property is effective only for DropDownList ComboBox style.")]
+ public Color DisabledForeColor
+ {
+ get { return _DisabledForeColor; }
+ set
+ {
+ _DisabledForeColor = value;
+ if (!this.Enabled)
+ this.Invalidate();
+ }
+ }
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool ShouldSerializeDisabledForeColor()
+ {
+ return !_DisabledForeColor.IsEmpty;
+ }
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public void ResetDisabledForeColor()
+ {
+ DisabledForeColor = Color.Empty;
+ }
+
+ private Color _DisabledBackColor = Color.Empty;
+ ///
+ /// Gets or sets the control background color when control is disabled. Default value is an empty color which indicates that system background color is used when control is disabled.
+ ///
+ [Description("Indicates control background color when control is disabled"), Category("Appearance")]
+ public Color DisabledBackColor
+ {
+ get { return _DisabledBackColor; }
+ set
+ {
+ if (_DisabledBackColor != value)
+ {
+ _DisabledBackColor = value;
+ if (!this.Enabled) this.Invalidate();
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeDisabledBackColor()
+ {
+ return !_DisabledBackColor.IsEmpty;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetDisabledBackColor()
+ {
+ DisabledBackColor = Color.Empty;
+ }
+
+ protected virtual void DrawComboItem(DrawItemEventArgs e)
+ {
+ ComboItem item = this.Items[e.Index] as ComboItem;
+ if (item.IsFontItem)
+ {
+ this.DrawFontItem(e);
+ return;
+ }
+
+ Graphics g = e.Graphics;
+ Image img = null;
+ Color clr;
+ Color textColor = item.ForeColor;
+
+ if (item.ImageIndex >= 0 && m_ImageList != null && m_ImageList.Images.Count > item.ImageIndex)
+ img = m_ImageList.Images[item.ImageIndex];
+ else if (item.Image != null)
+ img = item.Image;
+
+ Office2007ButtonItemStateColorTable ct = null;
+ if (BarFunctions.IsOffice2007Style(m_Style))
+ {
+ Office2007ButtonItemColorTable bct = GetComboItemColor();
+ if ((e.State & DrawItemState.Selected) != 0 || (e.State & DrawItemState.HotLight) != 0)
+ {
+ ct = bct.MouseOver;
+ if (textColor.IsEmpty)
+ textColor = ct.Text;
+ }
+ else if ((e.State & DrawItemState.Disabled) != 0 || !this.Enabled)
+ ct = bct.Disabled;
+ else
+ ct = bct.Default;
+ //if (ct == null)
+ if (!this.Enabled)
+ textColor = _DisabledForeColor.IsEmpty ? SystemColors.ControlDark : _DisabledForeColor;
+ }
+
+ if (textColor.IsEmpty)
+ textColor = this.ForeColor;
+
+ int contWidth = this.DropDownWidth;
+ if (item.ImagePosition != HorizontalAlignment.Center && img != null)
+ {
+ contWidth -= img.Width;
+ if (contWidth <= 0)
+ contWidth = this.DropDownWidth;
+ }
+
+ // Back Color
+ if ((e.State & DrawItemState.Selected) != 0 || (e.State & DrawItemState.HotLight) != 0)
+ {
+ Rectangle backBounds = e.Bounds;
+ if ((e.State & DrawItemState.ComboBoxEdit) != 0)
+ backBounds.Inflate(1, 1);
+ if (BarFunctions.IsOffice2007Style(m_Style))
+ Office2007ButtonItemPainter.PaintBackground(g, ct, backBounds,
+ (StyleManager.IsMetro(this.Style) ? RoundRectangleShapeDescriptor.RectangleShape : RoundRectangleShapeDescriptor.RoundCorner2));
+ else
+ e.DrawBackground();
+ DrawFocusRectangle(e);
+ }
+ else
+ {
+ clr = item.BackColor;
+ if (item.BackColor.IsEmpty)
+ clr = e.BackColor;
+ using (SolidBrush clrb = new SolidBrush(clr))
+ g.FillRectangle(clrb, e.Bounds);
+ }
+
+ // Draw Image
+ Rectangle rImg = e.Bounds;
+ Rectangle rText = e.Bounds;
+ //if (e.State != DrawItemState.ComboBoxEdit)
+ {
+ if ((e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit)
+ {
+ if (img != null)
+ {
+ rText.X += 3;
+ rText.Width -= 3;
+ }
+ //rText.Inflate(-1, 0);
+ //rText.Y++;
+ //rText.Height--;
+ }
+ else if (BarFunctions.IsOffice2007Style(m_Style))
+ rText.Inflate(-3, 0);
+ else
+ rText.Inflate(-2, 0);
+ }
+ if (img != null)
+ {
+ rImg.Width = img.Width;
+ rImg.Height = img.Height;
+ if (item.ImagePosition == HorizontalAlignment.Left)
+ {
+ // Left
+ if (e.Bounds.Height > img.Height)
+ rImg.Y += (e.Bounds.Height - img.Height) / 2;
+ rText.Width -= rImg.Width;
+ rText.X += rImg.Width;
+ }
+ else if (item.ImagePosition == HorizontalAlignment.Right)
+ {
+ // Right
+ if (e.Bounds.Height > img.Height)
+ rImg.Y += (e.Bounds.Height - img.Height) / 2;
+ rImg.X = e.Bounds.Right - img.Width;
+ rText.Width -= rImg.Width;
+ }
+ else
+ {
+ // Center
+ rImg.X += (e.Bounds.Width - img.Width) / 2;
+ rText.Y = rImg.Bottom;
+ }
+ g.DrawImage(img, rImg);
+ }
+
+ // Draw Text
+ if (item.Text != "")
+ {
+ System.Drawing.Font f = e.Font;
+ bool bDisposeFont = false;
+ try
+ {
+ if (item.FontName != "")
+ {
+ f = new Font(item.FontName, item.FontSize, item.FontStyle);
+ bDisposeFont = true;
+ }
+ else if (item.FontStyle != f.Style)
+ {
+ f = new Font(f, item.FontStyle);
+ bDisposeFont = true;
+ }
+ }
+ catch
+ {
+ f = e.Font;
+ if (f == null)
+ {
+ f = SystemFonts.DefaultFont; // System.Windows.Forms.SystemInformation.MenuFont.Clone() as Font;
+ bDisposeFont = true;
+ }
+ }
+
+ eTextFormat format = eTextFormat.Default | eTextFormat.NoClipping | eTextFormat.NoPrefix;
+ if (item.TextFormat.Alignment == StringAlignment.Center)
+ format = eTextFormat.HorizontalCenter;
+ else if (item.TextFormat.Alignment == StringAlignment.Far)
+ format = eTextFormat.Right;
+ if (item.TextLineAlignment == StringAlignment.Center)
+ format |= eTextFormat.VerticalCenter;
+ else if (item.TextLineAlignment == StringAlignment.Far)
+ format |= eTextFormat.Bottom;
+ TextDrawing.DrawString(g, item.Text, f, textColor, rText, format);
+
+ if (bDisposeFont)
+ f.Dispose();
+ }
+
+ }
+
+ protected virtual Size GetComboItemSize(ComboItem item, Graphics g)
+ {
+ if (this.DrawMode == DrawMode.OwnerDrawFixed)
+ return new Size(this.DropDownWidth, this.ItemHeight);
+
+ Size sz = Size.Empty;
+ Size textSize = Size.Empty;
+ Image img = null;
+ if (item.ImageIndex >= 0)
+ img = m_ImageList.Images[item.ImageIndex];
+ else if (item.Image != null)
+ img = item.Image;
+
+ int contWidth = this.DropDownWidth;
+ if (item.ImagePosition != HorizontalAlignment.Center && img != null)
+ {
+ contWidth -= img.Width;
+ if (contWidth <= 0)
+ contWidth = this.DropDownWidth;
+ }
+
+ Font font = this.Font;
+ if (item.FontName != "")
+ {
+ try
+ {
+ font = new Font(item.FontName, item.FontSize, item.FontStyle);
+ }
+ catch
+ {
+ font = this.Font;
+ }
+ }
+
+ eTextFormat format = eTextFormat.Default;
+ if (item.TextFormat.Alignment == StringAlignment.Center)
+ format = eTextFormat.HorizontalCenter;
+ else if (item.TextFormat.Alignment == StringAlignment.Far)
+ format = eTextFormat.Right;
+ if (item.TextLineAlignment == StringAlignment.Center)
+ format |= eTextFormat.VerticalCenter;
+ else if (item.TextLineAlignment == StringAlignment.Far)
+ format |= eTextFormat.Bottom;
+
+ textSize = TextDrawing.MeasureString(g, item.Text, font, this.DropDownWidth, format);
+ textSize.Width += 2;
+ sz.Width = textSize.Width;
+ sz.Height = textSize.Height;
+ if (sz.Width < this.DropDownWidth)
+ sz.Width = this.DropDownWidth;
+
+ if (item.ImagePosition == HorizontalAlignment.Center && img != null)
+ sz.Height += img.Height;
+ else if (img != null && img.Height > sz.Height)
+ sz.Height = img.Height;
+
+ return sz;
+ }
+
+ ///
+ /// Loads all fonts available on system into the combo box.
+ ///
+ public void LoadFonts()
+ {
+ this.Items.Clear();
+
+ System.Drawing.Text.InstalledFontCollection colInstalledFonts = new System.Drawing.Text.InstalledFontCollection();
+ FontFamily[] aFamilies = colInstalledFonts.Families;
+ foreach (FontFamily ff in aFamilies)
+ {
+ ComboItem item = new ComboItem();
+ item.IsFontItem = true;
+ item.FontName = ff.GetName(0);
+ item.FontSize = this.Font.Size;
+ item.Text = ff.GetName(0);
+ this.Items.Add(item);
+ }
+ this.DropDownWidth = this.Width * 2;
+ }
+
+ private void DrawFontItem(DrawItemEventArgs e)
+ {
+ FontStyle[] styles = new FontStyle[4] { FontStyle.Regular, FontStyle.Bold, FontStyle.Italic, FontStyle.Bold | FontStyle.Italic };
+ if (!BarFunctions.IsOffice2007Style(m_Style))
+ e.DrawBackground();
+ string fontname = this.Items[e.Index].ToString();
+ FontFamily family = new FontFamily(fontname);
+
+ int iWidth = this.DropDownWidth / 2 - 4;
+ if (iWidth <= 0)
+ iWidth = this.Width;
+ foreach (FontStyle style in styles)
+ {
+ if (family.IsStyleAvailable(style))
+ {
+ eTextFormat format = eTextFormat.Default | eTextFormat.NoPrefix;
+ Color textColor = (e.State & DrawItemState.Selected) != 0 ? SystemColors.HighlightText : SystemColors.ControlText;
+
+ Office2007ButtonItemStateColorTable ct = null;
+ if (BarFunctions.IsOffice2007Style(m_Style))
+ {
+ Office2007ButtonItemColorTable bct = GetComboItemColor();
+ if ((e.State & DrawItemState.Selected) != 0 || (e.State & DrawItemState.HotLight) != 0)
+ ct = bct.MouseOver;
+ else if ((e.State & DrawItemState.Disabled) != 0 || !this.Enabled)
+ ct = bct.Disabled;
+ else
+ ct = bct.Default;
+ //if (ct == null)
+ if (!this.Enabled)
+ textColor = _DisabledForeColor.IsEmpty ? SystemColors.ControlDark : _DisabledForeColor;
+ else if (StyleManager.IsMetro(StyleManager.Style))
+ textColor = ct.Text;
+ else if (this.ForeColor.IsEmpty)
+ textColor = SystemColors.ControlText;
+ else
+ textColor = this.ForeColor;
+
+ if ((e.State & DrawItemState.Selected) != 0 || (e.State & DrawItemState.HotLight) != 0)
+ Office2007ButtonItemPainter.PaintBackground(e.Graphics, ct, e.Bounds,
+ (StyleManager.IsMetro(this.Style) ? RoundRectangleShapeDescriptor.RectangleShape : RoundRectangleShapeDescriptor.RoundCorner2));
+ else
+ {
+ e.DrawBackground();
+ }
+ }
+
+ if ((e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit)
+ {
+ Rectangle rt = e.Bounds;
+ rt.Height = 0; // Prevents clipping based on height
+ format |= eTextFormat.NoClipping | eTextFormat.NoPadding;
+ TextDrawing.DrawString(e.Graphics, fontname, this.Font, textColor, rt, format);
+ }
+ else
+ {
+ Size szFont = TextDrawing.MeasureString(e.Graphics, fontname, this.Font);
+ int iDiff = (int)((e.Bounds.Height - szFont.Height) / 2);
+ Rectangle rFontName = new Rectangle(e.Bounds.X, e.Bounds.Y + iDiff,
+ ((e.State & DrawItemState.Disabled) == DrawItemState.Disabled ? e.Bounds.Width : Math.Max(e.Bounds.Width - 100, 32)), e.Bounds.Height - iDiff);
+ TextDrawing.DrawString(e.Graphics, fontname, this.Font, textColor, rFontName, format);
+ Rectangle rRemainder = new Rectangle(e.Bounds.X + iWidth + 4, e.Bounds.Y, e.Bounds.Width + 100, e.Bounds.Height);
+ //using(Font f = new Font(family, (float)e.Bounds.Height - 8, style))
+ using (Font f = new Font(family, this.Font.Size, style))
+ TextDrawing.DrawString(e.Graphics, fontname, f, textColor, rRemainder, format);
+ }
+ break;
+ }
+ }
+ if (family != null) family.Dispose();
+ }
+
+ private void MeasureFontItem(MeasureItemEventArgs e)
+ {
+ e.ItemHeight = Dpi.Height18;
+ }
+
+#if !FRAMEWORK20
+ ///
+ /// Specifies the height of the drop-down portion of combo box.
+ ///
+ [Browsable(true),Category("Behavior"),Description("The height, in pixels, of drop down box in a combo box."), DefaultValue(0)]
+ public int DropDownHeight
+ {
+ get
+ {
+ return m_DropDownHeight;
+ }
+ set
+ {
+ m_DropDownHeight=value;
+ }
+ }
+#endif
+ private bool _AutoReleaseFocus = true;
+ [DefaultValue(true), Browsable(false)]
+ public bool AutoReleaseFocus
+ {
+ get
+ {
+ return _AutoReleaseFocus;
+ }
+ set
+ {
+ _AutoReleaseFocus = value;
+ }
+ }
+ ///
+ /// Releases the focus from combo box. The control that last had focus will receive focus back when this method is called.
+ ///
+ public void ReleaseFocus()
+ {
+ if (_AutoReleaseFocus && this.Focused && m_LastFocusWindow != IntPtr.Zero)
+ {
+ Control ctrl = Control.FromChildHandle(m_LastFocusWindow);
+ if (ctrl != this)
+ {
+ if (ctrl != null)
+ ctrl.Focus();
+ else
+ {
+ NativeFunctions.SetFocus(m_LastFocusWindow);
+ }
+ this.OnLostFocus(new System.EventArgs());
+ }
+ m_LastFocusWindow = IntPtr.Zero;
+
+ }
+ }
+
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+ {
+ if (keyData == Keys.Enter && m_PreventEnterBeep)
+ {
+ this.OnKeyPress(new KeyPressEventArgs((char)13));
+ return true;
+ }
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ if (!IsStandalone)
+ {
+ if (e.KeyCode == Keys.Enter)
+ ReleaseFocus();
+ else if (e.KeyCode == Keys.Escape)
+ {
+ ReleaseFocus();
+ }
+ }
+
+ base.OnKeyDown(e);
+ }
+
+ ///
+ /// Gets the window handle that the drop down list is bound to.
+ ///
+ [Browsable(false)]
+ public IntPtr DropDownHandle
+ {
+ get
+ {
+ return m_DropDownHandle;
+ }
+ }
+
+ internal bool MouseOver
+ {
+ get
+ {
+ return m_MouseOver;
+ }
+ set
+ {
+ if (m_MouseOver != value)
+ {
+ m_MouseOver = value;
+ this.Invalidate(true);
+ }
+ }
+ }
+
+ [System.ComponentModel.Editor("DevComponents.DotNetBar.Design.ComboItemsEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Localizable(true)]
+ public new ComboBox.ObjectCollection Items
+ {
+ get { return base.Items; }
+ }
+
+ protected override void OnEnabledChanged(EventArgs e)
+ {
+ UpdateBackColor();
+ base.OnEnabledChanged(e);
+ }
+
+ private void UpdateBackColor()
+ {
+ if (!m_UseCustomBackColor)
+ {
+ Color c = GetComboColors().Background;
+ if (this.BackColor != c)
+ this.BackColor = c;
+ }
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ if (!m_MouseOver)
+ {
+ m_MouseOver = true;
+ UpdateBackColor();
+ this.Invalidate(true);
+ }
+ SetMouseOverTimerEnabled(true);
+ base.OnMouseEnter(e);
+ }
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ //if(this.DroppedDown)
+ //{
+ // m_MouseOver=false;
+ //}
+ //else if(this.DropDownStyle!=ComboBoxStyle.DropDownList && m_MouseOver)
+ //{
+ // // Get the mouse position
+ // Point p=this.PointToClient(Control.MousePosition);
+ // if(!this.ClientRectangle.Contains(p))
+ // {
+ // m_MouseOver=false;
+ // }
+ //}
+ //else if(m_MouseOver)
+ //{
+ // m_MouseOver=false;
+ //}
+ SetMouseOverTimerEnabled(true);
+ //Color c = GetComboColors().Background;
+ //if (this.BackColor != c)
+ // this.BackColor = c;
+ //this.Refresh();
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+ if (!m_MouseOver)
+ {
+ //if (!m_Focused)
+ {
+ m_MouseOver = true;
+ this.Invalidate();
+ SetMouseOverTimerEnabled(true);
+ }
+ }
+ }
+
+ private void SetMouseOverTimerEnabled(bool value)
+ {
+ if (m_MouseOverTimer != null) m_MouseOverTimer.Enabled = value;
+ }
+
+ private void SetupTextBoxMessageHandler()
+ {
+#if FRAMEWORK20
+ if (this.DropDownStyle != ComboBoxStyle.DropDownList && this.AutoCompleteMode == AutoCompleteMode.None)
+#else
+ if (this.DropDownStyle != ComboBoxStyle.DropDownList)
+#endif
+ {
+ if (m_TextWindowMsgHandler == null)
+ {
+ // Get hold of the text box
+ IntPtr hwnd = GetWindow(this.Handle, GW_CHILD);
+ // Subclass so we can track messages
+ if (hwnd != IntPtr.Zero)
+ {
+ m_TextWindowMsgHandler = new ComboTextBoxMsgHandler();
+ m_TextWindowMsgHandler.MouseLeave += new EventHandler(this.TextBoxMouseLeave);
+ m_TextWindowMsgHandler.Paint += new PaintEventHandler(TextBoxPaint);
+ m_TextWindowMsgHandler.AssignHandle(hwnd);
+ }
+ }
+ }
+ else if (m_TextWindowMsgHandler != null)
+ {
+ m_TextWindowMsgHandler.ReleaseHandle();
+ m_TextWindowMsgHandler = null;
+ }
+ }
+
+ protected override void OnDropDownStyleChanged(EventArgs e)
+ {
+ SetupTextBoxMessageHandler();
+ base.OnDropDownStyleChanged(e);
+ }
+
+ private void TextBoxPaint(object sender, PaintEventArgs e)
+ {
+ if (ShouldDrawWatermark())
+ DrawWatermark(e.Graphics);
+ }
+
+ private void TextBoxMouseLeave(object sender, EventArgs e)
+ {
+ if (!m_MouseOver)
+ return;
+ SetMouseOverTimerEnabled(true);
+ }
+
+ ///
+ /// Gets or sets whether FocusHighlightColor is used as background color to highlight text box when it has input focus. Default value is false.
+ ///
+ [DefaultValue(false), Browsable(true), Category("Appearance"), Description("Indicates whether FocusHighlightColor is used as background color to highlight text box when it has input focus.")]
+ public virtual bool FocusHighlightEnabled
+ {
+ get { return _FocusHighlightEnabled; }
+ set
+ {
+ if (_FocusHighlightEnabled != value)
+ {
+ _FocusHighlightEnabled = value;
+ if (this.Focused)
+ this.Invalidate();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the color used as background color to highlight text box when it has input focus and focus highlight is enabled.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates color used as background color to highlight text box when it has input focus and focus highlight is enabled.")]
+ public virtual Color FocusHighlightColor
+ {
+ get { return _FocusHighlightColor; }
+ set
+ {
+ if (_FocusHighlightColor != value)
+ {
+ _FocusHighlightColor = value;
+ if (this.Focused)
+ this.Invalidate();
+ }
+ }
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeFocusHighlightColor()
+ {
+ return !_FocusHighlightColor.Equals(_DefaultHighlightColor);
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetFocusHighlightColor()
+ {
+ FocusHighlightColor = _DefaultHighlightColor;
+ }
+ #endregion
+
+ #region Multi-Column DropDown
+ protected override void OnLeave(EventArgs e)
+ {
+ if (IsMultiColumnDropDown && IsPopupOpen)
+ IsPopupOpen = false;
+
+ base.OnLeave(e);
+ }
+
+ private string _DropDownColumns = "";
+ ///
+ /// Gets or sets comma separated list of field names that are displayed on drop down. When set it activates ComboBoxEx multi-column drop-down mode.
+ /// DataSource must be set in order for drop-down to display data.
+ ///
+ [DefaultValue(""), Category("Multi-Column"), Description("Indicates comma separated list of field names that are displayed on drop down. When set it activates ComboBoxEx multi-column drop-down mode.")]
+ [Editor("DevComponents.DotNetBar.Design.DataMembersSelector, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ public string DropDownColumns
+ {
+ get { return _DropDownColumns; }
+ set
+ {
+ if (value != _DropDownColumns)
+ {
+ string oldValue = _DropDownColumns;
+ _DropDownColumns = value;
+ OnDropDownColumnsChanged(oldValue, value);
+ }
+ }
+ }
+ private AdvTree.AdvTree _MultiColumnDisplay = null;
+ ///
+ /// Called when DropDownColumns property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnDropDownColumnsChanged(string oldValue, string newValue)
+ {
+ _DataChangeType |= eDataChange.DropDownColumnsChanged;
+ }
+
+ private string _DropDownColumnsHeaders = "";
+ ///
+ /// Indicates custom column names with each column separated by new line, i.e. \r\n escape sequence.
+ ///
+ [DefaultValue(""), Category("Multi-Column"), Description("Indicates custom column names with each column separated by new line, i.e. \r\n escape sequence.")]
+ [Editor("DevComponents.DotNetBar.Design.ColumnNamesEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ [TypeConverter("DevComponents.DotNetBar.Design.ColumnNamesConverter, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public string DropDownColumnsHeaders
+ {
+ get { return _DropDownColumnsHeaders; }
+ set
+ {
+ if (value != _DropDownColumnsHeaders)
+ {
+ string oldValue = _DropDownColumnsHeaders;
+ _DropDownColumnsHeaders = value;
+ OnDropDownColumnsHeadersChanged(oldValue, value);
+ }
+ }
+ }
+
+ private string[] _ColumnsHeaders = new string[0];
+ ///
+ /// Called when DropDownColumnsHeaders property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnDropDownColumnsHeadersChanged(string oldValue, string newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("DropDownColumnsHeaders"));
+ _DataChangeType |= eDataChange.DropDownColumnsChanged;
+
+ if (!string.IsNullOrEmpty(_DropDownColumnsHeaders))
+ {
+ _ColumnsHeaders = _DropDownColumnsHeaders.Split('\r');
+ for (int i = 0; i < _ColumnsHeaders.Length; i++)
+ {
+ _ColumnsHeaders[i] = _ColumnsHeaders[i].Replace("\n", "");
+ }
+ }
+ else
+ _ColumnsHeaders = new string[0];
+ }
+
+ private bool IsMultiColumnDropDown
+ {
+ get
+ {
+ return !string.IsNullOrEmpty(_DropDownColumns);
+ }
+ }
+
+ ///
+ /// Occurs before the multi-column popup is opened and it allows canceling of popup by setting CancelEventArgs.Cancel=true.
+ ///
+ [Description("Occurs before the multi-column popup is opened and it allows canceling of popup by setting CancelEventArgs.Cancel=true.")]
+ public event CancelEventHandler BeforeMultiColumnPopupOpen;
+ ///
+ /// Raises BeforeMultiColumnPopupOpen event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnBeforeMultiColumnPopupOpen(CancelEventArgs e)
+ {
+ CancelEventHandler handler = BeforeMultiColumnPopupOpen;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ private eDataChange _DataChangeType = eDataChange.None;
+ private DateTime _MultiDropDownOpenedAtTime = DateTime.MinValue;
+ private DateTime _MultiDropDownClosedAtTime = DateTime.MinValue;
+ private PopupHostController _PopupController = null;
+ private void OpenMultiColumnDropDown()
+ {
+ if (_PopupController == null)
+ {
+ _PopupController = new PopupHostController();
+ _PopupController.Closed += PopupControllerClosed;
+ }
+
+ if (_MultiColumnDisplay == null)
+ {
+ _MultiColumnDisplay = CreateMultiColumnDisplayControl();
+ _DataChangeType = eDataChange.All;
+ }
+ if (IsDataChange(eDataChange.BindingContextChanged))
+ _MultiColumnDisplay.BindingContext = this.BindingContext;
+ if (IsDataChange(eDataChange.DataSourceChanged))
+ _MultiColumnDisplay.DataSource = this.DataSource;
+ if (IsDataChange(eDataChange.DropDownColumnsChanged))
+ _MultiColumnDisplay.DisplayMembers = _DropDownColumns;
+
+ if (!_PopupController.PopupUserSize || !_PreservePopupSize)
+ {
+ _MultiColumnDisplay.Height = Dpi.Height(this.DropDownHeight);
+ _MultiColumnDisplay.Width = Dpi.Width(this.DropDownWidth);
+ }
+ _PopupController.CloseButtonVisible = _PopupCloseButtonVisible;
+ CancelEventArgs cancelArgs = new CancelEventArgs();
+ OnBeforeMultiColumnPopupOpen(cancelArgs);
+ if (cancelArgs.Cancel)
+ return;
+
+ _MultiColumnDisplay.SelectedIndex = this.SelectedIndex;
+
+ Point location = PointToScreen(new Point(0, Height));
+
+ ePopupResizeEdge resize = _EnablePopupResize ? ePopupResizeEdge.BottomRight : ePopupResizeEdge.None;
+ _PopupController.Show(_MultiColumnDisplay, location.X, location.Y, 0, 0, resize);
+ if (_MultiColumnDisplay.SelectedNode != null)
+ _MultiColumnDisplay.SelectedNode.EnsureVisible();
+ _DroppedDown = true;
+ _MultiDropDownOpenedAtTime = DateTime.Now;
+
+ _DataChangeType = eDataChange.None;
+
+ base.OnDropDown(EventArgs.Empty);
+ }
+ private bool _DisconnectedPopupDataSource = false;
+ protected bool DisconnectedPopupDataSource
+ {
+ get { return _DisconnectedPopupDataSource; }
+ set { _DisconnectedPopupDataSource = value; }
+ }
+ void PopupControllerClosed(object sender, ToolStripDropDownClosedEventArgs e)
+ {
+ _DroppedDown = false;
+
+ m_SelectedIndexInternal = this.SelectedIndex;
+ _MultiDropDownClosedAtTime = DateTime.Now;
+ if (DisconnectedPopupDataSource && _MultiColumnDisplay != null)
+ {
+ _MultiColumnDisplay.DataSource = null;
+ _MultiColumnDisplay.DisplayMembers = string.Empty;
+ _MultiColumnDisplay.BindingContext = null;
+ _DataChangeType = eDataChange.All;
+ }
+ base.OnDropDownClosed(e);
+ }
+ private void CloseMultiColumnDropDown()
+ {
+ if (_PopupController != null && _DroppedDown)
+ {
+ _PopupController.Hide();
+ }
+ }
+ private AdvTree.AdvTree CreateMultiColumnDisplayControl()
+ {
+ AdvTree.AdvTree tree = new DevComponents.AdvTree.AdvTree();
+#if (!TRIAL)
+ tree.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F";
+#endif
+ tree.EnableDataPositionChange = false;
+ tree.BackgroundStyle.Reset();
+ tree.BackgroundStyle.BackColor = SystemColors.Window;
+ tree.BackgroundStyle.Border = eStyleBorderType.None;
+ tree.ExpandButtonType = eExpandButtonType.Triangle;
+ tree.DragDropEnabled = false;
+ tree.HotTracking = true;
+ tree.Indent = 0;
+ tree.ExpandWidth = 0;
+ tree.SelectionFocusAware = false;
+ ElementStyle nodeStyle = new ElementStyle();
+ nodeStyle.Name = "nodeElementStyle";
+ nodeStyle.TextColor = System.Drawing.SystemColors.ControlText;
+ tree.NodeStyle = nodeStyle;
+ tree.PathSeparator = ";";
+ tree.Styles.Add(nodeStyle);
+ tree.AfterNodeSelect += TreeAfterNodeSelect;
+ tree.BeforeNodeSelect += TreeBeforeNodeSelect;
+ tree.NodeMouseDown += TreeNodeMouseDown;
+ tree.NodeClick += new TreeNodeMouseEventHandler(TreeNodeClick);
+ tree.DataColumnCreated += TreeDataColumnCreated;
+ tree.KeyDown += TreeKeyDown;
+ if (_MultiColumnControlFont != null)
+ tree.Font = _MultiColumnControlFont;
+ return tree;
+ }
+
+ void TreeKeyDown(object sender, KeyEventArgs e)
+ {
+ if (_DroppedDown && e.KeyCode == Keys.Enter)
+ {
+ //if (this.SelectionClosesPopup)
+ // CloseMultiColumnDropDown();
+ //else
+ {
+ this.SelectedIndex = _MultiColumnDisplay.SelectedIndex;
+ CloseMultiColumnDropDown();
+ OnSelectionChangeCommitted(e);
+ }
+ }
+ }
+ ///
+ /// Occurs when ColumnHeader is automatically created by control as result of data binding for multi-column drop-down and provides you with opportunity to modify it.
+ ///
+ [Description("Occurs when ColumnHeader is automatically created by control as result of data binding for multi-column drop down and provides you with opportunity to modify it.")]
+ public event DevComponents.DotNetBar.Controls.DataColumnEventHandler DataColumnCreated;
+ ///
+ /// Raises the DataColumnCreated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnDataColumnCreated(DevComponents.DotNetBar.Controls.DataColumnEventArgs e)
+ {
+ if (DataColumnCreated != null)
+ DataColumnCreated(this, e);
+ }
+ void TreeDataColumnCreated(object sender, DataColumnEventArgs e)
+ {
+ if (_ColumnsHeaders.Length > 0)
+ {
+ int i = e.ColumnHeader.Parent.IndexOf(e.ColumnHeader);
+ if (i < _ColumnsHeaders.Length)
+ e.ColumnHeader.Text = _ColumnsHeaders[i];
+ }
+ OnDataColumnCreated(e);
+ }
+ private void TreeNodeMouseDown(object sender, TreeNodeMouseEventArgs e)
+ {
+ //if (this.SelectionClosesPopup && e.Button == MouseButtons.Left && e.Node != null &&
+ // e.Node.IsSelected && _DroppedDown)
+ //{
+ // CloseMultiColumnDropDown();
+ //}
+ }
+ void TreeNodeClick(object sender, TreeNodeMouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left && e.Node != null &&
+ e.Node.IsSelected && _DroppedDown)
+ {
+ this.SelectedIndex = _MultiColumnDisplay.SelectedIndex;
+ if (this.SelectionClosesPopup)
+ CloseMultiColumnDropDown();
+ OnSelectionChangeCommitted(e);
+ }
+ }
+ private void TreeAfterNodeSelect(object sender, AdvTreeNodeEventArgs e)
+ {
+ //if (_DroppedDown && (e.Action == eTreeAction.Keyboard))
+ //{
+ // this.SelectedIndex = _MultiColumnDisplay.SelectedIndex;
+ //}
+
+ //if (this.SelectionClosesPopup && _DroppedDown && e.Action == eTreeAction.Keyboard)
+ //{
+ // CloseMultiColumnDropDown();
+ //}
+
+ //if (/*e.Action == eTreeAction.Mouse || */ e.Action == eTreeAction.Keyboard)
+ // OnSelectionChangeCommitted(e);
+ }
+ private void TreeBeforeNodeSelect(object sender, AdvTreeNodeCancelEventArgs e)
+ {
+ OnSelectionChanging(e);
+ }
+ ///
+ /// Occurs before selection on multi-column drop-down has changed and allows canceling of the change. Applies to multi-column drop-down only.
+ ///
+ [Description("Occurs before selection on multi-column drop-down has changed and allows canceling of the change.")]
+ public event AdvTreeNodeCancelEventHandler SelectionChanging;
+ ///
+ /// Raises SelectionChanging event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnSelectionChanging(AdvTreeNodeCancelEventArgs e)
+ {
+ AdvTreeNodeCancelEventHandler handler = SelectionChanging;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ private bool _SelectionClosesPopup = true;
+ ///
+ /// Gets or sets whether selection change on multi-column drop-down closes the popup. Default value is true. Applies to multi-column drop-down only.
+ ///
+ [DefaultValue(true), Category("Multi-Column"), Description("Indicates whether selection change on multi-column drop-down closes the popup. Default value is true. Applies to multi-column drop-down only.")]
+ public bool SelectionClosesPopup
+ {
+ get { return _SelectionClosesPopup; }
+ set
+ {
+ _SelectionClosesPopup = value;
+ }
+ }
+
+ private bool _PreservePopupSize = true;
+ ///
+ /// Indicates whether multi-column popup size is preserved between popup displays if popup is resized by end-user. Applies to multi-column drop-down only.
+ ///
+ [DefaultValue(true), Category("Multi-Column"), Description("Indicates whether multi-column popup size is preserved between popup displays if popup is resized by end-user. Applies to multi-column drop-down only.")]
+ public bool PreservePopupSize
+ {
+ get { return _PreservePopupSize; }
+ set
+ {
+ _PreservePopupSize = value;
+ }
+ }
+
+ private bool _EnablePopupResize = true;
+ ///
+ /// Indicates whether multi-column popup can be resized by end user. Applies to multi-column drop-down only.
+ ///
+ [DefaultValue(true), Category("Multi-Column"), Description("Indicates whether multi-column popup can be resized by end user. Applies to multi-column drop-down only.")]
+ public bool EnablePopupResize
+ {
+ get { return _EnablePopupResize; }
+ set
+ {
+ _EnablePopupResize = value;
+ }
+ }
+
+ private bool _PopupCloseButtonVisible = true;
+ ///
+ /// Indicates whether multi-column popup close button is visible.
+ ///
+ [DefaultValue(true), Category("Multi-Column"), Description("Indicates whether multi-column popup close button is visible.")]
+ public bool PopupCloseButtonVisible
+ {
+ get { return _PopupCloseButtonVisible; }
+ set
+ {
+ _PopupCloseButtonVisible = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether multi-column popup window is open. Applies to multi-column drop-down only.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool IsPopupOpen
+ {
+ get { return _DroppedDown; }
+ set
+ {
+ if (value != _DroppedDown)
+ {
+ if (IsMultiColumnDropDown)
+ {
+ if (value)
+ OpenMultiColumnDropDown();
+ else
+ CloseMultiColumnDropDown();
+ }
+ }
+ }
+ }
+
+ protected override void OnDataSourceChanged(EventArgs e)
+ {
+ if (_MultiColumnDisplay != null)
+ _MultiColumnDisplay.DataSource = null;
+ _DataChangeType |= eDataChange.DataSourceChanged;
+ base.OnDataSourceChanged(e);
+ }
+ protected override void OnBindingContextChanged(EventArgs e)
+ {
+ _DataChangeType |= eDataChange.BindingContextChanged;
+ base.OnBindingContextChanged(e);
+ }
+
+ private bool IsDataChange(eDataChange changeType)
+ {
+ return ((_DataChangeType & changeType) == changeType);
+ }
+ [Flags()]
+ private enum eDataChange
+ {
+ None = 0,
+ DataSourceChanged = 1,
+ DropDownColumnsChanged = 2,
+ BindingContextChanged = 4,
+ All = DataSourceChanged | DropDownColumnsChanged | BindingContextChanged
+ }
+ ///
+ /// Gets the reference to the control which is used to display multi-column data on popup. Control is created just before the popup is opened.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public AdvTree.AdvTree MultiColumnDisplayControl
+ {
+ get
+ {
+ return _MultiColumnDisplay;
+ }
+ }
+
+ private Font _MultiColumnControlFont = null;
+ ///
+ /// Indicates the font used by the multi-column control on the popup.
+ ///
+ [DefaultValue(null), Category("Appearance"), Description("Indicates the font used by the multi-column control on the popup.")]
+ public Font MultiColumnControlFont
+ {
+ get { return _MultiColumnControlFont; }
+ set
+ {
+ if (value != _MultiColumnControlFont)
+ {
+ Font oldValue = _MultiColumnControlFont;
+ _MultiColumnControlFont = value;
+ OnMultiColumnControlFontChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when MultiColumnControlFont property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnMultiColumnControlFontChanged(Font oldValue, Font newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("MultiColumnControlFont"));
+ if (_MultiColumnDisplay != null)
+ _MultiColumnDisplay.Font = _MultiColumnControlFont;
+ }
+ #endregion
+
+ #region ICommandSource Members
+ protected virtual void ExecuteCommand()
+ {
+ if (_Command == null) return;
+ CommandManager.ExecuteCommand(this);
+ }
+
+ ///
+ /// Gets or sets the command assigned to the item. Default value is null.
+ /// Note that if this property is set to null Enabled property will be set to false automatically to disable the item.
+ ///
+ [DefaultValue(null), Category("Commands"), Description("Indicates the command assigned to the item.")]
+ public Command Command
+ {
+ get { return (Command)((ICommandSource)this).Command; }
+ set
+ {
+ ((ICommandSource)this).Command = value;
+ }
+ }
+
+ private ICommand _Command = null;
+ //[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ ICommand ICommandSource.Command
+ {
+ get
+ {
+ return _Command;
+ }
+ set
+ {
+ bool changed = false;
+ if (_Command != value)
+ changed = true;
+
+ if (_Command != null)
+ CommandManager.UnRegisterCommandSource(this, _Command);
+ _Command = value;
+ if (value != null)
+ CommandManager.RegisterCommand(this, value);
+ if (changed)
+ OnCommandChanged();
+ }
+ }
+
+ ///
+ /// Called when Command property value changes.
+ ///
+ protected virtual void OnCommandChanged()
+ {
+ }
+
+ private object _CommandParameter = null;
+ ///
+ /// Gets or sets user defined data value that can be passed to the command when it is executed.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Commands"), Description("Indicates user defined data value that can be passed to the command when it is executed."), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)), System.ComponentModel.Localizable(true)]
+ public object CommandParameter
+ {
+ get
+ {
+ return _CommandParameter;
+ }
+ set
+ {
+ _CommandParameter = value;
+ }
+ }
+
+ #endregion
+
+ #region ComboTextBoxMsgHandler
+ private class ComboTextBoxMsgHandler : NativeWindow
+ {
+ private const int WM_MOUSELEAVE = 0x02A3;
+ private const int WM_MOUSEMOVE = 0x0200;
+ private const int TME_LEAVE = 0x02;
+ [DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)]
+ private static extern bool TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack);
+
+ public event EventHandler MouseLeave;
+ public event PaintEventHandler Paint;
+
+ private struct TRACKMOUSEEVENT
+ {
+ public int cbSize;
+ public int dwFlags;
+ public IntPtr hwndTrack;
+ public int dwHoverTime;
+ }
+
+ private bool m_MouseTracking = false;
+
+ protected override void WndProc(ref Message m)
+ {
+ const int WM_PAINT = 0xF;
+ if (m.Msg == WM_MOUSEMOVE && !m_MouseTracking)
+ {
+ m_MouseTracking = true;
+ TRACKMOUSEEVENT tme = new TRACKMOUSEEVENT();
+ tme.dwFlags = TME_LEAVE;
+ tme.cbSize = Marshal.SizeOf(tme);
+ tme.hwndTrack = this.Handle;
+ tme.dwHoverTime = 0;
+ m_MouseTracking = TrackMouseEvent(ref tme);
+ }
+ else if (m.Msg == WM_MOUSELEAVE)
+ {
+ if (MouseLeave != null)
+ MouseLeave(this, new EventArgs());
+ m_MouseTracking = false;
+ }
+ else if (m.Msg == WM_PAINT)
+ {
+ base.WndProc(ref m);
+ if (Paint != null)
+ {
+ using (Graphics g = Graphics.FromHwnd(m.HWnd))
+ Paint(this, new PaintEventArgs(g, Rectangle.Empty));
+ }
+ return;
+ }
+ base.WndProc(ref m);
+ }
+ }
+ #endregion
+
+ #region ComboBoxPopupMsgHandler
+ private class ComboBoxPopupMsgHandler : NativeWindow
+ {
+ protected override void WndProc(ref Message m)
+ {
+ if (m.Msg == (int)WinApi.WindowsMessages.WM_VSCROLL)
+ {
+ base.WndProc(ref m);
+ WinApi.RedrawWindow(m.HWnd,
+ IntPtr.Zero,
+ IntPtr.Zero,
+ WinApi.RedrawWindowFlags.RDW_INVALIDATE | WinApi.RedrawWindowFlags.RDW_UPDATENOW);
+ return;
+ }
+ base.WndProc(ref m);
+ }
+ }
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/ComboBoxEx.ico b/PROMS/DotNetBar Source Code/Controls/ComboBoxEx.ico
new file mode 100644
index 00000000..fbe135b6
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/ComboBoxEx.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/ComboTree.cs b/PROMS/DotNetBar Source Code/Controls/ComboTree.cs
new file mode 100644
index 00000000..4b598559
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/ComboTree.cs
@@ -0,0 +1,3447 @@
+#if FRAMEWORK20
+using System;
+using System.Text;
+using System.ComponentModel;
+using System.Drawing;
+using DevComponents.Editors;
+using System.Windows.Forms;
+using System.Drawing.Drawing2D;
+using System.Collections;
+using System.Drawing.Design;
+using DevComponents.AdvTree;
+using System.Security;
+using System.Globalization;
+using System.Threading;
+using System.Collections.Generic;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Represents the combo box like control which shows the AdvTree control on popup. Tree control
+ /// can be configured to display multiple columns as well.
+ ///
+ [ToolboxBitmap(typeof(ComboTree), "Controls.ComboTree.ico"), ToolboxItem(true), DefaultProperty("Text"), DefaultBindingProperty("Text"), DefaultEvent("TextChanged"), Designer("DevComponents.DotNetBar.Design.ComboTreeDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class ComboTree : PopupItemControl, IInputButtonControl, ICommandSource
+ {
+ #region Private Variables
+ //private TextBoxX _TextBox = null;
+ private AdvTree.AdvTree _AdvTree = null;
+ private ButtonItem _PopupItem = null;
+ private static string _DropDownItemContainerName = "sysPopupItemContainer";
+ private static string _DropDownControlContainerName = "sysPopupControlContainer";
+ private Color _FocusHighlightColor = ColorScheme.GetColor(0xFFFF88);
+ private bool _FocusHighlightEnabled = false;
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs when Clear button is clicked and allows you to cancel the default action performed by the button.
+ ///
+ public event CancelEventHandler ButtonClearClick;
+ ///
+ /// Occurs when Drop-Down button that shows popup is clicked and allows you to cancel showing of the popup.
+ ///
+ public event CancelEventHandler ButtonDropDownClick;
+ ///
+ /// Occurs when ButtonCustom control is clicked.
+ ///
+ public event EventHandler ButtonCustomClick;
+ ///
+ /// Occurs when ButtonCustom2 control is clicked.
+ ///
+ public event EventHandler ButtonCustom2Click;
+ ///
+ /// Occurs when the text alignment in text box has changed.
+ ///
+ [Description("Occurs when the text alignment in text box has changed.")]
+ public event EventHandler TextAlignChanged;
+ /////
+ ///// Occurs when the value of the Modified property has changed.
+ /////
+ //public event EventHandler ModifiedChanged;
+ ///
+ /// Occurs before Node has been selected by user or through the SelectedNode property. Event can be canceled.
+ ///
+ public event AdvTreeNodeCancelEventHandler SelectionChanging;
+ ///
+ /// Occurs after node has been selected by user or through the SelectedNode property.
+ ///
+ public event AdvTreeNodeEventHandler SelectionChanged;
+ ///
+ /// Occurs when the DataSource changes.
+ ///
+ [Description("Occurs when the DataSource changes.")]
+ public event EventHandler DataSourceChanged;
+ ///
+ /// Occurs when the DisplayMembers property changes.
+ ///
+ [Description("Occurs when the DisplayMembers property changes")]
+ public event EventHandler DisplayMembersChanged;
+ ///
+ /// Occurs when the control is bound to a data value that need to be converted.
+ ///
+ [Description("Occurs when the control is bound to a data value that need to be converted.")]
+ public event TreeConvertEventHandler Format;
+ ///
+ /// Occurs when FormattingEnabled property changes.
+ ///
+ [Description("Occurs when FormattingEnabled property changes.")]
+ public event EventHandler FormattingEnabledChanged;
+ ///
+ /// Occurs when FormatString property changes.
+ ///
+ [Description("Occurs when FormatString property changes.")]
+ public event EventHandler FormatStringChanged;
+ ///
+ /// Occurs when FormatInfo property has changed.
+ ///
+ [Description("Occurs when FormatInfo property has changed.")]
+ public event EventHandler FormatInfoChanged;
+ ///
+ /// Occurs when a Node for an data-bound object item has been created and provides you with opportunity to modify the node.
+ ///
+ [Description("Occurs when a Node for an data-bound object item has been created and provides you with opportunity to modify the node")]
+ public event DataNodeEventHandler DataNodeCreated;
+ ///
+ /// Occurs when a group Node is created as result of GroupingMembers property setting and provides you with opportunity to modify the node.
+ ///
+ [Description("Occurs when a group Node is created as result of GroupingMembers property setting and provides you with opportunity to modify the node")]
+ public event DataNodeEventHandler GroupNodeCreated;
+ ///
+ /// Occurs when value of ValueMember property has changed.
+ ///
+ [Description("Occurs when value of ValueMember property has changed.")]
+ public event EventHandler ValueMemberChanged;
+ ///
+ /// Occurs when value of SelectedValue property has changed.
+ ///
+ [Description("Occurs when value of SelectedValue property has changed.")]
+ public event EventHandler SelectedValueChanged;
+ ///
+ /// Occurs when value of SelectedIndex property has changed.
+ ///
+ [Description("Occurs when value of SelectedValue property has changed.")]
+ public event EventHandler SelectedIndexChanged;
+ ///
+ /// Occurs when ColumnHeader is automatically created by control as result of data binding and provides you with opportunity to modify it.
+ ///
+ [Description("Occurs when ColumnHeader is automatically created by control as result of data binding and provides you with opportunity to modify it.")]
+ public event DataColumnEventHandler DataColumnCreated;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Initializes a new instance of the TextBoxDropDown class.
+ ///
+ public ComboTree()
+ {
+ this.SetStyle(ControlStyles.Selectable, true);
+ InitControl();
+ this.BackColor = SystemColors.Window;
+ }
+ private void InitControl()
+ {
+ _BackgroundStyle.SetColorScheme(this.ColorScheme);
+ _BackgroundStyle.StyleChanged += new EventHandler(this.VisualPropertyChanged);
+
+ _ButtonCustom = new InputButtonSettings(this);
+ _ButtonCustom2 = new InputButtonSettings(this);
+ _ButtonClear = new InputButtonSettings(this);
+ _ButtonDropDown = new InputButtonSettings(this);
+ CreateButtonGroup();
+
+ //_TextBox = new TextBoxX();
+ //_TextBox.BorderStyle = BorderStyle.None;
+ //_TextBox.TextChanged += new EventHandler(TextBoxTextChanged);
+ //_TextBox.TextAlignChanged += new EventHandler(TextBoxTextAlignChanged);
+ //_TextBox.SizeChanged += new EventHandler(TextBoxSizeChanged);
+ //_TextBox.Visible=false;
+ ////_TextBox.ModifiedChanged += new EventHandler(TextBoxModifiedChanged);
+ //this.Controls.Add(_TextBox);
+
+ // Init popup tree
+ _AdvTree = new DevComponents.AdvTree.AdvTree();
+#if (!TRIAL)
+ _AdvTree.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F";
+#endif
+ _AdvTree.BackgroundStyle.Reset();
+ _AdvTree.BackgroundStyle.BackColor = SystemColors.Window;
+ _AdvTree.BackgroundStyle.Border = eStyleBorderType.None;
+ _AdvTree.ExpandButtonType = eExpandButtonType.Triangle;
+ _AdvTree.DragDropEnabled = false;
+ _AdvTree.HotTracking = true;
+ _AdvTree.Indent = 6;
+ _AdvTree.SelectionFocusAware = false;
+ ElementStyle nodeStyle = new ElementStyle();
+ nodeStyle.Name = "nodeElementStyle";
+ nodeStyle.TextColor = System.Drawing.SystemColors.ControlText;
+ _AdvTree.NodeStyle = nodeStyle;
+ _AdvTree.PathSeparator = ";";
+ _AdvTree.Styles.Add(nodeStyle);
+ _AdvTree.AfterNodeSelect += new AdvTreeNodeEventHandler(TreeAfterNodeSelect);
+ _AdvTree.BeforeNodeSelect += new AdvTreeNodeCancelEventHandler(TreeBeforeNodeSelect);
+ _AdvTree.NodeMouseDown += new TreeNodeMouseEventHandler(TreeNodeMouseDown);
+
+ this.DropDownControl = _AdvTree;
+ }
+ #endregion
+
+ #region Internal Implementation
+ protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
+ {
+ base.ScaleControl(factor, specified);
+ if (_ButtonGroup!=null)
+ _ButtonGroup.InvalidateArrange();
+ }
+
+ protected override void OnBackColorChanged(EventArgs e)
+ {
+ _AdvTree.BackgroundStyle.BackColor = this.BackColor;
+ base.OnBackColorChanged(e);
+ }
+ protected override void InvalidateAutoSize()
+ {
+ if (_AdvTree != null)
+ _AdvTree.AntiAlias = this.AntiAlias;
+ }
+ ///
+ /// Gets or sets the tree node that is currently selected in the tree control.
+ ///
+ ///
+ /// If no Node is currently selected, the
+ /// SelectedNode property is a null reference (Nothing in Visual
+ /// Basic).
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Node SelectedNode
+ {
+ get
+ {
+ return _AdvTree.SelectedNode;
+ }
+ set
+ {
+ _AdvTree.SelectedNode = value;
+ }
+ }
+
+ void TreeNodeMouseDown(object sender, TreeNodeMouseEventArgs e)
+ {
+ if (this.SelectionClosesPopup && e.Button == MouseButtons.Left && e.Node != null &&
+ e.Node.IsSelected && this.IsPopupOpen && !e.Node.ExpandPartRectangle.Contains(e.X, e.Y))
+ {
+ this.IsPopupOpen = false;
+ }
+ }
+
+ private void TreeBeforeNodeSelect(object sender, AdvTreeNodeCancelEventArgs e)
+ {
+ if (SelectionChanging != null)
+ SelectionChanging(this, e);
+ }
+ private void TreeAfterNodeSelect(object sender, AdvTreeNodeEventArgs e)
+ {
+ if (SelectionChanged != null)
+ SelectionChanged(this, e);
+
+ if (_DataManager != null)
+ {
+ Node selectedNode = _AdvTree.SelectedNode;
+ if (selectedNode != null && selectedNode.BindingIndex > -1 && _DataManager.Position != selectedNode.BindingIndex)
+ {
+ _DataManager.Position = selectedNode.BindingIndex;
+ }
+ //else if (selectedNode == null)
+ // _DataManager.Position = -1;
+ }
+
+ if (this.SelectionClosesPopup && this.IsPopupOpen && e.Action == eTreeAction.Mouse)
+ {
+ this.IsPopupOpen = false;
+ }
+
+ if (e.Node != null) this.Text = e.Node.ToString();
+ this.Invalidate();
+
+ OnSelectedIndexChanged(EventArgs.Empty);
+ if(!string.IsNullOrEmpty(this.ValueMember))
+ this.OnSelectedValueChanged(EventArgs.Empty);
+ }
+
+ private bool _SelectionClosesPopup = true;
+ ///
+ /// Gets or sets whether selection change on popup tree closes the popup. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether selection change on popup tree closes the popup.")]
+ public bool SelectionClosesPopup
+ {
+ get { return _SelectionClosesPopup; }
+ set
+ {
+ _SelectionClosesPopup = value;
+ }
+ }
+
+ private string _SelectedDisplayMember = "";
+ ///
+ /// Gets or sets the field name that holds the text that will be displayed in the control for selected item. When not set all items set in DisplayMembers will be displayed in control.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates field name that holds the text that will be displayed in the control for selected item. When not set all items set in DisplayMembers will be displayed in control.")]
+ [Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
+ public string SelectedDisplayMember
+ {
+ get { return _SelectedDisplayMember; }
+ set
+ {
+ _SelectedDisplayMember = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets the field name that holds the text that will be displayed in the control for selected item. When not set all items set in DisplayMembers will be displayed in control.
+ ///
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Obsolete("This property name was misspelled. Use SelectedDisplayMember instead.")]
+ public string SelectedDisplayMemeber
+ {
+ get { return _SelectedDisplayMember; }
+ set
+ {
+ _SelectedDisplayMember = value;
+ this.Invalidate();
+ }
+ }
+
+
+ private List _DisplayMembers = null;
+ ///
+ /// Gets or sets the comma separated list of property or column names to display on popup tree control.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates comma separated list of property or column names to display on popup tree control")]
+ [Editor("DevComponents.DotNetBar.Design.DataMembersSelector, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ public string DisplayMembers
+ {
+ get
+ {
+ if (_DisplayMembers == null || _DisplayMembers.Count == 0)
+ return "";
+ StringBuilder members = new StringBuilder();
+ for (int i = 0; i < _DisplayMembers.Count; i++)
+ {
+ BindingMemberInfo item = _DisplayMembers[i];
+ members.Append(item.BindingMember);
+ if (i + 1 < _DisplayMembers.Count)
+ members.Append(',');
+ }
+ return members.ToString();
+ }
+ set
+ {
+ List displayMembers = _DisplayMembers;
+
+ List newMembers = null;
+
+ if (!string.IsNullOrEmpty(value))
+ {
+ newMembers = new List();
+ // Parse the members comma separated list expected...
+ string[] members = value.Split(',');
+ for (int i = 0; i < members.Length; i++)
+ {
+ newMembers.Add(new BindingMemberInfo(members[i].Trim()));
+ }
+ }
+
+ try
+ {
+ this.SetDataConnection(_DataSource, newMembers, false);
+ }
+ catch
+ {
+ _DisplayMembers = displayMembers;
+ }
+ }
+ }
+
+ private object _DataSource = null;
+ ///
+ /// Gets or sets the data source for the ComboTree. Expected is an object that implements the IList or IListSource interfaces,
+ /// such as a DataSet or an Array. The default is null.
+ ///
+ [AttributeProvider(typeof(IListSource)), Description("Indicates data source for the ComboTree."), Category("Data"), DefaultValue(null), RefreshProperties(RefreshProperties.Repaint)]
+ public object DataSource
+ {
+ get
+ {
+ return _DataSource;
+ }
+ set
+ {
+ if (((value != null) && !(value is IList)) && !(value is IListSource))
+ {
+ throw new ArgumentException("Data type is not supported for complex data binding");
+ }
+ if (_DataSource != value)
+ {
+ try
+ {
+ this.SetDataConnection(value, _DisplayMembers, true);
+ }
+ catch
+ {
+ this.DisplayMembers = "";
+ }
+ if (value == null)
+ {
+ this.DisplayMembers = "";
+ }
+ }
+ }
+ }
+
+ private bool _FormattingEnabled = false;
+ ///
+ /// Gets or sets a value indicating whether formatting is applied to the DisplayMembers property of the control.
+ ///
+ [DefaultValue(false), Description("Indicates whether formatting is applied to the DisplayMembers property of the control.")]
+ public bool FormattingEnabled
+ {
+ get
+ {
+ return _FormattingEnabled;
+ }
+ set
+ {
+ if (value != _FormattingEnabled)
+ {
+ _FormattingEnabled = value;
+ RefreshItems();
+ OnFormattingEnabledChanged(EventArgs.Empty);
+ }
+ }
+ }
+ ///
+ /// Raises FormattingEnabledChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnFormattingEnabledChanged(EventArgs e)
+ {
+ EventHandler handler = FormattingEnabledChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ private string _FormatString = "";
+ ///
+ /// Gets or sets the format-specifier characters that indicate how a value is to be displayed.
+ ///
+ [MergableProperty(false), Editor("System.Windows.Forms.Design.FormatStringEditor, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), DefaultValue(""), Description("Indicates format-specifier characters that indicate how a value is to be displayed.")]
+ public string FormatString
+ {
+ get
+ {
+ return _FormatString;
+ }
+ set
+ {
+ if (value == null)
+ {
+ value = string.Empty;
+ }
+ if (!value.Equals(_FormatString))
+ {
+ _FormatString = value;
+ RefreshItems();
+ OnFormatStringChanged(EventArgs.Empty);
+ }
+ }
+ }
+ ///
+ /// Raises FormatStringChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnFormatStringChanged(EventArgs e)
+ {
+ EventHandler handler = FormatStringChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ private IFormatProvider _FormatInfo = null;
+ ///
+ /// Gets or sets the IFormatProvider that provides custom formatting behavior.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Advanced), Browsable(false), DefaultValue((string)null)]
+ public IFormatProvider FormatInfo
+ {
+ get
+ {
+ return _FormatInfo;
+ }
+ set
+ {
+ if (value != _FormatInfo)
+ {
+ _FormatInfo = value;
+ RefreshItems();
+ OnFormatInfoChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ ///
+ /// Raises FormatInfoChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnFormatInfoChanged(EventArgs e)
+ {
+ EventHandler handler = FormatInfoChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+
+ private bool _InSetDataConnection = false;
+ private void SetDataConnection(object newDataSource, List newDisplayMembers, bool force)
+ {
+ bool dataSourceChanged = _DataSource != newDataSource;
+ bool displayMemberChanged = _DisplayMembers != newDisplayMembers;
+
+ if (!_InSetDataConnection)
+ {
+ try
+ {
+ if ((force || dataSourceChanged) || displayMemberChanged)
+ {
+ _InSetDataConnection = true;
+ IList list = (this.DataManager != null) ? this.DataManager.List : null;
+ bool isDataManagerNull = this.DataManager == null;
+ this.UnwireDataSource();
+ _DataSource = newDataSource;
+ _DisplayMembers = newDisplayMembers;
+ this.WireDataSource();
+ if (_IsDataSourceInitialized)
+ {
+ CurrencyManager manager = null;
+ if (((newDataSource != null) && (this.BindingContext != null)) && (newDataSource != Convert.DBNull))
+ {
+ string bindingPath = "";
+ if (_DisplayMembers != null && _DisplayMembers.Count > 0)
+ bindingPath = newDisplayMembers[0].BindingPath;
+ manager = (CurrencyManager)this.BindingContext[newDataSource, bindingPath];
+ }
+ if (_DataManager != manager)
+ {
+ if (_DataManager != null)
+ {
+ _DataManager.ItemChanged -= new ItemChangedEventHandler(this.DataManager_ItemChanged);
+ _DataManager.PositionChanged -= new EventHandler(this.DataManager_PositionChanged);
+ }
+ _DataManager = manager;
+ if (_DataManager != null)
+ {
+ _DataManager.ItemChanged += new ItemChangedEventHandler(this.DataManager_ItemChanged);
+ _DataManager.PositionChanged += new EventHandler(this.DataManager_PositionChanged);
+ }
+ }
+ if (((_DataManager != null) && (displayMemberChanged || dataSourceChanged)) && !ValidateDisplayMembers(_DisplayMembers))
+ {
+ throw new ArgumentException("Wrong DisplayMembers parameter", "newDisplayMember");
+ }
+ if (((_DataManager != null) && ((dataSourceChanged || displayMemberChanged) || force)) && (displayMemberChanged || (force && ((list != _DataManager.List) || isDataManagerNull || dataSourceChanged))))
+ {
+ DataManager_ItemChanged(_DataManager, null);
+ }
+ }
+ _Converters.Clear();
+ }
+ if (dataSourceChanged)
+ {
+ this.OnDataSourceChanged(EventArgs.Empty);
+ }
+ if (displayMemberChanged)
+ {
+ this.OnDisplayMembersChanged(EventArgs.Empty);
+ }
+ }
+ finally
+ {
+ _InSetDataConnection = false;
+ }
+ }
+ }
+
+ private bool ValidateDisplayMembers(List members)
+ {
+ if (members == null || members.Count == 0) return true;
+
+ foreach (BindingMemberInfo item in members)
+ {
+ if (item.BindingMember != null && !BindingMemberInfoInDataManager(item))
+ return false;
+ }
+ return true;
+ }
+ private bool BindingMemberInfoInDataManager(BindingMemberInfo bindingMemberInfo)
+ {
+ if (_DataManager != null)
+ {
+ PropertyDescriptorCollection itemProperties = _DataManager.GetItemProperties();
+ int count = itemProperties.Count;
+ for (int i = 0; i < count; i++)
+ {
+ if (!typeof(IList).IsAssignableFrom(itemProperties[i].PropertyType) && itemProperties[i].Name.Equals(bindingMemberInfo.BindingField))
+ {
+ return true;
+ }
+ }
+ for (int j = 0; j < count; j++)
+ {
+ if (!typeof(IList).IsAssignableFrom(itemProperties[j].PropertyType) && (string.Compare(itemProperties[j].Name, bindingMemberInfo.BindingField, true, CultureInfo.CurrentCulture) == 0))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ ///
+ /// Raises the DataSourceChanged event.
+ ///
+ /// An EventArgs that contains the event data.
+ protected virtual void OnDataSourceChanged(EventArgs e)
+ {
+ EventHandler handler = DataSourceChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+ ///
+ /// Raises the DisplayMemberChanged event.
+ ///
+ /// An EventArgs that contains the event data.
+ protected virtual void OnDisplayMembersChanged(EventArgs e)
+ {
+ EventHandler handler = DisplayMembersChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ private Hashtable _Converters = new Hashtable();
+ private TypeConverter GetFieldConverter(string fieldName)
+ {
+ if (_Converters.ContainsKey(fieldName))
+ return (TypeConverter)_Converters[fieldName];
+ if (this.DataManager != null)
+ {
+ PropertyDescriptorCollection itemProperties = this.DataManager.GetItemProperties();
+ if (itemProperties != null)
+ {
+ PropertyDescriptor descriptor = itemProperties.Find(fieldName, true);
+ if (descriptor != null)
+ {
+ _Converters.Add(fieldName, descriptor.Converter);
+ return descriptor.Converter;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private void DataManager_ItemChanged(object sender, ItemChangedEventArgs e)
+ {
+ if (this.InvokeRequired)
+ {
+ this.Invoke(new ItemChangedEventHandler(DataManager_ItemChanged), sender, e);
+ return;
+ }
+ if (_DataManager != null)
+ {
+ if (e==null || e.Index == -1)
+ {
+ this.SetItemsCore(_DataManager.List);
+ if (this.AllowSelection)
+ {
+ if (_DataManager.Position == -1)
+ this.SelectedNode = null;
+ else
+ this.SelectedNode = _AdvTree.FindNodeByBindingIndex(_DataManager.Position);
+ }
+ }
+ else
+ {
+ this.SetItemCore(e.Index, _DataManager.List[e.Index]);
+ }
+ }
+ }
+ private void DataManager_PositionChanged(object sender, EventArgs e)
+ {
+ if ((_DataManager != null) && this.AllowSelection)
+ {
+ if (_DataManager.Position == -1)
+ this.SelectedNode = null;
+ else
+ this.SelectedNode = _AdvTree.FindNodeByBindingIndex(_DataManager.Position);
+ //this.SelectedIndex = _DataManager.Position;
+ }
+ }
+
+ ///
+ /// When overridden in a derived class, resynchronizes the item data with the contents of the data source.
+ ///
+ public virtual void RefreshItems()
+ {
+ if (_DataManager != null)
+ {
+ SetItemsCore(_DataManager.List);
+ if (this.AllowSelection)
+ {
+ if (_DataManager.Position == -1)
+ this.SelectedNode = null;
+ else
+ this.SelectedNode = _AdvTree.FindNodeByBindingIndex(_DataManager.Position);
+ }
+ }
+ }
+
+ private bool IsSimpleType(object current)
+ {
+ if (current == null) return false;
+ return current is string || current.GetType().IsPrimitive;
+ }
+ ///
+ /// When overridden in a derived class, sets the specified array of objects in a collection in the derived class.
+ ///
+ /// An array of items.
+ protected virtual void SetItemsCore(IList items)
+ {
+ if(this.DesignMode) return;
+ _AdvTree.BeginUpdate();
+ _AdvTree.ClearAndDisposeAllNodes();
+
+ bool isGrouping = !string.IsNullOrEmpty(_GroupingMembers);
+
+ List fieldNames = new List();
+ // Create Columns
+ if (string.IsNullOrEmpty(this.DisplayMembers))
+ {
+ if (_AdvTree.Columns.Count > 0)
+ {
+ foreach (DevComponents.AdvTree.ColumnHeader columnHeader in _AdvTree.Columns)
+ {
+ if(!string.IsNullOrEmpty(columnHeader.DataFieldName))
+ fieldNames.Add(columnHeader.DataFieldName);
+ }
+ }
+ if (fieldNames.Count == 0)
+ {
+ _AdvTree.Columns.Clear();
+ if (_DataManager.List is Array)
+ {
+ DevComponents.AdvTree.ColumnHeader ch = new DevComponents.AdvTree.ColumnHeader("Items");
+ ch.Width.Relative = 100;
+ _AdvTree.Columns.Add(ch);
+ OnDataColumnCreated(new DataColumnEventArgs(ch));
+ }
+ else if (_DataManager != null)
+ {
+ if (_DataManager.Current != null && IsSimpleType(_DataManager.Current))
+ {
+ DevComponents.AdvTree.ColumnHeader ch = new DevComponents.AdvTree.ColumnHeader();
+ ch.Width.Relative = 100;
+ _AdvTree.Columns.Add(ch);
+ OnDataColumnCreated(new DataColumnEventArgs(ch));
+ }
+ else
+ {
+ PropertyDescriptorCollection properties = _DataManager.GetItemProperties();
+ foreach (PropertyDescriptor prop in properties)
+ {
+ fieldNames.Add(prop.Name);
+ DevComponents.AdvTree.ColumnHeader ch = new DevComponents.AdvTree.ColumnHeader(StringHelper.GetFriendlyName(prop.Name));
+ ch.DataFieldName = prop.Name;
+ ch.Width.Relative = Math.Max(10, 100 / properties.Count);
+ _AdvTree.Columns.Add(ch);
+ OnDataColumnCreated(new DataColumnEventArgs(ch));
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ _AdvTree.Columns.Clear();
+ if (_DisplayMembers != null && _DisplayMembers.Count > 0)
+ {
+ foreach (BindingMemberInfo item in _DisplayMembers)
+ {
+ DevComponents.AdvTree.ColumnHeader ch = new DevComponents.AdvTree.ColumnHeader(StringHelper.GetFriendlyName(item.BindingMember));
+ ch.Tag = item;
+ ch.Width.Relative = Math.Max(10, 100 / _DisplayMembers.Count);
+ _AdvTree.Columns.Add(ch);
+ fieldNames.Add(item.BindingMember);
+ OnDataColumnCreated(new DataColumnEventArgs(ch));
+ }
+ }
+ }
+
+ if (string.IsNullOrEmpty(_GroupingMembers) && string.IsNullOrEmpty(_ParentFieldNames))
+ {
+ for (int i = 0; i < items.Count; i++)
+ {
+ object item = items[i];
+ Node node = CreateNode(_AdvTree.Nodes, item, i, fieldNames);
+ }
+ }
+ else if (!string.IsNullOrEmpty(_ParentFieldNames))
+ {
+ isGrouping = true;
+
+ Dictionary nodeParentCollection = new Dictionary();
+ Dictionary> nodeNeedsParentCollection = new Dictionary>();
+ string[] parentFields = _ParentFieldNames.Split(',');
+
+ for (int i = 0; i < items.Count; i++)
+ {
+ object item = items[i];
+ string nodeKey = GetItemText(item, parentFields[0]);
+ string parentKey = GetItemText(item, parentFields[1]);
+ Node parentNode = null;
+ if (nodeParentCollection.TryGetValue(parentKey, out parentNode))
+ {
+ Node node = CreateNode(parentNode.Nodes, item, i, fieldNames);
+ nodeParentCollection.Add(nodeKey, node);
+ }
+ else
+ {
+ Node node = CreateNode(this.Nodes, item, i, fieldNames);
+ List list = null;
+ if (!nodeNeedsParentCollection.TryGetValue(parentKey, out list))
+ {
+ list = new List();
+ nodeNeedsParentCollection.Add(parentKey, list);
+ }
+ list.Add(node);
+ nodeParentCollection.Add(nodeKey, node);
+ }
+ }
+ // If there are nodes that needed a parent process them now
+ foreach (KeyValuePair> keyValue in nodeNeedsParentCollection)
+ {
+ Node parentNode = null;
+ if (nodeParentCollection.TryGetValue(keyValue.Key, out parentNode))
+ {
+ foreach (Node node in keyValue.Value)
+ {
+ node.Remove();
+ parentNode.Nodes.Add(node);
+ }
+ }
+ }
+ }
+ else
+ {
+ string[] groupFields = _GroupingMembers.Split(',');
+ for (int i = 0; i < groupFields.Length; i++)
+ {
+ groupFields[i] = groupFields[i].Trim();
+ }
+ Dictionary _GroupTable = new Dictionary();
+ for (int i = 0; i < items.Count; i++)
+ {
+ object item = items[i];
+ NodeCollection parentCollection = _AdvTree.Nodes;
+
+ // Find the parent collection to add item to
+ string key = "";
+ for (int gi = 0; gi < groupFields.Length; gi++)
+ {
+ string text = GetItemText(item, groupFields[gi]);
+ key += text.ToLower() + "/";
+ Node groupNode = null;
+ if (!_GroupTable.TryGetValue(key, out groupNode))
+ {
+ groupNode = CreateGroupNode(parentCollection, text);
+ _GroupTable.Add(key, groupNode);
+ }
+ parentCollection = groupNode.Nodes;
+ }
+
+ Node node = CreateNode(parentCollection, item, i, fieldNames);
+ }
+ }
+
+ // If not grouping then remove the expand part space on left-hand side
+ if (isGrouping)
+ {
+ _AdvTree.ExpandWidth = 14;
+ }
+ else
+ {
+ _AdvTree.ExpandWidth = 0;
+ }
+
+ _AdvTree.EndUpdate();
+ }
+ ///
+ /// Raises the DataColumnCreated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnDataColumnCreated(DataColumnEventArgs args)
+ {
+ if (DataColumnCreated != null)
+ DataColumnCreated(this, args);
+ }
+
+ private Node CreateGroupNode(NodeCollection parentCollection, string text)
+ {
+ Node node = new Node();
+ node.Text = text;
+ node.Style = _GroupNodeStyle;
+ node.Expanded = true;
+ node.Selectable = false;
+ parentCollection.Add(node);
+ DataNodeEventArgs eventArgs = new DataNodeEventArgs(node, null);
+ OnGroupNodeCreated(eventArgs);
+ return node;
+ }
+ ///
+ /// Raises the DataNodeCreated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnGroupNodeCreated(DataNodeEventArgs dataNodeEventArgs)
+ {
+ if (GroupNodeCreated != null) GroupNodeCreated(this, dataNodeEventArgs);
+ }
+
+ ///
+ /// Creates a new node for the data item.
+ ///
+ /// Item to create node for.
+ /// New instance of the node.
+ private Node CreateNode(NodeCollection parentCollection, object item, int itemIndex, List fieldNames)
+ {
+ Node node = new Node();
+ parentCollection.Add(node);
+
+ SetNodeData(node, item, fieldNames, itemIndex);
+
+ DataNodeEventArgs eventArgs = new DataNodeEventArgs(node, item);
+
+ OnDataNodeCreated(eventArgs);
+
+ return eventArgs.Node;
+ }
+
+ private void SetNodeData(Node node, object item, List fieldNames, int bindingIndex)
+ {
+ node.DataKey = item;
+ node.BindingIndex = bindingIndex;
+
+ node.CreateCells();
+
+ if (fieldNames.Count > 0)
+ {
+ for (int i = 0; i < fieldNames.Count; i++)
+ {
+ object propertyValue = GetPropertyValue(item, fieldNames[i]);
+ if (propertyValue is Image)
+ {
+ node.Cells[i].Images.Image = (Image)propertyValue;
+ //node.Cells[i].Images.AutoDispose = true;
+ }
+ else
+ node.Cells[i].Text = GetItemText(item, fieldNames[i]);
+ }
+ }
+ else if (item != null)
+ node.Text = item.ToString();
+ }
+
+
+ ///
+ /// Raises the DataNodeCreated event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnDataNodeCreated(DataNodeEventArgs dataNodeEventArgs)
+ {
+ if (DataNodeCreated != null) DataNodeCreated(this, dataNodeEventArgs);
+ }
+
+ ///
+ /// When overridden in a derived class, sets the object with the specified index in the derived class.
+ ///
+ /// The array index of the object.
+ /// The object.
+ protected virtual void SetItemCore(int index, object value)
+ {
+ Node node = _AdvTree.FindNodeByBindingIndex(index);
+ if (node == null) return;
+
+ List fieldNames = new List();
+
+ foreach (DevComponents.AdvTree.ColumnHeader column in _AdvTree.Columns)
+ {
+ if (!string.IsNullOrEmpty(column.DataFieldName))
+ fieldNames.Add(column.DataFieldName);
+ }
+
+ SetNodeData(node, value, fieldNames, index);
+ }
+
+ private string _ParentFieldNames = "";
+ ///
+ /// Gets or sets comma separated field or property names that holds the value that is used to identify node and parent node. Format expected is: FieldNodeId,ParentNodeFieldId. For example if your table represents departments, you have DepartmentId field which uniquely identifies a department and ParentDepartmentId field which identifies parent of the department if any you would set this property to DepartmentId,ParentDepartmentId.
+ /// Note that you can only use ParentFieldNames or GroupingMembers property but not both. If both are set ParentFieldName take precedence.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates comma separated field or property names that holds the value that is used to identify node and parent node. Format expected is: FieldNodeId,ParentNodeFieldId. For example if your table represents departments, you have DepartmentId field which uniquely identifies a department and ParentDepartmentId field which identifies parent of the department if any you would set this property to DepartmentId,ParentDepartmentId.")]
+ public string ParentFieldNames
+ {
+ get { return _ParentFieldNames; }
+ set
+ {
+ if (value == null) value = "";
+ if (!string.IsNullOrEmpty(value))
+ {
+ string[] fields = value.Split(',');
+ if (fields.Length != 2)
+ throw new ArgumentException("ParentFieldNames excepts two and only two fields/property names separated by comma character.");
+ if (string.IsNullOrEmpty(fields[0]))
+ throw new ArgumentException("ParentFieldNames excepts two and only two fields/property names separated by comma character. First field name is empty.");
+ if (string.IsNullOrEmpty(fields[1]))
+ throw new ArgumentException("ParentFieldNames excepts two and only two fields/property names separated by comma character. Second field name is empty.");
+ }
+ _ParentFieldNames = value;
+ OnParentFieldNamesChanged();
+ }
+ }
+
+ ///
+ /// Called when ParentFieldName property has changed.
+ ///
+ protected virtual void OnParentFieldNamesChanged()
+ {
+ RefreshItems();
+ }
+
+ private string _GroupingMembers = "";
+ ///
+ /// Gets or sets comma separated list of field or property names that are used for grouping when data-binding is used.
+ ///
+ [DefaultValue(""), Category("Data"), Description("Indicates comma separated list of field or property names that are used for grouping when data-binding is used")]
+ public string GroupingMembers
+ {
+ get { return _GroupingMembers; }
+ set
+ {
+ if (value == null) value = "";
+ _GroupingMembers = value;
+ OnGroupingMembersChanged();
+ }
+ }
+
+ ///
+ /// Called when GroupingMembers property has changed.
+ ///
+ protected virtual void OnGroupingMembersChanged()
+ {
+ RefreshItems();
+ }
+
+ private ElementStyle _GroupNodeStyle = null;
+ ///
+ /// Gets or sets style for automatically created group nodes when data-binding is used and GroupingMembers property is set.
+ ///
+ ///
+ /// Name of the style assigned or null value indicating that no style is used.
+ /// Default value is null.
+ ///
+ [Browsable(true), Category("Node Style"), DefaultValue(null), Editor("DevComponents.AdvTree.Design.ElementStyleTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Description("Gets or sets default style for the node.")]
+ public ElementStyle GroupNodeStyle
+ {
+ get { return _GroupNodeStyle; }
+ set
+ {
+ if (_GroupNodeStyle != value)
+ {
+ _GroupNodeStyle = value;
+ if (_DataManager != null && _AdvTree.Nodes != null)
+ RefreshItems();
+ }
+ }
+ }
+
+ private bool AllowSelection
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+
+ private CurrencyManager _DataManager = null;
+ protected CurrencyManager DataManager
+ {
+ get
+ {
+ return _DataManager;
+ }
+ }
+ private bool _IsDataSourceInitEventHooked = false;
+ private void UnwireDataSource()
+ {
+ if (_DataSource is IComponent)
+ {
+ ((IComponent)_DataSource).Disposed -= new EventHandler(DataSourceDisposed);
+ }
+ ISupportInitializeNotification dataSource = _DataSource as ISupportInitializeNotification;
+ if ((dataSource != null) && _IsDataSourceInitEventHooked)
+ {
+ dataSource.Initialized -= new EventHandler(DataSourceInitialized);
+ _IsDataSourceInitEventHooked = false;
+ }
+ }
+ private void DataSourceDisposed(object sender, EventArgs e)
+ {
+ this.SetDataConnection(null, null, true);
+ }
+ private bool _IsDataSourceInitialized = false;
+ private void WireDataSource()
+ {
+ if (_DataSource is IComponent)
+ {
+ ((IComponent)_DataSource).Disposed += new EventHandler(DataSourceDisposed);
+ }
+ ISupportInitializeNotification dataSource = _DataSource as ISupportInitializeNotification;
+ if ((dataSource != null) && !dataSource.IsInitialized)
+ {
+ dataSource.Initialized += new EventHandler(DataSourceInitialized);
+ _IsDataSourceInitEventHooked = true;
+ _IsDataSourceInitialized = false;
+ }
+ else
+ {
+ _IsDataSourceInitialized = true;
+ }
+ }
+ private void DataSourceInitialized(object sender, EventArgs e)
+ {
+ this.SetDataConnection(_DataSource, _DisplayMembers, true);
+ }
+ ///
+ /// Raises the Format event.
+ ///
+ /// Event parameters
+ protected virtual void OnFormat(TreeConvertEventArgs e)
+ {
+ TreeConvertEventHandler handler = Format;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ private static TypeConverter stringTypeConverter;
+ public string GetItemText(object item, string fieldName)
+ {
+ object propertyValue = GetPropertyValue(item, fieldName);
+ if (!_FormattingEnabled)
+ {
+ if (item == null)
+ {
+ return string.Empty;
+ }
+ if (propertyValue == null)
+ {
+ return "";
+ }
+ return Convert.ToString(propertyValue, CultureInfo.CurrentCulture);
+ }
+
+ TreeConvertEventArgs e = new TreeConvertEventArgs(propertyValue, typeof(string), item, fieldName);
+ this.OnFormat(e);
+ if ((e.Value != item) && (e.Value is string))
+ {
+ return (string)e.Value;
+ }
+ if (stringTypeConverter == null)
+ {
+ stringTypeConverter = TypeDescriptor.GetConverter(typeof(string));
+ }
+ try
+ {
+ return (string)FormatHelper.FormatObject(propertyValue, typeof(string), GetFieldConverter(fieldName), stringTypeConverter, _FormatString, _FormatInfo, null, DBNull.Value);
+ }
+ catch (Exception ex)
+ {
+ if (ex is SecurityException || IsCriticalException(ex))
+ {
+ throw;
+ }
+ return ((propertyValue != null) ? Convert.ToString(item, CultureInfo.CurrentCulture) : "");
+ }
+ }
+ private static bool IsCriticalException(Exception ex)
+ {
+ return (((((ex is NullReferenceException) || (ex is StackOverflowException)) || ((ex is OutOfMemoryException) || (ex is ThreadAbortException))) || ((ex is ExecutionEngineException) || (ex is IndexOutOfRangeException))) || (ex is AccessViolationException));
+ }
+ protected object GetPropertyValue(object item, string fieldName)
+ {
+ if ((item != null) && (fieldName.Length > 0))
+ {
+ try
+ {
+ PropertyDescriptor descriptor;
+ if (_DataManager != null)
+ {
+ descriptor = _DataManager.GetItemProperties().Find(fieldName, true);
+ }
+ else
+ {
+ descriptor = TypeDescriptor.GetProperties(item).Find(fieldName, true);
+ }
+ if (descriptor != null)
+ {
+ item = descriptor.GetValue(item);
+ }
+ }
+ catch
+ {
+ }
+ }
+ return item;
+ }
+ ///
+ /// Gets or sets the index specifying the currently selected item.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Description("Gets or sets the index specifying the currently selected item.")]
+ public int SelectedIndex
+ {
+ get
+ {
+ if (_DataManager != null)
+ {
+ if (_AdvTree.SelectedNode == null || _AdvTree.SelectedNode.BindingIndex < 0)
+ return -1;
+ return _AdvTree.SelectedNode.BindingIndex;
+ }
+ if (_AdvTree.SelectedNode == null) return -1;
+ return _AdvTree.GetNodeFlatIndex(_AdvTree.SelectedNode);
+ }
+ set
+ {
+ SetSelectedIndex(value);
+ }
+ }
+ private void SetSelectedIndex(int value)
+ {
+ if (value == -1)
+ {
+ _AdvTree.SelectedNode = null;
+ return;
+ }
+ Node node = null;
+ if (_DataManager != null)
+ {
+ node = _AdvTree.FindNodeByBindingIndex(value);
+ }
+ else
+ {
+ node = _AdvTree.GetNodeByFlatIndex(value);
+ }
+ _AdvTree.SelectedNode = node;
+ }
+ ///
+ /// Raises the SelectedIndexChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnSelectedIndexChanged(EventArgs e)
+ {
+ EventHandler handler = SelectedIndexChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ protected override void OnParentChanged(EventArgs e)
+ {
+ if (this.DataSource != null && _AdvTree.Nodes.Count == 0 && _DisplayMembers!=null && _DisplayMembers.Count>0)
+ {
+ this.SetDataConnection(this.DataSource, _DisplayMembers, true);
+ _AdvTree.SetPendingLayout();
+ }
+
+ base.OnParentChanged(e);
+ }
+
+ private BindingMemberInfo _ValueMember = new BindingMemberInfo();
+ ///
+ /// Gets or sets the property to use as the actual value for the items in the control. Applies to data-binding scenarios. SelectedValue property will return the value of selected node as indicated by this property.
+ ///
+ [Category("Data"), DefaultValue(""), Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), Description("property to use as the actual value for the items in the control. Applies to data-binding scenarios. SelectedValue property will return the value of selected node as indicated by this property.")]
+ public string ValueMember
+ {
+ get
+ {
+ return _ValueMember.BindingMember;
+ }
+ set
+ {
+ if (value == null)
+ {
+ value = "";
+ }
+ BindingMemberInfo newValueMember = new BindingMemberInfo(value);
+ if (!newValueMember.Equals(_ValueMember))
+ {
+ if (this.DisplayMembers.Length == 0 && this.Columns.Count == 0)
+ {
+ List list = new List();
+ list.Add(newValueMember);
+ this.SetDataConnection(this.DataSource, list, false);
+ }
+ if (((_DataManager != null) && (value != null)) && ((value.Length != 0) && !this.BindingMemberInfoInDataManager(newValueMember)))
+ {
+ throw new ArgumentException("Invalid value for ValueMember", "value");
+ }
+ _ValueMember = newValueMember;
+ this.OnValueMemberChanged(EventArgs.Empty);
+ this.OnSelectedValueChanged(EventArgs.Empty);
+ }
+ }
+ }
+ ///
+ /// Raises the ValueMemberChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnValueMemberChanged(EventArgs e)
+ {
+ EventHandler handler = ValueMemberChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+ ///
+ /// Raises the SelectedValueChanged event.
+ ///
+ /// Event arguments.
+ protected virtual void OnSelectedValueChanged(EventArgs e)
+ {
+ EventHandler handler = SelectedValueChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+ ///
+ /// Gets or sets the value of the member property specified by the ValueMember property.
+ ///
+ [Browsable(false), DefaultValue(null), Bindable(true), Category("Data"), Description("Indicates value of the member property specified by the ValueMember property."), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public object SelectedValue
+ {
+ get
+ {
+ if (_DataManager != null && this.SelectedIndex != -1)
+ {
+ object item = _DataManager.List[this.SelectedIndex];
+ return this.GetPropertyValue(item, _ValueMember.BindingField);
+ }
+ return null;
+ }
+ set
+ {
+ if (_DataManager != null)
+ {
+ string bindingField = _ValueMember.BindingField;
+ if (string.IsNullOrEmpty(bindingField))
+ {
+ throw new InvalidOperationException("ValueMember property must be set to be able to set SelectedValue");
+ }
+ PropertyDescriptor property = _DataManager.GetItemProperties().Find(bindingField, true);
+ System.Reflection.MethodInfo mi = _DataManager.GetType().GetMethod("Find", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
+ int num = -1;
+ if (mi != null)
+ {
+ num = (int)mi.Invoke(_DataManager, new object[] { property, value, true });
+ }
+ else
+ {
+ //int num = _DataManager.Find(property, value, true);
+ // Provide an alternate implementation...
+ }
+ this.SelectedIndex = num;
+ }
+ }
+ }
+
+
+ //private void TextBoxSizeChanged(object sender, EventArgs e)
+ //{
+ // if (!_InternalSizeUpdate)
+ // UpdateLayout();
+ //}
+
+ //private void TextBoxTextChanged(object sender, EventArgs e)
+ //{
+ // base.Text = _TextBox.Text;
+ //}
+
+ //private void TextBoxTextAlignChanged(object sender, EventArgs e)
+ //{
+ // OnTextAlignChanged(e);
+ //}
+ /////
+ ///// Raises the TextAlignChanged event.
+ /////
+ //protected virtual void OnTextAlignChanged(EventArgs e)
+ //{
+ // EventHandler eh = TextAlignChanged;
+ // if (eh != null)
+ // eh(this, e);
+ //}
+
+ private Font _WatermarkFont = null;
+ ///
+ /// Gets or sets the watermark font.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates watermark font."), DefaultValue(null)]
+ public virtual Font WatermarkFont
+ {
+ get { return _WatermarkFont; }
+ set { _WatermarkFont = value; this.Invalidate(); }
+ }
+
+ private Color _WatermarkColor = SystemColors.GrayText;
+ ///
+ /// Gets or sets the watermark text color.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates watermark text color.")]
+ public virtual Color WatermarkColor
+ {
+ get { return _WatermarkColor; }
+ set { _WatermarkColor = value; this.Invalidate(); }
+ }
+ ///
+ /// Indicates whether property should be serialized by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeWatermarkColor()
+ {
+ return _WatermarkColor != SystemColors.GrayText;
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetWatermarkColor()
+ {
+ this.WatermarkColor = SystemColors.GrayText;
+ }
+
+ private bool _WatermarkEnabled = true;
+ ///
+ /// Gets or sets whether watermark text is displayed if set for the input items. Default value is true.
+ ///
+ [DefaultValue(true), Description("Indicates whether watermark text is displayed if set for the input items.")]
+ public virtual bool WatermarkEnabled
+ {
+ get { return _WatermarkEnabled; }
+ set { _WatermarkEnabled = value; this.Invalidate(); }
+ }
+
+ private string _WatermarkText = "";
+ ///
+ /// Gets or sets the watermark text displayed on the input control when control is empty.
+ ///
+ [DefaultValue(""), Localizable(true), Description("Indicates watermark text displayed on the input control when control is empty."), Category("Watermark")]
+ public string WatermarkText
+ {
+ get { return _WatermarkText; }
+ set
+ {
+ if (value != null)
+ {
+ _WatermarkText = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ private eTextAlignment _WatermarkAlignment = eTextAlignment.Left;
+ ///
+ /// Gets or sets the watermark text alignment. Default value is left.
+ ///
+ [Browsable(true), DefaultValue(eTextAlignment.Left), Description("Indicates watermark text alignment."), Category("Watermark")]
+ public eTextAlignment WatermarkAlignment
+ {
+ get { return _WatermarkAlignment; }
+ set
+ {
+ if (_WatermarkAlignment != value)
+ {
+ _WatermarkAlignment = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets whether FocusHighlightColor is used as background color to highlight text box when it has input focus. Default value is false.
+ ///
+ [DefaultValue(false), Browsable(true), Category("Appearance"), Description("Indicates whether FocusHighlightColor is used as background color to highlight text box when it has input focus.")]
+ public bool FocusHighlightEnabled
+ {
+ get { return _FocusHighlightEnabled; }
+ set
+ {
+ if (_FocusHighlightEnabled != value)
+ {
+ _FocusHighlightEnabled = value;
+ //_TextBox.FocusHighlightEnabled = value;
+ if (this.Focused)
+ this.Invalidate(true);
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the color used as background color to highlight text box when it has input focus and focus highlight is enabled.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates color used as background color to highlight text box when it has input focus and focus highlight is enabled.")]
+ public Color FocusHighlightColor
+ {
+ get { return _FocusHighlightColor; }
+ set
+ {
+ if (_FocusHighlightColor != value)
+ {
+ _FocusHighlightColor = value;
+ //_TextBox.FocusHighlightColor = value;
+ if (this.Focused)
+ this.Invalidate(true);
+ }
+ }
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeFocusHighlightColor()
+ {
+ return !_FocusHighlightColor.Equals(ColorScheme.GetColor(0xFFFF88));
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetFocusHighlightColor()
+ {
+ FocusHighlightColor = ColorScheme.GetColor(0xFFFF88);
+ }
+
+ private ElementStyle _BackgroundStyle = new ElementStyle();
+ ///
+ /// Specifies the background style of the control.
+ ///
+ [Category("Style"), Description("Gets or sets control background style."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return _BackgroundStyle; }
+ }
+
+ ///
+ /// Resets style to default value. Used by windows forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackgroundStyle()
+ {
+ _BackgroundStyle.StyleChanged -= new EventHandler(this.VisualPropertyChanged);
+ _BackgroundStyle = new ElementStyle();
+ _BackgroundStyle.StyleChanged += new EventHandler(this.VisualPropertyChanged);
+ this.Invalidate();
+ }
+
+ private void VisualPropertyChanged(object sender, EventArgs e)
+ {
+ OnVisualPropertyChanged();
+ }
+
+ protected virtual void OnVisualPropertyChanged()
+ {
+ _ButtonGroup.InvalidateArrange();
+ this.Invalidate();
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (_BackgroundStyle != null) _BackgroundStyle.StyleChanged -= new EventHandler(VisualPropertyChanged);
+ System.Windows.Forms.Timer timer = _SearchBufferExpireTimer;
+ _SearchBufferExpireTimer = null;
+ if (timer != null)
+ {
+ timer.Stop();
+ timer.Dispose();
+ }
+ if (_AdvTree != null)
+ {
+ _AdvTree.AfterNodeSelect -= new AdvTreeNodeEventHandler(TreeAfterNodeSelect);
+ _AdvTree.BeforeNodeSelect -= new AdvTreeNodeCancelEventHandler(TreeBeforeNodeSelect);
+ _AdvTree.NodeMouseDown -= new TreeNodeMouseEventHandler(TreeNodeMouseDown);
+ }
+ if(_DropDownControl!=null)
+ {
+ _DropDownControl.Dispose();
+ _DropDownControl = null;
+ }
+ base.Dispose(disposing);
+ }
+
+ private InputButtonSettings _ButtonDropDown = null;
+ ///
+ /// Gets the object that describes the settings for the button that shows drop-down when clicked.
+ ///
+ [Category("Buttons"), Description("Describes the settings for the button that shows drop-down when clicked."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonDropDown
+ {
+ get
+ {
+ return _ButtonDropDown;
+ }
+ }
+
+ private InputButtonSettings _ButtonClear = null;
+ ///
+ /// Gets the object that describes the settings for the button that clears the content of the control when clicked.
+ ///
+ [Category("Buttons"), Description("Describes the settings for the button that clears the content of the control when clicked."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonClear
+ {
+ get
+ {
+ return _ButtonClear;
+ }
+ }
+
+
+ private InputButtonSettings _ButtonCustom = null;
+ ///
+ /// Gets the object that describes the settings for the custom button that can execute an custom action of your choosing when clicked.
+ ///
+ [Category("Buttons"), Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom
+ {
+ get
+ {
+ return _ButtonCustom;
+ }
+ }
+
+ private InputButtonSettings _ButtonCustom2 = null;
+ ///
+ /// Gets the object that describes the settings for the custom button that can execute an custom action of your choosing when clicked.
+ ///
+ [Category("Buttons"), Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom2
+ {
+ get
+ {
+ return _ButtonCustom2;
+ }
+ }
+
+
+ void IInputButtonControl.InputButtonSettingsChanged(InputButtonSettings inputButtonSettings)
+ {
+ OnInputButtonSettingsChanged(inputButtonSettings);
+ }
+
+ protected virtual void OnInputButtonSettingsChanged(InputButtonSettings inputButtonSettings)
+ {
+ UpdateButtons();
+ }
+
+ private VisualGroup _ButtonGroup = null;
+ private void UpdateButtons()
+ {
+ RecreateButtons();
+ _ButtonGroup.InvalidateArrange();
+ this.Invalidate();
+ }
+
+ protected virtual void RecreateButtons()
+ {
+ VisualItem[] buttons = CreateOrderedButtonList();
+ // Remove all system buttons that are already in the list
+ VisualGroup group = _ButtonGroup;
+ VisualItem[] items = new VisualItem[group.Items.Count];
+ group.Items.CopyTo(items);
+ foreach (VisualItem item in items)
+ {
+ if (item.ItemType == eSystemItemType.SystemButton)
+ {
+ group.Items.Remove(item);
+ if (item == _ButtonCustom.ItemReference)
+ item.MouseUp -= new MouseEventHandler(CustomButtonClick);
+ else if (item == _ButtonCustom2.ItemReference)
+ item.MouseUp -= new MouseEventHandler(CustomButton2Click);
+ }
+ }
+
+ // Add new buttons to the list
+ group.Items.AddRange(buttons);
+ }
+
+ private void CustomButtonClick(object sender, MouseEventArgs e)
+ {
+ if (_ButtonCustom.ItemReference.RenderBounds.Contains(e.X, e.Y))
+ OnButtonCustomClick(e);
+ }
+
+ protected virtual void OnButtonCustomClick(EventArgs e)
+ {
+ if (ButtonCustomClick != null)
+ ButtonCustomClick(this, e);
+ }
+
+ private void CustomButton2Click(object sender, MouseEventArgs e)
+ {
+ if (_ButtonCustom2.ItemReference.RenderBounds.Contains(e.X, e.Y))
+ OnButtonCustom2Click(e);
+ }
+
+ protected virtual void OnButtonCustom2Click(EventArgs e)
+ {
+ if (ButtonCustom2Click != null)
+ ButtonCustom2Click(this, e);
+ }
+
+ private VisualItem[] CreateOrderedButtonList()
+ {
+ SortedList list = CreateSortedButtonList();
+
+ VisualItem[] items = new VisualItem[list.Count];
+ list.Values.CopyTo(items, 0);
+
+ return items;
+ }
+
+ protected virtual SortedList CreateSortedButtonList()
+ {
+ SortedList list = new SortedList(4);
+ if (_ButtonCustom.Visible)
+ {
+ VisualItem button = CreateButton(_ButtonCustom);
+ if (_ButtonCustom.ItemReference != null)
+ {
+ _ButtonCustom.ItemReference.MouseUp -= new MouseEventHandler(CustomButtonClick);
+ _ButtonCustom.ItemReference.Click -= CustomButtonKeyClick;
+ }
+ _ButtonCustom.ItemReference = button;
+ button.Click += CustomButtonKeyClick;
+ button.MouseUp += new MouseEventHandler(CustomButtonClick);
+ button.Enabled = _ButtonCustom.Enabled;
+ list.Add(_ButtonCustom, button);
+ }
+
+ if (_ButtonCustom2.Visible)
+ {
+ VisualItem button = CreateButton(_ButtonCustom2);
+ if (_ButtonCustom2.ItemReference != null)
+ {
+ _ButtonCustom2.ItemReference.MouseUp -= new MouseEventHandler(CustomButton2Click);
+ _ButtonCustom2.ItemReference.Click -= CustomButton2KeyClick;
+ }
+ _ButtonCustom2.ItemReference = button;
+ button.Click += CustomButton2KeyClick;
+ button.MouseUp += new MouseEventHandler(CustomButton2Click);
+ button.Enabled = _ButtonCustom2.Enabled;
+ list.Add(_ButtonCustom2, button);
+ }
+
+ if (_ButtonClear.Visible)
+ {
+ VisualItem button = CreateButton(_ButtonClear);
+ if (_ButtonClear.ItemReference != null)
+ {
+ _ButtonClear.ItemReference.MouseUp -= ClearButtonClick;
+ _ButtonClear.ItemReference.Click -= ClearButtonKeyClick;
+ }
+ _ButtonClear.ItemReference = button;
+ button.MouseUp += ClearButtonClick;
+ button.Click += ClearButtonKeyClick;
+ list.Add(_ButtonClear, button);
+ }
+
+ if (_ButtonDropDown.Visible)
+ {
+ VisualItem button = CreateButton(_ButtonDropDown);
+ if (_ButtonDropDown.ItemReference != null)
+ {
+ _ButtonDropDown.ItemReference.MouseDown -= new MouseEventHandler(DropDownButtonMouseDown);
+ _ButtonDropDown.ItemReference.Click -= DropDownButtonKeyClick;
+ }
+ _ButtonDropDown.ItemReference = button;
+ button.MouseDown += new MouseEventHandler(DropDownButtonMouseDown);
+ button.Click += DropDownButtonKeyClick;
+ list.Add(_ButtonDropDown, button);
+ }
+
+ return list;
+ }
+
+ private void ClearButtonKeyClick(object sender, EventArgs e)
+ {
+ if (e is KeyEventArgs)
+ ClearButtonClick(sender, e);
+ }
+ private void CustomButtonKeyClick(object sender, EventArgs e)
+ {
+ if (e is KeyEventArgs)
+ OnButtonCustomClick(e);
+ }
+ private void CustomButton2KeyClick(object sender, EventArgs e)
+ {
+ if (e is KeyEventArgs)
+ OnButtonCustom2Click(e);
+ }
+ private void DropDownButtonKeyClick(object sender, EventArgs e)
+ {
+ if (e is KeyEventArgs)
+ IsPopupOpen = !IsPopupOpen;
+ }
+ protected virtual VisualItem CreateButton(InputButtonSettings buttonSettings)
+ {
+ VisualItem item = null;
+
+ if (buttonSettings == _ButtonDropDown)
+ {
+ item = new VisualDropDownButton();
+ ApplyButtonSettings(buttonSettings, item as VisualButton);
+ }
+ else
+ {
+ item = new VisualCustomButton();
+ ApplyButtonSettings(buttonSettings, item as VisualButton);
+ }
+
+ VisualButton button = item as VisualButton;
+ button.ClickAutoRepeat = false;
+
+ if (buttonSettings == _ButtonClear)
+ {
+ if (buttonSettings.Image == null && string.IsNullOrEmpty(buttonSettings.Text))
+ {
+ //if (Dpi.Factor.Width > 1)
+ button.Symbol = "\uf00d";
+ //else
+ // button.Image = DevComponents.DotNetBar.BarFunctions.LoadBitmap("SystemImages.DateReset.png");
+ }
+ }
+
+ return item;
+ }
+
+ protected virtual void ApplyButtonSettings(InputButtonSettings buttonSettings, VisualButton button)
+ {
+ button.Text = buttonSettings.Text;
+ button.Image = buttonSettings.Image;
+ button.ItemType = eSystemItemType.SystemButton;
+ button.Enabled = buttonSettings.Enabled;
+ button.Shortcut = buttonSettings.Shortcut;
+ button.Tooltip = buttonSettings.Tooltip;
+ button.Symbol = buttonSettings.Symbol;
+ button.SymbolSet = buttonSettings.SymbolSet;
+ button.SymbolColor = buttonSettings.SymbolColor;
+ }
+
+ private void CreateButtonGroup()
+ {
+ VisualGroup group = new VisualGroup();
+ group.HorizontalItemSpacing = 0;
+ group.ArrangeInvalid += new EventHandler(ButtonGroupArrangeInvalid);
+ group.RenderInvalid += new EventHandler(ButtonGroupRenderInvalid);
+ group.ResetMouseHover += ButtonGroupRenderMouseHover;
+ _ButtonGroup = group;
+ }
+
+ private void ButtonGroupRenderInvalid(object sender, EventArgs e)
+ {
+ Invalidate();
+ }
+
+ private void ButtonGroupArrangeInvalid(object sender, EventArgs e)
+ {
+ Invalidate();
+ }
+
+ private void ButtonGroupRenderMouseHover(object sender, EventArgs e)
+ {
+ DevComponents.AdvTree.Interop.WinApi.ResetHover(this);
+ }
+
+ private bool _MouseOver = false;
+ private PaintInfo CreatePaintInfo(Graphics g)
+ {
+ PaintInfo p = new PaintInfo();
+ p.Graphics = g;
+ p.DefaultFont = this.Font;
+ p.ForeColor = this.ForeColor;
+ p.RenderOffset = new System.Drawing.Point();
+ Size s = this.Size;
+ bool disposeStyle = false;
+ ElementStyle style = GetBackgroundStyle(out disposeStyle);
+ s.Height -= (ElementStyleLayout.TopWhiteSpace(style, eSpacePart.Border) + ElementStyleLayout.BottomWhiteSpace(style, eSpacePart.Border)) + 2;
+ s.Width -= (ElementStyleLayout.LeftWhiteSpace(style, eSpacePart.Border) + ElementStyleLayout.RightWhiteSpace(style, eSpacePart.Border)) + 2;
+ p.AvailableSize = s;
+ p.ParentEnabled = this.Enabled;
+ p.MouseOver = _MouseOver || this.Focused;
+ if(disposeStyle) style.Dispose();
+ return p;
+ }
+
+ private ElementStyle GetBackgroundStyle(out bool disposeStyle)
+ {
+ disposeStyle = false;
+ _BackgroundStyle.SetColorScheme(this.GetColorScheme());
+ return ElementStyleDisplay.GetElementStyle(_BackgroundStyle, out disposeStyle);
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ base.OnPaint(e);
+ Graphics g = e.Graphics;
+ Rectangle clientRect = this.ClientRectangle;
+ bool enabled = this.Enabled;
+
+#if !TRIAL
+ if (NativeFunctions.keyValidated2 != 266)
+ TextDrawing.DrawString(e.Graphics, "Invalid License", this.Font, Color.FromArgb(180, Color.Red), this.ClientRectangle, eTextFormat.Bottom | eTextFormat.HorizontalCenter);
+#else
+ if (NativeFunctions.ColorExpAlt() || !NativeFunctions.CheckedThrough)
+ {
+ e.Graphics.Clear(SystemColors.Control);
+ return;
+ }
+#endif
+
+ if (!this.Enabled)
+ {
+ if (!_DisabledBackColor.IsEmpty)
+ {
+ using(SolidBrush brush=new SolidBrush(_DisabledBackColor))
+ e.Graphics.FillRectangle(brush, clientRect);
+ }
+ else
+ e.Graphics.FillRectangle(SystemBrushes.Control, clientRect);
+ }
+ else
+ {
+ using (SolidBrush brush = new SolidBrush(this.BackColor))
+ e.Graphics.FillRectangle(brush, clientRect);
+ }
+
+ bool disposeStyle = false;
+ ElementStyle style = GetBackgroundStyle(out disposeStyle);
+
+ if (style.Custom)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ if (this.AntiAlias)
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+ ElementStyleDisplayInfo displayInfo = new ElementStyleDisplayInfo(style, g, clientRect);
+ if (!enabled)
+ {
+ ElementStyleDisplay.PaintBorder(displayInfo);
+ }
+ else
+ ElementStyleDisplay.Paint(displayInfo);
+ if (this.AntiAlias)
+ g.SmoothingMode = sm;
+ }
+
+ Rectangle buttonBounds = PaintButtons(g);
+ // Paint selected content
+ Rectangle selectionRect = GetSelectionRectangle(style, clientRect);
+ if (!buttonBounds.IsEmpty)
+ {
+ Rectangle[] split = DisplayHelp.ExcludeRectangle(selectionRect, buttonBounds);
+ if (split.Length >= 1)
+ selectionRect = split[0];
+ selectionRect.Width--;
+ }
+
+ if (this.WatermarkEnabled && this.WatermarkText.Length > 0 && this.IsWatermarkRendered)
+ {
+ Rectangle watermarkBounds = selectionRect;
+ watermarkBounds.Inflate(-1, -1);
+ DrawWatermark(g, watermarkBounds);
+ }
+
+ PaintSelection(g, selectionRect);
+
+ if(disposeStyle) style.Dispose();
+ }
+
+ private void DrawWatermark(Graphics g, Rectangle r)
+ {
+ if (this.WatermarkText.Length == 0) return;
+ Font font = this.Font;
+ if (this.WatermarkFont != null) font = this.WatermarkFont;
+
+ eTextFormat format = eTextFormat.Default;
+ if (_WatermarkAlignment == eTextAlignment.Center)
+ format |= eTextFormat.HorizontalCenter;
+ else if (_WatermarkAlignment == eTextAlignment.Right)
+ format |= eTextFormat.Right;
+
+ TextDrawing.DrawString(g, this.WatermarkText, font, this.WatermarkColor, r, format);
+ }
+
+ protected virtual bool IsWatermarkRendered
+ {
+ get
+ {
+ return !this.Focused && this.SelectedNode == null;
+ }
+ }
+
+ private Rectangle GetSelectionRectangle(ElementStyle style, Rectangle clientRect)
+ {
+ return new Rectangle(ElementStyleLayout.LeftWhiteSpace(style, eSpacePart.Border) + 1,
+ ElementStyleLayout.TopWhiteSpace(style, eSpacePart.Border) + 1,
+ clientRect.Width-(ElementStyleLayout.RightWhiteSpace(style, eSpacePart.Border) + ElementStyleLayout.LeftWhiteSpace(style, eSpacePart.Border) + 2),
+ clientRect.Height-(ElementStyleLayout.TopWhiteSpace(style, eSpacePart.Border) + ElementStyleLayout.BottomWhiteSpace(style, eSpacePart.Border) + 2));
+
+ }
+
+ protected string GetSelectedDisplayMemberText(Node node)
+ {
+ int index = _AdvTree.Columns.IndexOfField(_SelectedDisplayMember);
+ if (index >= 0)
+ {
+ return node.Cells[index].Text;
+ }
+ // Try to get it from data
+ return GetItemText(node.DataKey, _SelectedDisplayMember);
+ }
+
+ ///
+ /// Renders the selected node inside the combo box.
+ ///
+ /// Graphics reference.
+ /// Render bounds.
+ protected virtual void PaintSelection(Graphics g, Rectangle bounds)
+ {
+ if (bounds.Width < 2 || bounds.Height < 2) return;
+
+ if (this.Focused && !this.IsPopupOpen)
+ {
+ SelectionRendererEventArgs selectionArgs = new SelectionRendererEventArgs();
+ selectionArgs.Bounds = bounds;
+ selectionArgs.Graphics = g;
+ selectionArgs.SelectionBoxStyle = eSelectionStyle.HighlightCells;
+ selectionArgs.TreeActive = true;
+ ((DevComponents.AdvTree.Display.NodeTreeDisplay)_AdvTree.NodeDisplay).GetTreeRenderer().DrawSelection(selectionArgs);
+ }
+
+ Node node = _AdvTree.SelectedNode;
+ if (node != null)
+ {
+ if (node.BoundsRelative.IsEmpty || _AdvTree.IsLayoutPending || node.BoundsRelative.Width <= 0 || _AdvTree.Width <= 0)
+ {
+ UpdateTreeSize();
+ if (_AdvTree.IsLayoutPending) _AdvTree.RecalcLayout();
+ }
+
+ Region oldClip = g.Clip;
+ g.SetClip(bounds);
+
+ Rectangle nodeRenderBounds = bounds;
+
+ if (!string.IsNullOrEmpty(_SelectedDisplayMember))
+ {
+ string text = GetSelectedDisplayMemberText(node);
+
+ if (string.IsNullOrEmpty(text) == false)
+ {
+ nodeRenderBounds.Y--;
+ nodeRenderBounds.X++;
+ nodeRenderBounds.Width--;
+
+ TextDrawing.DrawString(g, text, Font, Enabled ? ForeColor : SystemColors.ControlDark,
+ nodeRenderBounds, eTextFormat.Left | eTextFormat.NoClipping | eTextFormat.NoPadding | eTextFormat.VerticalCenter);
+ }
+ }
+ else
+ {
+
+ if (DevComponents.AdvTree.Display.NodeDisplay.DrawExpandPart(node))
+ {
+ nodeRenderBounds.X -= _AdvTree.ExpandWidth;
+ }
+ else
+ nodeRenderBounds.X -= (node.Bounds.X - node.BoundsRelative.X - 2);
+ if (nodeRenderBounds.Height > node.BoundsRelative.Height)
+ nodeRenderBounds.Y += (nodeRenderBounds.Height - node.BoundsRelative.Height) / 2;
+ else
+ nodeRenderBounds.Y += 1;
+ bool oldEnabled = node.Enabled;
+ if (node.Enabled != this.Enabled)
+ node.Enabled = this.Enabled;
+ bool oldSelectionVisible = node.IsSelectionVisible;
+ node.IsSelectionVisible = this.Focused && !this.IsPopupOpen;
+ ((DevComponents.AdvTree.Display.NodeTreeDisplay)_AdvTree.NodeDisplay).ExternalPaintNode(node, g, nodeRenderBounds);
+ node.Enabled = oldEnabled;
+ node.IsSelectionVisible = oldSelectionVisible;
+ }
+
+ g.Clip = oldClip;
+ if(oldClip!=null) oldClip.Dispose();
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBackColor()
+ {
+ return this.BackColor != SystemColors.Window;
+ }
+
+ //protected override void OnBackColorChanged(EventArgs e)
+ //{
+ // base.OnBackColorChanged(e);
+ // _TextBox.BackColor = this.BackColor;
+ //}
+
+ private Rectangle PaintButtons(Graphics g)
+ {
+ PaintInfo p = CreatePaintInfo(g);
+
+ if (!_ButtonGroup.IsLayoutValid)
+ {
+ UpdateLayout(p);
+ }
+
+ bool disposeStyle = false;
+ ElementStyle style = GetBackgroundStyle(out disposeStyle);
+ _ButtonGroup.RenderBounds = GetButtonsRenderBounds(style);
+ _ButtonGroup.ProcessPaint(p);
+ if(disposeStyle) style.Dispose();
+ return _ButtonGroup.RenderBounds;
+ }
+
+ private Rectangle GetButtonsRenderBounds(ElementStyle style)
+ {
+ if (this.RightToLeft == RightToLeft.Yes)
+ {
+ return new Rectangle((ElementStyleLayout.LeftWhiteSpace(style, eSpacePart.Border) + 1), ElementStyleLayout.TopWhiteSpace(style, eSpacePart.Border) + 1,
+ _ButtonGroup.Size.Width, _ButtonGroup.Size.Height);
+ }
+
+ return new Rectangle(this.Width - (ElementStyleLayout.RightWhiteSpace(style, eSpacePart.Border) + 1) - _ButtonGroup.Size.Width, ElementStyleLayout.TopWhiteSpace(style, eSpacePart.Border) + 1,
+ _ButtonGroup.Size.Width, _ButtonGroup.Size.Height);
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ _ButtonGroup.InvalidateArrange();
+ UpdateLayout();
+ this.Invalidate();
+ base.OnResize(e);
+ }
+
+ protected override void OnEnter(EventArgs e)
+ {
+ this.Invalidate();
+ base.OnEnter(e);
+ }
+
+ protected override void OnLeave(EventArgs e)
+ {
+ if (this.IsPopupOpen) this.IsPopupOpen = false;
+ this.Invalidate();
+ base.OnLeave(e);
+ }
+
+ //protected override void OnGotFocus(EventArgs e)
+ //{
+ // if(_TextBox.Visible)
+ // _TextBox.Focus();
+ // base.OnGotFocus(e);
+ //}
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ _ButtonGroup.ProcessKeyDown(e);
+ base.OnKeyDown(e);
+ }
+
+ private bool _EnterKeyTogglesPopup = true;
+ ///
+ /// Indicates whether Enter key when pressed while control has input focus toggles the popup. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether Enter key when pressed while control has input focus toggles the popup.")]
+ public bool EnterKeyTogglesPopup
+ {
+ get { return _EnterKeyTogglesPopup; }
+ set
+ {
+ _EnterKeyTogglesPopup = value;
+ }
+ }
+
+
+ protected override bool OnKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ if (this.Focused)
+ {
+ Keys key = (Keys)NativeFunctions.MapVirtualKey((uint)wParam, 2);
+ if (key == Keys.None)
+ key = (Keys)WinApi.ToInt(wParam);
+ if (key == Keys.F4)
+ {
+ this.IsPopupOpen = !this.IsPopupOpen;
+ return true;
+ }
+ else if (((key == Keys.Down && (Control.ModifierKeys & Keys.Alt) != 0) || key == Keys.Enter && _EnterKeyTogglesPopup) && !this.IsPopupOpen)
+ {
+ this.IsPopupOpen = !this.IsPopupOpen;
+ return true;
+ }
+ else if (this.IsPopupOpen && (key == Keys.Tab || key == Keys.Enter))
+ {
+ this.IsPopupOpen = false;
+ if(key == Keys.Enter)
+ return true;
+ }
+ else if (this.IsPopupOpen)
+ {
+ if (key == Keys.Up)
+ {
+ this.SelectPreviousNode(eTreeAction.Keyboard);
+ return true;
+ }
+ else if (key == Keys.Down)
+ {
+ this.SelectNextNode(eTreeAction.Keyboard);
+ return true;
+ }
+ else
+ {
+ try
+ {
+ byte[] keyState = new byte[256];
+ if (NativeFunctions.GetKeyboardState(keyState))
+ {
+ byte[] chars = new byte[2];
+ if (NativeFunctions.ToAscii((uint)key, 0, keyState, chars, 0) != 0)
+ {
+ char[] characters = new char[2];
+ System.Text.Encoding.Default.GetDecoder().GetChars(chars, 0, 2, characters, 0);
+ if (ProcessKeyboardCharacter(characters[0]))
+ return true;
+ }
+ }
+ }
+ catch (Exception)
+ {
+
+ }
+ }
+ }
+ }
+ return base.OnKeyDown(hWnd, wParam, lParam);
+ }
+
+ protected override void OnKeyUp(KeyEventArgs e)
+ {
+ _ButtonGroup.ProcessKeyUp(e);
+ base.OnKeyUp(e);
+ }
+
+ protected override bool IsInputChar(char charCode)
+ {
+ if(_KeyboardSearchEnabled && char.IsLetterOrDigit(charCode))
+ return true;
+ return base.IsInputChar(charCode);
+ }
+
+ protected override void OnKeyPress(KeyPressEventArgs e)
+ {
+ if(_KeyboardSearchEnabled)
+ e.Handled = ProcessKeyboardCharacter(e.KeyChar);
+ if(!e.Handled)
+ _ButtonGroup.ProcessKeyPress(e);
+ base.OnKeyPress(e);
+ }
+
+ private bool _KeyboardSearchEnabled = true;
+ ///
+ /// Gets or sets whether keyboard incremental search is enabled. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether keyboard incremental search is enabled.")]
+ public bool KeyboardSearchEnabled
+ {
+ get { return _KeyboardSearchEnabled; }
+ set
+ {
+ _KeyboardSearchEnabled = value;
+ }
+ }
+
+ private bool _KeyboardSearchNoSelectionAllowed = true;
+ ///
+ /// Gets or sets whether during keyboard search selected node can be set to nothing/null if there is no match found.
+ /// Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether during keyboard search selected node can be set to nothing/null if there is no match found.")]
+ public bool KeyboardSearchNoSelectionAllowed
+ {
+ get { return _KeyboardSearchNoSelectionAllowed; }
+ set
+ {
+ _KeyboardSearchNoSelectionAllowed = value;
+ }
+ }
+
+
+
+ private System.Windows.Forms.Timer _SearchBufferExpireTimer = null;
+ private bool ProcessKeyboardCharacter(char p)
+ {
+ if (!char.IsLetterOrDigit(p)) return false;
+ string searchString = UpdateSearchBuffer(p.ToString());
+ Node node = _AdvTree.FindNodeByText(searchString, _AdvTree.SelectedNode, true);
+ if (node == null && _AdvTree.SelectedNode != null)
+ {
+ // Try from top searching
+ node = _AdvTree.FindNodeByText(searchString, true);
+ }
+ // If binding to data do not select the groupping virtual nodes
+ if (_DataSource != null && node != null && node.BindingIndex == -1)
+ {
+ while (node != null && node.BindingIndex == -1)
+ node = _AdvTree.FindNodeByText(searchString, node, true);
+ }
+ if (!_KeyboardSearchNoSelectionAllowed && node == null) return false;
+
+ SelectNode(node, eTreeAction.Keyboard);
+ return false;
+ }
+
+ private int _SearchBufferExpireTimeout = 1000;
+ ///
+ /// Gets or sets the keyboard search buffer expiration timeout. Default value is 1000 which indicates that
+ /// key pressed within 1 second will add to the search buffer and control will be searched for node text
+ /// that begins with resulting string. Setting this value to 0 will disable the search buffer.
+ ///
+ [DefaultValue(1000), Category("Behavior"), Description("Indicates keyboard search buffer expiration timeout.")]
+ public int SearchBufferExpireTimeout
+ {
+ get { return _SearchBufferExpireTimeout; }
+ set
+ {
+ if (value < 0) value = 0;
+ _SearchBufferExpireTimeout = value;
+ }
+ }
+
+ private string _SearchBuffer = "";
+ private string UpdateSearchBuffer(string s)
+ {
+ if (_SearchBufferExpireTimeout <= 0)
+ return s;
+
+ if (_SearchBufferExpireTimer == null)
+ {
+ _SearchBufferExpireTimer = new System.Windows.Forms.Timer();
+ _SearchBufferExpireTimer.Interval = _SearchBufferExpireTimeout;
+ _SearchBufferExpireTimer.Tick += new EventHandler(SearchBufferExpireTimerTick);
+ _SearchBufferExpireTimer.Start();
+ }
+ else
+ _SearchBufferExpireTimer.Start();
+ _SearchBuffer += s;
+ return _SearchBuffer;
+ }
+
+ private void SearchBufferExpireTimerTick(object sender, EventArgs e)
+ {
+ _SearchBufferExpireTimer.Stop();
+ _SearchBuffer = "";
+ }
+
+ protected override bool ProcessMnemonic(char charCode)
+ {
+ if (this.Focused && Control.ModifierKeys != Keys.Alt)
+ return true;
+ return base.ProcessMnemonic(charCode);
+ }
+
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+ {
+ if ((keyData & Keys.Down) == Keys.Down && (Control.ModifierKeys & Keys.Alt) != 0 && !this.IsPopupOpen)
+ {
+ this.IsPopupOpen = !this.IsPopupOpen;
+ return true;
+ }
+ else if (keyData == Keys.Up)
+ {
+ this.SelectPreviousNode(eTreeAction.Keyboard);
+ return true;
+ }
+ else if (keyData == Keys.Down)
+ {
+ this.SelectNextNode(eTreeAction.Keyboard);
+ return true;
+ }
+ if (_ButtonGroup.ProcessCmdKey(ref msg, keyData))
+ return true;
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+
+ private void SelectNextNode(eTreeAction action)
+ {
+ Node node = null;
+ if (this.SelectedNode == null)
+ node = NodeOperations.GetFirstVisibleNode(_AdvTree);
+ else
+ node = NodeOperations.GetNextVisibleNode(this.SelectedNode);
+
+ if (node != null && !node.CanSelect)
+ {
+ int counter = 0;
+ while (node != null && counter < 100)
+ {
+ node = NodeOperations.GetNextVisibleNode(node);
+ if (node != null && node.CanSelect) break;
+ }
+ }
+
+ if (node != null)
+ {
+ if (_DataManager != null)
+ {
+ while (node != null && node.DataKey == null)
+ node = NodeOperations.GetNextVisibleNode(node);
+ if (node != null)
+ SelectNode(node, action);
+ }
+ else
+ SelectNode(node, action);
+ }
+ }
+
+ private void SelectPreviousNode(eTreeAction action)
+ {
+ Node node = null;
+ if (this.SelectedNode == null)
+ node = NodeOperations.GetLastVisibleNode(_AdvTree);
+ else
+ node = NodeOperations.GetPreviousVisibleNode(this.SelectedNode);
+
+ if (node != null && !node.CanSelect)
+ {
+ int counter = 0;
+ while (node != null && counter < 100)
+ {
+ node = NodeOperations.GetPreviousVisibleNode(node);
+ if (node != null && node.CanSelect) break;
+ }
+ }
+
+ if (node != null)
+ {
+ if (_DataManager != null)
+ {
+ while (node != null && node.DataKey == null)
+ node = NodeOperations.GetNextVisibleNode(node);
+ if (node != null)
+ SelectNode(node, action);
+ }
+ else
+ SelectNode(node, action);
+ }
+ }
+
+ private void SelectNode(Node node, eTreeAction action)
+ {
+ _AdvTree.SelectNode(node, action);
+ }
+
+ protected override void OnRightToLeftChanged(EventArgs e)
+ {
+ _ButtonGroup.InvalidateArrange();
+ UpdateLayout();
+ this.Invalidate();
+ base.OnRightToLeftChanged(e);
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ _ButtonGroup.InvalidateArrange();
+ _AdvTree.Font = this.Font;
+ UpdateLayout();
+ this.Invalidate();
+ base.OnFontChanged(e);
+ }
+
+ private void UpdateLayout()
+ {
+ using (Graphics g = BarFunctions.CreateGraphics(this))
+ UpdateLayout(CreatePaintInfo(g));
+ }
+
+ private bool _InternalSizeUpdate = false;
+ private void UpdateLayout(PaintInfo p)
+ {
+ if (_InternalSizeUpdate) return;
+
+ _InternalSizeUpdate = true;
+
+ try
+ {
+ if (!_ButtonGroup.IsLayoutValid)
+ {
+ _ButtonGroup.PerformLayout(p);
+ }
+
+ bool disposeStyle = false;
+ ElementStyle style = GetBackgroundStyle(out disposeStyle);
+
+ Rectangle textBoxControlRect = ElementStyleLayout.GetInnerRect(style, this.ClientRectangle);
+ if (RenderButtons)
+ {
+ Rectangle buttonsRect = GetButtonsRenderBounds(style);
+ if (this.RightToLeft == RightToLeft.Yes)
+ {
+ textBoxControlRect.X += buttonsRect.Right;
+ textBoxControlRect.Width -= buttonsRect.Right;
+ }
+ else
+ {
+ textBoxControlRect.Width -= (textBoxControlRect.Right - buttonsRect.X);
+ }
+ }
+
+ if (disposeStyle) style.Dispose();
+ //if (_TextBox.PreferredHeight < textBoxControlRect.Height)
+ //{
+ // textBoxControlRect.Y += (textBoxControlRect.Height - _TextBox.PreferredHeight) / 2;
+ //}
+ //_TextBox.Bounds = textBoxControlRect;
+ }
+ finally
+ {
+ _InternalSizeUpdate = false;
+ }
+ }
+
+ private Control _PreviousDropDownControlParent = null;
+ private void DropDownButtonMouseDown(object sender, MouseEventArgs e)
+ {
+ if (e.Button != MouseButtons.Left || _CloseTime != DateTime.MinValue && DateTime.Now.Subtract(_CloseTime).TotalMilliseconds < 250)
+ {
+ _CloseTime = DateTime.MinValue;
+ return;
+ }
+
+ ShowDropDown();
+ }
+ ///
+ /// Updates popup tree size based on its content.
+ ///
+ public void UpdateTreeSize()
+ {
+ _AdvTree.BeginUpdate();
+ bool recalcLayout = false;
+ if (_DropDownWidth == 0)
+ {
+ if (_AdvTree.Width != this.Width - 4)
+ {
+ _AdvTree.Width = this.Width - 4;
+ recalcLayout = true;
+ }
+ }
+
+ if (_DropDownHeight == 0)
+ _AdvTree.Height = 600;
+ else
+ _AdvTree.Height = _DropDownHeight;
+ _AdvTree.EndUpdate(false);
+
+ if (_DropDownHeight == 0)
+ {
+ // Auto calculate height based on content
+ _AdvTree.RecalcLayout();
+ ScreenInformation screenInfo = BarFunctions.ScreenFromControl(this);
+ if (screenInfo != null && _AdvTree.NodeLayout.Height > screenInfo.WorkingArea.Height / 2)
+ {
+ _AdvTree.Height = screenInfo.WorkingArea.Height / 2;
+ }
+ else if (_AdvTree.Nodes.Count > 0)
+ {
+ int height=_AdvTree.NodeLayout.Height + 4;//(_AdvTree.ColumnHeaderHeight > 0 ? (_AdvTree.ColumnHeaderHeight + 4) : 4);
+ if (_AdvTree.HScrollBar != null)
+ height += _AdvTree.HScrollBar.Height + 1;
+ _AdvTree.Height = height;
+ }
+ else
+ _AdvTree.Height = this.Height;
+ }
+ else
+ {
+ _AdvTree.Height = _DropDownHeight;
+ if (recalcLayout)
+ _AdvTree.RecalcLayout();
+ }
+ }
+
+ private bool _ShowingPopup = false;
+ ///
+ /// Shows drop-down popup. Note that popup will be shown only if there is a DropDownControl assigned or DropDownItems collection has at least one item.
+ ///
+ public void ShowDropDown()
+ {
+
+ if (_DropDownControl == null && _PopupItem.SubItems.Count == 0 || _ShowingPopup || _PopupItem.Expanded)
+ return;
+
+ _ShowingPopup = true;
+ try
+ {
+ ControlContainerItem cc = null;
+ ItemContainer ic = null;
+ if (_DropDownControl != null)
+ {
+ ic = new ItemContainer();
+ ic.Name = _DropDownItemContainerName;
+ cc = new ControlContainerItem(_DropDownControlContainerName);
+ ic.SubItems.Add(cc);
+ _PopupItem.SubItems.Insert(0, ic);
+ }
+
+ CancelEventArgs cancelArgs = new CancelEventArgs();
+ OnButtonDropDownClick(cancelArgs);
+ if (cancelArgs.Cancel || _PopupItem.SubItems.Count == 0)
+ {
+ if (ic != null)
+ _PopupItem.SubItems.Remove(ic);
+ ic.Dispose();
+ return;
+ }
+
+ UpdateTreeSize();
+
+ _PreviousDropDownControlParent = _DropDownControl.Parent;
+ cc.Control = _DropDownControl;
+
+ _PopupItem.SetDisplayRectangle(this.ClientRectangle);
+ if (_PopupLocation != null)
+ _PopupItem.PopupLocation = _PopupLocation.Value;
+ else if (this.RightToLeft == RightToLeft.No)
+ {
+ Point pl = new Point(this.Width - _PopupItem.PopupSize.Width, this.Height);
+ ScreenInformation screen = BarFunctions.ScreenFromControl(this);
+ Point ps = PointToScreen(pl);
+ if (screen != null && screen.WorkingArea.X > ps.X)
+ {
+ pl.X = 0;
+ }
+ _PopupItem.PopupLocation = pl;
+ }
+ if (!IsPopupOpen && this.SelectedNode != null)
+ this.SelectedNode.EnsureVisible();
+
+ _PopupItem.Expanded = !_PopupItem.Expanded;
+ }
+ finally
+ {
+ _ShowingPopup = false;
+ }
+ this.Invalidate();
+ }
+
+ ///
+ /// Closes the drop-down popup if it is open.
+ ///
+ public void CloseDropDown()
+ {
+ if (_PopupItem.Expanded) _PopupItem.Expanded = false;
+ }
+
+ private DateTime _CloseTime = DateTime.MinValue;
+ private void DropDownPopupClose(object sender, EventArgs e)
+ {
+ _CloseTime = DateTime.Now;
+ ItemContainer ic = _PopupItem.SubItems[_DropDownItemContainerName] as ItemContainer;
+ if (ic != null)
+ {
+ ControlContainerItem cc = ic.SubItems[_DropDownControlContainerName] as ControlContainerItem;
+ if (cc != null)
+ {
+ cc.Control = null;
+ ic.SubItems.Remove(cc);
+ cc.Dispose();
+ if (_DropDownControl != null)
+ {
+ _DropDownControl.Parent = _PreviousDropDownControlParent;
+ _PreviousDropDownControlParent = null;
+ }
+ }
+ _PopupItem.SubItems.Remove(ic);
+ ic.Dispose();
+ }
+ this.Invalidate();
+ }
+
+ private Point? _PopupLocation = null;
+ ///
+ /// Indicates the custom popup location for the ComboTree popup
+ ///
+ [Browsable(false),DefaultValue(null), Category("Behavior"), Description("Indicates the custom popup location for the ComboTree popup"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public Point? PopupLocation
+ {
+ get { return _PopupLocation; }
+ set
+ {
+ if (value != _PopupLocation)
+ {
+ Point? oldValue = _PopupLocation;
+ _PopupLocation = value;
+ OnPopupLocationChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when PopupLocation property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnPopupLocationChanged(Point? oldValue, Point? newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("PopupLocation"));
+
+ }
+
+ private void ClearButtonClick(object sender, EventArgs e)
+ {
+ if (_ButtonClear.Enabled)
+ {
+ CancelEventArgs cancelArgs = new CancelEventArgs();
+ OnButtonClearClick(cancelArgs);
+ if (cancelArgs.Cancel) return;
+
+ this.SelectedNode = null;
+ }
+ }
+
+ ///
+ /// Raises the ButtonClearClick event.
+ ///
+ ///
+ protected virtual void OnButtonClearClick(CancelEventArgs e)
+ {
+ if (ButtonClearClick != null)
+ ButtonClearClick(this, e);
+ }
+
+ ///
+ /// Raises the ButtonDropDownClick event.
+ ///
+ ///
+ protected virtual void OnButtonDropDownClick(CancelEventArgs e)
+ {
+ if (ButtonDropDownClick != null)
+ ButtonDropDownClick(this, e);
+ }
+
+ private Control _DropDownControl = null;
+ ///
+ /// Gets or sets the reference of the control that will be displayed on popup that is shown when drop-down button is clicked.
+ ///
+ [DefaultValue(null), Description("Indicates reference of the control that will be displayed on popup that is shown when drop-down button is clicked.")]
+ internal Control DropDownControl
+ {
+ get { return _DropDownControl; }
+ set
+ {
+ _DropDownControl = value;
+ }
+ }
+
+ protected override PopupItem CreatePopupItem()
+ {
+ ButtonItem button = new ButtonItem("sysPopupProvider");
+ button.PopupFinalized += new EventHandler(DropDownPopupClose);
+ _PopupItem = button;
+ return button;
+ }
+
+ ///
+ /// Gets the collection of BaseItem derived items displayed on popup menu.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public SubItemsCollection DropDownItems
+ {
+ get { return _PopupItem.SubItems; }
+ }
+
+ protected override void RecalcSize()
+ {
+ }
+
+ public override void PerformClick()
+ {
+ }
+
+ private bool RenderButtons
+ {
+ get
+ {
+ return _ButtonCustom != null && _ButtonCustom.Visible || _ButtonCustom2 != null && _ButtonCustom2.Visible ||
+ _ButtonDropDown != null && _ButtonDropDown.Visible || _ButtonClear != null && _ButtonClear.Visible;
+ }
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ if (RenderButtons)
+ {
+ _ButtonGroup.ProcessMouseMove(e);
+ }
+ base.OnMouseMove(e);
+ }
+ protected override void OnMouseHover(EventArgs e)
+ {
+ if (RenderButtons)
+ {
+ _ButtonGroup.ProcessMouseHover(e);
+ }
+ base.OnMouseHover(e);
+ }
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ if (RenderButtons)
+ {
+ _ButtonGroup.ProcessMouseLeave();
+ }
+ base.OnMouseLeave(e);
+ }
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ this.Focus();
+ if (RenderButtons)
+ {
+ _ButtonGroup.ProcessMouseDown(e);
+ }
+
+ Rectangle r = this.ClientRectangle;
+ r.Inflate(1, 1);
+ if (this.RenderButtons && !_ButtonGroup.RenderBounds.Contains(e.X, e.Y) && r.Contains(e.X, e.Y) && !IsPopupOpen)
+ {
+ if (_CloseTime != DateTime.MinValue && DateTime.Now.Subtract(_CloseTime).TotalMilliseconds < 150)
+ {
+ _CloseTime = DateTime.MinValue;
+ }
+ else if(e.Button == MouseButtons.Left)
+ IsPopupOpen = true;
+ }
+
+ base.OnMouseDown(e);
+ }
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ if (RenderButtons)
+ _ButtonGroup.ProcessMouseUp(e);
+ base.OnMouseUp(e);
+ }
+
+ /////
+ ///// Gets the reference to internal TextBox control. Use it to get access to the text box events and properties.
+ /////
+ //[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ //public TextBox TextBox
+ //{
+ // get
+ // {
+ // return _TextBox;
+ // }
+ //}
+ ///
+ /// Gets the reference to internal AdvTree control that is displayed on popup Use it to get access to the AdvTree events and properties.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public AdvTree.AdvTree AdvTree
+ {
+ get
+ {
+ return _AdvTree;
+ }
+ }
+
+ /////
+ ///// Gets or sets whether watermark text is displayed when control is empty. Default value is true.
+ /////
+ //[DefaultValue(true), Description("Indicates whether watermark text is displayed when control is empty.")]
+ //public virtual bool WatermarkEnabled
+ //{
+ // get { return _TextBox.WatermarkEnabled; }
+ // set { _TextBox.WatermarkEnabled = value; this.Invalidate(true); }
+ //}
+
+ /////
+ ///// Gets or sets the watermark (tip) text displayed inside of the control when Text is not set and control does not have input focus. This property supports text-markup.
+ /////
+ //[Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance"), Description("Indicates watermark text displayed inside of the control when Text is not set and control does not have input focus."), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ //public string WatermarkText
+ //{
+ // get { return _TextBox.WatermarkText; }
+ // set
+ // {
+ // if (value == null) value = "";
+ // _TextBox.WatermarkText = value;
+ // this.Invalidate(true);
+ // }
+ //}
+
+ /////
+ ///// Gets or sets the watermark font.
+ /////
+ //[Browsable(true), Category("Appearance"), Description("Indicates watermark font."), DefaultValue(null)]
+ //public Font WatermarkFont
+ //{
+ // get { return _TextBox.WatermarkFont; }
+ // set { _TextBox.WatermarkFont = value; this.Invalidate(true); }
+ //}
+
+ /////
+ ///// Gets or sets the watermark text color.
+ /////
+ //[Browsable(true), Category("Appearance"), Description("Indicates watermark text color.")]
+ //public Color WatermarkColor
+ //{
+ // get { return _TextBox.WatermarkColor; }
+ // set { _TextBox.WatermarkColor = value; this.Invalidate(); }
+ //}
+ /////
+ ///// Indicates whether property should be serialized by Windows Forms designer.
+ /////
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public bool ShouldSerializeWatermarkColor()
+ //{
+ // return _TextBox.WatermarkColor != SystemColors.GrayText;
+ //}
+ /////
+ ///// Resets the property to default value.
+ /////
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public void ResetWatermarkColor()
+ //{
+ // this.WatermarkColor = SystemColors.GrayText;
+ //}
+
+ /////
+ ///// Gets or sets the watermark hiding behaviour. Default value indicates that watermark is hidden when control receives input focus.
+ /////
+ //[DefaultValue(eWatermarkBehavior.HideOnFocus), Category("Behavior"), Description("Indicates watermark hiding behaviour.")]
+ //public eWatermarkBehavior WatermarkBehavior
+ //{
+ // get { return _TextBox.WatermarkBehavior; }
+ // set { _TextBox.WatermarkBehavior = value; this.Invalidate(true); }
+ //}
+
+ private int _DropDownHeight = 0;
+ ///
+ /// Gets or sets the height in pixels of the drop-down portion of the ComboTreeBox control.
+ ///
+ [DefaultValue(0), Category("Behavior"), Description("Indicates height in pixels of the drop-down portion of the ComboTreeBox control.")]
+ public int DropDownHeight
+ {
+ get { return _DropDownHeight; }
+ set
+ {
+ if (value < 0)
+ throw new ArgumentException("DropDownHeight Value must be equal or greater than zero.");
+ _DropDownHeight = value;
+ OnDropDownSizeChanged();
+ }
+ }
+ private int _DropDownWidth = 0;
+ ///
+ /// Gets or sets the width in pixels of the drop-down portion of the ComboTreeBox control.
+ ///
+ [DefaultValue(0), Category("Behavior"), Description("Indicates width in pixels of the drop-down portion of the ComboTreeBox control.")]
+ public int DropDownWidth
+ {
+ get { return _DropDownWidth; }
+ set
+ {
+ if (value < 0)
+ throw new ArgumentException("DropDownWidth Value must be equal or greater than zero.");
+ _DropDownWidth = value;
+ OnDropDownSizeChanged();
+ }
+ }
+ private void OnDropDownSizeChanged()
+ {
+ _AdvTree.BeginUpdate();
+ if (_DropDownWidth > 0)
+ _AdvTree.Width = _DropDownWidth;
+ if (_DropDownHeight > 0)
+ _AdvTree.Height = _DropDownHeight;
+ _AdvTree.EndUpdate(false);
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the combo box is displaying its drop-down portion.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool IsPopupOpen
+ {
+ get
+ {
+ return _PopupItem.Expanded;
+ }
+ set
+ {
+ if (value != _PopupItem.Expanded)
+ {
+ if (value)
+ ShowDropDown();
+ else
+ CloseDropDown();
+ }
+ }
+ }
+
+ ///
+ /// Gets the collection of tree nodes that are assigned to the popup tree view control.
+ ///
+ ///
+ /// A NodeCollection that represents the tree nodes
+ /// assigned to the tree control.
+ ///
+ ///
+ /// The Nodes property holds a collection of Node objects, each of which has a
+ /// Nodes property that can contain its own NodeCollection.
+ ///
+ [Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Description("Gets the collection of tree nodes that are assigned to the tree control.")]
+ public AdvTree.NodeCollection Nodes
+ {
+ get { return _AdvTree.Nodes; }
+ }
+
+ ///
+ /// Gets the collection of column headers that appear in the popup tree.
+ ///
+ ///
+ /// By default there are no column headers defined. In that case tree control
+ /// functions as regular tree control where text has unrestricted width.
+ /// If you want to restrict the horizontal width of the text but not display
+ /// column header you can create one column and set its width to the width desired and
+ /// set its Visible property to false.
+ ///
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Columns"), Description("Gets collection of column headers that appear in the popup tree.")]
+ public ColumnHeaderCollection Columns
+ {
+ get
+ {
+ return _AdvTree.Columns;
+ }
+ }
+
+ ///
+ /// Gets or sets whether column headers are visible if they are defined through Columns collection. Default value is true.
+ ///
+ [DefaultValue(true), Category("Columns"), Description("Indicates whether column headers are visible if they are defined through Columns collection.")]
+ public bool ColumnsVisible
+ {
+ get { return _AdvTree.ColumnsVisible; }
+ set
+ {
+ _AdvTree.ColumnsVisible = value;
+ }
+ }
+ ///
+ /// Gets or sets whether grid lines are displayed when columns are defined. Default value is true.
+ ///
+ [DefaultValue(true), Category("Columns"), Description("Indicates whether grid lines are displayed when columns are defined.")]
+ public bool GridColumnLines
+ {
+ get { return _AdvTree.GridColumnLines; }
+ set
+ {
+ _AdvTree.GridColumnLines = value;
+ }
+ }
+ ///
+ /// Gets or sets the grid lines color.
+ ///
+ [Category("Columns"), Description("Indicates grid lines color.")]
+ public Color GridLinesColor
+ {
+ get { return _AdvTree.GridLinesColor; }
+ set { _AdvTree.GridLinesColor = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeGridLinesColor()
+ {
+ return _AdvTree.ShouldSerializeGridLinesColor();
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetGridLinesColor()
+ {
+ _AdvTree.ResetGridLinesColor();
+ }
+ ///
+ /// Gets or sets whether horizontal grid lines between each row are displayed. Default value is false.
+ ///
+ [DefaultValue(false), Category("Columns"), Description("")]
+ public bool GridRowLines
+ {
+ get { return _AdvTree.GridRowLines; }
+ set
+ {
+ _AdvTree.GridRowLines = value;
+ }
+ }
+ ///
+ /// Gets or sets whether node is highlighted when mouse enters the node. Default value is false.
+ ///
+ ///
+ /// There are two ways to enable the node hot-tracking. You can set the HotTracking property to true in which case the
+ /// mouse tracking is enabled using system colors specified in TreeColorTable. You can also define the NodeStyleMouseOver
+ /// style which gets applied to the node when mouse is over the node.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether node is highlighted when mouse enters the node.")]
+ public bool HotTracking
+ {
+ get { return _AdvTree.HotTracking; }
+ set
+ {
+ _AdvTree.HotTracking = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the node selection box style for popup tree control.
+ ///
+ /// SelectionBox Property
+ /// SelectionBoxSize Property
+ /// SelectionBoxFillColor Property
+ /// SelectionBoxBorderColor Property
+ [DefaultValue(eSelectionStyle.HighlightCells), Category("Selection"), Description("Indicates node selection box style of popup tree control.")]
+ public eSelectionStyle SelectionBoxStyle
+ {
+ get { return _AdvTree.SelectionBoxStyle; }
+ set { _AdvTree.SelectionBoxStyle = value; }
+ }
+
+ ///
+ /// Gets or sets the ImageList that contains the Image objects used by the tree nodes.
+ ///
+ [Browsable(true),DefaultValue(null),Category("Images"),Description("Indicates the ImageList that contains the Image objects used by the tree nodes.")]
+ public ImageList ImageList
+ {
+ get
+ {
+ return _AdvTree.ImageList;
+ }
+ set
+ {
+ _AdvTree.ImageList=value;
+ }
+ }
+
+ ///
+ /// Gets or sets the image-list index value of the default image that is displayed by the tree nodes.
+ ///
+ [Browsable(true), Category("Images"), Description("Indicates the image-list index value of the default image that is displayed by the tree nodes."), Editor("DevComponents.AdvTree.Design.ImageIndexEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), TypeConverter(typeof(ImageIndexConverter)), DefaultValue(-1)]
+ public int ImageIndex
+ {
+ get { return _AdvTree.ImageIndex; }
+ set
+ {
+ _AdvTree.ImageIndex = value;
+ }
+ }
+
+ private Color _DisabledBackColor = Color.Empty;
+ ///
+ /// Gets or sets the control background color when control is disabled. Default value is an empty color which indicates that system background color is used when control is disabled.
+ ///
+ [Description("Indicates control background color when control is disabled"), Category("Appearance")]
+ public Color DisabledBackColor
+ {
+ get { return _DisabledBackColor; }
+ set
+ {
+ if (_DisabledBackColor != value)
+ {
+ _DisabledBackColor = value;
+ if (!this.Enabled) this.Invalidate();
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeDisabledBackColor()
+ {
+ return !_DisabledBackColor.IsEmpty;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetDisabledBackColor()
+ {
+ DisabledBackColor = Color.Empty;
+ }
+ #endregion
+
+ #region Property Forwarding
+ /////
+ ///// Gets or sets a custom StringCollection to use when the AutoCompleteSource property is set to CustomSource.
+ ///// A StringCollection to use with AutoCompleteSource.
+ /////
+ //[Browsable(true), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Localizable(true), Description("Indicates custom StringCollection to use when the AutoCompleteSource property is set to CustomSource."), Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
+ //private AutoCompleteStringCollection AutoCompleteCustomSource
+ //{
+ // get
+ // {
+ // return _TextBox.AutoCompleteCustomSource;
+ // }
+ // set
+ // {
+ // _TextBox.AutoCompleteCustomSource = value;
+ // }
+ //}
+
+ /////
+ ///// Gets or sets an option that controls how automatic completion works for the TextBox.
+ ///// One of the values of AutoCompleteMode. The values are Append, None, Suggest, and SuggestAppend. The default is None.
+ /////
+ //[Description("Gets or sets an option that controls how automatic completion works for the TextBox."), Browsable(true), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(0)]
+ //private AutoCompleteMode AutoCompleteMode
+ //{
+ // get
+ // {
+ // return _TextBox.AutoCompleteMode;
+ // }
+ // set
+ // {
+ // _TextBox.AutoCompleteMode = value;
+ // }
+ //}
+
+ /////
+ ///// Gets or sets a value specifying the source of complete strings used for automatic completion.
+ ///// One of the values of AutoCompleteSource. The options are AllSystemSources, AllUrl, FileSystem, HistoryList, RecentlyUsedList, CustomSource, and None. The default is None.
+ /////
+ //[DefaultValue(0x80), TypeConverter(typeof(TextBoxAutoCompleteSourceConverter)), Browsable(true), EditorBrowsable(EditorBrowsableState.Always), Description("Gets or sets a value specifying the source of complete strings used for automatic completion.")]
+ //private AutoCompleteSource AutoCompleteSource
+ //{
+ // get
+ // {
+ // return _TextBox.AutoCompleteSource;
+ // }
+ // set
+ // {
+ // _TextBox.AutoCompleteSource = value;
+ // }
+ //}
+ #endregion
+
+ #region ICommandSource Members
+ protected virtual void ExecuteCommand()
+ {
+ if (_Command == null) return;
+ CommandManager.ExecuteCommand(this);
+ }
+
+ ///
+ /// Gets or sets the command assigned to the item. Default value is null.
+ /// Note that if this property is set to null Enabled property will be set to false automatically to disable the item.
+ ///
+ [DefaultValue(null), Category("Commands"), Description("Indicates the command assigned to the item.")]
+ public Command Command
+ {
+ get { return (Command)((ICommandSource)this).Command; }
+ set
+ {
+ ((ICommandSource)this).Command = value;
+ }
+ }
+
+ private ICommand _Command = null;
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ ICommand ICommandSource.Command
+ {
+ get
+ {
+ return _Command;
+ }
+ set
+ {
+ bool changed = false;
+ if (_Command != value)
+ changed = true;
+
+ if (_Command != null)
+ CommandManager.UnRegisterCommandSource(this, _Command);
+ _Command = value;
+ if (value != null)
+ CommandManager.RegisterCommand(this, value);
+ if (changed)
+ OnCommandChanged();
+ }
+ }
+
+ ///
+ /// Called when Command property value changes.
+ ///
+ protected virtual void OnCommandChanged()
+ {
+ }
+
+ private object _CommandParameter = null;
+ ///
+ /// Gets or sets user defined data value that can be passed to the command when it is executed.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Commands"), Description("Indicates user defined data value that can be passed to the command when it is executed."), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)), System.ComponentModel.Localizable(true)]
+ public object CommandParameter
+ {
+ get
+ {
+ return _CommandParameter;
+ }
+ set
+ {
+ _CommandParameter = value;
+ }
+ }
+
+ #endregion
+
+ #region Licensing
+#if !TRIAL
+ private string _LicenseKey = "";
+ [Browsable(false), DefaultValue("")]
+ public string LicenseKey
+ {
+ get { return _LicenseKey; }
+ set
+ {
+ if (NativeFunctions.ValidateLicenseKey(value))
+ return;
+ _LicenseKey = (!NativeFunctions.CheckLicenseKey(value) ? "9dsjkhds7" : value);
+ }
+ }
+#endif
+ #endregion
+ }
+ ///
+ /// Represents the method that will handle converting for ComboTree control.
+ ///
+ ///
+ ///
+ public delegate void TreeConvertEventHandler(object sender, TreeConvertEventArgs e);
+
+ public class TreeConvertEventArgs : ConvertEventArgs
+ {
+ // Fields
+ private object _ListItem;
+
+ // Methods
+ public TreeConvertEventArgs(object value, Type desiredType, object listItem, string fieldName)
+ : base(value, desiredType)
+ {
+ _ListItem = listItem;
+ _FieldName = fieldName;
+ }
+
+ ///
+ /// Gets the reference to the item being converted.
+ ///
+ public object ListItem
+ {
+ get
+ {
+ return _ListItem;
+ }
+ }
+
+ private string _FieldName = "";
+ ///
+ /// Get the reference to the name of the field or property on the item that needs conversion.
+ ///
+ public string FieldName
+ {
+ get { return _FieldName; }
+ }
+ }
+ ///
+ /// Defines delegate for data node based events.
+ ///
+ public delegate void DataNodeEventHandler(object sender, DataNodeEventArgs e);
+ ///
+ /// Defines event arguments for data node based events.
+ ///
+ public class DataNodeEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets the node that is created for data item.
+ ///
+ public Node Node = null;
+ ///
+ /// Gets the data-item node is being created for.
+ ///
+ public readonly object DataItem = null;
+
+ ///
+ /// Initializes a new instance of the DataNodeEventArgs class.
+ ///
+ ///
+ ///
+ public DataNodeEventArgs(Node node, object dataItem)
+ {
+ Node = node;
+ DataItem = dataItem;
+ }
+ }
+ ///
+ /// Defines delegate for data column based events.
+ ///
+ public delegate void DataColumnEventHandler(object sender, DataColumnEventArgs e);
+ ///
+ /// Defines event arguments for data column based events.
+ ///
+ public class DataColumnEventArgs : EventArgs
+ {
+ ///
+ /// Gets or sets the column header that is created for data.
+ ///
+ public DevComponents.AdvTree.ColumnHeader ColumnHeader = null;
+
+ ///
+ /// Initializes a new instance of the DataColumnEventArgs class.
+ ///
+ ///
+ public DataColumnEventArgs(DevComponents.AdvTree.ColumnHeader header)
+ {
+ ColumnHeader = header;
+ }
+ }
+}
+#endif
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/Controls/ComboTree.ico b/PROMS/DotNetBar Source Code/Controls/ComboTree.ico
new file mode 100644
index 00000000..9bed9b81
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/ComboTree.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/ControlWithBackgroundStyle.cs b/PROMS/DotNetBar Source Code/Controls/ControlWithBackgroundStyle.cs
new file mode 100644
index 00000000..04ffa602
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/ControlWithBackgroundStyle.cs
@@ -0,0 +1,156 @@
+using System;
+using System.Text;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxItem(false)]
+ public class ControlWithBackgroundStyle : Control
+ {
+ #region Private Variables
+ private ElementStyle _BackgroundStyle = null;
+ private bool _AntiAlias = true;
+ #endregion
+
+ #region Events
+ #endregion
+
+ #region Constructor
+ ///
+ /// Initializes a new instance of the ControlWithBackgroundStyle class.
+ ///
+ public ControlWithBackgroundStyle()
+ {
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(ControlStyles.StandardDoubleClick, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
+
+ _BackgroundStyle = new ElementStyle();
+ _BackgroundStyle.StyleChanged += new EventHandler(this.VisualPropertyChanged);
+ }
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Gets or sets whether anti-alias smoothing is used while painting. Default value is true.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Gets or sets whether anti-aliasing is used while painting.")]
+ public virtual bool AntiAlias
+ {
+ get { return _AntiAlias; }
+ set
+ {
+ if (_AntiAlias != value)
+ {
+ _AntiAlias = value;
+ this.Invalidate();
+ }
+ }
+ }
+
+ ///
+ /// Specifies the background style of the control.
+ ///
+ [Category("Style"), Description("Indicates control background style."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return _BackgroundStyle; }
+ }
+
+ ///
+ /// Resets style to default value. Used by windows forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackgroundStyle()
+ {
+ _BackgroundStyle.StyleChanged -= new EventHandler(this.VisualPropertyChanged);
+ _BackgroundStyle = new ElementStyle();
+ _BackgroundStyle.StyleChanged += new EventHandler(this.VisualPropertyChanged);
+ this.Invalidate();
+ }
+
+ private void VisualPropertyChanged(object sender, EventArgs e)
+ {
+ OnVisualPropertyChanged();
+ }
+
+ protected virtual void OnVisualPropertyChanged()
+ {
+ this.Invalidate();
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (this.BackColor.IsEmpty || this.BackColor == Color.Transparent)
+ {
+ base.OnPaintBackground(e);
+ }
+
+ PaintBackground(e);
+ PaintContent(e);
+
+ base.OnPaint(e);
+ }
+
+ protected virtual void PaintContent(PaintEventArgs e)
+ {
+
+ }
+
+ protected virtual Rectangle GetContentRectangle()
+ {
+ bool disposeStyle = false;
+ ElementStyle style = this.GetBackgroundStyle(out disposeStyle);
+ Rectangle r = ElementStyleLayout.GetInnerRect(style, this.ClientRectangle);
+ if (disposeStyle) style.Dispose();
+ //Rectangle r=this.ClientRectangle;
+ //r.X += ElementStyleLayout.LeftWhiteSpace(style);
+ //r.Y += ElementStyleLayout.TopWhiteSpace(style);
+ //r.Width -= ElementStyleLayout.HorizontalStyleWhiteSpace(style);
+ //r.Height -= ElementStyleLayout.VerticalStyleWhiteSpace(style);
+
+ return r;
+ }
+
+ protected virtual ElementStyle GetBackgroundStyle(out bool disposeStyle)
+ {
+ disposeStyle = false;
+ return ElementStyleDisplay.GetElementStyle(_BackgroundStyle, out disposeStyle);
+ }
+
+ protected virtual void PaintBackground(PaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+ Rectangle r = this.ClientRectangle;
+ bool disposeStyle = false;
+ ElementStyle style = this.GetBackgroundStyle(out disposeStyle);
+
+ if (!this.BackColor.IsEmpty)
+ {
+ DisplayHelp.FillRectangle(g, r, this.BackColor);
+ }
+
+ if (style.Custom)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ if (this.AntiAlias)
+ g.SmoothingMode = SmoothingMode.HighQuality;
+ ElementStyleDisplayInfo displayInfo = new ElementStyleDisplayInfo(style, e.Graphics, r);
+ ElementStyleDisplay.Paint(displayInfo);
+ if (this.AntiAlias)
+ g.SmoothingMode = sm;
+ }
+
+ if (disposeStyle) style.Dispose();
+ }
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/CursorHelper.cs b/PROMS/DotNetBar Source Code/Controls/CursorHelper.cs
new file mode 100644
index 00000000..e87c752b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/CursorHelper.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ internal struct IconInfo
+ {
+ public bool fIcon;
+ public int xHotspot;
+ public int yHotspot;
+ public IntPtr hbmMask;
+ public IntPtr hbmColor;
+ }
+ internal class CursorHelper
+ {
+ [DllImport("user32.dll")]
+ public static extern IntPtr CreateIconIndirect(ref IconInfo icon);
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool GetIconInfo(IntPtr hIcon, ref IconInfo pIconInfo);
+ [DllImport("gdi32.dll")]
+ public static extern bool DeleteObject(IntPtr handle);
+ [DllImport("user32.dll", CharSet = CharSet.Auto)]
+ extern static bool DestroyIcon(IntPtr handle);
+ public static Cursor CreateCursor(Bitmap bm, int xHotspot, int yHotspot, bool resize = true)
+ {
+ IntPtr ptr = (resize) ? ((Bitmap)ResizeBitmap(bm, 32, 32)).GetHicon() : bm.GetHicon();
+ IconInfo inf = new IconInfo();
+ GetIconInfo(ptr, ref inf);
+ inf.xHotspot = xHotspot;
+ inf.yHotspot = yHotspot;
+ inf.fIcon = false;
+ IntPtr cursorPtr = CreateIconIndirect(ref inf);
+ if (inf.hbmColor != IntPtr.Zero) { DeleteObject(inf.hbmColor); }
+ if (inf.hbmMask != IntPtr.Zero) { DeleteObject(inf.hbmMask); }
+ if (ptr != IntPtr.Zero) { DestroyIcon(ptr); }
+ Cursor c = new Cursor(cursorPtr);
+ c.Tag = (resize) ? new Size(32, 32) : bm.Size;
+ return c;
+ }
+ public static Bitmap ResizeBitmap(Image image, int maxWidth, int maxHeight)
+ {
+ double ratio = System.Math.Min((double)maxHeight / image.Height, (double)maxWidth / image.Width);
+ var propWidth = (int)(image.Width * ratio);
+ var propHeight = (int)(image.Height * ratio);
+ var newImage = new Bitmap(propWidth, propHeight);
+ using (var g = Graphics.FromImage(newImage))
+ {
+ g.DrawImage(image, 0, 0, propWidth, propHeight);
+ }
+ return newImage;
+ }
+ public static Bitmap GetControlBitmap(Control c, Color transparent)
+ {
+ var bm = new Bitmap(c.Width, c.Height);
+ c.DrawToBitmap(bm, new Rectangle(0, 0, c.Width, c.Height));
+ if (!transparent.IsEmpty)
+ {
+ bm.MakeTransparent(transparent);
+ }
+ return bm;
+ }
+ public static Bitmap OverlayBitmap(Bitmap baseBitmap, Bitmap overlay, Point atPosition)
+ {
+ using (var g = Graphics.FromImage(baseBitmap))
+ {
+ g.DrawImage(overlay, new Rectangle(atPosition, overlay.Size));
+ }
+ return baseBitmap;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DGHScrollBar.cs b/PROMS/DotNetBar Source Code/Controls/DGHScrollBar.cs
new file mode 100644
index 00000000..4200b4e4
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DGHScrollBar.cs
@@ -0,0 +1,196 @@
+#if FRAMEWORK20
+using System;
+using System.Text;
+using System.Windows.Forms;
+using System.Drawing;
+using DevComponents.DotNetBar.ScrollBar;
+using System.ComponentModel;
+using DevComponents.DotNetBar.Rendering;
+using System.Runtime.InteropServices;
+using System.Reflection;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ internal class DGHScrollBar : HScrollBar, ScrollBarReplacement.IScrollBarExtender
+ {
+ #region Private Variables
+ private ScrollBarReplacement m_ScrollBarImpl = null;
+ private bool m_EnableStyling = true;
+ #endregion
+
+ #region Constructor
+ public DGHScrollBar()
+ {
+ m_ScrollBarImpl = new ScrollBarReplacement(this);
+
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor, false);
+ }
+ #endregion
+
+ #region Internal Implementation
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ CreateParams p = base.CreateParams;
+ if (m_EnableStyling)
+ {
+ p.ClassName = null;
+ p.Style = 0x2000000;
+ p.Style |= 0x44000000;
+ if (this.Visible)
+ p.Style |= 0x10000000;
+ if (!this.Enabled)
+ p.Style |= 0x8000000;
+ if (this.RightToLeft == RightToLeft.Yes)
+ {
+ p.ExStyle |= 0x2000;
+ p.ExStyle |= 0x1000;
+ p.ExStyle |= 0x4000;
+ }
+ }
+ return p;
+ }
+ }
+ protected override void Dispose(bool disposing)
+ {
+ m_ScrollBarImpl.Dispose();
+ base.Dispose(disposing);
+ }
+
+ ///
+ /// Gets or sets whether custom styling (Office 2007 style) is enabled. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether custom styling (Office 2007 style) is enabled.")]
+ public bool EnableStyling
+ {
+ get { return m_EnableStyling; }
+ set
+ {
+ if (m_EnableStyling != value)
+ {
+ m_EnableStyling = value;
+ if (this.IsHandleCreated)
+ this.RecreateHandle();
+ }
+ }
+ }
+
+ /////
+ ///// Gets or sets whether scroll bar appears as application style scroll bar which usually uses darker colors. Default value is true.
+ /////
+ //[Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether scroll bar appears as application style scroll bar which usually uses darker colors.")]
+ //public bool IsAppScrollBarStyle
+ //{
+ // get { return m_ScrollBarImpl.IsAppScrollBarStyle; }
+ // set { m_ScrollBarImpl.IsAppScrollBarStyle = value; }
+ //}
+
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ m_ScrollBarImpl.OnHandleCreated();
+ base.OnHandleCreated(e);
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.OnMouseDown(e);
+ base.OnMouseDown(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.OnMouseUp(e);
+ base.OnMouseUp(e);
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.OnMouseEnter(e);
+ base.OnMouseEnter(e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.OnMouseLeave(e);
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.OnMouseMove(e);
+ base.OnMouseMove(e);
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if(m_EnableStyling)
+ m_ScrollBarImpl.OnPaint(e);
+ base.OnPaint(e);
+ }
+
+ protected override void NotifyInvalidate(Rectangle invalidatedArea)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.NotifyInvalidate(invalidatedArea);
+ base.NotifyInvalidate(invalidatedArea);
+ }
+
+ public void UpdateScrollValues()
+ {
+ m_ScrollBarImpl.UpdateScrollValues();
+ }
+
+ protected override void OnParentChanged(EventArgs e)
+ {
+ if (this.Parent is DataGridView)
+ {
+ m_ScrollBarImpl.ScrollBarCore.SideBorderOnly = true;
+ m_ScrollBarImpl.ScrollBarCore.HasBorder = false;
+ }
+ else
+ {
+ m_ScrollBarImpl.ScrollBarCore.SideBorderOnly = false;
+ m_ScrollBarImpl.ScrollBarCore.HasBorder = true;
+ }
+ base.OnParentChanged(e);
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ UpdateScrollValues();
+ }
+
+ public bool AppStyleScrollBar
+ {
+ get { return m_ScrollBarImpl.AppStyleScrollBar; }
+ set { m_ScrollBarImpl.AppStyleScrollBar = value; }
+ }
+ #endregion
+
+ #region IScrollBarExtender Members
+ void ScrollBarReplacement.IScrollBarExtender.SetValue(int newValue, ScrollEventType type)
+ {
+ if (newValue != this.Value)
+ {
+ int v = this.Value;
+ this.Value = newValue;
+ ScrollEventArgs se = new ScrollEventArgs(type, v, newValue, ScrollOrientation.HorizontalScroll);
+ OnScroll(se);
+ }
+ }
+ #endregion
+ }
+}
+#endif
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/Controls/DGVScrollBar.cs b/PROMS/DotNetBar Source Code/Controls/DGVScrollBar.cs
new file mode 100644
index 00000000..f18bff33
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DGVScrollBar.cs
@@ -0,0 +1,206 @@
+#if FRAMEWORK20
+using System;
+using System.Text;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Represents the Vertical Office 2007 Style Scroll Bar control.
+ ///
+ internal class DGVScrollBar : VScrollBar, ScrollBarReplacement.IScrollBarExtender
+ {
+ #region Private Variables
+ private ScrollBarReplacement m_ScrollBarImpl = null;
+ private bool m_EnableStyling = true;
+ #endregion
+
+ #region Constructor
+ public DGVScrollBar()
+ {
+ m_ScrollBarImpl = new ScrollBarReplacement(this);
+
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.Opaque, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
+ this.SetStyle(ControlStyles.SupportsTransparentBackColor, false);
+ }
+ #endregion
+
+ #region Internal Implementation
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ CreateParams p = base.CreateParams;
+ if (m_EnableStyling)
+ {
+ p.ClassName = null;
+ p.Style = 0x2000000;
+ p.Style |= 0x44000000;
+ if (this.Visible)
+ p.Style |= 0x10000000;
+ if (!this.Enabled)
+ p.Style |= 0x8000000;
+ if (this.RightToLeft == RightToLeft.Yes)
+ {
+ p.ExStyle |= 0x2000;
+ p.ExStyle |= 0x1000;
+ p.ExStyle |= 0x4000;
+ }
+ }
+ return p;
+ }
+ }
+ protected override void Dispose(bool disposing)
+ {
+ m_ScrollBarImpl.Dispose();
+ base.Dispose(disposing);
+ }
+
+ ///
+ /// Gets or sets whether custom styling (Office 2007 style) is enabled. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether custom styling (Office 2007 style) is enabled.")]
+ public bool EnableStyling
+ {
+ get { return m_EnableStyling; }
+ set
+ {
+ if (m_EnableStyling != value)
+ {
+ m_EnableStyling = value;
+ if (this.IsHandleCreated)
+ this.RecreateHandle();
+ }
+ }
+ }
+
+ /////
+ ///// Gets or sets whether scroll bar appears as application style scroll bar which usually uses darker colors. Default value is true.
+ /////
+ //[Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether scroll bar appears as application style scroll bar which usually uses darker colors.")]
+ //public bool IsAppScrollBarStyle
+ //{
+ // get { return m_ScrollBarImpl.IsAppScrollBarStyle; }
+ // set { m_ScrollBarImpl.IsAppScrollBarStyle = value; }
+ //}
+
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ m_ScrollBarImpl.OnHandleCreated();
+ base.OnHandleCreated(e);
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.OnMouseDown(e);
+ base.OnMouseDown(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.OnMouseUp(e);
+ base.OnMouseUp(e);
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.OnMouseEnter(e);
+ base.OnMouseEnter(e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.OnMouseLeave(e);
+ base.OnMouseLeave(e);
+ }
+
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ if (m_EnableStyling)
+ {
+ m_ScrollBarImpl.UpdateScrollValues();
+ m_ScrollBarImpl.OnMouseMove(e);
+ }
+ base.OnMouseMove(e);
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if(m_EnableStyling)
+ m_ScrollBarImpl.OnPaint(e);
+ base.OnPaint(e);
+ }
+
+ protected override void NotifyInvalidate(Rectangle invalidatedArea)
+ {
+ if (m_EnableStyling)
+ m_ScrollBarImpl.NotifyInvalidate(invalidatedArea);
+ base.NotifyInvalidate(invalidatedArea);
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ UpdateScrollValues();
+ base.OnResize(e);
+ }
+
+ public void UpdateScrollValues()
+ {
+ m_ScrollBarImpl.UpdateScrollValues();
+ }
+
+ protected override void OnParentChanged(EventArgs e)
+ {
+ if (this.Parent is DataGridView)
+ {
+ m_ScrollBarImpl.ScrollBarCore.SideBorderOnly = true;
+ m_ScrollBarImpl.ScrollBarCore.HasBorder = false;
+ }
+ else
+ {
+ m_ScrollBarImpl.ScrollBarCore.SideBorderOnly = false;
+ m_ScrollBarImpl.ScrollBarCore.HasBorder = true;
+ }
+ base.OnParentChanged(e);
+ }
+
+ public bool AppStyleScrollBar
+ {
+ get { return m_ScrollBarImpl.AppStyleScrollBar; }
+ set { m_ScrollBarImpl.AppStyleScrollBar = value; }
+ }
+ #endregion
+
+ #region IScrollBarExtender Members
+ void ScrollBarReplacement.IScrollBarExtender.SetValue(int newValue, ScrollEventType type)
+ {
+ //if (newValue != this.Value)
+ {
+ // Fix for scrolling to the last row
+ if (type== ScrollEventType.SmallIncrement &&
+ (this.Maximum - this.LargeChange) - newValue < 21)
+ {
+ newValue = this.Maximum - this.LargeChange + 1;
+ type = ScrollEventType.Last;
+ }
+
+ int v = this.Value;
+ this.Value = newValue;
+ ScrollEventArgs se = new ScrollEventArgs(type, v, newValue, ScrollOrientation.VerticalScroll);
+ OnScroll(se);
+ }
+ }
+ #endregion
+ }
+}
+#endif
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX.bmp b/PROMS/DotNetBar Source Code/Controls/DataGridViewX.bmp
new file mode 100644
index 00000000..d474c2e2
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/DataGridViewX.bmp differ
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX.cs
new file mode 100644
index 00000000..bd24e17b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX.cs
@@ -0,0 +1,812 @@
+#if FRAMEWORK20
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using DevComponents.DotNetBar.Rendering;
+using System.Drawing.Drawing2D;
+using System.Reflection;
+using System.ComponentModel;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Represents the DataGridView control with enhanced Office 2007 style.
+ ///
+ [ToolboxBitmap(typeof(DataGridViewX), "Controls.DataGridViewX.bmp")]
+ public class DataGridViewX : DataGridView
+ {
+ #region Private Variables
+ private int m_MouseOverColumnHeader = -2;
+ private int m_MouseDownColumnHeader = -2;
+ private int m_MouseDownRowIndex = -2;
+ private int m_MouseOverRowIndex = -2;
+ private bool m_Office2007StyleEnabled = true;
+ private Office2007DataGridViewColorTable m_ColorTable = null;
+ private Office2007ButtonItemStateColorTable m_ButtonStateColorTable = null;
+ private SelectionInfo[] m_ColumnSelectionState = new SelectionInfo[1];
+ //private int m_CurrentCellRowIndex = -1;
+ private int m_SelectedRowIndex = -2;
+ private bool m_HighlightSelectedColumnHeaders = true;
+ private bool m_SelectAllSignVisible = true;
+ private bool m_PaintEnhancedSelection = true;
+ #endregion
+
+ #region Constructor
+ public DataGridViewX()
+ : base()
+ {
+ SetupScrollBars();
+ SetStyle(ControlStyles.OptimizedDoubleBuffer |
+ ControlStyles.AllPaintingInWmPaint |
+ ControlStyles.ResizeRedraw, true);
+ this.DoubleBuffered = true;
+ StyleManager.Register(this);
+ }
+ #endregion
+
+ #region internal properties
+
+ internal Office2007ButtonItemStateColorTable ButtonStateColorTable
+ {
+ get { return (m_ButtonStateColorTable); }
+ }
+
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Called by StyleManager to notify control that style on manager has changed and that control should refresh its appearance if
+ /// its style is controlled by StyleManager.
+ ///
+ /// New active style.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void StyleManagerStyleChanged(eDotNetBarStyle newStyle)
+ {
+ DGVScrollBar vsb = GetVScrollBar();
+ if (vsb != null && vsb.Visible) vsb.Invalidate();
+
+ DGHScrollBar hsb = GetHScrollBar();
+ if (hsb != null && hsb.Visible) hsb.Invalidate();
+
+ // Update Style
+ Office2007ColorTable ct = null;
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
+ m_ColorTable = ct.DataGridView;
+ m_ButtonStateColorTable = ct.ButtonItemColors[0].Checked;
+ }
+ try // Don't like to do this but bug in GridColor setter requires it
+ {
+ if (!_UseCustomBackgroundColor)
+ this.BackgroundColor = m_ColorTable.BackgroundColor;
+ this.ColumnHeadersDefaultCellStyle.ForeColor = m_ColorTable.ColumnHeaderNormalText;
+ this.ColumnHeadersDefaultCellStyle.SelectionForeColor = m_ColorTable.ColumnHeaderSelectedText;
+ this.DefaultCellStyle.BackColor = m_ColorTable.DefaultCellBackground;
+ this.DefaultCellStyle.ForeColor = m_ColorTable.DefaultCellText;
+ if (this.PaintEnhancedSelection)
+ this.DefaultCellStyle.SelectionForeColor = m_ButtonStateColorTable.Text;
+ this.GridColor = m_ColorTable.GridColor;
+ this.RowHeadersDefaultCellStyle.ForeColor = m_ColorTable.ColumnHeaderNormalText;
+ this.RowHeadersDefaultCellStyle.SelectionForeColor = m_ColorTable.ColumnHeaderSelectedText;
+ this.EnableHeadersVisualStyles = false;
+ }
+ catch { }
+ }
+
+ protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
+ {
+ bool enabled = this.Enabled;
+ Office2007DataGridViewColorTable ct = GetColorTable();
+ if (!m_Office2007StyleEnabled || ct == null ||
+ e.Handled || e.ColumnIndex >= 0 && e.RowIndex >= 0 &&
+ (!m_PaintEnhancedSelection || (e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected))
+ {
+ base.OnCellPainting(e);
+ return;
+ }
+
+ Rectangle r = e.CellBounds;
+ Graphics g = e.Graphics;
+ LinearGradientColorTable bt = null;
+ Color borderColor = Color.Empty;
+ DataGridViewColumn column = null;
+ int displayIndex = -1;
+ if (e.ColumnIndex >= 0)
+ {
+ column = this.Columns[e.ColumnIndex];
+ displayIndex = column.DisplayIndex;
+ }
+
+ if (e.ColumnIndex == -1 && e.RowIndex == -1)
+ {
+ // Paint top-left corner
+ if (m_MouseOverColumnHeader == -1)
+ {
+ bt = ct.SelectorMouseOverBackground;
+ borderColor = ct.SelectorMouseOverBorder;
+ }
+ else
+ {
+ bt = ct.SelectorBackground;
+ borderColor = ct.SelectorBorder;
+ }
+ DisplayHelp.FillRectangle(g, r, bt);
+ DisplayHelp.DrawRectangle(g, borderColor, r);
+ if (m_MouseOverColumnHeader == -1)
+ borderColor = ct.SelectorMouseOverBorderLight;
+ else
+ borderColor = ct.SelectorBorderLight;
+ Rectangle inner = r;
+ inner.Inflate(-1, -1);
+ using (Pen p = new Pen(borderColor))
+ {
+ g.DrawLine(p, inner.X, inner.Bottom - 1, inner.X, inner.Y);
+ g.DrawLine(p, inner.X, inner.Y, inner.Right - 1, inner.Y);
+ }
+ if (m_MouseOverColumnHeader == -1)
+ borderColor = ct.SelectorMouseOverBorderDark;
+ else
+ borderColor = ct.SelectorBorderDark;
+ using (Pen p = new Pen(borderColor))
+ {
+ g.DrawLine(p, inner.Right - 1, inner.Y, inner.Right - 1, inner.Bottom - 1);
+ g.DrawLine(p, inner.X, inner.Bottom - 1, inner.Right - 1, inner.Bottom - 1);
+ }
+
+ if (m_SelectAllSignVisible)
+ {
+ GraphicsPath path = GetSelectorPath(inner);
+ if (path != null)
+ {
+ DisplayHelp.FillPath(g, path, (m_MouseOverColumnHeader == -1 ? ct.SelectorMouseOverSign : ct.SelectorSign));
+ path.Dispose();
+ }
+ }
+ }
+ else if (e.ColumnIndex == -1)
+ {
+ // Paint Rows
+ bt = ct.RowNormalBackground;
+ borderColor = ct.RowNormalBorder;
+
+ if (m_MouseDownRowIndex == e.RowIndex)
+ {
+ bt = ct.RowPressedBackground;
+ borderColor = ct.RowPressedBorder;
+ }
+ else if (m_SelectedRowIndex == e.RowIndex && enabled)
+ {
+ if (m_MouseOverRowIndex == e.RowIndex)
+ {
+ bt = ct.RowSelectedMouseOverBackground;
+ borderColor = ct.RowSelectedMouseOverBorder;
+ }
+ else
+ {
+ bt = ct.RowSelectedBackground;
+ borderColor = ct.RowSelectedBorder;
+ }
+ }
+ else if (this.Rows[e.RowIndex].Selected && enabled)
+ {
+ if (m_MouseOverRowIndex == e.RowIndex)
+ {
+ bt = ct.RowPressedBackground;
+ borderColor = ct.RowPressedBorder;
+ }
+ else
+ {
+ bt = ct.RowPressedBackground;
+ borderColor = ct.RowPressedBorder;
+ }
+ }
+ else if (m_MouseOverRowIndex == e.RowIndex)
+ {
+ bt = ct.RowMouseOverBackground;
+ borderColor = ct.RowMouseOverBorder;
+ }
+
+ DisplayHelp.FillRectangle(g, r, bt);
+ // Paint border
+ using (Pen p = new Pen(borderColor))
+ {
+ g.DrawLine(p, r.Right - 1, r.Y, r.Right - 1, r.Bottom - 1);
+
+ if (m_SelectedRowIndex == e.RowIndex + 1 && enabled)
+ {
+ Color bc = ct.RowSelectedBorder;
+ if (m_MouseDownRowIndex == e.RowIndex + 1)
+ bc = ct.RowPressedBorder;
+ else if (m_MouseOverRowIndex == e.RowIndex + 1)
+ bc = ct.RowSelectedMouseOverBorder;
+ using (Pen p2 = new Pen(bc))
+ g.DrawLine(p2, r.X, r.Bottom - 1, r.Right - 1, r.Bottom - 1);
+ }
+ else
+ g.DrawLine(p, r.X, r.Bottom - 1, r.Right - 1, r.Bottom - 1);
+ }
+
+ e.PaintContent(r);
+ }
+ else if (e.RowIndex == -1)
+ {
+ // Determine Colors
+ if (m_MouseDownColumnHeader == e.ColumnIndex)
+ {
+ bt = ct.ColumnHeaderPressedBackground;
+ borderColor = ct.ColumnHeaderPressedBorder;
+ }
+ else if (m_MouseOverColumnHeader == e.ColumnIndex)
+ {
+ if (m_HighlightSelectedColumnHeaders && (displayIndex >= 0 && e.ColumnIndex >= 0 && (m_ColumnSelectionState.Length > displayIndex && m_ColumnSelectionState[displayIndex].Selected || this.Columns[e.ColumnIndex].Selected)))
+ {
+ bt = ct.ColumnHeaderSelectedMouseOverBackground;
+ borderColor = ct.ColumnHeaderSelectedMouseOverBorder;
+ }
+ else
+ {
+ bt = ct.ColumnHeaderMouseOverBackground;
+ borderColor = ct.ColumnHeaderMouseOverBorder;
+ }
+ }
+ else if (!m_HighlightSelectedColumnHeaders)
+ {
+ bt = ct.ColumnHeaderNormalBackground;
+ borderColor = ct.ColumnHeaderNormalBorder;
+ }
+ else if (displayIndex >= 0 && e.ColumnIndex >= 0 && (m_ColumnSelectionState.Length > displayIndex && m_ColumnSelectionState[displayIndex].Selected || this.Columns[e.ColumnIndex].Selected) && enabled)
+ {
+ bt = ct.ColumnHeaderSelectedBackground;
+ borderColor = ct.ColumnHeaderSelectedBorder;
+ }
+ else
+ {
+ if (this.Columns[e.ColumnIndex].Selected && enabled)
+ {
+ bt = ct.ColumnHeaderPressedBackground;
+ borderColor = ct.ColumnHeaderPressedBorder;
+ }
+ else
+ {
+ bt = ct.ColumnHeaderNormalBackground;
+ borderColor = ct.ColumnHeaderNormalBorder;
+ }
+ }
+
+ // Paint row markers
+ DisplayHelp.FillRectangle(g, r, bt);
+ // Paint border
+ using (Pen p = new Pen(borderColor))
+ {
+ g.DrawLine(p, r.X, r.Bottom-1, r.Right - 1, r.Bottom-1);
+ //if (displayIndex == 0)
+ // g.DrawLine(p, r.X, r.Y, r.X, r.Bottom - 1);
+
+ if (enabled && (m_HighlightSelectedColumnHeaders && (displayIndex>=0 && m_ColumnSelectionState.Length > displayIndex + 1 && (m_ColumnSelectionState[displayIndex + 1].Selected ||
+ m_ColumnSelectionState[displayIndex + 1].ColumnIndex == m_MouseDownColumnHeader))))
+ {
+ Color bc = ct.ColumnHeaderSelectedBorder;
+ if (m_ColumnSelectionState[displayIndex + 1].ColumnIndex == m_MouseDownColumnHeader)
+ bc = ct.ColumnHeaderPressedBorder;
+ else if (m_MouseOverColumnHeader == displayIndex + 1)
+ bc = ct.ColumnHeaderSelectedMouseOverBorder;
+ using (Pen p2 = new Pen(bc))
+ g.DrawLine(p2, r.Right - 1, r.Y, r.Right - 1, r.Bottom - 1);
+ }
+ else
+ g.DrawLine(p, r.Right - 1, r.Y, r.Right - 1, r.Bottom - 1);
+ }
+ e.PaintContent(r);
+ }
+ else if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
+ {
+ IDataGridViewColumn ic = this.Columns[e.ColumnIndex] as IDataGridViewColumn;
+
+ if (ic != null && ic.OwnerPaintCell == true)
+ {
+ base.OnCellPainting(e);
+ return;
+ }
+
+ e.PaintBackground(r, false);
+
+ if (enabled)
+ {
+ r.Height--;
+ Office2007ButtonItemPainter.PaintBackground(g, m_ButtonStateColorTable, r, RoundRectangleShapeDescriptor.RectangleShape, false, false);
+ r.Height++;
+
+ if (CurrentCellAddress.X==e.ColumnIndex && CurrentCellAddress.Y==e.RowIndex && (e.PaintParts & DataGridViewPaintParts.Focus) == DataGridViewPaintParts.Focus &&
+ ShowFocusCues && Focused && r.Width > 0 && r.Height > 0)
+ {
+ if (m_ButtonStateColorTable.TopBackground != null)
+ ControlPaint.DrawFocusRectangle(g, r, Color.Empty, m_ButtonStateColorTable.TopBackground.End);
+ else if (m_ButtonStateColorTable.Background != null)
+ ControlPaint.DrawFocusRectangle(g, r, Color.Empty, m_ButtonStateColorTable.Background.Start);
+ else
+ ControlPaint.DrawFocusRectangle(g, r, Color.Empty, this.BackgroundColor);
+ }
+ }
+
+ e.PaintContent(r);
+
+ }
+ e.Handled = true;
+ base.OnCellPainting(e);
+ }
+
+ private GraphicsPath GetSelectorPath(Rectangle inner)
+ {
+ inner.Inflate(-3, -3);
+ if (inner.Width > 2 && inner.Height > 2)
+ {
+ GraphicsPath path = new GraphicsPath();
+ path.AddLine(inner.Right, inner.Y, inner.Right, inner.Bottom);
+ path.AddLine(inner.Right, inner.Bottom, inner.Right - inner.Height, inner.Bottom);
+ path.CloseAllFigures();
+ return path;
+ }
+
+ return null;
+ }
+
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ Office2007DataGridViewColorTable ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.DataGridView;
+ UpdateOffice2007Styles(ct);
+ }
+ base.OnHandleCreated(e);
+ }
+
+ private void UpdateOffice2007Styles(Office2007DataGridViewColorTable ct)
+ {
+ if (this.GridColor != ct.GridColor)
+ this.GridColor = ct.GridColor;
+ if(m_PaintEnhancedSelection)
+ this.DefaultCellStyle.SelectionForeColor = this.DefaultCellStyle.ForeColor;
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ Office2007ColorTable ct = null;
+ if (GlobalManager.Renderer is Office2007Renderer)
+ {
+ ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
+ m_ColorTable = ct.DataGridView;
+ if(StyleManager.IsVisualStudio2012(StyleManager.Style))
+ m_ButtonStateColorTable = ct.ButtonItemColors[0].Pressed;
+ else
+ m_ButtonStateColorTable = ct.ButtonItemColors[0].Checked;
+ }
+
+ if (this.CurrentCell != null)
+ m_SelectedRowIndex = this.CurrentCell.RowIndex;
+ else
+ m_SelectedRowIndex = -1;
+
+ base.OnPaint(e);
+
+ if (this.VerticalScrollBar.Visible && this.HorizontalScrollBar.Visible)
+ {
+ Rectangle r = new Rectangle(this.VerticalScrollBar.Left, this.VerticalScrollBar.Bottom, this.VerticalScrollBar.Width, this.HorizontalScrollBar.Height);
+ Color c = ct.AppScrollBar.Default.Background.End;
+ if (c.IsEmpty) c = ct.AppScrollBar.Default.Background.Start;
+ DisplayHelp.FillRectangle(e.Graphics, r, c);
+ //e.Graphics.FillRectangle(Brushes.BlueViolet, r);
+ }
+
+ m_ColorTable = null;
+ m_ButtonStateColorTable = null;
+ }
+
+ protected override void OnCurrentCellChanged(EventArgs e)
+ {
+ if (this.SelectionMode == DataGridViewSelectionMode.FullRowSelect)
+ UpdateSelectionState();
+ base.OnCurrentCellChanged(e);
+ }
+
+ protected override void OnSelectionChanged(EventArgs e)
+ {
+ UpdateSelectionState();
+ base.OnSelectionChanged(e);
+ }
+
+ protected override void OnDataSourceChanged(EventArgs e)
+ {
+ base.OnDataSourceChanged(e);
+ UpdateSelectionState();
+ }
+
+ private void UpdateSelectionState()
+ {
+ SelectionInfo[] newSelection = new SelectionInfo[this.Columns.Count];
+ for (int i = 0; i < this.Columns.Count; i++)
+ newSelection[this.Columns[i].DisplayIndex].ColumnIndex = i;
+ int columnCount = this.Columns.Count;
+
+ if (this.SelectionMode == DataGridViewSelectionMode.FullRowSelect)
+ {
+ if (this.CurrentCell != null)
+ {
+ int displayIndex = this.Columns[this.CurrentCell.ColumnIndex].DisplayIndex;
+ newSelection[displayIndex].Selected = true;
+ newSelection[displayIndex].ColumnIndex = this.CurrentCell.ColumnIndex;
+ }
+ }
+ else
+ {
+ foreach (DataGridViewCell cell in this.SelectedCells)
+ {
+ if (cell.ColumnIndex == -1) continue;
+ int displayIndex = this.Columns[cell.ColumnIndex].DisplayIndex;
+ if (!newSelection[displayIndex].Selected)
+ {
+ columnCount--;
+ newSelection[displayIndex].Selected = true;
+ newSelection[displayIndex].ColumnIndex = cell.ColumnIndex;
+ if (columnCount == 0) break;
+ }
+ }
+ }
+
+ for (int i = 0; i < newSelection.Length; i++)
+ {
+ if (m_ColumnSelectionState.Length > i && newSelection[i].Selected != m_ColumnSelectionState[i].Selected)
+ {
+ int ci = m_ColumnSelectionState[i].ColumnIndex;
+ if (!(ci < 0 || ci >= this.Columns.Count))
+ {
+ this.InvalidateColumn(ci);
+ if (ci > 0) this.InvalidateColumn(ci - 1);
+ }
+ }
+ }
+ if (m_SelectedRowIndex > 0 && m_SelectedRowIndex < this.Rows.Count)
+ this.InvalidateRow(m_SelectedRowIndex - 1);
+ if (this.CurrentCell != null && this.CurrentCell.RowIndex > 0)
+ {
+ m_SelectedRowIndex = this.CurrentCell.RowIndex;
+ this.InvalidateRow(m_SelectedRowIndex - 1);
+ }
+ else
+ m_SelectedRowIndex = -2;
+ m_ColumnSelectionState = newSelection;
+ }
+
+ protected virtual Office2007DataGridViewColorTable GetColorTable()
+ {
+ return m_ColorTable;
+ }
+
+ protected override void OnCellMouseDown(DataGridViewCellMouseEventArgs e)
+ {
+ // Disable double buffer so column resize drag markers will work
+ if (e.ColumnIndex == -1 || e.RowIndex == -1)
+ {
+ this.DoubleBuffered = false;
+ }
+
+ if (e.RowIndex == -1)
+ {
+ m_MouseDownColumnHeader = e.ColumnIndex;
+ if (e.ColumnIndex >= 0)
+ this.InvalidatePreviousColumn(this.Columns[e.ColumnIndex].DisplayIndex);
+ }
+ else
+ m_MouseDownColumnHeader = -2;
+
+ if (e.ColumnIndex == -1)
+ {
+ m_MouseDownRowIndex = e.RowIndex;
+ if (m_MouseDownRowIndex > 0 && m_MouseDownRowIndex < this.Rows.Count)
+ this.InvalidateRow(m_MouseDownRowIndex - 1);
+ }
+ else
+ m_MouseDownRowIndex = -2;
+
+ base.OnCellMouseDown(e);
+ }
+
+ private void InvalidatePreviousColumn(int displayIndex)
+ {
+ displayIndex--;
+ for (int i = 0; i < this.Columns.Count; i++)
+ {
+ DataGridViewColumn c = this.Columns[i];
+ if (c.Displayed && c.DisplayIndex == displayIndex)
+ {
+ this.InvalidateColumn(i);
+ break;
+ }
+ }
+ }
+
+ protected override void OnDragDrop(DragEventArgs drgevent)
+ {
+ CleanUpOnCellMouseUp();
+ base.OnDragDrop(drgevent);
+ }
+
+ private void CleanUpOnCellMouseUp()
+ {
+ // Enable double buffering that was disabled in CellMouseDown
+ if (!this.DoubleBuffered)
+ this.DoubleBuffered = true;
+
+ if (m_MouseDownRowIndex > 0 && m_MouseDownRowIndex < this.Rows.Count)
+ this.InvalidateRow(m_MouseDownRowIndex - 1);
+ if (m_MouseDownRowIndex >= 0 && m_MouseDownRowIndex < this.Rows.Count)
+ this.InvalidateRow(m_MouseDownRowIndex);
+
+ m_MouseDownRowIndex = -2;
+ m_MouseDownColumnHeader = -2;
+ }
+ protected override void OnCellMouseUp(DataGridViewCellMouseEventArgs e)
+ {
+ CleanUpOnCellMouseUp();
+ base.OnCellMouseUp(e);
+ }
+
+ protected override void OnCellMouseEnter(DataGridViewCellEventArgs e)
+ {
+ if (e.RowIndex == -1)
+ m_MouseOverColumnHeader = e.ColumnIndex;
+ else
+ m_MouseOverColumnHeader = -2;
+ if (e.ColumnIndex == -1)
+ {
+ if (m_MouseOverRowIndex != e.RowIndex)
+ {
+ m_MouseOverRowIndex = e.RowIndex;
+ if (m_MouseOverRowIndex > 0)
+ this.InvalidateRow(m_MouseOverRowIndex - 1);
+ }
+ }
+ else
+ m_MouseOverRowIndex = -2;
+ base.OnCellMouseEnter(e);
+ }
+
+ protected override void OnCellMouseLeave(DataGridViewCellEventArgs e)
+ {
+ m_MouseOverColumnHeader = -2;
+ m_MouseOverRowIndex = -2;
+ base.OnCellMouseLeave(e);
+ }
+
+ private struct SelectionInfo
+ {
+ public bool Selected;
+ public int ColumnIndex;
+ }
+
+ protected override void OnScroll(ScrollEventArgs e)
+ {
+ base.OnScroll(e);
+ DGVScrollBar vsb = GetVScrollBar();
+ if (vsb != null && vsb.Visible) vsb.UpdateScrollValues();
+
+ DGHScrollBar hsb = GetHScrollBar();
+ if (hsb != null && hsb.Visible) hsb.UpdateScrollValues();
+ }
+
+ private DGVScrollBar GetVScrollBar()
+ {
+ return this.VerticalScrollBar as DGVScrollBar;
+ //Type t = typeof(System.Windows.Forms.DataGridView);
+ //FieldInfo fi = t.GetField("vertScrollBar", BindingFlags.NonPublic | BindingFlags.Instance);
+ //if (fi == null) return null;
+ //DGVScrollBar sb = fi.GetValue(this) as DGVScrollBar;
+ //return sb;
+ }
+
+ private DGHScrollBar GetHScrollBar()
+ {
+ return this.HorizontalScrollBar as DGHScrollBar;
+ //Type t = typeof(System.Windows.Forms.DataGridView);
+ //FieldInfo fi = t.GetField("horizScrollBar", BindingFlags.NonPublic | BindingFlags.Instance);
+ //if (fi == null) return null;
+ //DGHScrollBar sb = fi.GetValue(this) as DGHScrollBar;
+ //return sb;
+ }
+
+ private void InvokeDelayed(MethodInvoker method)
+ {
+ Timer delayedInvokeTimer = new Timer();
+ delayedInvokeTimer = new Timer();
+ delayedInvokeTimer.Tag = method;
+ delayedInvokeTimer.Interval = 10;
+ delayedInvokeTimer.Tick += new EventHandler(DelayedInvokeTimerTick);
+ delayedInvokeTimer.Start();
+ }
+ void DelayedInvokeTimerTick(object sender, EventArgs e)
+ {
+ Timer timer = (Timer)sender;
+ MethodInvoker method = (MethodInvoker)timer.Tag;
+ timer.Stop();
+ timer.Dispose();
+ method.Invoke();
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ if (_DelayResizeCallWhenMdiChild)
+ {
+ Form form = this.FindForm();
+ if (form != null && form.IsMdiChild)
+ InvokeDelayed(new MethodInvoker(delegate { CallBaseOnResize(e); }));
+ else
+ base.OnResize(e);
+ }
+ else
+ base.OnResize(e);
+ }
+
+ private void CallBaseOnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ }
+
+ private bool _DelayResizeCallWhenMdiChild = true;
+ ///
+ /// Indicates whether control will delay call to OnResize base DataGridView method when control is running on MDI Child which was introduced as workaround to an issue in control.
+ ///
+ [DefaultValue(true), Browsable(false)]
+ public bool DelayResizeCallWhenMdiChild
+ {
+ get { return _DelayResizeCallWhenMdiChild; }
+ set { _DelayResizeCallWhenMdiChild = value; }
+ }
+
+ private eScrollBarAppearance _ScrollBarAppearance = eScrollBarAppearance.ApplicationScroll;
+ ///
+ /// Gets or sets the scroll-bar visual style.
+ ///
+ [DefaultValue(eScrollBarAppearance.ApplicationScroll), Category("Appearance"), Description("Gets or sets the scroll-bar visual style.")]
+ public eScrollBarAppearance ScrollBarAppearance
+ {
+ get { return _ScrollBarAppearance; }
+ set
+ {
+ _ScrollBarAppearance = value;
+ OnScrollBarAppearance();
+ }
+ }
+ private void OnScrollBarAppearance()
+ {
+ DGVScrollBar sbv = GetVScrollBar();
+ if (sbv != null)
+ sbv.AppStyleScrollBar = (_ScrollBarAppearance == eScrollBarAppearance.ApplicationScroll);
+
+ DGHScrollBar sbh = GetHScrollBar();
+ if (sbh != null)
+ sbh.AppStyleScrollBar = (_ScrollBarAppearance == eScrollBarAppearance.ApplicationScroll);
+ }
+
+ private void SetupScrollBars()
+ {
+ // Vertical Scroll Bar Replacement
+ Type t = typeof(System.Windows.Forms.DataGridView);
+ FieldInfo fi = t.GetField("vertScrollBar", BindingFlags.NonPublic | BindingFlags.Instance);
+ if(fi==null) return;
+ System.Windows.Forms.ScrollBar sb = fi.GetValue(this) as System.Windows.Forms.ScrollBar;
+ if (sb == null) return;
+ //sb.Scroll += new ScrollEventHandler(sb_Scroll); return;
+ MethodInfo mi = t.GetMethod("DataGridViewVScrolled", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (mi == null) return;
+
+ DGVScrollBar newVSb = new DGVScrollBar();
+ newVSb.AppStyleScrollBar = (_ScrollBarAppearance == eScrollBarAppearance.ApplicationScroll);
+ newVSb.Minimum = sb.Minimum;
+ newVSb.Maximum = sb.Maximum;
+ newVSb.SmallChange = sb.SmallChange;
+ newVSb.LargeChange = sb.LargeChange;
+ newVSb.Top = sb.Top;
+ newVSb.AccessibleName = sb.AccessibleName;
+ newVSb.Left = sb.Left;
+ newVSb.Visible = sb.Visible;
+ newVSb.Scroll += (ScrollEventHandler)ScrollEventHandler.CreateDelegate(typeof(ScrollEventHandler), this, mi);
+ fi.SetValue(this, newVSb);
+ sb.Dispose();
+ this.Controls.Remove(sb);
+ this.Controls.Add(newVSb);
+
+ // Horizontal Scroll Bar Replacement
+ fi = t.GetField("horizScrollBar", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (fi == null) return;
+ sb = fi.GetValue(this) as System.Windows.Forms.ScrollBar;
+ if (sb == null) return;
+ mi = t.GetMethod("DataGridViewHScrolled", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (mi == null) return;
+
+ DGHScrollBar newHSb = new DGHScrollBar();
+ newHSb.AppStyleScrollBar = (_ScrollBarAppearance == eScrollBarAppearance.ApplicationScroll); ;
+ newHSb.Minimum = sb.Minimum;
+ newHSb.Maximum = sb.Maximum;
+ newHSb.SmallChange = sb.SmallChange;
+ newHSb.LargeChange = sb.LargeChange;
+ newHSb.Top = sb.Top;
+ newHSb.AccessibleName = sb.AccessibleName;
+ newHSb.Left = sb.Left;
+ newHSb.Visible = sb.Visible;
+ newHSb.RightToLeft = sb.RightToLeft;
+ newHSb.Scroll += (ScrollEventHandler)ScrollEventHandler.CreateDelegate(typeof(ScrollEventHandler), this, mi);
+ fi.SetValue(this, newHSb);
+ sb.Dispose();
+ this.Controls.Remove(sb);
+ this.Controls.Add(newHSb);
+
+ base.PerformLayout();
+ }
+
+ //void sb_Scroll(object sender, ScrollEventArgs e)
+ //{
+ // Console.WriteLine(e.NewValue);
+ //}
+
+ ///
+ /// Gets or sets whether selected column header is highlighted. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior"), Description("Indicates whether selected column header is highlighted.")]
+ public bool HighlightSelectedColumnHeaders
+ {
+ get { return m_HighlightSelectedColumnHeaders; }
+ set
+ {
+ m_HighlightSelectedColumnHeaders = value;
+ if(BarFunctions.IsHandleValid(this))
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets whether select all sign displayed in top-left corner of the grid is visible. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior"), Description("Indicates whether select all sign displayed in top-left corner of the grid is visible.")]
+ public bool SelectAllSignVisible
+ {
+ get { return m_SelectAllSignVisible; }
+ set
+ {
+ m_SelectAllSignVisible = value;
+ if (BarFunctions.IsHandleValid(this))
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets whether enhanced selection for the cells is painted in Office 2007 style. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether enhanced selection for the cells is painted in Office 2007 style")]
+ public bool PaintEnhancedSelection
+ {
+ get { return m_PaintEnhancedSelection; }
+ set
+ {
+ m_PaintEnhancedSelection = value;
+ if (BarFunctions.IsHandleValid(this))
+ this.Invalidate();
+ }
+ }
+
+ private bool _UseCustomBackgroundColor = false;
+ ///
+ /// Indicates whether BackgroundColor property set on DataGridView is obeyed instead of using system color scheme color.
+ ///
+ [DefaultValue(false), Category("Appearance"), Description("Indicates whether BackgroundColor property set on DataGridView is obeyed instead of using system color scheme color.")]
+ public bool UseCustomBackgroundColor
+ {
+ get { return _UseCustomBackgroundColor; }
+ set
+ {
+ _UseCustomBackgroundColor = value;
+ }
+ }
+ #endregion
+ }
+}
+#endif
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewButtonX/DataGridViewButtonXCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewButtonX/DataGridViewButtonXCell.cs
new file mode 100644
index 00000000..ad03a29f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewButtonX/DataGridViewButtonXCell.cs
@@ -0,0 +1,498 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewButtonXCell : DataGridViewButtonCell
+ {
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (null); }
+ }
+
+ #endregion
+
+ #region FormattedValueType
+
+ ///
+ /// FormattedValueType
+ ///
+ public override Type FormattedValueType
+ {
+ get { return (typeof (string)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetContentBounds
+
+ ///
+ /// GetContentBounds
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex)
+ {
+ Rectangle cellBounds = DataGridView.GetCellDisplayRectangle(ColumnIndex, rowIndex, false);
+ cellBounds.Location = new Point(0, 0);
+
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn)OwningColumn;
+ ButtonX bx = oc.ButtonX;
+
+ Rectangle rBt = GetButtonBounds(cellBounds, true);
+
+ if (bx.ButtonItem.SubItems.Count > 0)
+ rBt.Width -= bx.ButtonItem.SubItemsExpandWidth;
+
+ return (rBt);
+ }
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState,
+ object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintButtonBackground(g, cellStyle, rBk);
+ PaintButtonContent(cellBounds, rowIndex, formattedValue, cellStyle, paintParts, bm);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintButtonBackground
+
+ ///
+ /// Paints the Button background
+ ///
+ ///
+ ///
+ ///
+ private void PaintButtonBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintButtonContent
+
+ ///
+ /// Paints the button background and content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintButtonContent(Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts, Bitmap bm)
+ {
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn)OwningColumn;
+ ButtonX bx = oc.ButtonX;
+
+ Rectangle rBt = GetButtonBounds(cellBounds, true);
+
+ if (rBt.Width > 0 && rBt.Height > 0)
+ {
+ bool mouseIsOver = bx.ButtonItem.MouseIsOver;
+ bool mouerIsOverExpand = bx.ButtonItem.MouseIsOverExpand;
+ bool mouseIsDown = bx.ButtonItem.MouseIsDown;
+ bool buttonIsExpanded = bx.ButtonItem.ButtonIsExpanded;
+
+ try
+ {
+ string s = oc.Text;
+
+ oc.InCellCallBack = true;
+
+ if (rowIndex != oc.ActiveRowIndex)
+ {
+ bx.ButtonItem.MouseIsOver = false;
+ bx.ButtonItem.MouseIsOverExpand = false;
+ bx.ButtonItem.MouseIsDown = false;
+ bx.ButtonItem.ButtonIsExpanded = false;
+ }
+
+ bx.Font = cellStyle.Font;
+ bx.ForeColor = cellStyle.ForeColor;
+ bx.BackColor = cellStyle.BackColor;
+
+ if (rowIndex < DataGridView.RowCount)
+ {
+ bx.Text = UseColumnTextForButtonValue ? s : GetValue(value);
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+ }
+ else
+ {
+ bx.Text = "";
+ }
+
+ bx.Bounds = rBt;
+ bx.RecalcLayout();
+ bx.DrawToBitmap(bm, rBt);
+ }
+ finally
+ {
+ bx.ButtonItem.MouseIsOver = mouseIsOver;
+ bx.ButtonItem.MouseIsOverExpand = mouerIsOverExpand;
+ bx.ButtonItem.MouseIsDown = mouseIsDown;
+ bx.ButtonItem.ButtonIsExpanded = buttonIsExpanded;
+
+ oc.InCellCallBack = false;
+ }
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Mouse processing
+
+ #region OnMouseEnter
+
+ ///
+ /// OnMouseEnter
+ ///
+ ///
+ protected override void OnMouseEnter(int rowIndex)
+ {
+ base.OnMouseEnter(rowIndex);
+
+ DoMouseEnter(rowIndex);
+ }
+
+ ///
+ /// Establishes the given rowIndex as the
+ /// ActiveRowIndex.
+ ///
+ ///
+ internal void DoMouseEnter(int rowIndex)
+ {
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn)OwningColumn;
+ ButtonX bx = oc.ButtonX;
+
+ oc.CurrentRowIndex = rowIndex;
+
+ if (bx.Expanded == false)
+ {
+ oc.ActiveRowIndex = rowIndex;
+
+ bx.ButtonItem.InternalMouseEnter();
+
+ RefreshButton(ColumnIndex, rowIndex);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseLeave
+
+ ///
+ /// Processes MouseLeave events
+ ///
+ ///
+ protected override void OnMouseLeave(int rowIndex)
+ {
+ base.OnMouseLeave(rowIndex);
+
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn)OwningColumn;
+ ButtonX bx = oc.ButtonX;
+
+ oc.CurrentRowIndex = -1;
+
+ if (bx.Expanded == false)
+ {
+ oc.ActiveRowIndex = -1;
+
+ bx.ButtonItem.InternalMouseLeave();
+
+ RefreshButton(ColumnIndex, rowIndex);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseMove
+
+ ///
+ /// Processes MouseMove events
+ ///
+ ///
+ protected override void OnMouseMove(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn) OwningColumn;
+ ButtonX bx = oc.ButtonX;
+
+ if (oc.ActiveRowIndex == e.RowIndex || bx.Expanded == false)
+ {
+ bx.ButtonItem.InternalMouseMove(
+ new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
+
+ RefreshButton(e.ColumnIndex, e.RowIndex);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseDown
+
+ ///
+ /// Processes MouseDown events
+ ///
+ ///
+ protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn) OwningColumn;
+ ButtonX bx = oc.ButtonX;
+
+ if (DataGridView.Controls.Contains(bx) == false)
+ DataGridView.Controls.Add(bx);
+
+ if (oc.ExpandClosed == false || bx.ButtonItem.MouseIsOverExpand == false)
+ {
+ Rectangle cellBounds = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
+ Rectangle rBt = GetButtonBounds(cellBounds, false);
+
+ Point pt = e.Location;
+ pt.Offset(rBt.Location);
+
+ if (rBt.Contains(pt) == true)
+ {
+ bx.Bounds = rBt;
+
+ bx.ButtonItem.InternalMouseDown(
+ new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
+
+ DataGridView.Invalidate(rBt);
+ }
+ }
+
+ oc.ExpandClosed = false;
+ }
+
+ #endregion
+
+ #region OnMouseUp
+
+ ///
+ /// Processes MouseUp events
+ ///
+ ///
+ protected override void OnMouseUp(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn) OwningColumn;
+ ButtonX bx = oc.ButtonX;
+
+ Rectangle cellBounds = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
+ Rectangle rBt = GetButtonBounds(cellBounds, false);
+
+ DataGridView.Invalidate(rBt);
+
+ bx.Bounds = rBt;
+ bx.ButtonItem.InternalMouseUp(
+ new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetButtonBounds
+
+ ///
+ /// Gets the button bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetButtonBounds(Rectangle cellBounds, bool localize)
+ {
+ DataGridViewButtonXColumn oc = (DataGridViewButtonXColumn)OwningColumn;
+
+ cellBounds.Width -= (oc.DividerWidth + 3);
+ cellBounds.Height -= 3;
+
+ if (localize == true)
+ cellBounds.Location = new Point(0, 0);
+
+ cellBounds.X++;
+ cellBounds.Y++;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetValue
+
+ ///
+ /// GetValue
+ ///
+ ///
+ ///
+ private string GetValue(object value)
+ {
+ return (value != Convert.DBNull ? Convert.ToString(value) : "" );
+ }
+
+ #endregion
+
+ #region RefreshButton
+
+ ///
+ /// Initiates the refresh of the cell button
+ ///
+ ///
+ ///
+ private void RefreshButton(int columnIndex, int rowIndex)
+ {
+ if (DataGridView != null)
+ {
+ Rectangle cellBounds = DataGridView.GetCellDisplayRectangle(columnIndex, rowIndex, false);
+ Rectangle rBt = GetButtonBounds(cellBounds, false);
+
+ DataGridView.Invalidate(rBt);
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewButtonX/DataGridViewButtonXColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewButtonX/DataGridViewButtonXColumn.cs
new file mode 100644
index 00000000..f2592174
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewButtonX/DataGridViewButtonXColumn.cs
@@ -0,0 +1,751 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Design;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewButtonXColumn), "ButtonX.ButtonX.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewButtonXColumn : DataGridViewButtonColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ [Description("Occurs right before a Button Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ [Description("Occurs when a Button Cell is Clicked.")]
+ public event EventHandler Click;
+
+ #endregion
+
+ #region Private variables
+
+ private ButtonX _ButtonX;
+
+ private int _ActiveRowIndex = -1;
+ private int _CurrentRowIndex = -1;
+
+ private bool _ExpandClosed;
+ private bool _InCellCallBack;
+
+ private Bitmap _CellBitmap;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewButtonXColumn()
+ {
+ CellTemplate = new DataGridViewButtonXCell();
+
+ _ButtonX = new ButtonX();
+
+ _ButtonX.Visible = false;
+ _ButtonX.FadeEffect = false;
+
+ HookEvents(true);
+ }
+
+ #region Internal properties
+
+ #region ActiveRowIndex
+
+ ///
+ /// Gets or sets the active row index
+ ///
+ internal int ActiveRowIndex
+ {
+ get { return (_ActiveRowIndex); }
+ set { _ActiveRowIndex = value; }
+ }
+
+ #endregion
+
+ #region ButtonX
+
+ ///
+ /// Gets the Control Button
+ ///
+ internal ButtonX ButtonX
+ {
+ get { return (_ButtonX); }
+ }
+
+ #endregion
+
+ #region CurrentRowIndex
+
+ ///
+ /// Gets or sets the Current row index
+ ///
+ internal int CurrentRowIndex
+ {
+ get { return (_CurrentRowIndex); }
+ set { _CurrentRowIndex = value; }
+ }
+
+ #endregion
+
+ #region ExpandClosed
+
+ ///
+ /// Gets or sets a expanded button
+ /// was just closed
+ ///
+ internal bool ExpandClosed
+ {
+ get { return (_ExpandClosed); }
+ set { _ExpandClosed = value; }
+ }
+
+ #endregion
+
+ #region InCellCallBack
+
+ ///
+ /// Gets or sets the cell callback state
+ ///
+ internal bool InCellCallBack
+ {
+ get { return (_InCellCallBack); }
+ set { _InCellCallBack = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region AutoCheckOnClick
+
+ ///
+ /// Gets or sets whether Checked property is automatically inverted, button checked/unchecked, when button is clicked. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Behavior")]
+ [Description("Indicates whether Checked property is automatically inverted when button is clicked.")]
+ public bool AutoCheckOnClick
+ {
+ get { return (_ButtonX.AutoCheckOnClick); }
+ set { _ButtonX.AutoCheckOnClick = value; }
+ }
+
+ #endregion
+
+ #region AutoExpandOnClick
+
+ ///
+ /// Indicates whether the button will auto-expand when clicked.
+ /// When button contains sub-items, sub-items will be shown only if user
+ /// click the expand part of the button. Setting this property to true will expand the button and show sub-items when user
+ /// clicks anywhere inside of the button. Default value is false which indicates that button is expanded only
+ /// if its expand part is clicked.
+ ///
+ [DefaultValue(false), Browsable(true), DevCoBrowsable(true), Category("Behavior")]
+ [Description("Indicates whether the button will auto-expand (display pop-up menu or toolbar) when clicked.")]
+ public virtual bool AutoExpandOnClick
+ {
+ get { return (_ButtonX.AutoExpandOnClick); }
+ set { _ButtonX.AutoExpandOnClick = value; }
+ }
+
+ #endregion
+
+ #region Checked
+
+ ///
+ /// Gets or set a value indicating whether the button is in the checked state.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance"), DefaultValue(false)]
+ [Description("Indicates whether item is checked or not.")]
+ public virtual bool Checked
+ {
+ get { return (_ButtonX.Checked); }
+ set { _ButtonX.Checked = value; }
+ }
+
+ #endregion
+
+ #region ColorScheme
+
+ ///
+ /// Gets or sets button Color Scheme. ColorScheme does not apply to Office2007 styled buttons.
+ ///
+ [Browsable(false), DevCoBrowsable(false), Category("Appearance")]
+ [Description("Gets or sets Bar Color Scheme."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ColorScheme ColorScheme
+ {
+ get { return (_ButtonX.ColorScheme); }
+ set { _ButtonX.ColorScheme = value; }
+ }
+
+ #endregion
+
+ #region ColorTable
+
+ ///
+ /// Gets or sets the predefined color of the button. Color specified applies to buttons with Office 2007 style only. It does not have
+ /// any effect on other styles. Default value is eButtonColor.BlueWithBackground
+ ///
+ [Browsable(true), DevCoBrowsable(false), DefaultValue(eButtonColor.BlueWithBackground), Category("Appearance")]
+ [Description("Indicates predefined color of button when Office 2007 style is used.")]
+ [NotifyParentProperty(true)]
+ public eButtonColor ColorTable
+ {
+ get { return (_ButtonX.ColorTable); }
+ set { _ButtonX.ColorTable = value; }
+ }
+
+ #endregion
+
+ #region CustomColorName
+
+ ///
+ /// Gets or sets the custom color name. Name specified here must be represented by the corresponding object with the same name that is part
+ /// of the Office2007ColorTable.ButtonItemColors collection. See documentation for Office2007ColorTable.ButtonItemColors for more information.
+ /// If color table with specified name cannot be found default color will be used. Valid settings for this property override any
+ /// setting to the Color property. Applies to items with Office 2007 style only.
+ ///
+ [Browsable(true), DevCoBrowsable(false), DefaultValue(""), Category("Appearance")]
+ [Description("Indicates custom color table name for the button when Office 2007 style is used.")]
+ public string CustomColorName
+ {
+ get { return (_ButtonX.CustomColorName); }
+ set { _ButtonX.CustomColorName = value; }
+ }
+
+ #endregion
+
+ #region DisabledImage
+
+ ///
+ /// Specifies the image for the button when items Enabled property is set to false.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(null), Category("Appearance")]
+ [Description("The image that will be displayed when item is disabled.")]
+ public Image DisabledImage
+ {
+ get { return (_ButtonX.DisabledImage); }
+ set { _ButtonX.DisabledImage = value; }
+ }
+
+ #endregion
+
+ #region EnableMarkup
+
+ ///
+ /// Gets or sets whether text-markup support is enabled for items Text property. Default value is true.
+ /// Set this property to false to display HTML or other markup in the item instead of it being parsed as text-markup.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether text-markup support is enabled for items Text property.")]
+ public bool EnableMarkup
+ {
+ get { return (_ButtonX.EnableMarkup); }
+ set { _ButtonX.EnableMarkup = value; }
+ }
+
+ #endregion
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_ButtonX.Enabled); }
+ set { _ButtonX.Enabled = value; }
+ }
+
+ #endregion
+
+ #region HotTrackingStyle
+
+ ///
+ /// Indicates the way button is rendering the mouse over state. Setting the value to
+ /// Color will render the image in gray-scale when mouse is not over the item.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(eHotTrackingStyle.Default), Category("Appearance")]
+ [Description("Indicates the button mouse over tracking style. Setting the value to Color will render the image in gray-scale when mouse is not over the item.")]
+ public eHotTrackingStyle HotTrackingStyle
+ {
+ get { return (_ButtonX.HotTrackingStyle); }
+ set { _ButtonX.HotTrackingStyle = value; }
+ }
+
+ #endregion
+
+ #region HoverImage
+
+ ///
+ /// Specifies the image for the button when mouse is over the item.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(null), Category("Appearance")]
+ [Description("The image that will be displayed when mouse hovers over the item.")]
+ public Image HoverImage
+ {
+ get { return (_ButtonX.HoverImage); }
+ set { _ButtonX.HoverImage = value; }
+ }
+
+ #endregion
+
+ #region Image
+
+ ///
+ /// Specifies the Button image.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(null), Category("Appearance")]
+ [Description("The image that will be displayed on the face of the button.")]
+ public Image Image
+ {
+ get { return (_ButtonX.Image); }
+ set { _ButtonX.Image = value; }
+ }
+
+ #endregion
+
+ #region ImageFixedSize
+
+ ///
+ /// Sets fixed size of the image. Image will be scaled and painted it size specified.
+ ///
+ [Browsable(true)]
+ public Size ImageFixedSize
+ {
+ get { return (_ButtonX.ImageFixedSize); }
+ set { _ButtonX.ImageFixedSize = value; }
+ }
+
+ ///
+ /// Gets whether ImageFixedSize property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeImageFixedSize()
+ {
+ return (_ButtonX.ShouldSerializeImageFixedSize());
+ }
+
+ #endregion
+
+ #region ImagePosition
+
+ ///
+ /// Gets/Sets the image position inside the button.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(eImagePosition.Left), Category("Appearance")]
+ [Description("The alignment of the image in relation to text displayed by this item.")]
+ public eImagePosition ImagePosition
+ {
+ get { return (_ButtonX.ImagePosition); }
+ set { _ButtonX.ImagePosition = value; }
+ }
+
+ #endregion
+
+ #region ImageTextSpacing
+
+ ///
+ /// Gets or sets the amount of spacing between button image if specified and text.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout")]
+ [Description("Indicates amount of spacing between button image if specified and text.")]
+ public int ImageTextSpacing
+ {
+ get { return (_ButtonX.ImageTextSpacing); }
+ set { _ButtonX.ImageTextSpacing = value; }
+
+ }
+
+ #endregion
+
+ #region PopupSide
+
+ ///
+ /// Gets or sets the location of popup in relation to it's parent.
+ ///
+ [Browsable(true), DevCoBrowsable(false), DefaultValue(ePopupSide.Default)]
+ [Description("Indicates location of popup in relation to it's parent.")]
+ public ePopupSide PopupSide
+ {
+ get { return (_ButtonX.PopupSide); }
+ set { _ButtonX.PopupSide = value; }
+ }
+
+ #endregion
+
+ #region PressedImage
+
+ ///
+ /// Specifies the image for the button when mouse left button is pressed.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(null), Category("Appearance")]
+ [Description("The image that will be displayed when item is pressed.")]
+ public Image PressedImage
+ {
+ get { return (_ButtonX.PressedImage); }
+ set { _ButtonX.PressedImage = value; }
+ }
+
+ #endregion
+
+ #region Shape
+
+ ///
+ /// Gets or sets an shape descriptor for the button
+ /// which describes the shape of the button. Default value is null
+ /// which indicates that system default shape is used.
+ ///
+ [DefaultValue(null)]
+ [Editor("DevComponents.DotNetBar.Design.ShapeTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(UITypeEditor))]
+ [TypeConverter("DevComponents.DotNetBar.Design.ShapeStringConverter, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public ShapeDescriptor Shape
+ {
+ get { return (_ButtonX.Shape); }
+ set { _ButtonX.Shape = value; }
+ }
+
+ #endregion
+
+ #region ShowSubItems
+
+ ///
+ /// Gets or sets whether button displays the expand part that indicates that button has popup.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Determines whether sub-items are displayed.")]
+ public bool ShowSubItems
+ {
+ get { return (_ButtonX.ShowSubItems); }
+ set { _ButtonX.ShowSubItems = value; }
+ }
+
+ #endregion
+
+ #region SplitButton
+
+ ///
+ /// Gets or sets whether button appears as split button. Split button appearance
+ /// divides button into two parts. Image which raises the click event when clicked
+ /// and text and expand sign which shows button sub items on popup menu when clicked.
+ /// Button must have both text and image visible (ButtonStyle property) in order to
+ /// appear as a full split button.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance")]
+ [Description("Indicates whether button appears as split button.")]
+ public bool SplitButton
+ {
+ get { return (_ButtonX.SplitButton); }
+ set { _ButtonX.SplitButton = value; }
+ }
+
+ #endregion
+
+ #region Style
+
+ ///
+ /// Gets/Sets the visual style for the button.
+ ///
+ [Category("Appearance"), Description("Specifies the visual style of the button.")]
+ [DefaultValue(eDotNetBarStyle.Office2007)]
+ public eDotNetBarStyle Style
+ {
+ get { return (_ButtonX.Style); }
+ set { _ButtonX.Style = value; }
+ }
+
+ #endregion
+
+ #region SubItems
+
+ ///
+ /// Returns the collection of sub items.
+ ///
+ [Browsable(false), DevCoBrowsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public SubItemsCollection SubItems
+ {
+ get { return (_ButtonX.SubItems); }
+ }
+
+ #endregion
+
+ #region SubItemsExpandWidth
+
+ ///
+ /// Gets or sets the width of the expand part of the button item.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(12), Category("Behavior")]
+ [Description("Indicates the width of the expand part of the button item.")]
+ public int SubItemsExpandWidth
+ {
+ get { return (_ButtonX.SubItemsExpandWidth); }
+ set { _ButtonX.SubItemsExpandWidth = value; }
+ }
+
+ #endregion
+
+ #region Text
+
+ ///
+ /// Gets or sets the default Text to display on the Button
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue("")]
+ [Description("Indicates the default Text to display on the Button.")]
+ public new string Text
+ {
+ get
+ {
+ return (_InCellCallBack == true ?
+ _ButtonX.Text : base.Text);
+ }
+
+ set
+ {
+ if (_InCellCallBack == true)
+ _ButtonX.Text = value;
+ else
+ base.Text = value;
+ }
+ }
+
+ #endregion
+
+ #region TextAlignment
+
+ ///
+ /// Gets or sets the text alignment. Applies only when button text is not composed using text markup. Default value is center.
+ ///
+ [Browsable(true), DefaultValue(eButtonTextAlignment.Center), Category("Appearance")]
+ [Description("Indicates text alignment. Applies only when button text is not composed using text markup. Default value is center.")]
+ public eButtonTextAlignment TextAlignment
+ {
+ get { return (_ButtonX.TextAlignment); }
+ set { _ButtonX.TextAlignment = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region HookEvents
+
+ ///
+ /// Hooks or unhooks our system events
+ ///
+ ///
+ private void HookEvents(bool hook)
+ {
+ if (hook == true)
+ {
+ _ButtonX.ButtonItem.Click += ButtonItem_Click;
+ _ButtonX.ButtonItem.ExpandChange += ButtonItem_ExpandChange;
+ }
+ else
+ {
+ _ButtonX.ButtonItem.Click -= ButtonItem_Click;
+ _ButtonX.ButtonItem.ExpandChange -= ButtonItem_ExpandChange;
+ }
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region ButtonItem_ExpandChange
+
+ ///
+ /// Processes Button expand changes
+ ///
+ ///
+ ///
+ void ButtonItem_ExpandChange(object sender, EventArgs e)
+ {
+ if (_ButtonX.ButtonItem.Expanded == false)
+ {
+ DataGridView.InvalidateCell(Index, ActiveRowIndex);
+
+ _ExpandClosed = (_ActiveRowIndex == _CurrentRowIndex);
+ _ActiveRowIndex = -1;
+
+ if (_CurrentRowIndex >= 0)
+ {
+ DataGridViewButtonXCell cell =
+ DataGridView.Rows[_CurrentRowIndex].Cells[Index] as DataGridViewButtonXCell;
+
+ if (cell != null)
+ cell.DoMouseEnter(_CurrentRowIndex);
+ }
+ }
+ }
+
+ #endregion
+
+ #region ButtonItem_Click
+
+ ///
+ /// ButtonItem_Click
+ ///
+ ///
+ ///
+ void ButtonItem_Click(object sender, EventArgs e)
+ {
+ if (Click != null)
+ Click(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewButtonXColumn bc = base.Clone() as DataGridViewButtonXColumn;
+
+ if (bc != null)
+ {
+ _ButtonX.ButtonItem.InternalCopyToItem(bc.ButtonX.ButtonItem);
+
+ bc.Enabled = Enabled;
+ bc.TextAlignment = TextAlignment;
+ bc.ImageTextSpacing = ImageTextSpacing;
+
+ bc.Shape = Shape;
+ }
+
+ return (bc);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the ButtonX control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+
+ #region Dispose
+
+ ///
+ /// Dispose
+ ///
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ HookEvents(false);
+
+ if (disposing == true)
+ _ButtonX.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+ }
+
+ #region BeforeCellPaintEventArgs
+
+ ///
+ /// BeforeCellPaintEventArgs
+ ///
+ public class BeforeCellPaintEventArgs : EventArgs
+ {
+ #region Private variables
+
+ private int _RowIndex;
+ private int _ColumnIndex;
+
+ #endregion
+
+ public BeforeCellPaintEventArgs(int rowIndex, int columnIndex)
+ {
+ _RowIndex = rowIndex;
+ _ColumnIndex = columnIndex;
+ }
+
+ #region Public properties
+
+ ///
+ /// RowIndex of cell being painted
+ ///
+ public int RowIndex
+ {
+ get { return (_RowIndex); }
+ }
+
+ ///
+ /// ColumnIndex of cell being painted
+ ///
+ public int ColumnIndex
+ {
+ get { return (_ColumnIndex); }
+ }
+
+ #endregion
+ }
+
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewCheckBoxX/DataGridViewCheckBoxXCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewCheckBoxX/DataGridViewCheckBoxXCell.cs
new file mode 100644
index 00000000..d78e8aba
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewCheckBoxX/DataGridViewCheckBoxXCell.cs
@@ -0,0 +1,696 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewCheckBoxXCell : DataGridViewCell
+ {
+ #region Private variables
+
+ private bool _MouseEntered;
+ private string _Text;
+
+ #endregion
+
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (null); }
+ }
+
+ #endregion
+
+ #region FormattedValueType
+
+ ///
+ /// FormattedValueType
+ ///
+ public override Type FormattedValueType
+ {
+ get { return (typeof(string)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetContentBounds(editingControlBounds);
+
+ if (cellStyle != null)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.TopCenter:
+ editingControlBounds.X += (editingControlBounds.Width - r.Width) / 2;
+ break;
+
+ case DataGridViewContentAlignment.TopRight:
+ editingControlBounds.X = (editingControlBounds.Right - r.Width);
+ break;
+
+ case DataGridViewContentAlignment.MiddleLeft:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height) / 2;
+ break;
+
+ case DataGridViewContentAlignment.MiddleCenter:
+ editingControlBounds.X += (editingControlBounds.Width - r.Width) / 2;
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height) / 2;
+ break;
+
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.X = (editingControlBounds.Right - r.Width);
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height) / 2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+
+ case DataGridViewContentAlignment.BottomCenter:
+ editingControlBounds.X += (editingControlBounds.Width - r.Width) / 2;
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.X = (editingControlBounds.Right - r.Width);
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ if (editingControlBounds.Y < 1)
+ editingControlBounds.Y = 1;
+
+ editingControlBounds.Width = Math.Max(1, editingControlBounds.Width);
+ editingControlBounds.Height = Math.Max(1, r.Height);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ #region GetPreferredSize
+
+ ///
+ /// GetPreferredSize
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Size GetPreferredSize(Graphics graphics,
+ DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ {
+ if (DataGridView == null)
+ return (new Size(-1, -1));
+
+ Size preferredSize = Size.Empty;
+
+ if (constraintSize.Width == 0)
+ {
+ DataGridViewCheckBoxXColumn oc = OwningColumn as DataGridViewCheckBoxXColumn;
+
+ if (oc != null)
+ {
+ GetFormattedValue(GetValue(rowIndex), rowIndex,
+ ref cellStyle, null, null, new DataGridViewDataErrorContexts());
+
+ if (rowIndex < DataGridView.RowCount)
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+
+ CheckBoxX cb = oc.CheckBoxX;
+
+ SizeF sf = graphics.MeasureString(cb.Text, cellStyle.Font);
+
+ preferredSize.Width = (int) sf.Width + 4;
+ preferredSize.Height = cb.Height;
+
+ preferredSize.Width += cb.CheckBoxItem.CheckSignSize.Width;
+ }
+ }
+
+ return (preferredSize);
+ }
+
+ #endregion
+
+ #region GetFormattedValue
+
+ protected override object GetFormattedValue(object value, int rowIndex,
+ ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter,
+ TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
+ {
+ return (base.GetFormattedValue(value, rowIndex,
+ ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState,
+ object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewCheckBoxXColumn oc = (DataGridViewCheckBoxXColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintButtonBackground(g, cellStyle, rBk);
+ PaintButtonContent(cellBounds, rowIndex, value, cellStyle, paintParts, g);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintButtonBackground
+
+ ///
+ /// Paints the Button background
+ ///
+ ///
+ ///
+ ///
+ private void PaintButtonBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintButtonContent
+
+ ///
+ /// Paints the button background and content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintButtonContent(Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts, Graphics g)
+ {
+ DataGridViewCheckBoxXColumn oc = (DataGridViewCheckBoxXColumn) OwningColumn;
+ CheckBoxX bx = oc.CheckBoxX;
+
+ string text = bx.Text;
+ bool isChecked = bx.Checked;
+ object checkValue = bx.CheckValue;
+ CheckState checkState = bx.CheckState;
+ bool isMouseOver = bx.CheckBoxItem.IsMouseOver;
+ bool isMouseDown = bx.CheckBoxItem.IsMouseDown;
+
+ GraphicsState gs = g.Save();
+
+ try
+ {
+ oc.InCellCallBack = true;
+
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ bx.CheckValue = (oc.ThreeState == true) ? value : GetCheckValue(oc, value);
+
+ bx.Font = cellStyle.Font;
+ bx.ForeColor = cellStyle.ForeColor;
+ bx.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+
+ if (rowIndex != oc.ActiveRowIndex)
+ {
+ bx.CheckBoxItem.IsMouseOver = false;
+ bx.CheckBoxItem.IsMouseDown = false;
+ }
+
+ if (rowIndex < DataGridView.RowCount)
+ {
+ bx.Text = text;
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+ }
+ else
+ {
+ bx.Text = "";
+ }
+
+ _Text = bx.Text;
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+
+ bx.CallBasePaintBackground = false;
+
+ g.TranslateTransform(r.X, r.Y);
+
+ bx.Bounds = r;
+ bx.RecalcLayout();
+ bx.InternalPaint(new PaintEventArgs(g, Rectangle.Empty));
+ }
+ finally
+ {
+ bx.Text = text;
+
+ if (bx.ThreeState == true)
+ bx.CheckValue = checkValue;
+
+ bx.Checked = isChecked;
+ bx.CheckState = checkState;
+
+ bx.CheckBoxItem.IsMouseOver = isMouseOver;
+ bx.CheckBoxItem.IsMouseDown = isMouseDown;
+
+ g.Restore(gs);
+
+ oc.InCellCallBack = false;
+ }
+ }
+
+ #region GetCheckValue
+
+ private bool GetCheckValue(DataGridViewCheckBoxXColumn oc, object value)
+ {
+ if (value == null || value == DBNull.Value)
+ return (false);
+
+ Type type = value.GetType();
+
+ if (type == typeof(bool))
+ return ((bool)value);
+
+ if (type == typeof(string))
+ {
+ string s = (string)value;
+
+ if (oc.CheckValueChecked is string && s.Equals(oc.CheckValueChecked))
+ return (true);
+
+ if (oc.CheckValueUnchecked is string && s.Equals(oc.CheckValueUnchecked))
+ return (false);
+ }
+ else
+ {
+ int n = Convert.ToInt32(value);
+
+ if (n == 1)
+ return (true);
+ }
+
+ return (false);
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region Mouse processing
+
+ #region OnMouseEnter
+
+ ///
+ /// OnMouseEnter
+ ///
+ ///
+ protected override void OnMouseEnter(int rowIndex)
+ {
+ base.OnMouseEnter(rowIndex);
+
+ DataGridViewCheckBoxXColumn oc = OwningColumn as DataGridViewCheckBoxXColumn;
+
+ if (oc != null && DataGridView != null)
+ {
+ _MouseEntered = false;
+
+ oc.ActiveRowIndex = rowIndex;
+ ToolTipText = _Text;
+
+ RefreshCell(ColumnIndex, rowIndex);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseLeave
+
+ ///
+ /// Processes MouseLeave events
+ ///
+ ///
+ protected override void OnMouseLeave(int rowIndex)
+ {
+ base.OnMouseLeave(rowIndex);
+
+ DataGridViewCheckBoxXColumn oc = OwningColumn as DataGridViewCheckBoxXColumn;
+
+ if (oc != null && DataGridView != null)
+ {
+ oc.ActiveRowIndex = -1;
+
+ if (_MouseEntered == true)
+ {
+ _MouseEntered = false;
+
+ oc.CheckBoxX.CheckBoxItem.InternalMouseLeave();
+ }
+
+ RefreshCell(ColumnIndex, rowIndex);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseMove
+
+ ///
+ /// Processes MouseMove events
+ ///
+ ///
+ protected override void OnMouseMove(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+
+ DataGridViewCheckBoxXColumn oc = OwningColumn as DataGridViewCheckBoxXColumn;
+
+ if (oc != null && DataGridView != null)
+ {
+ if (this.ReadOnly == true || oc.ReadOnly == true || DataGridView.ReadOnly == true)
+ return;
+
+ Rectangle cellBounds = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
+
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+
+ DataGridViewCellStyle cellStyle = DataGridView.Columns[e.ColumnIndex].InheritedStyle;
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+ Point pt = new Point(e.X - r.X, e.Y - r.Y);
+
+ if (oc.CheckBoxX.CheckBoxItem.DisplayRectangle.Contains(pt) == true)
+ {
+ if (_MouseEntered == false)
+ {
+ _MouseEntered = true;
+ oc.CheckBoxX.CheckBoxItem.InternalMouseEnter();
+ }
+ }
+ else
+ {
+ if (_MouseEntered == true)
+ {
+ _MouseEntered = false;
+ oc.CheckBoxX.CheckBoxItem.InternalMouseLeave();
+ }
+ }
+
+ oc.CheckBoxX.CheckBoxItem.InternalMouseMove(
+ new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
+
+ RefreshCell(e.ColumnIndex, e.RowIndex);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseDown
+
+ ///
+ /// Processes MouseDown events
+ ///
+ ///
+ protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+
+ if (_MouseEntered == true)
+ {
+ DataGridViewCheckBoxXColumn oc = OwningColumn as DataGridViewCheckBoxXColumn;
+
+ if (oc != null && !oc.ReadOnly && DataGridView != null)
+ {
+ oc.DownRowIndex = e.RowIndex;
+
+ Rectangle cellBounds = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
+
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+
+ DataGridViewCellStyle cellStyle = DataGridView.Columns[e.ColumnIndex].InheritedStyle;
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+ Point pt = new Point(e.X - r.X, e.Y - r.Y);
+
+ if (oc.CheckBoxX.CheckBoxItem.DisplayRectangle.Contains(pt) == true)
+ {
+ oc.CheckBoxX.CheckValue = GetValue(e.RowIndex);
+
+ oc.CheckBoxX.CheckBoxItem.InternalMouseDown(
+ new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
+
+ RefreshCell(e.ColumnIndex, e.RowIndex);
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region OnMouseUp
+
+ ///
+ /// Processes MouseUp events
+ ///
+ ///
+ protected override void OnMouseUp(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+
+ DataGridViewCheckBoxXColumn oc = OwningColumn as DataGridViewCheckBoxXColumn;
+
+ if (oc != null && !oc.ReadOnly && DataGridView != null)
+ {
+ Rectangle cellBounds = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
+
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+
+ DataGridViewCellStyle cellStyle = DataGridView.Columns[e.ColumnIndex].InheritedStyle;
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+ Point pt = new Point(e.X - r.X, e.Y - r.Y);
+
+ oc.CheckBoxX.CheckBoxItem.InternalMouseUp(
+ new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
+
+ if (e.RowIndex == oc.DownRowIndex)
+ {
+ if (r.Contains(e.Location) == true)
+ Value = oc.CheckBoxX.CheckValue;
+
+ RefreshCell(e.ColumnIndex, e.RowIndex);
+ }
+
+ oc.DownRowIndex = -1;
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewCheckBoxXColumn oc = (DataGridViewCheckBoxXColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetContentBounds
+
+ ///
+ /// Gets the Content bounds for the given cell
+ ///
+ ///
+ ///
+ private Rectangle GetContentBounds(Rectangle cellBounds)
+ {
+ DataGridViewCheckBoxXColumn oc = OwningColumn as DataGridViewCheckBoxXColumn;
+
+ if (oc != null)
+ {
+ if (oc.CheckBoxX.Parent == null)
+ {
+ Form form = oc.DataGridView.FindForm();
+
+ if (form != null)
+ oc.CheckBoxX.Parent = form;
+ }
+
+ oc.CheckBoxX.CheckBoxItem.RecalcSize();
+
+ cellBounds.Width = Math.Min(oc.CheckBoxX.CheckBoxItem.WidthInternal, cellBounds.Width);
+ cellBounds.Width -= (oc.DividerWidth + 3);
+ cellBounds.Height = oc.CheckBoxX.CheckBoxItem.HeightInternal;
+ }
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region RefreshCell
+
+ ///
+ /// Initiates the refresh of the cell
+ ///
+ ///
+ ///
+ private void RefreshCell(int columnIndex, int rowIndex)
+ {
+ if (DataGridView != null)
+ DataGridView.InvalidateCell(columnIndex, rowIndex);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewCheckBoxX/DataGridViewCheckBoxXColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewCheckBoxX/DataGridViewCheckBoxXColumn.cs
new file mode 100644
index 00000000..c55cc11c
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewCheckBoxX/DataGridViewCheckBoxXColumn.cs
@@ -0,0 +1,562 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewButtonXColumn), "Controls.CheckBoxX.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewCheckBoxXColumn : DataGridViewColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ [Description("Occurs right before a CheckBoxX Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ [Description("Occurs when a CheckBoxX Cell is Clicked.")]
+ public event EventHandler Click;
+
+ [Description("Occurs when a CheckBoxX Cell is DoubleClicked.")]
+ public event EventHandler DoubleClicked;
+
+ #endregion
+
+ #region Private variables
+
+ private CheckBoxX _CheckBoxX;
+
+ private int _ActiveRowIndex = -1;
+ private int _CurrentRowIndex = -1;
+ private int _DownRowIndex = -1;
+
+ private bool _InCellCallBack;
+
+ private Bitmap _CellBitmap;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewCheckBoxXColumn()
+ {
+ CellTemplate = new DataGridViewCheckBoxXCell();
+
+ _CheckBoxX = new CheckBoxX();
+ _CheckBoxX.Visible = false;
+
+ _CheckBoxX.CheckValueChecked = true;
+ _CheckBoxX.CheckValueUnchecked = false;
+
+ HookEvents(true);
+ }
+
+ #region Internal properties
+
+ #region ActiveRowIndex
+
+ ///
+ /// Gets or sets the active row index
+ ///
+ internal int ActiveRowIndex
+ {
+ get { return (_ActiveRowIndex); }
+ set { _ActiveRowIndex = value; }
+ }
+
+ #endregion
+
+ #region CheckBoxX
+
+ ///
+ /// Gets the Control Button
+ ///
+ internal CheckBoxX CheckBoxX
+ {
+ get { return (_CheckBoxX); }
+ }
+
+ #endregion
+
+ #region CurrentRowIndex
+
+ ///
+ /// Gets or sets the Current row index
+ ///
+ internal int CurrentRowIndex
+ {
+ get { return (_CurrentRowIndex); }
+ set { _CurrentRowIndex = value; }
+ }
+
+ #endregion
+
+ #region DownRowIndex
+
+ ///
+ /// Gets or sets the MouseDown row index
+ ///
+ internal int DownRowIndex
+ {
+ get { return (_DownRowIndex); }
+ set { _DownRowIndex = value; }
+ }
+
+ #endregion
+
+ #region InCellCallBack
+
+ ///
+ /// Gets or sets the cell callback state
+ ///
+ internal bool InCellCallBack
+ {
+ get { return (_InCellCallBack); }
+ set { _InCellCallBack = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region CheckBoxImageChecked
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box is checked.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box is checked")]
+ public Image CheckBoxImageChecked
+ {
+ get { return _CheckBoxX.CheckBoxImageChecked; }
+ set
+ {
+ _CheckBoxX.CheckBoxImageChecked = value;
+ }
+ }
+ #endregion
+ #region CheckBoxImageUnChecked
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box is unchecked.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box is unchecked")]
+ public Image CheckBoxImageUnChecked
+ {
+ get { return _CheckBoxX.CheckBoxImageUnChecked; }
+ set
+ {
+ _CheckBoxX.CheckBoxImageUnChecked = value;
+ }
+ }
+ #endregion
+ #region CheckBoxImageIndeterminate
+ ///
+ /// Gets or sets the custom image that is displayed instead default check box representation when check box is in indeterminate state.
+ ///
+ [DefaultValue(null), Category("CheckBox Images"), Description("Indicates custom image that is displayed instead default check box representation when check box is in indeterminate state")]
+ public Image CheckBoxImageIndeterminate
+ {
+ get { return _CheckBoxX.CheckBoxImageIndeterminate; }
+ set
+ {
+ _CheckBoxX.CheckBoxImageIndeterminate = value;
+ }
+ }
+ #endregion
+
+ #region CheckBoxPosition
+
+ ///
+ /// Gets or sets the check box position relative to the text.
+ /// Default value is Left.
+ ///
+ [Browsable(true), DefaultValue(eCheckBoxPosition.Left), Category("Appearance")]
+ [Description("Indicates the check box position relative to the text.")]
+ public eCheckBoxPosition CheckBoxPosition
+ {
+ get { return (_CheckBoxX.CheckBoxPosition); }
+ set { _CheckBoxX.CheckBoxPosition = value; }
+ }
+
+ #endregion
+
+ #region Checked
+
+ ///
+ /// Gets or set a value indicating whether the button is in the checked state.
+ ///
+ [Browsable(false)]
+ public virtual bool Checked
+ {
+ get { return (_CheckBoxX.Checked); }
+ set { _CheckBoxX.Checked = value; }
+ }
+
+ #endregion
+
+ #region CheckState
+
+ ///
+ /// Specifies the state of the control, that can be
+ /// checked, unchecked, or set to an indeterminate state.
+ ///
+ [Browsable(false)]
+ public CheckState CheckState
+ {
+ get { return (_CheckBoxX.CheckState); }
+ set { _CheckBoxX.CheckState = value; }
+ }
+
+ #endregion
+
+ #region CheckValue
+
+ ///
+ /// CheckValue
+ ///
+ [Browsable(false)]
+ public object CheckValue
+ {
+ get { return (_CheckBoxX.CheckValue); }
+ set { _CheckBoxX.CheckValue = value; }
+ }
+
+ #endregion
+
+ #region CheckValueChecked
+
+ ///
+ /// Gets or sets the value that represents the Checked state value of the check
+ /// box when CheckValue property is set to that value. Default value is null.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior"), TypeConverter(typeof(StringConverter))]
+ [Description("Represents the Checked state value of the check box when CheckValue property is set to that value. Note that in the designer, this value type is always a string.")]
+ public object CheckValueChecked
+ {
+ get { return (_CheckBoxX.CheckValueChecked); }
+ set { _CheckBoxX.CheckValueChecked = value; }
+ }
+
+ #endregion
+
+ #region CheckValueIndeterminate
+
+ ///
+ /// Gets or sets the value that represents the Indeterminate state of the check
+ /// box when CheckValue property is set to that value. Default value is null.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Behavior"), TypeConverter(typeof(StringConverter))]
+ [Description("Represents the Indeterminate state value of the check box when CheckValue property is set to that value. Note that in the designer, this value type is always a string.")]
+ public object CheckValueIndeterminate
+ {
+ get { return (_CheckBoxX.CheckValueIndeterminate); }
+ set { _CheckBoxX.CheckValueIndeterminate = value; }
+ }
+
+ #endregion
+
+ #region CheckValueUnchecked
+
+ ///
+ /// Gets or sets the value that represents the Unchecked state value of check
+ /// box when CheckValue property is set to that value. Default value is 'N'.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Behavior"), TypeConverter(typeof(StringConverter))]
+ [Description("Represents the Unchecked state value of the check box when CheckValue property is set to that value. Note that in the designer, this value type is always a string.")]
+ public object CheckValueUnchecked
+ {
+ get { return (_CheckBoxX.CheckValueUnchecked); }
+ set { _CheckBoxX.CheckValueUnchecked = value; }
+ }
+
+ #endregion
+
+ #region ConsiderEmptyStringAsNull
+
+ ///
+ /// Gets or sets whether empty string is consider as null value
+ /// during CheckValue value comparison. Default value is true.
+ ///
+ [DefaultValue(true), Category("Behavior"), Browsable(true)]
+ [Description("Indicates whether empty string is consider as null value during CheckValue value comparison.")]
+ public bool ConsiderEmptyStringAsNull
+ {
+ get { return (_CheckBoxX.ConsiderEmptyStringAsNull); }
+ set { _CheckBoxX.ConsiderEmptyStringAsNull = value; }
+ }
+
+ #endregion
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_CheckBoxX.Enabled); }
+ set { _CheckBoxX.Enabled = value; }
+ }
+
+ #endregion
+
+ #region EnableMarkup
+
+ ///
+ /// Gets or sets whether text-markup support is enabled for controls
+ /// Text property. Default value is true. Set this property to false to
+ /// display HTML or other markup in the control instead of it being parsed as text-markup.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether text-markup support is enabled for controls Text property.")]
+ public bool EnableMarkup
+ {
+ get { return (_CheckBoxX.EnableMarkup); }
+ set { _CheckBoxX.EnableMarkup = value; }
+ }
+
+ #endregion
+
+ #region Text
+
+ ///
+ /// Gets or sets the default Text to display
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue("")]
+ [Description("Indicates the default Text to display.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public string Text
+ {
+ get { return (_CheckBoxX.Text); }
+ set { _CheckBoxX.Text = value; }
+ }
+
+ #endregion
+
+ #region TextColor
+
+ ///
+ /// Gets or sets the text color. Default value is
+ /// Color.Empty which indicates that default color is used.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates control text color.")]
+ public Color TextColor
+ {
+ get { return (_CheckBoxX.TextColor); }
+ set { _CheckBoxX.TextColor = value; }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTextColor()
+ {
+ return (_CheckBoxX.TextColor.IsEmpty == false);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTextColor()
+ {
+ TextColor = Color.Empty;
+ }
+
+ #endregion
+
+ #region TextVisible
+
+ ///
+ /// Gets or sets whether text assigned to the check box is visible.
+ /// Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether text assigned to the check box is visible.")]
+ public bool TextVisible
+ {
+ get { return (_CheckBoxX.TextVisible); }
+ set { _CheckBoxX.TextVisible = value; }
+ }
+
+ #endregion
+
+ #region ThreeState
+
+ ///
+ /// Gets or sets a value indicating whether the CheckBox will allow
+ /// three check states rather than two. If the ThreeState property is
+ /// set to true CheckState property should be used instead of Checked
+ /// property to set the extended state of the control.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(false)]
+ [Description("Indicates whether the CheckBox will allow three check states rather than two.")]
+ public bool ThreeState
+ {
+ get { return (_CheckBoxX.ThreeState); }
+ set { _CheckBoxX.ThreeState = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region HookEvents
+
+ ///
+ /// HookEvents
+ ///
+ ///
+ private void HookEvents(bool hook)
+ {
+ if (hook == true)
+ {
+ _CheckBoxX.CheckBoxItem.Click += CheckBoxItem_Click;
+ _CheckBoxX.CheckBoxItem.DoubleClick += CheckBoxItem_DoubleClick;
+ }
+ else
+ {
+ _CheckBoxX.CheckBoxItem.Click -= CheckBoxItem_Click;
+ _CheckBoxX.CheckBoxItem.DoubleClick -= CheckBoxItem_DoubleClick;
+ }
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region CheckBoxItem_Click
+
+ ///
+ /// CheckBoxItem_Click
+ ///
+ ///
+ ///
+ void CheckBoxItem_Click(object sender, EventArgs e)
+ {
+ if (Click != null)
+ Click(sender, e);
+ }
+
+ #endregion
+
+ #region CheckBoxItem_DoubleClick
+
+ ///
+ /// CheckBoxItem_DoubleClick
+ ///
+ ///
+ ///
+ void CheckBoxItem_DoubleClick(object sender, EventArgs e)
+ {
+ if (DoubleClicked != null)
+ DoubleClicked(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewCheckBoxXColumn cb = base.Clone() as DataGridViewCheckBoxXColumn;
+
+ if (cb != null)
+ {
+ _CheckBoxX.CheckBoxItem.InternalCopyToItem(cb.CheckBoxX.CheckBoxItem);
+
+ cb.CheckValue = CheckValue;
+ cb.CheckValueChecked = CheckValueChecked;
+ cb.CheckValueIndeterminate = CheckValueIndeterminate;
+ cb.CheckValueUnchecked = CheckValueUnchecked;
+ cb.ConsiderEmptyStringAsNull = ConsiderEmptyStringAsNull;
+ cb.Enabled = Enabled;
+ cb.Text = Text;
+ }
+
+ return (cb);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the ButtonX control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+
+ #region Dispose
+
+ ///
+ /// Dispose
+ ///
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ HookEvents(false);
+
+ if (disposing == true)
+ _CheckBoxX.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewComboBoxEx/DataGridViewComboBoxExCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewComboBoxEx/DataGridViewComboBoxExCell.cs
new file mode 100644
index 00000000..0cc6f5db
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewComboBoxEx/DataGridViewComboBoxExCell.cs
@@ -0,0 +1,895 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewComboBoxExCell : DataGridViewTextBoxCell
+ {
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (typeof(DataGridViewComboBoxExEditingControl)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region InitializeEditingControl
+
+ ///
+ /// InitializeEditingControl
+ ///
+ ///
+ ///
+ ///
+ public override void InitializeEditingControl(int rowIndex,
+ object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ DetachEditingControl();
+
+ base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
+
+ DataGridViewComboBoxExEditingControl ctl =
+ (DataGridViewComboBoxExEditingControl) DataGridView.EditingControl;
+
+ DataGridViewComboBoxExColumn oc = (DataGridViewComboBoxExColumn) OwningColumn;
+ ComboBoxEx cb = oc.ComboBoxEx;
+
+ ctl.DropDownStyle = cb.DropDownStyle;
+ ctl.AutoCompleteCustomSource = cb.AutoCompleteCustomSource;
+ ctl.AutoCompleteMode = cb.AutoCompleteMode;
+ ctl.AutoCompleteSource = cb.AutoCompleteSource;
+ ctl.DrawMode = cb.DrawMode;
+ ctl.DropDownHeight = cb.DropDownHeight;
+ ctl.Enabled = cb.Enabled;
+ ctl.FlatStyle = cb.FlatStyle;
+ ctl.FocusCuesEnabled = cb.FocusCuesEnabled;
+ ctl.FormatString = cb.FormatString;
+ ctl.FormattingEnabled = cb.FormattingEnabled;
+ ctl.Images = cb.Images;
+ ctl.ImeMode = cb.ImeMode;
+ ctl.IntegralHeight = cb.IntegralHeight;
+ ctl.IsStandalone = cb.IsStandalone;
+ ctl.ItemHeight = cb.ItemHeight;
+ ctl.MaxDropDownItems = cb.MaxDropDownItems;
+ ctl.MaxLength = cb.MaxLength;
+ ctl.RenderBorder = cb.RenderBorder;
+ ctl.RightToLeft = cb.RightToLeft;
+ ctl.Style = cb.Style;
+ ctl.WatermarkBehavior = cb.WatermarkBehavior;
+ ctl.WatermarkColor = cb.WatermarkColor;
+ ctl.WatermarkEnabled = cb.WatermarkEnabled;
+ ctl.WatermarkFont = cb.WatermarkFont;
+ ctl.WatermarkText = cb.WatermarkText;
+
+ ctl.DataSource = cb.DataSource;
+
+ if (ctl.DataSource is List == false)
+ ctl.ValueMember = cb.ValueMember;
+
+ ctl.DisplayMember = cb.DisplayMember;
+
+ if (ctl.DataSource == null)
+ {
+ object[] items = new object[cb.Items.Count];
+ cb.Items.CopyTo(items, 0);
+
+ ctl.Items.Clear();
+ ctl.Items.AddRange(items);
+
+ ctl.Text = Convert.ToString(initialFormattedValue);
+ }
+ else
+ {
+ object o = GetValue(rowIndex);
+ object value = GetDataSourceValueEx(oc, cb, o);
+
+ if (value == null)
+ {
+ ctl.SelectedIndex = -1;
+ ctl.SelectedIndex = -1;
+ }
+ else
+ {
+ ctl.SelectedItem = value;
+ }
+ }
+
+ ctl.Click += Click;
+ ctl.DrawItem += DrawItem;
+ ctl.DropDownChange += DropDownChange;
+ ctl.MeasureItem += MeasureItem;
+ }
+
+ #endregion
+
+ #region DetachEditingControl
+
+ ///
+ /// DetachEditingControl
+ ///
+ public override void DetachEditingControl()
+ {
+ if (DataGridView != null && DataGridView.EditingControl != null)
+ {
+ DataGridViewComboBoxExEditingControl cb =
+ DataGridView.EditingControl as DataGridViewComboBoxExEditingControl;
+
+ if (cb != null)
+ {
+ cb.Click -= Click;
+ cb.DrawItem -= DrawItem;
+ cb.DropDownChange -= DropDownChange;
+ cb.MeasureItem -= MeasureItem;
+ }
+ }
+
+ base.DetachEditingControl();
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region Click
+
+ ///
+ /// Click
+ ///
+ ///
+ ///
+ void Click(object sender, EventArgs e)
+ {
+ ((DataGridViewComboBoxExColumn)OwningColumn).DoComboBoxEx_Click(sender, e);
+ }
+
+ #endregion
+
+ #region DrawItem
+
+ ///
+ /// DrawItem
+ ///
+ ///
+ ///
+ void DrawItem(object sender, DrawItemEventArgs e)
+ {
+ ((DataGridViewComboBoxExColumn)OwningColumn).DoComboBoxEx_DrawItem(sender, e);
+ }
+
+ #endregion
+
+ #region DropDownChange
+
+ ///
+ /// DropDownChange
+ ///
+ ///
+ ///
+ void DropDownChange(object sender, bool expanded)
+ {
+ ((DataGridViewComboBoxExColumn)OwningColumn).DoComboBoxEx_DropDownChange(
+ sender, new DropDownChangeEventArgs(RowIndex, ColumnIndex, expanded));
+ }
+
+ #endregion
+
+ #region MeasureItem
+
+ ///
+ /// MeasureItem
+ ///
+ ///
+ ///
+ void MeasureItem(object sender, MeasureItemEventArgs e)
+ {
+ ((DataGridViewComboBoxExColumn)OwningColumn).DoComboBoxEx_MeasureItem(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PositionEditingControl
+
+ ///
+ /// PositionEditingControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override void PositionEditingControl(bool setLocation, bool setSize, Rectangle cellBounds,
+ Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded,
+ bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
+ {
+ Rectangle editingControlBounds =
+ PositionEditingPanel(cellBounds, cellClip, cellStyle, singleVerticalBorderAdded,
+ singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow);
+
+ editingControlBounds = GetAdjustedEditingControlBounds(editingControlBounds, cellStyle);
+
+ DataGridView.EditingControl.Location = new Point(editingControlBounds.X, editingControlBounds.Y);
+ DataGridView.EditingControl.Size = new Size(editingControlBounds.Width, editingControlBounds.Height);
+ }
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetCellBounds(editingControlBounds);
+
+ if (r.Height < editingControlBounds.Height)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.MiddleLeft:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height) / 2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ editingControlBounds.Width = Math.Max(1, editingControlBounds.Width);
+ editingControlBounds.Height = Math.Max(1, r.Height);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ #region GetPreferredSize
+
+ ///
+ /// GetPreferredSize
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Size GetPreferredSize(Graphics graphics,
+ DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ {
+ if (DataGridView == null)
+ return (new Size(-1, -1));
+
+ Size preferredSize = base.GetPreferredSize(graphics, cellStyle, rowIndex, constraintSize);
+
+ DataGridViewComboBoxExColumn oc = OwningColumn as DataGridViewComboBoxExColumn;
+
+ if (oc != null)
+ {
+ ComboBoxEx cb = oc.ComboBoxEx;
+
+ preferredSize.Height = cb.Height;
+
+ if (constraintSize.Width == 0)
+ {
+ Rectangle r = DataGridView.GetCellDisplayRectangle(ColumnIndex, rowIndex, true);
+ preferredSize.Width += cb.GetThumbRect(r).Width;
+ }
+ }
+
+ return (preferredSize);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region ParseFormattedValue
+
+ ///
+ /// ParseFormattedValue
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override object ParseFormattedValue(object formattedValue,
+ DataGridViewCellStyle cellStyle, TypeConverter formattedValueTypeConverter, TypeConverter valueTypeConverter)
+ {
+ DataGridViewComboBoxExColumn oc = (DataGridViewComboBoxExColumn)OwningColumn;
+ ComboBoxEx di = oc.ComboBoxEx;
+
+ if (di.DataSource != null)
+ return (GetDataSourceValue(oc, di, formattedValue));
+
+ return (base.ParseFormattedValue(formattedValue,
+ cellStyle, formattedValueTypeConverter, valueTypeConverter));
+ }
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
+ DataGridViewElementStates elementState, object value, object formattedValue,
+ string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle,
+ DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewComboBoxExColumn oc = (DataGridViewComboBoxExColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintCellBackground(g, cellStyle, rBk);
+ PaintCellContent(g, cellBounds, rowIndex, value, cellStyle, paintParts, bm);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintCellBackground
+
+ ///
+ /// Paints the cell background
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintCellContent
+
+ private BindingContext _BindingContext = new BindingContext();
+ ///
+ /// Paints the cell content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellContent(Graphics g, Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts, Bitmap bm)
+ {
+ DataGridViewComboBoxExColumn oc = (DataGridViewComboBoxExColumn)OwningColumn;
+ ComboBoxEx di = oc.ComboBoxEx;
+
+ Point ptCurrentCell = DataGridView.CurrentCellAddress;
+ bool cellCurrent = ptCurrentCell.X == ColumnIndex && ptCurrentCell.Y == rowIndex;
+ bool cellEdited = cellCurrent && DataGridView.EditingControl != null;
+
+ // If the cell is in editing mode, there is nothing else to paint
+
+ if (cellEdited == false && rowIndex < DataGridView.RowCount)
+ {
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ {
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ if (di.DataSource == null)
+ {
+ di.DisplayMember = "Text";
+ di.ValueMember = null;
+ }
+ else
+ {
+ value = GetDataSourceDisplayValue(oc, di, value);
+ di.BindingContext = _BindingContext;
+ }
+
+ di.Font = cellStyle.Font;
+ di.ForeColor = cellStyle.ForeColor;
+ di.BackColor = cellStyle.BackColor;
+
+ string s = (value == Convert.DBNull ||
+ string.IsNullOrEmpty(Convert.ToString(value))) ? null : Convert.ToString(value);
+
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+
+ if (oc.DisplayControlForCurrentCellOnly == false)
+ DrawControl(di, r, bm, g, oc, s);
+ else
+ DrawText(di, r, g, s);
+ }
+ }
+ }
+
+ #region DrawControl
+
+ ///
+ /// DrawControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void DrawControl(ComboBoxEx di, Rectangle r,
+ Bitmap bm, Graphics g, DataGridViewComboBoxExColumn oc, string s)
+ {
+ Rectangle t = di.GetThumbRect(new Rectangle(0, 0, r.Width, r.Height));
+
+ if (t.IsEmpty == false)
+ {
+ // Work around Windows XP and Windows DropDownList
+ // DrawToBitmap problems
+
+ if (MustRenderVisibleControl(di.DropDownStyle) == true)
+ {
+ di.Location = oc.DataGridView.Location;
+
+ if (di.Parent == null)
+ {
+ Form form = oc.DataGridView.FindForm();
+
+ if (form != null)
+ di.Parent = form;
+ }
+
+ di.SendToBack();
+ di.Visible = true;
+ }
+
+ using (Bitmap bm2 = new Bitmap(bm))
+ {
+ di.Bounds = r;
+ di.DrawToBitmap(bm2, r);
+
+ t.X += r.X;
+ t.Y += r.Y;
+
+ g.DrawImage(bm2, t, t, GraphicsUnit.Pixel);
+
+ if (t.Left < r.Right)
+ r.Width -= (r.Right - t.Left - 3);
+ }
+
+ di.Visible = false;
+ }
+
+ DrawText(di, r, g, s);
+ }
+
+ #endregion
+
+ #region DrawText
+
+ ///
+ /// DrawText
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void DrawText(ComboBoxEx di, Rectangle r, Graphics g, string s)
+ {
+ r.Inflate(-2, 0);
+
+ TextDrawing.DrawString(g, s, di.Font, di.ForeColor, r,
+ eTextFormat.VerticalCenter | eTextFormat.EndEllipsis | eTextFormat.NoPrefix);
+ }
+
+ #endregion
+
+ #region GetDataSource
+
+ #region GetDataSourceDisplayValue
+
+ private object GetDataSourceDisplayValue(
+ DataGridViewComboBoxExColumn oc, ComboBoxEx di, object key)
+ {
+ if (key != null &&
+ string.IsNullOrEmpty(di.ValueMember) == false &&
+ string.IsNullOrEmpty(di.DisplayMember) == false)
+ {
+ CurrencyManager cm = GetCurrencyManager(oc, di);
+
+ if (cm != null)
+ {
+ string t = key.ToString();
+
+ for (int i = 0; i < cm.List.Count; i++)
+ {
+ if (cm.List[i] is DataRowView)
+ {
+ DataRowView drView = (DataRowView) cm.List[i];
+
+ string s = drView[di.ValueMember].ToString();
+
+ if (t.Equals(s) == true)
+ return (drView[di.DisplayMember]);
+ }
+ else if (cm.List[i] is string)
+ {
+ if (t.Equals(cm.List[i]) == true)
+ return (key);
+ }
+ else
+ {
+ object o = cm.List[i];
+ object value = o.GetType().GetProperty(di.ValueMember).GetValue(o, null);
+
+ //if (value is string)
+ {
+ if (key.Equals(value) == true)
+ {
+ value = o.GetType().GetProperty(di.DisplayMember).GetValue(o, null);
+
+ return (value);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return ((key == Convert.DBNull) ? "" : key);
+ }
+
+ #endregion
+
+ #region GetDataSourceValueEx
+
+ private object GetDataSourceValueEx(
+ DataGridViewComboBoxExColumn oc, ComboBoxEx di, object key)
+ {
+ if (key != null &&
+ string.IsNullOrEmpty(di.ValueMember) == false &&
+ string.IsNullOrEmpty(di.DisplayMember) == false)
+ {
+ CurrencyManager cm = GetCurrencyManager(oc, di);
+
+ if (cm != null)
+ {
+ string t = key.ToString();
+
+ for (int i = 0; i < cm.List.Count; i++)
+ {
+ if (cm.List[i] is DataRowView)
+ {
+ DataRowView drView = (DataRowView)cm.List[i];
+
+ string s = drView[di.ValueMember].ToString();
+
+ if (t.Equals(s) == true)
+ return (drView);
+ }
+ else if (cm.List[i] is string)
+ {
+ if (t.Equals(cm.List[i]) == true)
+ return (key);
+ }
+ else
+ {
+ object o = cm.List[i];
+ object value = o.GetType().GetProperty(di.ValueMember).GetValue(o, null);
+
+ if (key.Equals(value) == true)
+ return (o);
+ }
+ }
+ }
+ }
+
+ return ((key == Convert.DBNull) ? null : key);
+ }
+
+ #endregion
+
+ #region GetDataSourceValue
+
+ private object GetDataSourceValue(
+ DataGridViewComboBoxExColumn oc, ComboBoxEx di, object key)
+ {
+ if (key != null &&
+ string.IsNullOrEmpty(di.ValueMember) == false &&
+ string.IsNullOrEmpty(di.DisplayMember) == false)
+ {
+ CurrencyManager cm = GetCurrencyManager(oc, di);
+
+ if (cm != null)
+ {
+ string t = key.ToString();
+
+ for (int i = 0; i < cm.List.Count; i++)
+ {
+ if (cm.List[i] is DataRowView)
+ {
+ DataRowView drView = (DataRowView) cm.List[i];
+
+ string s = drView[di.DisplayMember].ToString();
+
+ if (t.Equals(s) == true)
+ return (drView[di.ValueMember]);
+ }
+ else if (cm.List[i] is string)
+ {
+ if (t.Equals(cm.List[i]) == true)
+ return (key);
+ }
+ else
+ {
+ object o = cm.List[i];
+ object value = o.GetType().GetProperty(di.DisplayMember).GetValue(o, null);
+
+ if (value is string)
+ {
+ if (t.Equals(value) == true)
+ {
+ value = o.GetType().GetProperty(di.ValueMember).GetValue(o, null);
+
+ return (value);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return (key);
+ }
+
+ #endregion
+
+ #region GetCurrencyManager
+
+ private CurrencyManager GetCurrencyManager(
+ DataGridViewComboBoxExColumn oc, ComboBoxEx di)
+ {
+ if (oc.CurrencyManager == null)
+ {
+ if (DataGridView != null && DataGridView.BindingContext != null &&
+ di.DataSource != null && di.DataSource != Convert.DBNull)
+ {
+ oc.CurrencyManager = (CurrencyManager) DataGridView.BindingContext[di.DataSource];
+ }
+ }
+
+ return (oc.CurrencyManager);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region MustRenderVisibleControl
+
+ ///
+ /// MustRenderVisibleControl
+ ///
+ ///
+ ///
+ private bool MustRenderVisibleControl(ComboBoxStyle style)
+ {
+ if (style == ComboBoxStyle.DropDownList)
+ return (true);
+
+ OperatingSystem osInfo = Environment.OSVersion;
+
+ return (osInfo.Platform == PlatformID.Win32Windows ||
+ (osInfo.Platform == PlatformID.Win32NT && osInfo.Version.Major < 6));
+
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region Mouse support
+
+ #region OnMouseEnter
+
+ ///
+ /// OnMouseEnter
+ ///
+ ///
+ protected override void OnMouseEnter(int rowIndex)
+ {
+ DataGridViewComboBoxExColumn oc = (DataGridViewComboBoxExColumn) OwningColumn;
+ ComboBoxEx di = oc.ComboBoxEx;
+
+ if (DataGridView != null)
+ {
+ if ((uint)RowIndex < DataGridView.Rows.Count)
+ {
+ if (di.DataSource != null)
+ this.ToolTipText = Convert.ToString(GetDataSourceDisplayValue(oc, di, Value));
+ else
+ this.ToolTipText = Convert.ToString(Value);
+ }
+ }
+
+ base.OnMouseEnter(rowIndex);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewComboBoxExColumn oc = (DataGridViewComboBoxExColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetCellBounds
+
+ ///
+ /// Gets the button bounds for the given cell
+ ///
+ ///
+ ///
+ private Rectangle GetCellBounds(Rectangle cellBounds)
+ {
+ DataGridViewComboBoxExColumn oc = (DataGridViewComboBoxExColumn)OwningColumn;
+
+ Size size = oc.ComboBoxEx.Size;
+
+ cellBounds.Location = new Point(1, 1);
+
+ cellBounds.Width -= oc.DividerWidth;
+ cellBounds.Height = Math.Min(size.Height, cellBounds.Height);
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewComboBoxEx/DataGridViewComboBoxExColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewComboBoxEx/DataGridViewComboBoxExColumn.cs
new file mode 100644
index 00000000..5bdf2500
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewComboBoxEx/DataGridViewComboBoxExColumn.cs
@@ -0,0 +1,954 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Design;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewButtonXColumn), "Controls.ComboBoxEx.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewComboBoxExColumn : DataGridViewTextBoxColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ ///
+ /// Occurs right before a ComboBox Cell is painted
+ ///
+ [Description("Occurs right before a ComboBox Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ ///
+ /// Occurs when the ComboBox is clicked
+ ///
+ [Description("Occurs when the ComboBox is clicked.")]
+ public event EventHandler Click;
+
+ ///
+ /// Occurs when a visual aspect of an owner-drawn ComboBox changes
+ ///
+ [Description("Occurs when a visual aspect of an owner-drawn ComboBox changes.")]
+ public event EventHandler DrawItem;
+
+ ///
+ /// Occurs when drop down portion of the ComboBox is shown or hidden.
+ ///
+ [Description("Occurs when drop down portion of the ComboBox is shown or hidden.")]
+ public event EventHandler DropDownChange;
+
+ ///
+ /// Occurs each time an owner-drawn ComboBox item needs
+ /// to be drawn and when the sizes of the list items are determined
+ ///
+ [Description("Occurs each time an owner-drawn ComboBox item needs to be drawn and when the sizes of the list items are determined.")]
+ public event EventHandler MeasureItem;
+
+ #endregion
+
+ #region Private variables
+
+ private ComboBoxEx _ComboBoxEx;
+ private Bitmap _CellBitmap;
+ private CurrencyManager _CurrencyManager;
+ private bool _DisplayControlForCurrentCellOnly = true;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewComboBoxExColumn()
+ {
+ CellTemplate = new DataGridViewComboBoxExCell();
+
+ _ComboBoxEx = new ComboBoxEx();
+
+ _ComboBoxEx.RenderBorder = false;
+ _ComboBoxEx.Visible = false;
+
+ HookEvents(true);
+ }
+
+ #region Internal properties
+
+ #region ComboBoxEx
+
+ ///
+ /// Gets the underlying ComboBoxEx control
+ ///
+ internal ComboBoxEx ComboBoxEx
+ {
+ get { return (_ComboBoxEx); }
+ }
+
+ #endregion
+
+ #region CurrencyManager
+
+ ///
+ /// Gets or sets the ComboBox CurrencyManager
+ ///
+ internal CurrencyManager CurrencyManager
+ {
+ get { return (_CurrencyManager); }
+ set { _CurrencyManager = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region AutoCompleteCustomSource
+
+ ///
+ /// Gets or sets a custom System.Collections.Specialized.StringCollection
+ /// to use when the AutoCompleteSource property is set to CustomSource.
+ ///
+ [Browsable(true), DefaultValue(null)]
+ [Description("Gets or sets a custom Specialized.StringCollection to use when the AutoCompleteSource property is set to CustomSource.")]
+ public AutoCompleteStringCollection AutoCompleteCustomSource
+ {
+ get { return (_ComboBoxEx.AutoCompleteCustomSource); }
+ set { _ComboBoxEx.AutoCompleteCustomSource = value; }
+ }
+
+ #endregion
+
+ #region AutoCompleteMode
+
+ ///
+ /// Gets or sets an option that controls how automatic completion works for the ComboBox.
+ ///
+ [Browsable(true), DefaultValue(AutoCompleteMode.None)]
+ [Description("Indicates how automatic completion works for the ComboBox.")]
+ public AutoCompleteMode AutoCompleteMode
+ {
+ get { return (_ComboBoxEx.AutoCompleteMode); }
+ set { _ComboBoxEx.AutoCompleteMode = value; }
+ }
+
+ #endregion
+
+ #region AutoCompleteSource
+
+ ///
+ /// Gets or sets a value specifying the source of complete strings used for automatic completion.
+ ///
+ [Browsable(true), DefaultValue(AutoCompleteSource.None)]
+ [Description("Indicates the source of complete strings used for automatic completion.")]
+ public AutoCompleteSource AutoCompleteSource
+ {
+ get { return (_ComboBoxEx.AutoCompleteSource); }
+ set { _ComboBoxEx.AutoCompleteSource = value; }
+ }
+
+ #endregion
+
+ #region DataSource
+
+ ///
+ /// Gets or sets the data source that populates the selections for the combo box
+ ///
+ [Browsable(true), Category("Data"), DefaultValue((string)null)]
+ [AttributeProvider(typeof(IListSource))]
+ [Description("Indicates the data source that populates the selections for the combo box.")]
+ public object DataSource
+ {
+ get { return (_ComboBoxEx.DataSource); }
+
+ set
+ {
+ _ComboBoxEx.DataSource = value;
+
+ CurrencyManager = null;
+ }
+ }
+
+ #endregion
+
+ #region DisplayMember
+
+ ///
+ /// Gets or sets a string that specifies the property or column
+ /// from which to retrieve strings for display in the combo box.
+ ///
+ [Browsable(true), DefaultValue(""), Category("Data")]
+ [Description("Indicates a string that specifies the property or column from which to retrieve strings for display in the combo box")]
+ [Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
+ [TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+ public string DisplayMember
+ {
+ get { return (_ComboBoxEx.DisplayMember); }
+ set { _ComboBoxEx.DisplayMember = value; }
+ }
+
+ #endregion
+
+ #region DisplayControlForCurrentCellOnly
+
+ ///
+ /// Gets or sets whether the control
+ /// will be displayed for the current cell only.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether the control will be displayed for the current cell only.")]
+ public bool DisplayControlForCurrentCellOnly
+ {
+ get { return (_DisplayControlForCurrentCellOnly); }
+
+ set
+ {
+ if (_DisplayControlForCurrentCellOnly != value)
+ {
+ _DisplayControlForCurrentCellOnly = value;
+ _ComboBoxEx.Invalidate();
+ }
+ }
+ }
+
+ #endregion
+
+ #region DrawMode
+
+ ///
+ /// Gets or sets a value indicating whether user code or
+ /// operating system code will handle drawing of elements in the list.
+ ///
+ [Browsable(true), DefaultValue(DrawMode.Normal)]
+ [Description("Indicates whether user code or operating system code will handle drawing of elements in the list.")]
+ public DrawMode DrawMode
+ {
+ get { return (_ComboBoxEx.DrawMode); }
+ set { _ComboBoxEx.DrawMode = value; }
+ }
+
+ #endregion
+
+ #region DropDownStyle
+
+ ///
+ /// Gets or sets a value specifying the style of the combo box.
+ ///
+ [Browsable(true), DefaultValue(ComboBoxStyle.DropDown)]
+ [Description("Indicates the style of the combo box.")]
+ public ComboBoxStyle DropDownStyle
+ {
+ get { return (_ComboBoxEx.DropDownStyle); }
+ set { _ComboBoxEx.DropDownStyle = value; }
+ }
+
+ #endregion
+
+ #region DropDownHeight
+
+ ///
+ /// Gets or sets the height in pixels of the drop-down portion of the ComboBox.
+ ///
+ [Browsable(true), DefaultValue(100)]
+ [Description("Indicates the height in pixels of the drop-down portion of the ComboBox.")]
+ public int DropDownHeight
+ {
+ get { return (_ComboBoxEx.DropDownHeight); }
+ set { _ComboBoxEx.DropDownHeight = value; }
+ }
+
+ #endregion
+
+ #region DropDownWidth
+
+ ///
+ /// Gets or sets the width of the drop-down lists of the combo box.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(1)]
+ [Description("Indicates the width of the drop-down lists of the combo box")]
+ public int DropDownWidth
+ {
+ get { return (_ComboBoxEx.DropDownWidth); }
+ set { _ComboBoxEx.DropDownWidth = value; }
+ }
+
+ #endregion
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_ComboBoxEx.Enabled); }
+ set { _ComboBoxEx.Enabled = value; }
+ }
+
+ #endregion
+
+ #region FlatStyle
+
+ ///
+ /// Gets or sets the flat style appearance of the column's cells.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(FlatStyle.Standard)]
+ [Description("Indicates the flat style appearance of the column's cells")]
+ public FlatStyle FlatStyle
+ {
+ get { return (_ComboBoxEx.FlatStyle); }
+ set { _ComboBoxEx.FlatStyle = value; }
+ }
+
+ #endregion
+
+ #region FocusCuesEnabled
+
+ ///
+ /// Gets or sets whether control displays focus cues when focused.
+ ///
+ [DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether control displays focus cues when focused.")]
+ public bool FocusCuesEnabled
+ {
+ get { return (_ComboBoxEx.FocusCuesEnabled); }
+ set { _ComboBoxEx.FocusCuesEnabled = value; }
+ }
+
+ #endregion
+
+ #region FormatString
+
+ ///
+ /// Gets or sets the format-specifier
+ /// characters that indicate how a value is to be displayed.
+ ///
+ [Browsable(true), DefaultValue("")]
+ [Description("Indicates the format-specifier characters that indicate how a value is to be displayed.")]
+ public string FormatString
+ {
+ get { return (_ComboBoxEx.FormatString); }
+ set { _ComboBoxEx.FormatString = value; }
+ }
+
+ #endregion
+
+ #region FormattingEnabled
+
+ ///
+ /// Gets or sets a value indicating whether formatting is applied to the DisplayMember property.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether formatting is applied to the DisplayMember.")]
+ public bool FormattingEnabled
+ {
+ get { return (_ComboBoxEx.FormattingEnabled); }
+ set { _ComboBoxEx.FormattingEnabled = value; }
+ }
+
+ #endregion
+
+ #region Images
+
+ ///
+ /// Gets or sets the ImageList control used by Combo box to draw images.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(null)]
+ [Description("The ImageList control used by Combo box to draw images.")]
+ public ImageList Images
+ {
+ get { return (_ComboBoxEx.Images); }
+ set { _ComboBoxEx.Images = value; }
+ }
+
+ #endregion
+
+ #region ImeMode
+
+ ///
+ /// Gets or sets the Input Method Editor (IME) mode of the control.
+ ///
+ [Browsable(true), DefaultValue(ImeMode.Inherit)]
+ [Description("Indicates the Input Method Editor (IME) mode of the control.")]
+ public ImeMode ImeMode
+ {
+ get { return (_ComboBoxEx.ImeMode); }
+ set { _ComboBoxEx.ImeMode = value; }
+ }
+
+ #endregion
+
+ #region IntegralHeight
+
+ ///
+ /// Gets or sets a value indicating whether
+ /// the control should resize to avoid showing partial items.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether the control should resize to avoid showing partial items.")]
+ public bool IntegralHeight
+ {
+ get { return (_ComboBoxEx.IntegralHeight); }
+ set { _ComboBoxEx.IntegralHeight = value; }
+ }
+
+ #endregion
+
+ #region IsStandalone
+
+ ///
+ /// Gets or sets whether control is stand-alone control.
+ /// Stand-alone flag affects the appearance of the control in Office 2007 style.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates the appearance of the control.")]
+ public bool IsStandalone
+ {
+ get { return (_ComboBoxEx.IsStandalone); }
+ set { _ComboBoxEx.IsStandalone = value; }
+ }
+
+ #endregion
+
+ #region ItemHeight
+
+ ///
+ /// Gets or sets the height of an item in the combo box.
+ ///
+ [Browsable(true), DefaultValue(12)]
+ [Description("Indicates the height of an item in the combo box.")]
+ public int ItemHeight
+ {
+ get { return (_ComboBoxEx.ItemHeight); }
+ set { _ComboBoxEx.ItemHeight = value; }
+ }
+
+ #endregion
+
+ #region Items
+
+ ///
+ /// Gets the collection of objects used as selections in the combo box.
+ ///
+ [Browsable(true), Category("Data")]
+ [Description("Indicates the collection of objects used as selections in the combo box")]
+ [Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ComboBox.ObjectCollection Items
+ {
+ get { return (_ComboBoxEx.Items); }
+ }
+
+ #endregion
+
+ #region MaxDropDownItems
+
+ ///
+ /// Gets or sets the maximum number of items
+ /// in the drop-down list of the cells in the column.
+ ///
+ [Browsable(true), DefaultValue(8), Category("Behavior")]
+ [Description("Indicates the maximum number of items in the drop-down list of the cells in the column.")]
+ public int MaxDropDownItems
+ {
+ get { return (_ComboBoxEx.MaxDropDownItems); }
+ set { _ComboBoxEx.MaxDropDownItems = value; }
+ }
+
+ #endregion
+
+ #region MaxLength
+
+ ///
+ /// Gets or sets the number of characters a user can type into the ComboBox.
+ ///
+ [Browsable(true), DefaultValue(0)]
+ [Description("Indicates the number of characters a user can type into the ComboBox.")]
+ public int MaxLength
+ {
+ get { return (_ComboBoxEx.MaxLength); }
+ set { _ComboBoxEx.MaxLength = value; }
+ }
+
+ #endregion
+
+ #region RightToLeft
+
+ ///
+ /// Gets or sets a value indicating whether control's
+ /// elements are aligned to support locales using right-to-left fonts.
+ ///
+ [Browsable(true), DefaultValue(RightToLeft.Inherit)]
+ [Description("Indicates control's elements are aligned to support locales using right-to-left fonts.")]
+ public RightToLeft RightToLeft
+ {
+ get { return (_ComboBoxEx.RightToLeft); }
+ set { _ComboBoxEx.RightToLeft = value; }
+ }
+
+ #endregion
+
+ #region Sorted
+
+ ///
+ /// Gets or sets whether the items in the combo box are sorted.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Behavior")]
+ [Description("Indicates whether the items in the combo box are sorted.")]
+ public bool Sorted
+ {
+ get { return (_ComboBoxEx.Sorted); }
+ set { _ComboBoxEx.Sorted = value; }
+ }
+
+ #endregion
+
+ #region Style
+
+ ///
+ /// Determines the visual style applied to
+ /// the combo box when shown. Default style is Office 2007.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(eDotNetBarStyle.Office2007)]
+ [Description("Determines the display of the item when shown.")]
+ public eDotNetBarStyle Style
+ {
+ get { return (_ComboBoxEx.Style); }
+ set { _ComboBoxEx.Style = value; }
+ }
+
+ #endregion
+
+ #region Text
+
+ ///
+ /// Gets or sets the text associated with this control.
+ ///
+ [Browsable(true), DefaultValue("")]
+ [Description("Indicates the text associated with this control.")]
+ public string Text
+ {
+ get { return (_ComboBoxEx.Text); }
+ set { _ComboBoxEx.Text = value; }
+ }
+
+ #endregion
+
+ #region ValueMember
+
+ ///
+ /// Gets or sets a string that specifies the property or column
+ /// from which to get values that correspond to the selections in the drop-down list.
+ ///
+ [Browsable(true), Category("Data"), DefaultValue("")]
+ [Description("Indicates a string that specifies the property or column from which to get values that correspond to the selections in the drop-down list.")]
+ [Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
+ [TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+ public string ValueMember
+ {
+ get { return (_ComboBoxEx.ValueMember); }
+ set { _ComboBoxEx.ValueMember = value; }
+ }
+
+ #endregion
+
+ #region WatermarkBehavior
+
+ ///
+ /// Gets or sets the watermark hiding behaviour. Default value
+ /// indicates that watermark is hidden when control receives input focus.
+ ///
+ [DefaultValue(eWatermarkBehavior.HideOnFocus), Category("Behavior")]
+ [Description("Indicates watermark hiding behaviour.")]
+ public eWatermarkBehavior WatermarkBehavior
+ {
+ get { return (_ComboBoxEx.WatermarkBehavior); }
+ set { _ComboBoxEx.WatermarkBehavior = value; }
+ }
+
+ #endregion
+
+ #region WatermarkColor
+
+ ///
+ /// Gets or sets the watermark text color.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates watermark text color.")]
+ public Color WatermarkColor
+ {
+ get { return (_ComboBoxEx.WatermarkColor); }
+ set { _ComboBoxEx.WatermarkColor = value; }
+ }
+ ///
+ /// Indicates whether property should be serialized by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeWatermarkColor()
+ {
+ return (_ComboBoxEx.ShouldSerializeWatermarkColor());
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetWatermarkColor()
+ {
+ _ComboBoxEx.ResetWatermarkColor();
+ }
+
+ #endregion
+
+ #region WatermarkEnabled
+
+ ///
+ /// Gets or sets whether watermark text is
+ /// displayed when control is empty. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether watermark text is displayed when control is empty.")]
+ public virtual bool WatermarkEnabled
+ {
+ get { return (_ComboBoxEx.WatermarkEnabled); }
+ set { _ComboBoxEx.WatermarkEnabled = value; }
+ }
+
+ #endregion
+
+ #region WatermarkFont
+
+ ///
+ /// Gets or sets the watermark font.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(null)]
+ [Description("Indicates watermark font.")]
+ public Font WatermarkFont
+ {
+ get { return (_ComboBoxEx.WatermarkFont); }
+ set { _ComboBoxEx.WatermarkFont = value; }
+ }
+
+ #endregion
+
+ #region WatermarkText
+
+ ///
+ /// Gets or sets the watermark (tip) text displayed inside of the control when Text
+ /// is not set and control does not have input focus. This property supports text-markup.
+ /// Note that WatermarkText is not compatible with the auto-complete feature of .NET Framework 2.0.
+ ///
+ [Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance")]
+ [Description("Indicates watermark text displayed inside of the control when Text is not set and control does not have input focus.")]
+ [Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(UITypeEditor))]
+ public string WatermarkText
+ {
+ get { return (_ComboBoxEx.WatermarkText); }
+ set { _ComboBoxEx.WatermarkText = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region HookEvents
+
+ ///
+ /// HookEvents
+ ///
+ ///
+ private void HookEvents(bool hook)
+ {
+ if (hook == true)
+ _ComboBoxEx.DataSourceChanged += ComboBoxEx_DataSourceChanged;
+ else
+ _ComboBoxEx.DataSourceChanged -= ComboBoxEx_DataSourceChanged;
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region ComboBoxEx_DataSourceChanged
+
+ ///
+ /// ComboBoxEx_DataSourceChanged
+ ///
+ ///
+ ///
+ void ComboBoxEx_DataSourceChanged(object sender, EventArgs e)
+ {
+ _CurrencyManager = null;
+
+ _ComboBoxEx.Items.Clear();
+ _ComboBoxEx.DisplayMember = null;
+ _ComboBoxEx.ValueMember = null;
+ }
+
+ #endregion
+
+ #region DoComboBoxEx_Click
+
+ ///
+ /// DoComboBoxEx_Click
+ ///
+ ///
+ ///
+ internal void DoComboBoxEx_Click(object sender, EventArgs e)
+ {
+ if (Click != null)
+ Click(sender, e);
+ }
+
+ #endregion
+
+ #region DoComboBoxEx_DrawItem
+
+ ///
+ /// DoComboBoxEx_DrawItem
+ ///
+ ///
+ ///
+ internal void DoComboBoxEx_DrawItem(object sender, DrawItemEventArgs e)
+ {
+ if (DrawItem != null)
+ DrawItem(sender, e);
+ }
+
+ #endregion
+
+ #region DoComboBoxEx_DropDownChange
+
+ ///
+ /// DoComboBoxEx_DropDownChange
+ ///
+ ///
+ ///
+ internal void DoComboBoxEx_DropDownChange(object sender, DropDownChangeEventArgs e)
+ {
+ if (DropDownChange != null)
+ DropDownChange(sender, e);
+ }
+
+ #endregion
+
+ #region DoComboBoxEx_MeasureItem
+
+ ///
+ /// DoComboBoxEx_MeasureItem
+ ///
+ ///
+ ///
+ internal void DoComboBoxEx_MeasureItem(object sender, MeasureItemEventArgs e)
+ {
+ if (MeasureItem != null)
+ MeasureItem(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ToString
+
+ public override string ToString()
+ {
+ StringBuilder builder = new StringBuilder();
+
+ builder.Append("DataGridViewComboBoxExColumn { Name=");
+ builder.Append(Name);
+ builder.Append(", Index=");
+ builder.Append(Index.ToString(CultureInfo.CurrentCulture));
+ builder.Append(" }");
+
+ return (builder.ToString());
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewComboBoxExColumn cb = base.Clone() as DataGridViewComboBoxExColumn;
+
+ if (cb != null)
+ {
+ cb.AutoCompleteCustomSource = AutoCompleteCustomSource;
+ cb.AutoCompleteMode = AutoCompleteMode;
+ cb.AutoCompleteSource = AutoCompleteSource;
+ cb.DrawMode = DrawMode;
+ cb.DropDownHeight = DropDownHeight;
+ cb.DropDownStyle = DropDownStyle;
+ cb.Enabled = Enabled;
+ cb.FlatStyle = FlatStyle;
+ cb.FocusCuesEnabled = FocusCuesEnabled;
+ cb.FormatString = FormatString;
+ cb.FormattingEnabled = FormattingEnabled;
+ cb.Images = Images;
+ cb.ImeMode = ImeMode;
+ cb.IntegralHeight = IntegralHeight;
+ cb.IsStandalone = IsStandalone;
+ cb.ItemHeight = ItemHeight;
+ cb.MaxDropDownItems = MaxDropDownItems;
+ cb.MaxLength = MaxLength;
+ cb.RightToLeft = RightToLeft;
+ cb.Style = Style;
+ cb.Text = Text;
+ cb.WatermarkBehavior = WatermarkBehavior;
+ cb.WatermarkColor = WatermarkColor;
+ cb.WatermarkEnabled = WatermarkEnabled;
+ cb.WatermarkFont = WatermarkFont;
+ cb.WatermarkText = WatermarkText;
+
+ cb.DataSource = DataSource;
+ cb.DisplayMember = DisplayMember;
+ cb.ValueMember = ValueMember;
+
+ if (cb.DataSource == null)
+ {
+ for (int i = 0; i < Items.Count; i++)
+ cb.Items.Add(Items[i]);
+ }
+
+ cb.DisplayControlForCurrentCellOnly = DisplayControlForCurrentCellOnly;
+ }
+
+ return (cb);
+ }
+
+ #endregion
+
+ #region Dispose
+
+ ///
+ /// Dispose
+ ///
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ HookEvents(false);
+
+ if (disposing == true)
+ _ComboBoxEx.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+ }
+
+ #region DropDownChangeEventArgs
+
+ ///
+ /// DropDownChangeEventArgs
+ ///
+ public class DropDownChangeEventArgs : EventArgs
+ {
+ #region Private variables
+
+ private int _RowIndex;
+ private int _ColumnIndex;
+ private bool _Expanded;
+
+ #endregion
+
+ public DropDownChangeEventArgs(int rowIndex, int columnIndex, bool expanded)
+ {
+ _RowIndex = rowIndex;
+ _ColumnIndex = columnIndex;
+ _Expanded = expanded;
+ }
+
+ #region Public properties
+
+ ///
+ /// ColumnIndex
+ ///
+ public int ColumnIndex
+ {
+ get { return (_ColumnIndex); }
+ }
+
+ ///
+ /// Expanded state
+ ///
+ public bool Expanded
+ {
+ get { return (_Expanded); }
+ }
+
+ ///
+ /// RowIndex
+ ///
+ public int RowIndex
+ {
+ get { return (_RowIndex); }
+ }
+
+ #endregion
+ }
+
+ #endregion
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewComboBoxEx/DataGridViewComboBoxExEditingControl.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewComboBoxEx/DataGridViewComboBoxExEditingControl.cs
new file mode 100644
index 00000000..3374a6dc
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewComboBoxEx/DataGridViewComboBoxExEditingControl.cs
@@ -0,0 +1,240 @@
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewComboBoxExEditingControl : ComboBoxEx, IDataGridViewEditingControl
+ {
+ #region Private variables
+
+ private DataGridView _DataGridView;
+
+ private int _RowIndex;
+ private bool _ValueChanged;
+
+ #endregion
+
+ public DataGridViewComboBoxExEditingControl()
+ {
+ TabStop = false;
+ }
+
+ #region OnTextChanged
+
+ ///
+ /// Handles OnTextChanged events
+ ///
+ ///
+ protected override void OnTextChanged(EventArgs e)
+ {
+ NotifyDataGridViewOfValueChange();
+
+ base.OnTextChanged(e);
+ }
+
+ #endregion
+
+ #region OnSelectedIndexChanged
+
+ ///
+ /// OnSelectedIndexChanged
+ ///
+ ///
+ protected override void OnSelectedIndexChanged(EventArgs e)
+ {
+ base.OnSelectedIndexChanged(e);
+
+ if (SelectedIndex != -1)
+ NotifyDataGridViewOfValueChange();
+ }
+
+ ///
+ /// NotifyDataGridViewOfValueChange
+ ///
+ private void NotifyDataGridViewOfValueChange()
+ {
+ if (_DataGridView.EditingControl == this)
+ {
+ _ValueChanged = true;
+ _DataGridView.NotifyCurrentCellDirty(true);
+ }
+ }
+
+ #endregion
+
+ #region IDataGridViewEditingControl Members
+
+ #region Public properties
+
+ #region EditingControlDataGridView
+
+ ///
+ /// Gets or sets the DataGridView
+ ///
+ public DataGridView EditingControlDataGridView
+ {
+ get { return (_DataGridView); }
+ set { _DataGridView = value; }
+ }
+
+ #endregion
+
+ #region EditingControlFormattedValue
+
+ ///
+ /// Gets or sets the Control Formatted Value
+ ///
+ public object EditingControlFormattedValue
+ {
+ get { return (GetEditingControlFormattedValue(DataGridViewDataErrorContexts.Formatting)); }
+
+ set
+ {
+ string s = value as string;
+
+ if (s != null)
+ {
+ Text = s;
+
+ if (string.Compare(s, this.Text, true, CultureInfo.CurrentCulture) != 0)
+ SelectedIndex = -1;
+ }
+ }
+ }
+
+ #endregion
+
+ #region EditingControlRowIndex
+
+ ///
+ /// Gets or sets the Control RoeIndex
+ ///
+ public int EditingControlRowIndex
+ {
+ get { return (_RowIndex); }
+ set { _RowIndex = value; }
+ }
+
+ #endregion
+
+ #region EditingControlValueChanged
+
+ ///
+ /// Gets or sets the Control ValueChanged state
+ ///
+ public bool EditingControlValueChanged
+ {
+ get { return (_ValueChanged); }
+ set { _ValueChanged = value; }
+ }
+
+ #endregion
+
+ #region EditingPanelCursor
+
+ ///
+ /// Gets the Panel Cursor
+ ///
+ public Cursor EditingPanelCursor
+ {
+ get { return (Cursors.Default); }
+ }
+
+ #endregion
+
+ #region RepositionEditingControlOnValueChange
+
+ ///
+ /// Gets whether to RepositionEditingControlOnValueChange
+ ///
+ public bool RepositionEditingControlOnValueChange
+ {
+ get { return (false); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region ApplyCellStyleToEditingControl
+
+ ///
+ /// ApplyCellStyleToEditingControl
+ ///
+ ///
+ public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ Font = dataGridViewCellStyle.Font;
+
+ ForeColor = dataGridViewCellStyle.ForeColor;
+ BackColor = dataGridViewCellStyle.BackColor;
+ }
+
+ #endregion
+
+ #region GetEditingControlFormattedValue
+
+ ///
+ /// Gets EditingControlFormattedValue
+ ///
+ ///
+ ///
+ public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
+ {
+ return (Text);
+ }
+
+ #endregion
+
+ #region EditingControlWantsInputKey
+
+ ///
+ /// Gets whether the given key wants to be processed
+ /// by the Control
+ ///
+ ///
+ ///
+ ///
+ public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
+ {
+ if (DroppedDown == false)
+ {
+ if ((keyData & Keys.Right) == Keys.Right)
+ return (true);
+
+ if ((keyData & Keys.Left) == Keys.Left)
+ return (true);
+ }
+
+ if (((((keyData & Keys.KeyCode) != Keys.Down) && ((keyData & Keys.KeyCode) != Keys.Up)) &&
+ (!DroppedDown || ((keyData & Keys.KeyCode) != Keys.Escape))) && ((keyData & Keys.KeyCode) != Keys.Return))
+ {
+ return (dataGridViewWantsInputKey == false);
+ }
+
+ return (true);
+ }
+
+ #endregion
+
+ #region PrepareEditingControlForEdit
+
+ ///
+ /// PrepareEditingControlForEdit
+ ///
+ ///
+ public void PrepareEditingControlForEdit(bool selectAll)
+ {
+ if (selectAll)
+ SelectAll();
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDateTimeInput/DataGridViewDateTimeInputCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDateTimeInput/DataGridViewDateTimeInputCell.cs
new file mode 100644
index 00000000..ab0528b3
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDateTimeInput/DataGridViewDateTimeInputCell.cs
@@ -0,0 +1,746 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Media;
+using System.Windows.Forms;
+using DevComponents.Editors;
+using DevComponents.Editors.DateTimeAdv;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewDateTimeInputCell : DataGridViewTextBoxCell
+ {
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (typeof(DataGridViewDateTimeInputEditingControl)); }
+ }
+
+ #endregion
+
+ #region FormattedValueType
+
+ ///
+ /// FormattedValueType
+ ///
+ public override Type FormattedValueType
+ {
+ get { return (typeof(string)); }
+ }
+
+ #endregion
+
+ #region ValueType
+
+ public override Type ValueType
+ {
+ get { return (typeof(DateTime)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region InitializeEditingControl
+
+ ///
+ /// InitializeEditingControl
+ ///
+ ///
+ ///
+ ///
+ public override void InitializeEditingControl(int rowIndex,
+ object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ DetachEditingControl();
+
+ base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
+
+ DataGridViewDateTimeInputEditingControl ctl =
+ (DataGridViewDateTimeInputEditingControl)DataGridView.EditingControl;
+
+ DataGridViewDateTimeInputColumn oc = OwningColumn as DataGridViewDateTimeInputColumn;
+
+ if (oc != null)
+ {
+ DateTimeInput di = oc.DateTimeInput;
+
+ ctl.AllowEmptyState = di.AllowEmptyState;
+ ctl.AutoAdvance = di.AutoAdvance;
+ ctl.AutoOverwrite = di.AutoOverwrite;
+ ctl.AutoSelectDate = di.AutoSelectDate;
+ ctl.CustomFormat = di.CustomFormat;
+ ctl.DefaultInputValues = di.DefaultInputValues;
+ ctl.Enabled = di.Enabled;
+ ctl.Format = di.Format;
+ ctl.InputHorizontalAlignment = GetHorizontalAlignment(dataGridViewCellStyle.Alignment);
+ ctl.IsInputReadOnly = di.IsInputReadOnly;
+ ctl.LockUpdateChecked = di.LockUpdateChecked;
+ ctl.MinDate = di.MinDate;
+ ctl.MaxDate = di.MaxDate;
+ ctl.SelectNextInputCharacters = di.SelectNextInputCharacters;
+ ctl.ShowCheckBox = di.ShowCheckBox;
+ ctl.ShowUpDown = di.ShowUpDown;
+
+ ctl.BackgroundStyle.ApplyStyle(di.BackgroundStyle);
+ ctl.BackgroundStyle.Class = di.BackgroundStyle.Class;
+
+ di.ButtonClear.CopyToItem(ctl.ButtonClear);
+ di.ButtonDropDown.CopyToItem(ctl.ButtonDropDown);
+ di.ButtonFreeText.CopyToItem(ctl.ButtonFreeText);
+ di.ButtonCustom.CopyToItem(ctl.ButtonCustom);
+ di.ButtonCustom2.CopyToItem(ctl.ButtonCustom2);
+ di.MonthCalendar.InternalCopyToItem(ctl.MonthCalendar);
+
+ ctl.ButtonClearClick += ButtonClearClick;
+ ctl.ButtonCustomClick += ButtonCustomClick;
+ ctl.ButtonCustom2Click += ButtonCustom2Click;
+ ctl.ButtonDropDownClick += ButtonDropDownClick;
+ ctl.ButtonFreeTextClick += ButtonFreeTextClick;
+ ctl.ConvertFreeTextEntry += ConvertFreeTextEntry;
+
+ //ctl.Value = GetValue(initialFormattedValue);
+ ctl.ValueObject = Value;
+
+ ctl.EditCancelled = false;
+ }
+ }
+
+ #endregion
+
+ #region DetachEditingControl
+
+ ///
+ /// DetachEditingControl
+ ///
+ public override void DetachEditingControl()
+ {
+ if (DataGridView != null && DataGridView.EditingControl != null)
+ {
+ DataGridViewDateTimeInputEditingControl di =
+ DataGridView.EditingControl as DataGridViewDateTimeInputEditingControl;
+
+ if (di != null)
+ {
+ di.ButtonClearClick -= ButtonClearClick;
+ di.ButtonCustomClick -= ButtonCustomClick;
+ di.ButtonCustom2Click -= ButtonCustom2Click;
+ di.ButtonDropDownClick -= ButtonDropDownClick;
+ di.ButtonFreeTextClick -= ButtonFreeTextClick;
+ di.ConvertFreeTextEntry -= ConvertFreeTextEntry;
+
+ if (di.EditCancelled == true)
+ {
+ di.EditCancelled = false;
+
+ SystemSounds.Beep.Play();
+ }
+ }
+ }
+
+ base.DetachEditingControl();
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region ButtonClearClick
+
+ ///
+ /// ButtonClearClick
+ ///
+ ///
+ ///
+ void ButtonClearClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewDateTimeInputColumn)OwningColumn).DoButtonClearClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustomClick
+
+ ///
+ /// ButtonCustomClick
+ ///
+ ///
+ ///
+ void ButtonCustomClick(object sender, EventArgs e)
+ {
+ ((DataGridViewDateTimeInputColumn)OwningColumn).DoButtonCustomClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustom2Click
+
+ ///
+ /// ButtonCustom2Click
+ ///
+ ///
+ ///
+ void ButtonCustom2Click(object sender, EventArgs e)
+ {
+ ((DataGridViewDateTimeInputColumn)OwningColumn).DoButtonCustom2Click(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonDropDownClick
+
+ ///
+ /// ButtonDropDownClick
+ ///
+ ///
+ ///
+ void ButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewDateTimeInputColumn)OwningColumn).DoButtonDropDownClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonFreeTextClick
+
+ ///
+ /// ButtonFreeTextClick
+ ///
+ ///
+ ///
+ void ButtonFreeTextClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewDateTimeInputColumn)OwningColumn).DoButtonFreeTextClick(sender, e);
+ }
+
+ #endregion
+
+ #region ConvertFreeTextEntry
+
+ ///
+ /// ConvertFreeTextEntry
+ ///
+ ///
+ ///
+ void ConvertFreeTextEntry(object sender, FreeTextEntryConversionEventArgs e)
+ {
+ ((DataGridViewDateTimeInputColumn)OwningColumn).DoConvertFreeTextEntry(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PositionEditingControl
+
+ ///
+ /// PositionEditingControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override void PositionEditingControl(bool setLocation, bool setSize, Rectangle cellBounds,
+ Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded,
+ bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
+ {
+ Rectangle editingControlBounds =
+ PositionEditingPanel(cellBounds, cellClip, cellStyle, singleVerticalBorderAdded,
+ singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow);
+
+ editingControlBounds = GetAdjustedEditingControlBounds(editingControlBounds, cellStyle);
+
+ DataGridView.EditingControl.Location = new Point(editingControlBounds.X, editingControlBounds.Y);
+ DataGridView.EditingControl.Size = new Size(editingControlBounds.Width, editingControlBounds.Height);
+ }
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetCellBounds(editingControlBounds);
+
+ if (cellStyle != null && r.Height < editingControlBounds.Height)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.MiddleLeft:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height) / 2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ editingControlBounds.Width = Math.Max(1, editingControlBounds.Width);
+ editingControlBounds.Height = Math.Max(1, r.Height);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ #region GetPreferredSize
+
+ ///
+ /// GetPreferredSize
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Size GetPreferredSize(Graphics graphics,
+ DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ {
+ if (DataGridView == null)
+ return (new Size(-1, -1));
+
+ Size preferredSize = base.GetPreferredSize(graphics, cellStyle, rowIndex, constraintSize);
+
+ DataGridViewDateTimeInputColumn oc = OwningColumn as DataGridViewDateTimeInputColumn;
+
+ if (oc != null)
+ {
+ DateTimeInput dt = oc.DateTimeInput;
+
+ preferredSize.Width += 6;
+ preferredSize.Height = dt.Height;
+
+ if (constraintSize.Width == 0)
+ {
+ preferredSize.Width += GetImageWidth(dt.ButtonClear);
+ preferredSize.Width += GetImageWidth(dt.ButtonCustom);
+ preferredSize.Width += GetImageWidth(dt.ButtonCustom2);
+ preferredSize.Width += GetImageWidth(dt.ButtonDropDown);
+ preferredSize.Width += GetImageWidth(dt.ButtonFreeText);
+
+ if (dt.ShowUpDown == true)
+ preferredSize.Width += 16;
+
+ if (dt.ShowCheckBox == true)
+ preferredSize.Width += 16;
+ }
+ }
+
+ return (preferredSize);
+ }
+
+ #endregion
+
+ #region GetFormattedValue
+
+ protected override object GetFormattedValue(object value, int rowIndex,
+ ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter,
+ TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
+ {
+ DataGridViewDateTimeInputColumn oc = OwningColumn as DataGridViewDateTimeInputColumn;
+
+ if (oc != null)
+ {
+ DateTimeInput dt = oc.DateTimeInput;
+ dt.Value = GetValue(value);
+
+ return (dt.Text);
+ }
+
+ return (base.GetFormattedValue(value, rowIndex,
+ ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
+ }
+
+ #endregion
+
+ #region GetImageWidth
+
+ private int GetImageWidth(InputButtonSettings ibs)
+ {
+ if (ibs.Visible == true)
+ return (ibs.Image != null ? ibs.Image.Width : 16);
+
+ return (0);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
+ DataGridViewElementStates elementState, object value, object formattedValue,
+ string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle,
+ DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewDateTimeInputColumn oc = (DataGridViewDateTimeInputColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintCellBackground(g, cellStyle, rBk);
+ PaintCellContent(g, cellBounds, rowIndex, formattedValue, cellStyle, paintParts);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintCellBackground
+
+ ///
+ /// Paints the cell background
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintCellContent
+
+ ///
+ /// Paints the cell content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellContent(Graphics g, Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts)
+ {
+ DataGridViewDateTimeInputColumn oc = (DataGridViewDateTimeInputColumn)OwningColumn;
+ DateTimeInput di = oc.DateTimeInput;
+
+ Point ptCurrentCell = DataGridView.CurrentCellAddress;
+ bool cellCurrent = ptCurrentCell.X == ColumnIndex && ptCurrentCell.Y == rowIndex;
+ bool cellEdited = cellCurrent && DataGridView.EditingControl != null;
+
+ // If the cell is in editing mode, there is nothing else to paint
+
+ if (cellEdited == false && rowIndex < DataGridView.RowCount)
+ {
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ {
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ di.Font = cellStyle.Font;
+ di.ForeColor = cellStyle.ForeColor;
+ di.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+
+ di.BackgroundStyle.TextColor = cellStyle.ForeColor;
+ di.BackgroundStyle.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+
+ di.InputHorizontalAlignment = GetHorizontalAlignment(cellStyle.Alignment);
+
+ di.Value = GetValue(value);
+
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+
+ if (oc.DisplayControlForCurrentCellOnly == false)
+ DrawControl(di, r, g);
+ else
+ DrawText(di, r, g);
+ }
+ }
+ }
+
+ #region DrawControl
+
+ ///
+ /// DrawControl
+ ///
+ ///
+ ///
+ ///
+ private void DrawControl(DateTimeInput di, Rectangle r, Graphics g)
+ {
+ GraphicsState gs = g.Save();
+
+ try
+ {
+ g.TranslateTransform(r.X, r.Y);
+
+ di.Width = r.Width;
+ di.InternalPaint(new PaintEventArgs(g, Rectangle.Empty));
+ }
+ finally
+ {
+ g.Restore(gs);
+ }
+ }
+
+ #endregion
+
+ #region DrawText
+
+ ///
+ /// DrawText
+ ///
+ ///
+ ///
+ ///
+ private void DrawText(DateTimeInput di, Rectangle r, Graphics g)
+ {
+ r.Inflate(-2, 0);
+
+ eTextFormat tf = eTextFormat.VerticalCenter;
+
+ switch (di.InputHorizontalAlignment)
+ {
+ case eHorizontalAlignment.Center:
+ tf |= eTextFormat.HorizontalCenter;
+ break;
+
+ case eHorizontalAlignment.Right:
+ tf |= eTextFormat.Right;
+ break;
+ }
+
+ TextDrawing.DrawString(g, di.Text, di.Font, di.ForeColor, r, tf);
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewDateTimeInputColumn oc = (DataGridViewDateTimeInputColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetCellBounds
+
+ ///
+ /// Gets the button bounds for the given cell
+ ///
+ ///
+ ///
+ private Rectangle GetCellBounds(Rectangle cellBounds)
+ {
+ DataGridViewDateTimeInputColumn oc = (DataGridViewDateTimeInputColumn)OwningColumn;
+
+ Size size = oc.DateTimeInput.Size;
+
+ cellBounds.Location = new Point(1, 1);
+
+ cellBounds.Width = Math.Min(size.Width, cellBounds.Width);
+ cellBounds.Width -= oc.DividerWidth;
+ cellBounds.Height = size.Height;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetValue
+
+ ///
+ /// GetValue
+ ///
+ ///
+ ///
+ private DateTime GetValue(object value)
+ {
+ if (value == Convert.DBNull ||
+ (value is string && String.IsNullOrEmpty((string)value) == true))
+ {
+ return (DateTime.MinValue);
+ }
+
+ if (value is DateTime)
+ return (Convert.ToDateTime(value));
+ else if (value is string && DevComponents.Editors.DateTimeAdv.DateTimeInput.CurrentCulture != null)
+ {
+ System.DateTime d = new System.DateTime();
+ if (System.DateTime.TryParse(value.ToString(), DevComponents.Editors.DateTimeAdv.DateTimeInput.GetActiveCulture().DateTimeFormat,
+ System.Globalization.DateTimeStyles.None, out d))
+ return d;
+ }
+
+ return (Convert.ToDateTime(value));
+ }
+
+ #endregion
+
+ #region GetHorizontalAlignment
+
+ ///
+ /// GetHorizontalAlignment
+ ///
+ ///
+ ///
+ private eHorizontalAlignment GetHorizontalAlignment(DataGridViewContentAlignment alignment)
+ {
+ switch (alignment)
+ {
+ case DataGridViewContentAlignment.TopCenter:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.BottomCenter:
+ return (eHorizontalAlignment.Center);
+
+ case DataGridViewContentAlignment.TopRight:
+ case DataGridViewContentAlignment.MiddleRight:
+ case DataGridViewContentAlignment.BottomRight:
+ return (eHorizontalAlignment.Right);
+
+ default:
+ return (eHorizontalAlignment.Left);
+ }
+ }
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDateTimeInput/DataGridViewDateTimeInputColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDateTimeInput/DataGridViewDateTimeInputColumn.cs
new file mode 100644
index 00000000..a21a75d8
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDateTimeInput/DataGridViewDateTimeInputColumn.cs
@@ -0,0 +1,750 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.Editors;
+using DevComponents.Editors.DateTimeAdv;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewButtonXColumn), "DateTimeInput.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewDateTimeInputColumn : DataGridViewTextBoxColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ ///
+ /// Occurs right before a DateTimeInput Cell is painted
+ ///
+ [Description("Occurs right before a DateTimeInput Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ ///
+ /// Occurs when Clear button is clicked and allows you
+ /// to cancel the default action performed by the button
+ ///
+ [Description("Occurs when Clear button is clicked and allows you to cancel the default action performed by the button.")]
+ public event EventHandler ButtonClearClick;
+
+ ///
+ /// Occurs when ButtonCustom control is clicked
+ ///
+ [Description("Occurs when ButtonCustom control is clicked.")]
+ public event EventHandler ButtonCustomClick;
+
+ ///
+ /// Occurs when ButtonCustom2 control is clicked
+ ///
+ [Description("Occurs when ButtonCustom2 control is clicked.")]
+ public event EventHandler ButtonCustom2Click;
+
+ ///
+ /// Occurs when Drop-Down button that shows calendar
+ /// is clicked and allows you to cancel showing of the popup
+ ///
+ [Description("Occurs when Drop-Down button that shows calendar is clicked and allows you to cancel showing of the popup.")]
+ public event EventHandler ButtonDropDownClick;
+
+ ///
+ /// Occurs when Free-Text button is clicked
+ /// and allows you to cancel its default action
+ ///
+ [Description("Occurs when Free-Text button is clicked and allows you to cancel its default action.")]
+ public event EventHandler ButtonFreeTextClick;
+
+ ///
+ /// Occurs if Free-Text entry value is not natively recognized by
+ /// the control and provides you with opportunity to convert that
+ /// value to the value the control expects
+ ///
+ [Description("Occurs if Free-Text entry value is not natively recognized by the control and provides you with opportunity to convert that value to the value the control expects.")]
+ public event EventHandler ConvertFreeTextEntry;
+
+ #endregion
+
+ #region Private variables
+
+ private DateTimeInput _DateTimeInput;
+ private Bitmap _CellBitmap;
+ private bool _DisplayControlForCurrentCellOnly = true;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewDateTimeInputColumn()
+ {
+ CellTemplate = new DataGridViewDateTimeInputCell();
+
+ _DateTimeInput = new DateTimeInput();
+
+ _DateTimeInput.BackgroundStyle.Class = ElementStyleClassKeys.DataGridViewDateTimeBorderKey;
+ _DateTimeInput.Visible = false;
+ }
+
+ #region Dispose
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing == true)
+ _DateTimeInput.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+
+ #region Internal properties
+
+ #region DateTimeInput
+
+ ///
+ /// Gets the underlying DateTimeInput control
+ ///
+ internal DateTimeInput DateTimeInput
+ {
+ get { return (_DateTimeInput); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region AllowEmptyState
+
+ ///
+ /// Gets or sets whether empty null/nothing state of the control is
+ /// allowed. Default value is true which means that IsEmpty property may
+ /// return true if input value is resets or ValueObject set to null/nothing.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether empty null/nothing state of the control is allowed.")]
+ public bool AllowEmptyState
+ {
+ get { return (_DateTimeInput.AllowEmptyState); }
+ set { _DateTimeInput.AllowEmptyState = value; }
+ }
+
+ #endregion
+
+ #region AutoAdvance
+
+ ///
+ /// Gets or sets whether input focus is automatically advanced
+ /// to next input field when input is complete in current one.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Behavior")]
+ [Description("Indicates whether input focus is automatically advanced to next input field when input is complete in current one.")]
+ public bool AutoAdvance
+ {
+ get { return (_DateTimeInput.AutoAdvance); }
+ set { _DateTimeInput.AutoAdvance = value; }
+ }
+
+ #endregion
+
+ #region AutoSelectDate
+
+ ///
+ /// Gets or sets whether first day in month is automatically
+ /// selected on popup date picker when month or year is changed.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Behavior")]
+ [Description("Indicates whether first day in month is automatically selected on popup date picker when month or year is changed.")]
+ public bool AutoSelectDate
+ {
+ get { return (_DateTimeInput.AutoSelectDate); }
+ set { _DateTimeInput.AutoSelectDate = value; }
+ }
+
+ #endregion
+
+ #region AutoOverwrite
+
+ ///
+ /// Gets or sets whether auto-overwrite functionality for input is enabled.
+ /// When in auto-overwrite mode input field will erase existing entry
+ /// and start new one if typing is continued after InputComplete method is called.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether auto-overwrite functionality for input is enabled.")]
+ public bool AutoOverwrite
+ {
+ get { return (_DateTimeInput.AutoOverwrite); }
+ set { _DateTimeInput.AutoOverwrite = value; }
+ }
+
+ #endregion
+
+ #region BackgroundStyle
+
+ ///
+ /// Specifies the background style of the control.
+ ///
+ [Browsable(true), Category("Style")]
+ [Description("Gets or sets control background style.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return (_DateTimeInput.BackgroundStyle); }
+ }
+
+ ///
+ /// Resets style to default value. Used by windows forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackgroundStyle()
+ {
+ _DateTimeInput.ResetBackgroundStyle();
+
+ _DateTimeInput.BackgroundStyle.Class = "TextBoxBorder";
+ _DateTimeInput.BackgroundStyle.CornerType = eCornerType.Square;
+ }
+
+ #endregion
+
+ #region ButtonClear
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that clears the content of the control when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that clears the content of the control when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonClear
+ {
+ get { return (_DateTimeInput.ButtonClear); }
+ }
+
+ #endregion
+
+ #region ButtonCustom
+
+ ///
+ /// Gets the object that describes the settings for the custom button
+ /// that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom
+ {
+ get { return (_DateTimeInput.ButtonCustom); }
+ }
+
+ #endregion
+
+ #region ButtonCustom2
+
+ ///
+ /// Gets the object that describes the settings for the custom button that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom2
+ {
+ get { return (_DateTimeInput.ButtonCustom2); }
+ }
+
+ #endregion
+
+ #region ButtonDropDown
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that shows drop-down when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that shows drop-down when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonDropDown
+ {
+ get { return (_DateTimeInput.ButtonDropDown); }
+ }
+
+ #endregion
+
+ #region ButtonFreeText
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that switches the control into the free-text entry mode when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that switches the control into the free-text entry mode when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonFreeText
+ {
+ get { return (_DateTimeInput.ButtonFreeText); }
+ }
+
+ #endregion
+
+ #region CustomFormat
+
+ ///
+ /// Gets or sets the custom date/time format string.
+ ///
+ [Browsable(true), DefaultValue("")]
+ [Description("Indicates the custom date/time format string. "), Localizable(true)]
+ public string CustomFormat
+ {
+ get { return (_DateTimeInput.CustomFormat); }
+ set { _DateTimeInput.CustomFormat = value; }
+ }
+
+ #endregion
+
+ #region DisplayControlForCurrentCellOnly
+
+ ///
+ /// Gets or sets whether the control
+ /// will be displayed for the current cell only.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether the control will be displayed for the current cell only.")]
+ public bool DisplayControlForCurrentCellOnly
+ {
+ get { return (_DisplayControlForCurrentCellOnly); }
+
+ set
+ {
+ if (_DisplayControlForCurrentCellOnly != value)
+ {
+ _DisplayControlForCurrentCellOnly = value;
+ _DateTimeInput.Invalidate();
+ }
+ }
+ }
+
+ #endregion
+
+ #region DefaultInputValues
+
+ ///
+ /// Gets or sets whether empty input values (year, month or day) are
+ /// set to defaults while user is entering data. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether empty input values (year, month or day) are set to defaults while user is entering data")]
+ public bool DefaultInputValues
+ {
+ get { return (_DateTimeInput.DefaultInputValues); }
+ set { _DateTimeInput.DefaultInputValues = value; }
+ }
+
+ #endregion
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_DateTimeInput.Enabled); }
+ set { _DateTimeInput.Enabled = value; }
+ }
+
+ #endregion
+
+ #region Format
+
+ ///
+ /// Gets or sets the format date/time is displayed in. To specify
+ /// custom format set this value to Custom and specify custom format
+ /// using CustomFormat property.
+ ///
+ [Browsable(true), DefaultValue(eDateTimePickerFormat.Short)]
+ [Description("Indicates the format date/time is displayed in. To specify custom format set this value to Custom and specify custom format using CustomFormat property.")]
+ public eDateTimePickerFormat Format
+ {
+ get { return (_DateTimeInput.Format); }
+ set { _DateTimeInput.Format = value; }
+ }
+
+ #endregion
+
+ #region InputHorizontalAlignment
+
+ ///
+ /// Gets or sets the input field alignment inside the control
+ ///
+ [Browsable(true), DefaultValue(eHorizontalAlignment.Right), Category("Appearance")]
+ [Description("Indicates alignment of input fields inside of the control.")]
+ public eHorizontalAlignment InputHorizontalAlignment
+ {
+ get { return (_DateTimeInput.InputHorizontalAlignment); }
+ set { _DateTimeInput.InputHorizontalAlignment = value; }
+ }
+
+ #endregion
+
+ #region IsInputReadOnly
+
+ ///
+ /// Gets or sets whether input part of the control is read-only. When set
+ /// to true the input part of the control becomes read-only and does not allow
+ /// the typing. However, drop-down part if visible still allows user to change
+ /// the value of the control. Use this property to allow change of the value
+ /// through drop-down picker only.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether input part of the control is read-only.")]
+ public bool IsInputReadOnly
+ {
+ get { return (_DateTimeInput.IsInputReadOnly); }
+ set { _DateTimeInput.IsInputReadOnly = value; }
+ }
+
+ #endregion
+
+ #region LockUpdateChecked
+
+ ///
+ /// Gets or sets whether check box shown using ShowCheckBox
+ /// property which locks/unlocks the control update is checked.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether check box shown using ShowCheckBox property which locks/unlocks the control update is checked.")]
+ public bool LockUpdateChecked
+ {
+ get { return (_DateTimeInput.LockUpdateChecked); }
+ set { _DateTimeInput.LockUpdateChecked = value; }
+ }
+
+ #endregion
+
+ #region MaxDate
+
+ ///
+ /// Gets or sets the maximum date and time that can be selected in the control.
+ ///
+ [Browsable(true)]
+ [Description("Indicates maximum date and time that can be selected in the control.")]
+ public DateTime MaxDate
+ {
+ get { return (_DateTimeInput.MaxDate); }
+ set { _DateTimeInput.MaxDate = value; }
+ }
+
+ ///
+ /// Gets whether Value property should be serialized by Windows Forms designer.
+ ///
+ /// true if value serialized otherwise false.
+ public bool ShouldSerializeMaxDate()
+ {
+ return (MaxDate.Equals(DateTimeGroup.MaxDateTime) == false);
+ }
+
+ #endregion
+
+ #region MinDate
+
+ ///
+ /// Gets or sets the minimum date and time that can be selected in the control.
+ ///
+ [Browsable(true)]
+ [Description("Indicates minimum date and time that can be selected in the control.")]
+ public DateTime MinDate
+ {
+ get { return (_DateTimeInput.MinDate); }
+ set { _DateTimeInput.MinDate = value; }
+ }
+
+ ///
+ /// Gets whether Value property should be serialized by Windows Forms designer.
+ ///
+ /// true if value serialized otherwise false.
+ public bool ShouldSerializeMinDate()
+ {
+ return (MinDate.Equals(DateTimeGroup.MinDateTime) == false);
+ }
+
+ #endregion
+
+ #region MonthCalendar
+
+ ///
+ /// Gets the reference to the internal MonthCalendarItem control which is used to display calendar when drop-down is open.
+ ///
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ [Description("Gets the reference to the internal MonthCalendarAdv control which is used to display calendar when drop-down is open.")]
+ public MonthCalendarItem MonthCalendar
+ {
+ get { return (_DateTimeInput.MonthCalendar); }
+ }
+
+ #endregion
+
+ #region SelectNextInputCharacters
+
+ ///
+ /// List of characters that when pressed would select next input field. For example if you are
+ /// allowing time input you could set this property to : so when user presses the : character,
+ /// the input is forwarded to the next input field.
+ ///
+ [Browsable(true), DefaultValue(""), Category("Behavior")]
+ [Description("List of characters that when pressed would select next input field.")]
+ public string SelectNextInputCharacters
+ {
+ get { return (_DateTimeInput.SelectNextInputCharacters); }
+ set { _DateTimeInput.SelectNextInputCharacters = value; }
+ }
+
+ #endregion
+
+ #region ShowCheckBox
+
+ ///
+ /// Gets or sets a value indicating whether a check box is
+ /// displayed to the left of the input value. Set to true if a check box
+ /// is displayed to the left of the input value; otherwise, false. The default is false.
+ ///
+ /// When the ShowCheckBox property is set to true, a check box is displayed
+ /// to the left of the input in the control. When the check box is selected, the value
+ /// can be updated. When the check box is cleared, the value is unable to be changed.
+ /// You can handle the LockUpdateChanged event to be notified when this check box is checked
+ /// and unchecked. Use LockUpdateChecked property to get or sets whether check box is checked.
+ ///
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether a check box is displayed to the left of the input value which allows locking of the control.")]
+ public bool ShowCheckBox
+ {
+ get { return (_DateTimeInput.ShowCheckBox); }
+ set { _DateTimeInput.ShowCheckBox = value; }
+ }
+
+ #endregion
+
+ #region ShowUpDown
+
+ ///
+ /// Gets or sets a value indicating whether a spin button control
+ /// (up-down control) is used to adjust the current value. The default is false.
+ ///
+ /// When the ShowUpDown property is set to true, a spin button control
+ /// is shown to adjust value of currently focused input item. The value can
+ /// be adjusted by using the up and down buttons to change the value.
+ ///
+ ///
+ [Browsable(true), DefaultValue(false)]
+ public bool ShowUpDown
+ {
+ get { return (_DateTimeInput.ShowUpDown); }
+ set { _DateTimeInput.ShowUpDown = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Event processing
+
+ #region DoButtonClearClick
+
+ ///
+ /// DoButtonClearClick
+ ///
+ ///
+ ///
+ internal void DoButtonClearClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonClearClick != null)
+ ButtonClearClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustomClick
+
+ ///
+ /// DoButtonCustomClick
+ ///
+ ///
+ ///
+ internal void DoButtonCustomClick(object sender, EventArgs e)
+ {
+ if (ButtonCustomClick != null)
+ ButtonCustomClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustom2Click
+
+ ///
+ /// DoButtonCustom2Click
+ ///
+ ///
+ ///
+ internal void DoButtonCustom2Click(object sender, EventArgs e)
+ {
+ if (ButtonCustom2Click != null)
+ ButtonCustom2Click(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonDropDownClick
+
+ ///
+ /// DoButtonDropDownClick
+ ///
+ ///
+ ///
+ internal void DoButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonDropDownClick != null)
+ ButtonDropDownClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonFreeTextClick
+
+ ///
+ /// DoButtonFreeTextClick
+ ///
+ ///
+ ///
+ internal void DoButtonFreeTextClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonFreeTextClick != null)
+ ButtonFreeTextClick(this, e);
+ }
+
+ #endregion
+
+ #region DoConvertFreeTextEntry
+
+ ///
+ /// DoConvertFreeTextEntry
+ ///
+ ///
+ ///
+ internal void DoConvertFreeTextEntry(object sender, FreeTextEntryConversionEventArgs e)
+ {
+ if (ConvertFreeTextEntry != null)
+ ConvertFreeTextEntry(this, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewDateTimeInputColumn dc = base.Clone() as DataGridViewDateTimeInputColumn;
+
+ if (dc != null)
+ {
+ dc.AllowEmptyState = AllowEmptyState;
+ dc.AutoAdvance = AutoAdvance;
+ dc.AutoOverwrite = AutoOverwrite;
+ dc.AutoSelectDate = AutoSelectDate;
+ dc.CustomFormat = CustomFormat;
+ dc.DefaultInputValues = DefaultInputValues;
+ dc.Enabled = Enabled;
+ dc.Format = Format;
+ dc.InputHorizontalAlignment = InputHorizontalAlignment;
+ dc.IsInputReadOnly = IsInputReadOnly;
+ dc.LockUpdateChecked = LockUpdateChecked;
+ dc.MinDate = MinDate;
+ dc.MaxDate = MaxDate;
+ dc.SelectNextInputCharacters = SelectNextInputCharacters;
+ dc.ShowCheckBox = ShowCheckBox;
+ dc.ShowUpDown = ShowUpDown;
+
+ dc.DisplayControlForCurrentCellOnly = DisplayControlForCurrentCellOnly;
+
+ DateTimeInput.MonthCalendar.InternalCopyToItem(dc.DateTimeInput.MonthCalendar);
+
+ dc.BackgroundStyle.ApplyStyle(DateTimeInput.BackgroundStyle);
+ dc.BackgroundStyle.Class = DateTimeInput.BackgroundStyle.Class;
+
+ DateTimeInput.ButtonClear.CopyToItem(dc.DateTimeInput.ButtonClear);
+ DateTimeInput.ButtonDropDown.CopyToItem(dc.DateTimeInput.ButtonDropDown);
+ DateTimeInput.ButtonFreeText.CopyToItem(dc.DateTimeInput.ButtonFreeText);
+ DateTimeInput.ButtonCustom.CopyToItem(dc.DateTimeInput.ButtonCustom);
+ DateTimeInput.ButtonCustom2.CopyToItem(dc.DateTimeInput.ButtonCustom2);
+ }
+
+ return (dc);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDateTimeInput/DataGridViewDateTimeInputEditingControl.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDateTimeInput/DataGridViewDateTimeInputEditingControl.cs
new file mode 100644
index 00000000..3e61ea96
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDateTimeInput/DataGridViewDateTimeInputEditingControl.cs
@@ -0,0 +1,218 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.Editors.DateTimeAdv;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewDateTimeInputEditingControl : DateTimeInput, IDataGridViewEditingControl
+ {
+ #region Private variables
+
+ private DataGridView _DataGridView;
+
+ private int _RowIndex;
+ private bool _ValueChanged;
+ private bool _EditCancelled;
+
+ #endregion
+
+ #region OnValueChanged
+
+ ///
+ /// Handles OnValueChanged events
+ ///
+ ///
+ protected override void OnValueChanged(EventArgs e)
+ {
+ _ValueChanged = true;
+
+ _DataGridView.NotifyCurrentCellDirty(true);
+
+ base.OnValueChanged(e);
+ }
+
+ #endregion
+
+ #region Internal properties
+
+ ///
+ /// Gets or sets the Edit state
+ ///
+ internal bool EditCancelled
+ {
+ get { return (_EditCancelled); }
+ set { _EditCancelled = value; }
+ }
+
+ #endregion
+
+ #region IDataGridViewEditingControl Members
+
+ #region Public properties
+
+ #region EditingControlDataGridView
+
+ ///
+ /// Gets or sets the DataGridView
+ ///
+ public DataGridView EditingControlDataGridView
+ {
+ get { return (_DataGridView); }
+ set { _DataGridView = value; }
+ }
+
+ #endregion
+
+ #region EditingControlFormattedValue
+
+ ///
+ /// Gets or sets the Control Formatted Value
+ ///
+ public object EditingControlFormattedValue
+ {
+ get
+ {
+ DateTime date = Value;
+
+ if (date.Equals(DateTime.MinValue))
+ return (String.Empty);
+
+ return (this.Value.ToString());
+ }
+
+ set
+ {
+ string newValue = value as string;
+
+ if (newValue != null)
+ Value = DateTime.Parse(newValue);
+ }
+ }
+
+ #endregion
+
+ #region EditingControlRowIndex
+
+ ///
+ /// Gets or sets the Control RoeIndex
+ ///
+ public int EditingControlRowIndex
+ {
+ get { return (_RowIndex); }
+ set { _RowIndex = value; }
+ }
+
+ #endregion
+
+ #region EditingControlValueChanged
+
+ ///
+ /// Gets or sets the Control ValueChanged state
+ ///
+ public bool EditingControlValueChanged
+ {
+ get { return (_ValueChanged); }
+ set { _ValueChanged = value; }
+ }
+
+ #endregion
+
+ #region EditingPanelCursor
+
+ ///
+ /// Gets the Panel Cursor
+ ///
+ public Cursor EditingPanelCursor
+ {
+ get { return (base.Cursor); }
+ }
+
+ #endregion
+
+ #region RepositionEditingControlOnValueChange
+
+ ///
+ /// Gets whether to RepositionEditingControlOnValueChange
+ ///
+ public bool RepositionEditingControlOnValueChange
+ {
+ get { return (false); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region ApplyCellStyleToEditingControl
+
+ ///
+ /// ApplyCellStyleToEditingControl
+ ///
+ ///
+ public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ Font = dataGridViewCellStyle.Font;
+
+ ForeColor = dataGridViewCellStyle.ForeColor;
+ BackColor = dataGridViewCellStyle.BackColor;
+ }
+
+ #endregion
+
+ #region GetEditingControlFormattedValue
+
+ ///
+ /// Gets EditingControlFormattedValue
+ ///
+ ///
+ ///
+ public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
+ {
+ return (EditingControlFormattedValue);
+ }
+
+ #endregion
+
+ #region EditingControlWantsInputKey
+
+ ///
+ /// Gets whether the given key wants to be processed
+ /// by the Control
+ ///
+ ///
+ ///
+ ///
+ public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
+ {
+ if ((keyData & Keys.Right) == Keys.Right)
+ return (true);
+
+ if ((keyData & Keys.Left) == Keys.Left)
+ return (true);
+
+ if ((keyData & Keys.Escape) == Keys.Escape)
+ _EditCancelled = true;
+
+ return (dataGridViewWantsInputKey == false);
+ }
+
+ #endregion
+
+ #region PrepareEditingControlForEdit
+
+ ///
+ /// PrepareEditingControlForEdit
+ ///
+ ///
+ public void PrepareEditingControlForEdit(bool selectAll)
+ {
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDoubleInput/DataGridViewDoubleInputCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDoubleInput/DataGridViewDoubleInputCell.cs
new file mode 100644
index 00000000..5a562188
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDoubleInput/DataGridViewDoubleInputCell.cs
@@ -0,0 +1,730 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Media;
+using System.Windows.Forms;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewDoubleInputCell : DataGridViewTextBoxCell
+ {
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (typeof(DataGridViewDoubleInputEditingControl)); }
+ }
+
+ #endregion
+
+ #region FormattedValueType
+
+ ///
+ /// FormattedValueType
+ ///
+ public override Type FormattedValueType
+ {
+ get { return (typeof(string)); }
+ }
+
+ #endregion
+
+ #region ValueType
+
+ public override Type ValueType
+ {
+ get { return (typeof(double)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region InitializeEditingControl
+
+ ///
+ /// InitializeEditingControl
+ ///
+ ///
+ ///
+ ///
+ public override void InitializeEditingControl(int rowIndex,
+ object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ DetachEditingControl();
+
+ base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
+
+ DataGridViewDoubleInputEditingControl ctl =
+ (DataGridViewDoubleInputEditingControl)DataGridView.EditingControl;
+
+ DataGridViewDoubleInputColumn oc = OwningColumn as DataGridViewDoubleInputColumn;
+
+ if (oc != null)
+ {
+ DoubleInput di = oc.DoubleInput;
+
+ ctl.Value = GetValue(di.Value);
+
+ ctl.DisplayFormat = di.DisplayFormat;
+ ctl.Enabled = di.Enabled;
+ ctl.Increment = di.Increment;
+ ctl.LockUpdateChecked = di.LockUpdateChecked;
+ ctl.MaxValue = di.MaxValue;
+ ctl.MinValue = di.MinValue;
+ ctl.ShowCheckBox = di.ShowCheckBox;
+ ctl.ShowUpDown = di.ShowUpDown;
+
+ ctl.BackgroundStyle.ApplyStyle(di.BackgroundStyle);
+ ctl.BackgroundStyle.Class = di.BackgroundStyle.Class;
+
+ ctl.InputHorizontalAlignment = GetHorizontalAlignment(dataGridViewCellStyle.Alignment);
+
+ di.ButtonClear.CopyToItem(ctl.ButtonClear);
+ di.ButtonCustom.CopyToItem(ctl.ButtonCustom);
+ di.ButtonCustom2.CopyToItem(ctl.ButtonCustom2);
+ di.ButtonDropDown.CopyToItem(ctl.ButtonDropDown);
+ di.ButtonFreeText.CopyToItem(ctl.ButtonFreeText);
+
+ ctl.ButtonClearClick += ButtonClearClick;
+ ctl.ButtonCustomClick += ButtonCustomClick;
+ ctl.ButtonCustom2Click += ButtonCustom2Click;
+ ctl.ButtonDropDownClick += ButtonDropDownClick;
+ ctl.ButtonFreeTextClick += ButtonFreeTextClick;
+ ctl.ConvertFreeTextEntry += ConvertFreeTextEntry;
+
+ ctl.EditCancelled = false;
+ }
+ }
+
+ #endregion
+
+ #region DetachEditingControl
+
+ ///
+ /// DetachEditingControl
+ ///
+ public override void DetachEditingControl()
+ {
+ if (DataGridView != null && DataGridView.EditingControl != null)
+ {
+ DataGridViewDoubleInputEditingControl di =
+ DataGridView.EditingControl as DataGridViewDoubleInputEditingControl;
+
+ if (di != null)
+ {
+ di.ButtonClearClick -= ButtonClearClick;
+ di.ButtonDropDownClick -= ButtonDropDownClick;
+ di.ButtonFreeTextClick -= ButtonFreeTextClick;
+ di.ButtonCustomClick -= ButtonCustomClick;
+ di.ButtonCustom2Click -= ButtonCustom2Click;
+ di.ConvertFreeTextEntry -= ConvertFreeTextEntry;
+
+ if (di.EditCancelled == true)
+ {
+ di.EditCancelled = false;
+
+ SystemSounds.Beep.Play();
+ }
+ }
+ }
+
+ base.DetachEditingControl();
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region ButtonClearClick
+
+ ///
+ /// ButtonClearClick
+ ///
+ ///
+ ///
+ void ButtonClearClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewDoubleInputColumn)OwningColumn).DoButtonClearClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustomClick
+
+ ///
+ /// ButtonCustomClick
+ ///
+ ///
+ ///
+ void ButtonCustomClick(object sender, EventArgs e)
+ {
+ ((DataGridViewDoubleInputColumn)OwningColumn).DoButtonCustomClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustom2Click
+
+ ///
+ /// ButtonCustom2Click
+ ///
+ ///
+ ///
+ void ButtonCustom2Click(object sender, EventArgs e)
+ {
+ ((DataGridViewDoubleInputColumn)OwningColumn).DoButtonCustom2Click(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonDropDownClick
+
+ ///
+ /// ButtonDropDownClick
+ ///
+ ///
+ ///
+ void ButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewDoubleInputColumn)OwningColumn).DoButtonDropDownClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonFreeTextClick
+
+ ///
+ /// ButtonFreeTextClick
+ ///
+ ///
+ ///
+ void ButtonFreeTextClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewDoubleInputColumn)OwningColumn).DoButtonFreeTextClick(sender, e);
+ }
+
+ #endregion
+
+ #region ConvertFreeTextEntry
+
+ ///
+ /// ConvertFreeTextEntry
+ ///
+ ///
+ ///
+ void ConvertFreeTextEntry(object sender, FreeTextEntryConversionEventArgs e)
+ {
+ ((DataGridViewDoubleInputColumn)OwningColumn).DoConvertFreeTextEntry(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PositionEditingControl
+
+ ///
+ /// PositionEditingControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override void PositionEditingControl(bool setLocation, bool setSize, Rectangle cellBounds,
+ Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded,
+ bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
+ {
+ Rectangle editingControlBounds =
+ PositionEditingPanel(cellBounds, cellClip, cellStyle, singleVerticalBorderAdded,
+ singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow);
+
+ editingControlBounds = GetAdjustedEditingControlBounds(editingControlBounds, cellStyle);
+
+ DataGridView.EditingControl.Location = new Point(editingControlBounds.X, editingControlBounds.Y);
+ DataGridView.EditingControl.Size = new Size(editingControlBounds.Width, editingControlBounds.Height);
+ }
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetCellBounds(editingControlBounds);
+
+ if (cellStyle != null && r.Height < editingControlBounds.Height)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.MiddleLeft:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height) / 2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ editingControlBounds.Width = Math.Max(1, editingControlBounds.Width);
+ editingControlBounds.Height = Math.Max(1, r.Height);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ #region GetPreferredSize
+
+ ///
+ /// GetPreferredSize
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Size GetPreferredSize(Graphics graphics,
+ DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ {
+ if (DataGridView == null)
+ return (new Size(-1, -1));
+
+ Size preferredSize = base.GetPreferredSize(graphics, cellStyle, rowIndex, constraintSize);
+
+ DataGridViewDoubleInputColumn oc = OwningColumn as DataGridViewDoubleInputColumn;
+
+ if (oc != null)
+ {
+ DoubleInput di = oc.DoubleInput;
+
+ preferredSize.Height = di.Height;
+
+ if (constraintSize.Width == 0)
+ {
+ preferredSize.Width += GetImageWidth(di.ButtonClear);
+ preferredSize.Width += GetImageWidth(di.ButtonCustom);
+ preferredSize.Width += GetImageWidth(di.ButtonCustom2);
+ preferredSize.Width += GetImageWidth(di.ButtonDropDown);
+ preferredSize.Width += GetImageWidth(di.ButtonFreeText);
+
+ if (di.ShowUpDown == true)
+ preferredSize.Width += 16;
+
+ if (di.ShowCheckBox == true)
+ preferredSize.Width += 16;
+ }
+ }
+
+ return (preferredSize);
+ }
+
+ #endregion
+
+ #region GetFormattedValue
+
+ protected override object GetFormattedValue(object value, int rowIndex,
+ ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter,
+ TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
+ {
+ DataGridViewDoubleInputColumn oc = OwningColumn as DataGridViewDoubleInputColumn;
+
+ if (oc != null)
+ {
+ DoubleInput di = oc.DoubleInput;
+ di.Value = GetValue(value);
+
+ return (di.Text);
+ }
+
+ return (base.GetFormattedValue(value, rowIndex,
+ ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
+ }
+
+ #endregion
+
+ #region GetImageWidth
+
+ private int GetImageWidth(InputButtonSettings ibs)
+ {
+ if (ibs.Visible == true)
+ return (ibs.Image != null ? ibs.Image.Width : 16);
+
+ return (0);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
+ DataGridViewElementStates elementState, object value, object formattedValue,
+ string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle,
+ DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewDoubleInputColumn oc = (DataGridViewDoubleInputColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintCellBackground(g, cellStyle, rBk);
+ PaintCellContent(g, cellBounds, rowIndex, value, cellStyle, paintParts);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintCellBackground
+
+ ///
+ /// Paints the cell background
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintCellContent
+
+ ///
+ /// Paints the cell content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellContent(Graphics g, Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts)
+ {
+ DataGridViewDoubleInputColumn oc = (DataGridViewDoubleInputColumn)OwningColumn;
+ DoubleInput di = oc.DoubleInput;
+
+ Point ptCurrentCell = DataGridView.CurrentCellAddress;
+ bool cellCurrent = ptCurrentCell.X == ColumnIndex && ptCurrentCell.Y == rowIndex;
+ bool cellEdited = cellCurrent && DataGridView.EditingControl != null;
+
+ // If the cell is in editing mode, there is nothing else to paint
+
+ if (cellEdited == false && rowIndex < DataGridView.RowCount)
+ {
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ {
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ di.Font = cellStyle.Font;
+ di.ForeColor = cellStyle.ForeColor;
+ di.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+
+ di.BackgroundStyle.TextColor = cellStyle.ForeColor;
+ di.BackgroundStyle.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+
+ di.InputHorizontalAlignment = GetHorizontalAlignment(cellStyle.Alignment);
+
+ di.Value = GetValue(value);
+
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+
+ if (oc.DisplayControlForCurrentCellOnly == false)
+ DrawControl(di, r, g);
+ else
+ DrawText(di, r, g);
+ }
+ }
+ }
+
+ #region DrawControl
+
+ ///
+ /// DrawControl
+ ///
+ ///
+ ///
+ ///
+ private void DrawControl(DoubleInput di, Rectangle r, Graphics g)
+ {
+ GraphicsState gs = g.Save();
+
+ try
+ {
+ g.TranslateTransform(r.X, r.Y);
+
+ di.Width = r.Width;
+ di.InternalPaint(new PaintEventArgs(g, Rectangle.Empty));
+ }
+ finally
+ {
+ g.Restore(gs);
+ }
+ }
+
+ #endregion
+
+ #region DrawText
+
+ ///
+ /// DrawText
+ ///
+ ///
+ ///
+ ///
+ private void DrawText(DoubleInput di, Rectangle r, Graphics g)
+ {
+ r.Inflate(-2, 0);
+
+ eTextFormat tf = eTextFormat.VerticalCenter;
+
+ switch (di.InputHorizontalAlignment)
+ {
+ case eHorizontalAlignment.Center:
+ tf |= eTextFormat.HorizontalCenter;
+ break;
+
+ case eHorizontalAlignment.Right:
+ tf |= eTextFormat.Right;
+ break;
+ }
+
+ TextDrawing.DrawString(g, di.Text, di.Font, di.ForeColor, r, tf);
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewDoubleInputColumn oc = (DataGridViewDoubleInputColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetCellBounds
+
+ ///
+ /// Gets the button bounds for the given cell
+ ///
+ ///
+ ///
+ private Rectangle GetCellBounds(Rectangle cellBounds)
+ {
+ DataGridViewDoubleInputColumn oc = (DataGridViewDoubleInputColumn)OwningColumn;
+
+ Size size = oc.DoubleInput.Size;
+
+ cellBounds.Location = new Point(1, 1);
+
+ cellBounds.Width = Math.Min(size.Width, cellBounds.Width);
+ cellBounds.Width -= oc.DividerWidth;
+ cellBounds.Height = size.Height;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetValue
+
+ ///
+ /// GetValue
+ ///
+ ///
+ ///
+ private double GetValue(object value)
+ {
+ if (value == Convert.DBNull ||
+ (value is string && String.IsNullOrEmpty((string)value) == true))
+ {
+ return (0);
+ }
+ if (value is string)
+ {
+ string svalue = value.ToString();
+ return Convert.ToDouble(svalue.Replace(" ", ""));
+ }
+ return (Convert.ToDouble(value));
+ }
+
+ #endregion
+
+ #region GetHorizontalAlignment
+
+ ///
+ /// GetHorizontalAlignment
+ ///
+ ///
+ ///
+ private eHorizontalAlignment GetHorizontalAlignment(DataGridViewContentAlignment alignment)
+ {
+ switch (alignment)
+ {
+ case DataGridViewContentAlignment.TopCenter:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.BottomCenter:
+ return (eHorizontalAlignment.Center);
+
+ case DataGridViewContentAlignment.TopRight:
+ case DataGridViewContentAlignment.MiddleRight:
+ case DataGridViewContentAlignment.BottomRight:
+ return (eHorizontalAlignment.Right);
+
+ default:
+ return (eHorizontalAlignment.Left);
+ }
+ }
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDoubleInput/DataGridViewDoubleInputColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDoubleInput/DataGridViewDoubleInputColumn.cs
new file mode 100644
index 00000000..0aa6d49b
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDoubleInput/DataGridViewDoubleInputColumn.cs
@@ -0,0 +1,597 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewButtonXColumn), "DoubleInput.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewDoubleInputColumn : DataGridViewTextBoxColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ ///
+ /// Occurs right before a DoubleInput Cell is painted
+ ///
+ [Description("Occurs right before a DoubleInput Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ ///
+ /// Occurs when Clear button is clicked and allows you
+ /// to cancel the default action performed by the button
+ ///
+ [Description("Occurs when Clear button is clicked and allows you to cancel the default action performed by the button.")]
+ public event EventHandler ButtonClearClick;
+
+ ///
+ /// Occurs when ButtonCustom control is clicked
+ ///
+ [Description("Occurs when ButtonCustom control is clicked.")]
+ public event EventHandler ButtonCustomClick;
+
+ ///
+ /// Occurs when ButtonCustom2 control is clicked
+ ///
+ [Description("Occurs when ButtonCustom2 control is clicked.")]
+ public event EventHandler ButtonCustom2Click;
+
+ ///
+ /// Occurs when Drop-Down button that shows calendar
+ /// is clicked and allows you to cancel showing of the popup
+ ///
+ [Description("Occurs when Drop-Down button that shows calendar is clicked and allows you to cancel showing of the popup.")]
+ public event EventHandler ButtonDropDownClick;
+
+ ///
+ /// Occurs when Free-Text button is clicked
+ /// and allows you to cancel its default action
+ ///
+ [Description("Occurs when Free-Text button is clicked and allows you to cancel its default action.")]
+ public event EventHandler ButtonFreeTextClick;
+
+ ///
+ /// Occurs if Free-Text entry value is not natively recognized by
+ /// the control and provides you with opportunity to convert that
+ /// value to the value the control expects
+ ///
+ [Description("Occurs if Free-Text entry value is not natively recognized by the control and provides you with opportunity to convert that value to the value the control expects.")]
+ public event EventHandler ConvertFreeTextEntry;
+
+ #endregion
+
+ #region Private variables
+
+ private DoubleInput _DoubleInput;
+ private Bitmap _CellBitmap;
+ private bool _DisplayControlForCurrentCellOnly = true;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewDoubleInputColumn()
+ {
+ CellTemplate = new DataGridViewDoubleInputCell();
+
+ _DoubleInput = new DoubleInput();
+
+ _DoubleInput.BackgroundStyle.Class = ElementStyleClassKeys.DataGridViewNumericBorderKey;
+ _DoubleInput.Visible = false;
+ }
+
+ #region Internal properties
+
+ #region DoubleInput
+
+ ///
+ /// DoubleInput
+ ///
+ internal DoubleInput DoubleInput
+ {
+ get { return (_DoubleInput); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region BackgroundStyle
+
+ ///
+ /// Specifies the background style of the control.
+ ///
+ [Browsable(true), Category("Style")]
+ [Description("Gets or sets control background style.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return (_DoubleInput.BackgroundStyle); }
+ }
+
+ ///
+ /// Resets style to default value. Used by windows forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackgroundStyle()
+ {
+ _DoubleInput.ResetBackgroundStyle();
+
+ _DoubleInput.BackgroundStyle.Class = "TextBoxBorder";
+ _DoubleInput.BackgroundStyle.CornerType = eCornerType.Square;
+ }
+
+ #endregion
+
+ #region ButtonClear
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that clears the content of the control when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that clears the content of the control when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonClear
+ {
+ get { return (_DoubleInput.ButtonClear); }
+ }
+
+ #endregion
+
+ #region ButtonCustom
+
+ ///
+ /// Gets the object that describes the settings for the custom button
+ /// that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom
+ {
+ get { return (_DoubleInput.ButtonCustom); }
+ }
+
+ #endregion
+
+ #region ButtonCustom2
+
+ ///
+ /// Gets the object that describes the settings for the custom button that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom2
+ {
+ get { return (_DoubleInput.ButtonCustom2); }
+ }
+
+ #endregion
+
+ #region ButtonDropDown
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that shows drop-down when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that shows drop-down when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonDropDown
+ {
+ get { return (_DoubleInput.ButtonDropDown); }
+ }
+
+ #endregion
+
+ #region ButtonFreeText
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that switches the control into the free-text entry mode when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that switches the control into the free-text entry mode when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonFreeText
+ {
+ get { return (_DoubleInput.ButtonFreeText); }
+ }
+
+ #endregion
+
+ #region DisplayFormat
+
+ ///
+ /// Gets or sets the Numeric String Format that is used to format
+ /// the numeric value entered for display purpose. Read more about
+ /// available formats in MSDN under "Standard Numeric Format Strings"
+ /// and "Custom Numeric Format Strings" topics.
+ ///
+ /// The format specified here indicates the format for display purpose
+ /// only, not for the input purpose. For example to display the number
+ /// in system Currency format set the DisplayFormat to 'C'.
+ ///
+ ///
+ [Browsable(true), DefaultValue("")]
+ [Description("Indicates Numeric String Format that is used to format the numeric value entered for display purpose.")]
+ public string DisplayFormat
+ {
+ get { return (_DoubleInput.DisplayFormat); }
+ set { _DoubleInput.DisplayFormat = value; }
+ }
+
+ #endregion
+
+ #region DisplayControlForCurrentCellOnly
+
+ ///
+ /// Gets or sets whether the control
+ /// will be displayed for the current cell only.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether the control will be displayed for the current cell only.")]
+ public bool DisplayControlForCurrentCellOnly
+ {
+ get { return (_DisplayControlForCurrentCellOnly); }
+
+ set
+ {
+ if (_DisplayControlForCurrentCellOnly != value)
+ {
+ _DisplayControlForCurrentCellOnly = value;
+ _DoubleInput.Invalidate();
+ }
+ }
+ }
+
+ #endregion
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_DoubleInput.Enabled); }
+ set { _DoubleInput.Enabled = value; }
+ }
+
+ #endregion
+
+ #region Increment
+
+ ///
+ /// Gets or sets the value to increment or decrement the value of the
+ /// control when the up or down buttons are clicked.
+ ///
+ [Browsable(true), DefaultValue(1)]
+ [Description("Indicates value to increment or decrement the value of the control when the up or down buttons are clicked. ")]
+ public double Increment
+ {
+ get { return (_DoubleInput.Increment); }
+ set { _DoubleInput.Increment = value; }
+ }
+
+ #endregion
+
+ #region InputHorizontalAlignment
+
+ ///
+ /// Gets or sets the input field alignment inside the control
+ ///
+ [Browsable(true), DefaultValue(eHorizontalAlignment.Right), Category("Appearance")]
+ [Description("Indicates alignment of input fields inside of the control.")]
+ public eHorizontalAlignment InputHorizontalAlignment
+ {
+ get { return (_DoubleInput.InputHorizontalAlignment); }
+ set { _DoubleInput.InputHorizontalAlignment = value; }
+ }
+
+ #endregion
+
+ #region LockUpdateChecked
+
+ ///
+ /// Gets or sets whether check box shown using ShowCheckBox
+ /// property which locks/unlocks the control update is checked.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether check box shown using ShowCheckBox property which locks/unlocks the control update is checked.")]
+ public bool LockUpdateChecked
+ {
+ get { return (_DoubleInput.LockUpdateChecked); }
+ set { _DoubleInput.LockUpdateChecked = value; }
+ }
+
+ #endregion
+
+ #region MaxValue
+
+ ///
+ /// Gets or sets the maximum value that can be entered.
+ ///
+ [Browsable(true), DefaultValue(double.MaxValue)]
+ [Description("Indicates maximum value that can be entered.")]
+ public double MaxValue
+ {
+ get { return (_DoubleInput.MaxValue); }
+ set { _DoubleInput.MaxValue = value; }
+ }
+
+ #endregion
+
+ #region MinValue
+
+ ///
+ /// Gets or sets the minimum value that can be entered.
+ ///
+ [Browsable(true), DefaultValue(double.MinValue)]
+ [Description("Indicates minimum value that can be entered.")]
+ public double MinValue
+ {
+ get { return (_DoubleInput.MinValue); }
+ set { _DoubleInput.MinValue = value; }
+ }
+
+ #endregion
+
+ #region ShowCheckBox
+
+ ///
+ /// Gets or sets a value indicating whether a check box is
+ /// displayed to the left of the input value. Set to true if a check box
+ /// is displayed to the left of the input value; otherwise, false. The default is false.
+ ///
+ /// When the ShowCheckBox property is set to true, a check box is displayed
+ /// to the left of the input in the control. When the check box is selected, the value
+ /// can be updated. When the check box is cleared, the value is unable to be changed.
+ /// You can handle the LockUpdateChanged event to be notified when this check box is checked
+ /// and unchecked. Use LockUpdateChecked property to get or sets whether check box is checked.
+ ///
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether a check box is displayed to the left of the input value which allows locking of the control.")]
+ public bool ShowCheckBox
+ {
+ get { return (_DoubleInput.ShowCheckBox); }
+ set { _DoubleInput.ShowCheckBox = value; }
+ }
+
+ #endregion
+
+ #region ShowUpDown
+
+ ///
+ /// Gets or sets a value indicating whether a spin button control
+ /// (up-down control) is used to adjust the current value. The default is false.
+ ///
+ /// When the ShowUpDown property is set to true, a spin button control
+ /// is shown to adjust value of currently focused input item. The value can
+ /// be adjusted by using the up and down buttons to change the value.
+ ///
+ ///
+ [Browsable(true), DefaultValue(false)]
+ public bool ShowUpDown
+ {
+ get { return (_DoubleInput.ShowUpDown); }
+ set { _DoubleInput.ShowUpDown = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Event processing
+
+ #region DoButtonClearClick
+
+ ///
+ /// DoButtonClearClick
+ ///
+ ///
+ ///
+ internal void DoButtonClearClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonClearClick != null)
+ ButtonClearClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustomClick
+
+ ///
+ /// DoButtonCustomClick
+ ///
+ ///
+ ///
+ internal void DoButtonCustomClick(object sender, EventArgs e)
+ {
+ if (ButtonCustomClick != null)
+ ButtonCustomClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustom2Click
+
+ ///
+ /// DoButtonCustom2Click
+ ///
+ ///
+ ///
+ internal void DoButtonCustom2Click(object sender, EventArgs e)
+ {
+ if (ButtonCustom2Click != null)
+ ButtonCustom2Click(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonDropDownClick
+
+ ///
+ /// DoButtonDropDownClick
+ ///
+ ///
+ ///
+ internal void DoButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonDropDownClick != null)
+ ButtonDropDownClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonFreeTextClick
+
+ ///
+ /// DoButtonFreeTextClick
+ ///
+ ///
+ ///
+ internal void DoButtonFreeTextClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonFreeTextClick != null)
+ ButtonFreeTextClick(this, e);
+ }
+
+ #endregion
+
+ #region DoConvertFreeTextEntry
+
+ ///
+ /// DoConvertFreeTextEntry
+ ///
+ ///
+ ///
+ internal void DoConvertFreeTextEntry(object sender, FreeTextEntryConversionEventArgs e)
+ {
+ if (ConvertFreeTextEntry != null)
+ ConvertFreeTextEntry(this, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewDoubleInputColumn dc = base.Clone() as DataGridViewDoubleInputColumn;
+
+ if (dc != null)
+ {
+ dc.DisplayFormat = DisplayFormat;
+ dc.Enabled = Enabled;
+ dc.Increment = Increment;
+ dc.InputHorizontalAlignment = InputHorizontalAlignment;
+ dc.LockUpdateChecked = LockUpdateChecked;
+ dc.MaxValue = MaxValue;
+ dc.MinValue = MinValue;
+ dc.ShowCheckBox = ShowCheckBox;
+ dc.ShowUpDown = ShowUpDown;
+
+ dc.DisplayControlForCurrentCellOnly = DisplayControlForCurrentCellOnly;
+
+ dc.BackgroundStyle.ApplyStyle(DoubleInput.BackgroundStyle);
+ dc.BackgroundStyle.Class = DoubleInput.BackgroundStyle.Class;
+
+ DoubleInput.ButtonClear.CopyToItem(dc.DoubleInput.ButtonClear);
+ DoubleInput.ButtonDropDown.CopyToItem(dc.DoubleInput.ButtonDropDown);
+ DoubleInput.ButtonFreeText.CopyToItem(dc.DoubleInput.ButtonFreeText);
+ DoubleInput.ButtonCustom.CopyToItem(dc.DoubleInput.ButtonCustom);
+ DoubleInput.ButtonCustom2.CopyToItem(dc.DoubleInput.ButtonCustom2);
+ }
+
+ return (dc);
+ }
+
+ #endregion
+
+ #region Dispose
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing == true)
+ _DoubleInput.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDoubleInput/DataGridViewDoubleInputEditingControl.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDoubleInput/DataGridViewDoubleInputEditingControl.cs
new file mode 100644
index 00000000..69c1015f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewDoubleInput/DataGridViewDoubleInputEditingControl.cs
@@ -0,0 +1,211 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewDoubleInputEditingControl : DoubleInput, IDataGridViewEditingControl
+ {
+ #region Private variables
+
+ private DataGridView _DataGridView;
+
+ private int _RowIndex;
+ private bool _ValueChanged;
+ private bool _EditCancelled;
+
+ #endregion
+
+ #region OnValueChanged
+
+ ///
+ /// Handles OnValueChanged events
+ ///
+ ///
+ protected override void OnValueChanged(EventArgs e)
+ {
+ _ValueChanged = true;
+
+ _DataGridView.NotifyCurrentCellDirty(true);
+
+ base.OnValueChanged(e);
+ }
+
+ #endregion
+
+ #region Internal properties
+
+ ///
+ /// Gets or sets the Edit state
+ ///
+ internal bool EditCancelled
+ {
+ get { return (_EditCancelled); }
+ set { _EditCancelled = value; }
+ }
+
+ #endregion
+
+ #region IDataGridViewEditingControl Members
+
+ #region Public properties
+
+ #region EditingControlDataGridView
+
+ ///
+ /// Gets or sets the DataGridView
+ ///
+ public DataGridView EditingControlDataGridView
+ {
+ get { return (_DataGridView); }
+ set {_DataGridView = value; }
+ }
+
+ #endregion
+
+ #region EditingControlFormattedValue
+
+ ///
+ /// Gets or sets the Control Formatted Value
+ ///
+ public object EditingControlFormattedValue
+ {
+ get { return (Value.ToString()); }
+
+ set
+ {
+ string newValue = value as string;
+
+ if (newValue != null)
+ Value = int.Parse(newValue);
+ }
+ }
+
+ #endregion
+
+ #region EditingControlRowIndex
+
+ ///
+ /// Gets or sets the Control RoeIndex
+ ///
+ public int EditingControlRowIndex
+ {
+ get { return (_RowIndex); }
+ set { _RowIndex = value; }
+ }
+
+ #endregion
+
+ #region EditingControlValueChanged
+
+ ///
+ /// Gets or sets the Control ValueChanged state
+ ///
+ public bool EditingControlValueChanged
+ {
+ get { return (_ValueChanged); }
+ set { _ValueChanged = value; }
+ }
+
+ #endregion
+
+ #region EditingPanelCursor
+
+ ///
+ /// Gets the Panel Cursor
+ ///
+ public Cursor EditingPanelCursor
+ {
+ get { return (base.Cursor); }
+ }
+
+ #endregion
+
+ #region RepositionEditingControlOnValueChange
+
+ ///
+ /// Gets whether to RepositionEditingControlOnValueChange
+ ///
+ public bool RepositionEditingControlOnValueChange
+ {
+ get { return (false); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region ApplyCellStyleToEditingControl
+
+ ///
+ /// ApplyCellStyleToEditingControl
+ ///
+ ///
+ public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ Font = dataGridViewCellStyle.Font;
+
+ ForeColor = dataGridViewCellStyle.ForeColor;
+ BackColor = dataGridViewCellStyle.BackColor;
+ }
+
+ #endregion
+
+ #region GetEditingControlFormattedValue
+
+ ///
+ /// Gets EditingControlFormattedValue
+ ///
+ ///
+ ///
+ public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
+ {
+ return (EditingControlFormattedValue);
+ }
+
+ #endregion
+
+ #region EditingControlWantsInputKey
+
+ ///
+ /// Gets whether the given key wants to be processed
+ /// by the Control
+ ///
+ ///
+ ///
+ ///
+ public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
+ {
+ if ((keyData & Keys.Right) == Keys.Right)
+ return (true);
+
+ if ((keyData & Keys.Left) == Keys.Left)
+ return (true);
+
+ if ((keyData & Keys.Escape) == Keys.Escape)
+ _EditCancelled = true;
+
+ return (dataGridViewWantsInputKey == false);
+ }
+
+ #endregion
+
+ #region PrepareEditingControlForEdit
+
+ ///
+ /// PrepareEditingControlForEdit
+ ///
+ ///
+ public void PrepareEditingControlForEdit(bool selectAll)
+ {
+ }
+
+ #endregion
+
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIntegerInput/DataGridViewIntegerInputCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIntegerInput/DataGridViewIntegerInputCell.cs
new file mode 100644
index 00000000..0901f033
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIntegerInput/DataGridViewIntegerInputCell.cs
@@ -0,0 +1,724 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Media;
+using System.Windows.Forms;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewIntegerInputCell : DataGridViewTextBoxCell
+ {
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (typeof(DataGridViewIntegerInputEditingControl)); }
+ }
+
+ #endregion
+
+ #region FormattedValueType
+
+ ///
+ /// FormattedValueType
+ ///
+ public override Type FormattedValueType
+ {
+ get { return (typeof(string)); }
+ }
+
+ #endregion
+
+ #region ValueType
+
+ public override Type ValueType
+ {
+ get { return (typeof(int)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region InitializeEditingControl
+
+ ///
+ /// InitializeEditingControl
+ ///
+ ///
+ ///
+ ///
+ public override void InitializeEditingControl(int rowIndex,
+ object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ DetachEditingControl();
+
+ base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
+
+ DataGridViewIntegerInputEditingControl ctl =
+ (DataGridViewIntegerInputEditingControl)DataGridView.EditingControl;
+
+ DataGridViewIntegerInputColumn oc = OwningColumn as DataGridViewIntegerInputColumn;
+
+ if (oc != null)
+ {
+ IntegerInput di = oc.IntegerInput;
+
+ ctl.Value = GetValue(DataGridView[OwningColumn.Index, rowIndex].Value);
+
+ ctl.DisplayFormat = di.DisplayFormat;
+ ctl.Enabled = di.Enabled;
+ ctl.Increment = di.Increment;
+ ctl.InputHorizontalAlignment = GetHorizontalAlignment(dataGridViewCellStyle.Alignment);
+ ctl.LockUpdateChecked = di.LockUpdateChecked;
+ ctl.MaxValue = di.MaxValue;
+ ctl.MinValue = di.MinValue;
+ ctl.ShowCheckBox = di.ShowCheckBox;
+ ctl.ShowUpDown = di.ShowUpDown;
+
+ ctl.BackgroundStyle.ApplyStyle(di.BackgroundStyle);
+ ctl.BackgroundStyle.Class = di.BackgroundStyle.Class;
+
+ di.ButtonClear.CopyToItem(ctl.ButtonClear);
+ di.ButtonCustom.CopyToItem(ctl.ButtonCustom);
+ di.ButtonCustom2.CopyToItem(ctl.ButtonCustom2);
+ di.ButtonDropDown.CopyToItem(ctl.ButtonDropDown);
+ di.ButtonFreeText.CopyToItem(ctl.ButtonFreeText);
+
+ ctl.ButtonClearClick += ButtonClearClick;
+ ctl.ButtonCustomClick += ButtonCustomClick;
+ ctl.ButtonCustom2Click += ButtonCustom2Click;
+ ctl.ButtonDropDownClick += ButtonDropDownClick;
+ ctl.ButtonFreeTextClick += ButtonFreeTextClick;
+ ctl.ConvertFreeTextEntry += ConvertFreeTextEntry;
+
+ ctl.EditCancelled = false;
+ }
+ }
+
+ #endregion
+
+ #region DetachEditingControl
+
+ ///
+ /// DetachEditingControl
+ ///
+ public override void DetachEditingControl()
+ {
+ if (DataGridView != null && DataGridView.EditingControl != null)
+ {
+ DataGridViewIntegerInputEditingControl di =
+ DataGridView.EditingControl as DataGridViewIntegerInputEditingControl;
+
+ if (di != null)
+ {
+ di.ButtonClearClick -= ButtonClearClick;
+ di.ButtonDropDownClick -= ButtonDropDownClick;
+ di.ButtonFreeTextClick -= ButtonFreeTextClick;
+ di.ButtonCustomClick -= ButtonCustomClick;
+ di.ButtonCustom2Click -= ButtonCustom2Click;
+ di.ConvertFreeTextEntry -= ConvertFreeTextEntry;
+
+ if (di.EditCancelled == true)
+ {
+ di.EditCancelled = false;
+
+ SystemSounds.Beep.Play();
+ }
+ }
+ }
+
+ base.DetachEditingControl();
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region ButtonClearClick
+
+ ///
+ /// ButtonClearClick
+ ///
+ ///
+ ///
+ void ButtonClearClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewIntegerInputColumn)OwningColumn).DoButtonClearClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustomClick
+
+ ///
+ /// ButtonCustomClick
+ ///
+ ///
+ ///
+ void ButtonCustomClick(object sender, EventArgs e)
+ {
+ ((DataGridViewIntegerInputColumn)OwningColumn).DoButtonCustomClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustom2Click
+
+ ///
+ /// ButtonCustom2Click
+ ///
+ ///
+ ///
+ void ButtonCustom2Click(object sender, EventArgs e)
+ {
+ ((DataGridViewIntegerInputColumn)OwningColumn).DoButtonCustom2Click(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonDropDownClick
+
+ ///
+ /// ButtonDropDownClick
+ ///
+ ///
+ ///
+ void ButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewIntegerInputColumn)OwningColumn).DoButtonDropDownClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonFreeTextClick
+
+ ///
+ /// ButtonFreeTextClick
+ ///
+ ///
+ ///
+ void ButtonFreeTextClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewIntegerInputColumn)OwningColumn).DoButtonFreeTextClick(sender, e);
+ }
+
+ #endregion
+
+ #region ConvertFreeTextEntry
+
+ ///
+ /// ConvertFreeTextEntry
+ ///
+ ///
+ ///
+ void ConvertFreeTextEntry(object sender, FreeTextEntryConversionEventArgs e)
+ {
+ ((DataGridViewIntegerInputColumn)OwningColumn).DoConvertFreeTextEntry(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PositionEditingControl
+
+ ///
+ /// PositionEditingControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override void PositionEditingControl(bool setLocation, bool setSize, Rectangle cellBounds,
+ Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded,
+ bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
+ {
+ Rectangle editingControlBounds =
+ PositionEditingPanel(cellBounds, cellClip, cellStyle, singleVerticalBorderAdded,
+ singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow);
+
+ editingControlBounds = GetAdjustedEditingControlBounds(editingControlBounds, cellStyle);
+
+ DataGridView.EditingControl.Location = new Point(editingControlBounds.X, editingControlBounds.Y);
+ DataGridView.EditingControl.Size = new Size(editingControlBounds.Width, editingControlBounds.Height);
+ }
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetCellBounds(editingControlBounds);
+
+ if (r.Height < editingControlBounds.Height)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.MiddleLeft:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height) / 2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ editingControlBounds.Width = Math.Max(1, editingControlBounds.Width);
+ editingControlBounds.Height = Math.Max(1, r.Height);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ #region GetPreferredSize
+
+ ///
+ /// GetPreferredSize
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Size GetPreferredSize(Graphics graphics,
+ DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ {
+ if (DataGridView == null)
+ return (new Size(-1, -1));
+
+ Size preferredSize = base.GetPreferredSize(graphics, cellStyle, rowIndex, constraintSize);
+
+ DataGridViewIntegerInputColumn oc = OwningColumn as DataGridViewIntegerInputColumn;
+
+ if (oc != null)
+ {
+ IntegerInput ip = oc.IntegerInput;
+
+ preferredSize.Height = ip.Height;
+
+ if (constraintSize.Width == 0)
+ {
+ preferredSize.Width += GetImageWidth(ip.ButtonClear);
+ preferredSize.Width += GetImageWidth(ip.ButtonCustom);
+ preferredSize.Width += GetImageWidth(ip.ButtonCustom2);
+ preferredSize.Width += GetImageWidth(ip.ButtonDropDown);
+ preferredSize.Width += GetImageWidth(ip.ButtonFreeText);
+
+ if (ip.ShowUpDown == true)
+ preferredSize.Width += 16;
+
+ if (ip.ShowCheckBox == true)
+ preferredSize.Width += 16;
+ }
+ }
+
+ return (preferredSize);
+ }
+
+ #endregion
+
+ #region GetFormattedValue
+
+ protected override object GetFormattedValue(object value, int rowIndex,
+ ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter,
+ TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
+ {
+ DataGridViewIntegerInputColumn oc = OwningColumn as DataGridViewIntegerInputColumn;
+
+ if (oc != null)
+ {
+ IntegerInput ip = oc.IntegerInput;
+ ip.Value = GetValue(value);
+
+ return (ip.Text);
+ }
+
+ return (base.GetFormattedValue(value, rowIndex,
+ ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
+ }
+
+ #endregion
+
+ #region GetImageWidth
+
+ private int GetImageWidth(InputButtonSettings ibs)
+ {
+ if (ibs.Visible == true)
+ return (ibs.Image != null ? ibs.Image.Width : 16);
+
+ return (0);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
+ DataGridViewElementStates elementState, object value, object formattedValue,
+ string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle,
+ DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewIntegerInputColumn oc = (DataGridViewIntegerInputColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintCellBackground(g, cellStyle, rBk);
+ PaintCellContent(g, cellBounds, rowIndex, value, cellStyle, paintParts);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintCellBackground
+
+ ///
+ /// Paints the cell background
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintCellContent
+
+ ///
+ /// Paints the cell content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellContent(Graphics g, Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts)
+ {
+ DataGridViewIntegerInputColumn oc = (DataGridViewIntegerInputColumn)OwningColumn;
+ IntegerInput di = oc.IntegerInput;
+
+ Point ptCurrentCell = DataGridView.CurrentCellAddress;
+ bool cellCurrent = ptCurrentCell.X == ColumnIndex && ptCurrentCell.Y == rowIndex;
+ bool cellEdited = cellCurrent && DataGridView.EditingControl != null;
+
+ // If the cell is in editing mode, there is nothing else to paint
+
+ if (cellEdited == false && rowIndex < DataGridView.RowCount)
+ {
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ {
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ di.Font = cellStyle.Font;
+ di.ForeColor = cellStyle.ForeColor;
+ di.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+
+ di.BackgroundStyle.TextColor = cellStyle.ForeColor;
+ di.BackgroundStyle.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+ di.InputHorizontalAlignment = GetHorizontalAlignment(cellStyle.Alignment);
+
+ di.Value = GetValue(value);
+
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+
+ if (oc.DisplayControlForCurrentCellOnly == false)
+ DrawControl(di, r, g);
+ else
+ DrawText(di, r, g);
+ }
+ }
+ }
+
+ #region DrawControl
+
+ ///
+ /// DrawControl
+ ///
+ ///
+ ///
+ ///
+ private void DrawControl(IntegerInput di, Rectangle r, Graphics g)
+ {
+ GraphicsState gs = g.Save();
+
+ try
+ {
+ g.TranslateTransform(r.X, r.Y);
+
+ di.Width = r.Width;
+ di.InternalPaint(new PaintEventArgs(g, Rectangle.Empty));
+ }
+ finally
+ {
+ g.Restore(gs);
+ }
+ }
+
+ #endregion
+
+ #region DrawText
+
+ ///
+ /// DrawText
+ ///
+ ///
+ ///
+ ///
+ private void DrawText(IntegerInput di, Rectangle r, Graphics g)
+ {
+ r.Inflate(-2, 0);
+
+ eTextFormat tf = eTextFormat.VerticalCenter;
+
+ switch (di.InputHorizontalAlignment)
+ {
+ case eHorizontalAlignment.Center:
+ tf |= eTextFormat.HorizontalCenter;
+ break;
+
+ case eHorizontalAlignment.Right:
+ tf |= eTextFormat.Right;
+ break;
+ }
+
+ TextDrawing.DrawString(g, di.Text, di.Font, di.ForeColor, r, tf);
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewIntegerInputColumn oc = (DataGridViewIntegerInputColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetCellBounds
+
+ ///
+ /// Gets the button bounds for the given cell
+ ///
+ ///
+ ///
+ private Rectangle GetCellBounds(Rectangle cellBounds)
+ {
+ DataGridViewIntegerInputColumn oc = (DataGridViewIntegerInputColumn)OwningColumn;
+
+ Size size = oc.IntegerInput.Size;
+
+ cellBounds.Location = new Point(1, 1);
+
+ cellBounds.Width = Math.Min(size.Width, cellBounds.Width);
+ cellBounds.Width -= oc.DividerWidth;
+ cellBounds.Height = size.Height;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetValue
+
+ ///
+ /// GetValue
+ ///
+ ///
+ ///
+ private int GetValue(object value)
+ {
+ if (value == Convert.DBNull ||
+ (value is string && String.IsNullOrEmpty((string) value) == true))
+ {
+ return (0);
+ }
+
+ return (Convert.ToInt32(value));
+ }
+
+ #endregion
+
+ #region GetHorizontalAlignment
+
+ ///
+ /// GetHorizontalAlignment
+ ///
+ ///
+ ///
+ private eHorizontalAlignment GetHorizontalAlignment(DataGridViewContentAlignment alignment)
+ {
+ switch (alignment)
+ {
+ case DataGridViewContentAlignment.TopCenter:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.BottomCenter:
+ return (eHorizontalAlignment.Center);
+
+ case DataGridViewContentAlignment.TopRight:
+ case DataGridViewContentAlignment.MiddleRight:
+ case DataGridViewContentAlignment.BottomRight:
+ return (eHorizontalAlignment.Right);
+
+ default:
+ return (eHorizontalAlignment.Left);
+ }
+ }
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIntegerInput/DataGridViewIntegerInputColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIntegerInput/DataGridViewIntegerInputColumn.cs
new file mode 100644
index 00000000..e40feae0
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIntegerInput/DataGridViewIntegerInputColumn.cs
@@ -0,0 +1,597 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewButtonXColumn), "IntegerInput.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewIntegerInputColumn : DataGridViewTextBoxColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ ///
+ /// Occurs right before a DateTimeInput Cell is painted
+ ///
+ [Description("Occurs right before an IntegerInput Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ ///
+ /// Occurs when Clear button is clicked and allows you
+ /// to cancel the default action performed by the button
+ ///
+ [Description("Occurs when Clear button is clicked and allows you to cancel the default action performed by the button.")]
+ public event EventHandler ButtonClearClick;
+
+ ///
+ /// Occurs when ButtonCustom control is clicked
+ ///
+ [Description("Occurs when ButtonCustom control is clicked.")]
+ public event EventHandler ButtonCustomClick;
+
+ ///
+ /// Occurs when ButtonCustom2 control is clicked
+ ///
+ [Description("Occurs when ButtonCustom2 control is clicked.")]
+ public event EventHandler ButtonCustom2Click;
+
+ ///
+ /// Occurs when Drop-Down button that shows calendar
+ /// is clicked and allows you to cancel showing of the popup
+ ///
+ [Description("Occurs when Drop-Down button that shows calendar is clicked and allows you to cancel showing of the popup.")]
+ public event EventHandler ButtonDropDownClick;
+
+ ///
+ /// Occurs when Free-Text button is clicked
+ /// and allows you to cancel its default action
+ ///
+ [Description("Occurs when Free-Text button is clicked and allows you to cancel its default action.")]
+ public event EventHandler ButtonFreeTextClick;
+
+ ///
+ /// Occurs if Free-Text entry value is not natively recognized by
+ /// the control and provides you with opportunity to convert that
+ /// value to the value the control expects
+ ///
+ [Description("Occurs if Free-Text entry value is not natively recognized by the control and provides you with opportunity to convert that value to the value the control expects.")]
+ public event EventHandler ConvertFreeTextEntry;
+
+ #endregion
+
+ #region Private variables
+
+ private IntegerInput _IngegerInput;
+ private Bitmap _CellBitmap;
+ private bool _DisplayControlForCurrentCellOnly = true;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewIntegerInputColumn()
+ {
+ CellTemplate = new DataGridViewIntegerInputCell();
+
+ _IngegerInput = new IntegerInput();
+
+ _IngegerInput.BackgroundStyle.Class = ElementStyleClassKeys.DataGridViewNumericBorderKey;
+ _IngegerInput.Visible = false;
+ }
+
+ #region Internal properties
+
+ #region IntegerInput
+
+ ///
+ /// IntegerInput
+ ///
+ internal IntegerInput IntegerInput
+ {
+ get { return (_IngegerInput); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region BackgroundStyle
+
+ ///
+ /// Specifies the background style of the control.
+ ///
+ [Browsable(true), Category("Style")]
+ [Description("Gets or sets control background style.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return (_IngegerInput.BackgroundStyle); }
+ }
+
+ ///
+ /// Resets style to default value. Used by windows forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackgroundStyle()
+ {
+ _IngegerInput.ResetBackgroundStyle();
+
+ _IngegerInput.BackgroundStyle.Class = "TextBoxBorder";
+ _IngegerInput.BackgroundStyle.CornerType = eCornerType.Square;
+ }
+
+ #endregion
+
+ #region ButtonClear
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that clears the content of the control when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that clears the content of the control when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonClear
+ {
+ get { return (_IngegerInput.ButtonClear); }
+ }
+
+ #endregion
+
+ #region ButtonCustom
+
+ ///
+ /// Gets the object that describes the settings for the custom button
+ /// that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom
+ {
+ get { return (_IngegerInput.ButtonCustom); }
+ }
+
+ #endregion
+
+ #region ButtonCustom2
+
+ ///
+ /// Gets the object that describes the settings for the custom button that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom2
+ {
+ get { return (_IngegerInput.ButtonCustom2); }
+ }
+
+ #endregion
+
+ #region ButtonDropDown
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that shows drop-down when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that shows drop-down when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonDropDown
+ {
+ get { return (_IngegerInput.ButtonDropDown); }
+ }
+
+ #endregion
+
+ #region ButtonFreeText
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that switches the control into the free-text entry mode when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that switches the control into the free-text entry mode when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonFreeText
+ {
+ get { return (_IngegerInput.ButtonFreeText); }
+ }
+
+ #endregion
+
+ #region DisplayFormat
+
+ ///
+ /// Gets or sets the Numeric String Format that is used to format
+ /// the numeric value entered for display purpose. Read more about
+ /// available formats in MSDN under "Standard Numeric Format Strings"
+ /// and "Custom Numeric Format Strings" topics.
+ ///
+ /// The format specified here indicates the format for display purpose
+ /// only, not for the input purpose. For example to display the number
+ /// in system Currency format set the DisplayFormat to 'C'.
+ ///
+ ///
+ [Browsable(true), DefaultValue("")]
+ [Description("Indicates Numeric String Format that is used to format the numeric value entered for display purpose.")]
+ public string DisplayFormat
+ {
+ get { return (_IngegerInput.DisplayFormat); }
+ set { _IngegerInput.DisplayFormat = value; }
+ }
+
+ #endregion
+
+ #region DisplayControlForCurrentCellOnly
+
+ ///
+ /// Gets or sets whether the control
+ /// will be displayed for the current cell only.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether the control will be displayed for the current cell only.")]
+ public bool DisplayControlForCurrentCellOnly
+ {
+ get { return (_DisplayControlForCurrentCellOnly); }
+
+ set
+ {
+ if (_DisplayControlForCurrentCellOnly != value)
+ {
+ _DisplayControlForCurrentCellOnly = value;
+ _IngegerInput.Invalidate();
+ }
+ }
+ }
+
+ #endregion
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_IngegerInput.Enabled); }
+ set { _IngegerInput.Enabled = value; }
+ }
+
+ #endregion
+
+ #region Increment
+
+ ///
+ /// Gets or sets the value to increment or decrement the value of the
+ /// control when the up or down buttons are clicked.
+ ///
+ [Browsable(true), DefaultValue(1)]
+ [Description("Indicates value to increment or decrement the value of the control when the up or down buttons are clicked. ")]
+ public int Increment
+ {
+ get { return (_IngegerInput.Increment); }
+ set { _IngegerInput.Increment = value; }
+ }
+
+ #endregion
+
+ #region InputHorizontalAlignment
+
+ ///
+ /// Gets or sets the input field alignment inside the control
+ ///
+ [Browsable(true), DefaultValue(eHorizontalAlignment.Right), Category("Appearance")]
+ [Description("Indicates alignment of input fields inside of the control.")]
+ public eHorizontalAlignment InputHorizontalAlignment
+ {
+ get { return (_IngegerInput.InputHorizontalAlignment); }
+ set { _IngegerInput.InputHorizontalAlignment = value; }
+ }
+
+ #endregion
+
+ #region LockUpdateChecked
+
+ ///
+ /// Gets or sets whether check box shown using ShowCheckBox
+ /// property which locks/unlocks the control update is checked.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether check box shown using ShowCheckBox property which locks/unlocks the control update is checked.")]
+ public bool LockUpdateChecked
+ {
+ get { return (_IngegerInput.LockUpdateChecked); }
+ set { _IngegerInput.LockUpdateChecked = value; }
+ }
+
+ #endregion
+
+ #region MaxValue
+
+ ///
+ /// Gets or sets the maximum value that can be entered.
+ ///
+ [Browsable(true), DefaultValue(int.MaxValue)]
+ [Description("Indicates maximum value that can be entered.")]
+ public int MaxValue
+ {
+ get { return (_IngegerInput.MaxValue); }
+ set { _IngegerInput.MaxValue = value; }
+ }
+
+ #endregion
+
+ #region MinValue
+
+ ///
+ /// Gets or sets the minimum value that can be entered.
+ ///
+ [Browsable(true), DefaultValue(int.MinValue)]
+ [Description("Indicates minimum value that can be entered.")]
+ public int MinValue
+ {
+ get { return (_IngegerInput.MinValue); }
+ set { _IngegerInput.MinValue = value; }
+ }
+
+ #endregion
+
+ #region ShowCheckBox
+
+ ///
+ /// Gets or sets a value indicating whether a check box is
+ /// displayed to the left of the input value. Set to true if a check box
+ /// is displayed to the left of the input value; otherwise, false. The default is false.
+ ///
+ /// When the ShowCheckBox property is set to true, a check box is displayed
+ /// to the left of the input in the control. When the check box is selected, the value
+ /// can be updated. When the check box is cleared, the value is unable to be changed.
+ /// You can handle the LockUpdateChanged event to be notified when this check box is checked
+ /// and unchecked. Use LockUpdateChecked property to get or sets whether check box is checked.
+ ///
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether a check box is displayed to the left of the input value which allows locking of the control.")]
+ public bool ShowCheckBox
+ {
+ get { return (_IngegerInput.ShowCheckBox); }
+ set { _IngegerInput.ShowCheckBox = value; }
+ }
+
+ #endregion
+
+ #region ShowUpDown
+
+ ///
+ /// Gets or sets a value indicating whether a spin button control
+ /// (up-down control) is used to adjust the current value. The default is false.
+ ///
+ /// When the ShowUpDown property is set to true, a spin button control
+ /// is shown to adjust value of currently focused input item. The value can
+ /// be adjusted by using the up and down buttons to change the value.
+ ///
+ ///
+ [Browsable(true), DefaultValue(false)]
+ public bool ShowUpDown
+ {
+ get { return (_IngegerInput.ShowUpDown); }
+ set { _IngegerInput.ShowUpDown = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Event processing
+
+ #region DoButtonClearClick
+
+ ///
+ /// DoButtonClearClick
+ ///
+ ///
+ ///
+ internal void DoButtonClearClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonClearClick != null)
+ ButtonClearClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustomClick
+
+ ///
+ /// DoButtonCustomClick
+ ///
+ ///
+ ///
+ internal void DoButtonCustomClick(object sender, EventArgs e)
+ {
+ if (ButtonCustomClick != null)
+ ButtonCustomClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustom2Click
+
+ ///
+ /// DoButtonCustom2Click
+ ///
+ ///
+ ///
+ internal void DoButtonCustom2Click(object sender, EventArgs e)
+ {
+ if (ButtonCustom2Click != null)
+ ButtonCustom2Click(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonDropDownClick
+
+ ///
+ /// DoButtonDropDownClick
+ ///
+ ///
+ ///
+ internal void DoButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonDropDownClick != null)
+ ButtonDropDownClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonFreeTextClick
+
+ ///
+ /// DoButtonFreeTextClick
+ ///
+ ///
+ ///
+ internal void DoButtonFreeTextClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonFreeTextClick != null)
+ ButtonFreeTextClick(this, e);
+ }
+
+ #endregion
+
+ #region DoConvertFreeTextEntry
+
+ ///
+ /// DoConvertFreeTextEntry
+ ///
+ ///
+ ///
+ internal void DoConvertFreeTextEntry(object sender, FreeTextEntryConversionEventArgs e)
+ {
+ if (ConvertFreeTextEntry != null)
+ ConvertFreeTextEntry(this, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewIntegerInputColumn dc = base.Clone() as DataGridViewIntegerInputColumn;
+
+ if (dc != null)
+ {
+ dc.DisplayFormat = DisplayFormat;
+ dc.Enabled = Enabled;
+ dc.Increment = Increment;
+ dc.InputHorizontalAlignment = InputHorizontalAlignment;
+ dc.LockUpdateChecked = LockUpdateChecked;
+ dc.MaxValue = MaxValue;
+ dc.MinValue = MinValue;
+ dc.ShowCheckBox = ShowCheckBox;
+ dc.ShowUpDown = ShowUpDown;
+
+ dc.DisplayControlForCurrentCellOnly = DisplayControlForCurrentCellOnly;
+
+ dc.BackgroundStyle.ApplyStyle(IntegerInput.BackgroundStyle);
+ dc.BackgroundStyle.Class = IntegerInput.BackgroundStyle.Class;
+
+ IntegerInput.ButtonClear.CopyToItem(dc.IntegerInput.ButtonClear);
+ IntegerInput.ButtonDropDown.CopyToItem(dc.IntegerInput.ButtonDropDown);
+ IntegerInput.ButtonFreeText.CopyToItem(dc.IntegerInput.ButtonFreeText);
+ IntegerInput.ButtonCustom.CopyToItem(dc.IntegerInput.ButtonCustom);
+ IntegerInput.ButtonCustom2.CopyToItem(dc.IntegerInput.ButtonCustom2);
+ }
+
+ return (dc);
+ }
+
+ #endregion
+
+ #region Dispose
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing == true)
+ _IngegerInput.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIntegerInput/DataGridViewIntegerInputEditingControl.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIntegerInput/DataGridViewIntegerInputEditingControl.cs
new file mode 100644
index 00000000..dfaa04b7
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIntegerInput/DataGridViewIntegerInputEditingControl.cs
@@ -0,0 +1,210 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewIntegerInputEditingControl : IntegerInput, IDataGridViewEditingControl
+ {
+ #region Private variables
+
+ private DataGridView _DataGridView;
+
+ private int _RowIndex;
+ private bool _ValueChanged;
+ private bool _EditCancelled;
+
+ #endregion
+
+ #region OnValueChanged
+
+ ///
+ /// Handles OnValueChanged events
+ ///
+ ///
+ protected override void OnValueChanged(EventArgs e)
+ {
+ _ValueChanged = true;
+
+ _DataGridView.NotifyCurrentCellDirty(true);
+
+ base.OnValueChanged(e);
+ }
+
+ #endregion
+
+ #region Internal properties
+
+ ///
+ /// Gets or sets the Edit state
+ ///
+ internal bool EditCancelled
+ {
+ get { return (_EditCancelled); }
+ set { _EditCancelled = value; }
+ }
+
+ #endregion
+
+ #region IDataGridViewEditingControl Members
+
+ #region Public properties
+
+ #region EditingControlDataGridView
+
+ ///
+ /// Gets or sets the DataGridView
+ ///
+ public DataGridView EditingControlDataGridView
+ {
+ get { return (_DataGridView); }
+ set { _DataGridView = value; }
+ }
+
+ #endregion
+
+ #region EditingControlFormattedValue
+
+ ///
+ /// Gets or sets the Control Formatted Value
+ ///
+ public object EditingControlFormattedValue
+ {
+ get { return (this.Value.ToString()); }
+
+ set
+ {
+ string newValue = value as string;
+
+ if (newValue != null)
+ Value = int.Parse(newValue);
+ }
+ }
+
+ #endregion
+
+ #region EditingControlRowIndex
+
+ ///
+ /// Gets or sets the Control RoeIndex
+ ///
+ public int EditingControlRowIndex
+ {
+ get { return (_RowIndex); }
+ set { _RowIndex = value; }
+ }
+
+ #endregion
+
+ #region EditingControlValueChanged
+
+ ///
+ /// Gets or sets the Control ValueChanged state
+ ///
+ public bool EditingControlValueChanged
+ {
+ get { return (_ValueChanged); }
+ set { _ValueChanged = value; }
+ }
+
+ #endregion
+
+ #region EditingPanelCursor
+
+ ///
+ /// Gets the Panel Cursor
+ ///
+ public Cursor EditingPanelCursor
+ {
+ get { return (base.Cursor); }
+ }
+
+ #endregion
+
+ #region RepositionEditingControlOnValueChange
+
+ ///
+ /// Gets whether to RepositionEditingControlOnValueChange
+ ///
+ public bool RepositionEditingControlOnValueChange
+ {
+ get { return (false); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region ApplyCellStyleToEditingControl
+
+ ///
+ /// ApplyCellStyleToEditingControl
+ ///
+ ///
+ public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ Font = dataGridViewCellStyle.Font;
+
+ ForeColor = dataGridViewCellStyle.ForeColor;
+ BackColor = dataGridViewCellStyle.BackColor;
+ }
+
+ #endregion
+
+ #region GetEditingControlFormattedValue
+
+ ///
+ /// Gets EditingControlFormattedValue
+ ///
+ ///
+ ///
+ public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
+ {
+ return (EditingControlFormattedValue);
+ }
+
+ #endregion
+
+ #region EditingControlWantsInputKey
+
+ ///
+ /// Gets whether the given key wants to be processed
+ /// by the Control
+ ///
+ ///
+ ///
+ ///
+ public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
+ {
+ if ((keyData & Keys.Right) == Keys.Right)
+ return (true);
+
+ if ((keyData & Keys.Left) == Keys.Left)
+ return (true);
+
+ if ((keyData & Keys.Escape) == Keys.Escape)
+ _EditCancelled = true;
+
+ return (dataGridViewWantsInputKey == false);
+ }
+
+ #endregion
+
+ #region PrepareEditingControlForEdit
+
+ ///
+ /// PrepareEditingControlForEdit
+ ///
+ ///
+ public void PrepareEditingControlForEdit(bool selectAll)
+ {
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIpAddressInput/DataGridViewIpAddressInputCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIpAddressInput/DataGridViewIpAddressInputCell.cs
new file mode 100644
index 00000000..4d27e7c8
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIpAddressInput/DataGridViewIpAddressInputCell.cs
@@ -0,0 +1,711 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Media;
+using System.Windows.Forms;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewIpAddressInputCell : DataGridViewTextBoxCell
+ {
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (typeof(DataGridViewIpAddressInputEditingControl)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region InitializeEditingControl
+
+ ///
+ /// InitializeEditingControl
+ ///
+ ///
+ ///
+ ///
+ public override void InitializeEditingControl(int rowIndex,
+ object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ DetachEditingControl();
+
+ base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
+
+ DataGridViewIpAddressInputEditingControl ctl =
+ (DataGridViewIpAddressInputEditingControl)DataGridView.EditingControl;
+
+ DataGridViewIpAddressInputColumn oc = (DataGridViewIpAddressInputColumn)OwningColumn;
+ IpAddressInput tb = oc.IpAddressInput;
+
+ ctl.Font = dataGridViewCellStyle.Font;
+ ctl.ForeColor = dataGridViewCellStyle.ForeColor;
+ ctl.BackColor = dataGridViewCellStyle.BackColor;
+
+ ctl.AllowEmptyState = tb.AllowEmptyState;
+ ctl.AutoOffFreeTextEntry = tb.AutoOffFreeTextEntry;
+ ctl.AutoOverwrite = tb.AutoOverwrite;
+ ctl.AutoResolveFreeTextEntries = tb.AutoResolveFreeTextEntries;
+ ctl.DropDownControl = tb.DropDownControl;
+ ctl.Enabled = tb.Enabled;
+ ctl.FocusHighlightColor = tb.FocusHighlightColor;
+ ctl.FocusHighlightEnabled = tb.FocusHighlightEnabled;
+ ctl.FreeTextEntryMode = tb.FreeTextEntryMode;
+ ctl.ImeMode = tb.ImeMode;
+ ctl.InputHorizontalAlignment = GetHorizontalAlignment(dataGridViewCellStyle.Alignment);
+ ctl.IsInputReadOnly = tb.IsInputReadOnly;
+ ctl.LockUpdateChecked = tb.LockUpdateChecked;
+ ctl.RightToLeft = tb.RightToLeft;
+ ctl.SelectNextInputCharacters = tb.SelectNextInputCharacters;
+ ctl.ShowCheckBox = tb.ShowCheckBox;
+ ctl.WatermarkColor = tb.WatermarkColor;
+ ctl.WatermarkEnabled = tb.WatermarkEnabled;
+ ctl.WatermarkFont = tb.WatermarkFont;
+ ctl.WatermarkText = tb.WatermarkText;
+
+ ctl.DropDownItems.Clear();
+
+ if (tb.DropDownItems.Count > 0)
+ {
+ for (int i = 0; i < tb.DropDownItems.Count; i++)
+ ctl.DropDownItems.Add(tb.DropDownItems[i]);
+ }
+
+ ctl.BackgroundStyle.ApplyStyle(tb.BackgroundStyle);
+ ctl.BackgroundStyle.Class = tb.BackgroundStyle.Class;
+
+ tb.ButtonClear.CopyToItem(ctl.ButtonClear);
+ tb.ButtonCustom.CopyToItem(ctl.ButtonCustom);
+ tb.ButtonCustom2.CopyToItem(ctl.ButtonCustom2);
+ tb.ButtonDropDown.CopyToItem(ctl.ButtonDropDown);
+
+ ctl.ButtonClearClick += ButtonClearClick;
+ ctl.ButtonCustomClick += ButtonCustomClick;
+ ctl.ButtonCustom2Click += ButtonCustom2Click;
+ ctl.ButtonDropDownClick += ButtonDropDownClick;
+
+ ctl.Value = GetValue(initialFormattedValue);
+
+ ctl.EditCancelled = false;
+ }
+
+ #endregion
+
+ #region DetachEditingControl
+
+ ///
+ /// DetachEditingControl
+ ///
+ public override void DetachEditingControl()
+ {
+ if (DataGridView != null && DataGridView.EditingControl != null)
+ {
+ DataGridViewIpAddressInputEditingControl di =
+ DataGridView.EditingControl as DataGridViewIpAddressInputEditingControl;
+
+ if (di != null)
+ {
+ di.ButtonClearClick -= ButtonClearClick;
+ di.ButtonCustomClick -= ButtonCustomClick;
+ di.ButtonCustom2Click -= ButtonCustom2Click;
+ di.ButtonDropDownClick -= ButtonDropDownClick;
+
+ if (di.EditCancelled == true)
+ {
+ di.EditCancelled = false;
+
+ SystemSounds.Beep.Play();
+ }
+ }
+ }
+
+ base.DetachEditingControl();
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region ButtonClearClick
+
+ ///
+ /// ButtonClearClick
+ ///
+ ///
+ ///
+ void ButtonClearClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewIpAddressInputColumn)OwningColumn).DoButtonClearClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustomClick
+
+ ///
+ /// ButtonCustomClick
+ ///
+ ///
+ ///
+ void ButtonCustomClick(object sender, EventArgs e)
+ {
+ ((DataGridViewIpAddressInputColumn)OwningColumn).DoButtonCustomClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustom2Click
+
+ ///
+ /// ButtonCustom2Click
+ ///
+ ///
+ ///
+ void ButtonCustom2Click(object sender, EventArgs e)
+ {
+ ((DataGridViewIpAddressInputColumn)OwningColumn).DoButtonCustom2Click(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonDropDownClick
+
+ ///
+ /// ButtonDropDownClick
+ ///
+ ///
+ ///
+ void ButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewIpAddressInputColumn)OwningColumn).DoButtonDropDownClick(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PositionEditingControl
+
+ ///
+ /// PositionEditingControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override void PositionEditingControl(bool setLocation, bool setSize, Rectangle cellBounds,
+ Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded,
+ bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
+ {
+ Rectangle editingControlBounds =
+ PositionEditingPanel(cellBounds, cellClip, cellStyle, singleVerticalBorderAdded,
+ singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow);
+
+ editingControlBounds = GetAdjustedEditingControlBounds(editingControlBounds, cellStyle);
+
+ DataGridView.EditingControl.Location = new Point(editingControlBounds.X, editingControlBounds.Y);
+ DataGridView.EditingControl.Size = new Size(editingControlBounds.Width, editingControlBounds.Height);
+ }
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetCellBounds(editingControlBounds);
+
+ if (cellStyle != null && r.Height < editingControlBounds.Height)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.MiddleLeft:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height) / 2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ editingControlBounds.Width = Math.Max(1, editingControlBounds.Width);
+ editingControlBounds.Height = Math.Max(1, r.Height);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ #region GetPreferredSize
+
+ ///
+ /// GetPreferredSize
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Size GetPreferredSize(Graphics graphics,
+ DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ {
+ if (DataGridView == null)
+ return (new Size(-1, -1));
+
+ Size preferredSize = base.GetPreferredSize(graphics, cellStyle, rowIndex, constraintSize);
+
+ DataGridViewIpAddressInputColumn oc = OwningColumn as DataGridViewIpAddressInputColumn;
+
+ if (oc != null)
+ {
+ IpAddressInput ip = oc.IpAddressInput;
+
+ preferredSize.Width += 6;
+ preferredSize.Height = ip.Height;
+
+ if (constraintSize.Width == 0)
+ {
+ preferredSize.Width += GetImageWidth(ip.ButtonClear);
+ preferredSize.Width += GetImageWidth(ip.ButtonCustom);
+ preferredSize.Width += GetImageWidth(ip.ButtonCustom2);
+ preferredSize.Width += GetImageWidth(ip.ButtonDropDown);
+ preferredSize.Width += GetImageWidth(ip.ButtonFreeText);
+
+ if (ip.ShowCheckBox == true)
+ preferredSize.Width += 16;
+ }
+ }
+
+ return (preferredSize);
+ }
+
+ #endregion
+
+ #region GetFormattedValue
+
+ protected override object GetFormattedValue(object value, int rowIndex,
+ ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter,
+ TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
+ {
+ DataGridViewIpAddressInputColumn oc = OwningColumn as DataGridViewIpAddressInputColumn;
+
+ if (oc != null)
+ {
+ IpAddressInput ip = oc.IpAddressInput;
+ ip.Value = GetValue(value);
+
+ return (ip.Text);
+ }
+
+ return (base.GetFormattedValue(value, rowIndex,
+ ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
+ }
+
+ #endregion
+
+ #region GetImageWidth
+
+ private int GetImageWidth(InputButtonSettings ibs)
+ {
+ if (ibs.Visible == true)
+ return (ibs.Image != null ? ibs.Image.Width : 16);
+
+ return (0);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
+ DataGridViewElementStates elementState, object value, object formattedValue,
+ string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle,
+ DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewIpAddressInputColumn oc = (DataGridViewIpAddressInputColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintCellBackground(g, cellStyle, rBk);
+ PaintCellContent(g, cellBounds, rowIndex, formattedValue, cellStyle, paintParts);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintCellBackground
+
+ ///
+ /// Paints the cell background
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintCellContent
+
+ ///
+ /// Paints the cell content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellContent(Graphics g, Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts)
+ {
+ DataGridViewIpAddressInputColumn oc = (DataGridViewIpAddressInputColumn)OwningColumn;
+ IpAddressInput di = oc.IpAddressInput;
+
+ Point ptCurrentCell = DataGridView.CurrentCellAddress;
+ bool cellCurrent = ptCurrentCell.X == ColumnIndex && ptCurrentCell.Y == rowIndex;
+ bool cellEdited = cellCurrent && DataGridView.EditingControl != null;
+
+ // If the cell is in editing mode, there is nothing else to paint
+
+ if (cellEdited == false && rowIndex < DataGridView.RowCount)
+ {
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ {
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ di.Font = cellStyle.Font;
+ di.ForeColor = cellStyle.ForeColor;
+ di.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+ di.InputHorizontalAlignment = GetHorizontalAlignment(cellStyle.Alignment);
+
+ di.Value = GetValue(value);
+
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+
+ if (oc.DisplayControlForCurrentCellOnly == false)
+ DrawControl(di, r, g);
+ else
+ DrawText(di, r, g);
+ }
+ }
+ }
+
+ #region DrawControl
+
+ ///
+ /// DrawControl
+ ///
+ ///
+ ///
+ ///
+ private void DrawControl(IpAddressInput di, Rectangle r, Graphics g)
+ {
+ GraphicsState gs = g.Save();
+
+ try
+ {
+ g.TranslateTransform(r.X, r.Y);
+
+ di.Width = r.Width;
+ di.InternalPaint(new PaintEventArgs(g, Rectangle.Empty));
+ }
+ finally
+ {
+ g.Restore(gs);
+ }
+ }
+
+ #endregion
+
+ #region DrawText
+
+ ///
+ /// DrawText
+ ///
+ ///
+ ///
+ ///
+ private void DrawText(IpAddressInput di, Rectangle r, Graphics g)
+ {
+ r.Inflate(-2, 0);
+
+ eTextFormat tf = eTextFormat.VerticalCenter;
+
+ switch (di.InputHorizontalAlignment)
+ {
+ case eHorizontalAlignment.Center:
+ tf |= eTextFormat.HorizontalCenter;
+ break;
+
+ case eHorizontalAlignment.Right:
+ tf |= eTextFormat.Right;
+ break;
+ }
+
+ TextDrawing.DrawString(g, di.Text, di.Font, di.ForeColor, r, tf);
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewIpAddressInputColumn oc = (DataGridViewIpAddressInputColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetCellBounds
+
+ ///
+ /// Gets the button bounds for the given cell
+ ///
+ ///
+ ///
+ private Rectangle GetCellBounds(Rectangle cellBounds)
+ {
+ DataGridViewIpAddressInputColumn oc = (DataGridViewIpAddressInputColumn)OwningColumn;
+
+ oc.IpAddressInput.RecalcLayout();
+ Size size = oc.IpAddressInput.PreferredSize;
+
+ if (oc.IpAddressInput.ButtonClear.Visible == true)
+ {
+ if (oc.IpAddressInput.ButtonClear.Image != null)
+ size.Width += oc.IpAddressInput.ButtonClear.Image.Size.Width;
+ else
+ size.Width += 16;
+ }
+
+ if (oc.IpAddressInput.ButtonCustom.Visible == true)
+ {
+ if (oc.IpAddressInput.ButtonCustom.Image != null)
+ size.Width += oc.IpAddressInput.ButtonCustom.Image.Size.Width;
+ else
+ size.Width += 16;
+ }
+
+ if (oc.IpAddressInput.ButtonCustom2.Visible == true)
+ {
+ if (oc.IpAddressInput.ButtonCustom2.Image != null)
+ size.Width += oc.IpAddressInput.ButtonCustom2.Image.Size.Width;
+ else
+ size.Width += 16;
+ }
+
+ if (oc.IpAddressInput.ButtonDropDown.Visible == true)
+ {
+ if (oc.IpAddressInput.ButtonDropDown.Image != null)
+ size.Width += oc.IpAddressInput.ButtonDropDown.Image.Size.Width;
+ else
+ size.Width += 16;
+ }
+
+ cellBounds.Location = new Point(1, 1);
+
+ cellBounds.Width = Math.Min(size.Width, cellBounds.Width);
+ cellBounds.Width -= oc.DividerWidth;
+ cellBounds.Height = size.Height;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetValue
+
+ ///
+ /// GetValue
+ ///
+ ///
+ ///
+ private string GetValue(object value)
+ {
+ return (value != Convert.DBNull ? Convert.ToString(value) : "");
+ }
+
+ #endregion
+
+ #region GetHorizontalAlignment
+
+ ///
+ /// GetHorizontalAlignment
+ ///
+ ///
+ ///
+ private eHorizontalAlignment GetHorizontalAlignment(DataGridViewContentAlignment alignment)
+ {
+ switch (alignment)
+ {
+ case DataGridViewContentAlignment.TopCenter:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.BottomCenter:
+ return (eHorizontalAlignment.Center);
+
+ case DataGridViewContentAlignment.TopRight:
+ case DataGridViewContentAlignment.MiddleRight:
+ case DataGridViewContentAlignment.BottomRight:
+ return (eHorizontalAlignment.Right);
+
+ default:
+ return (eHorizontalAlignment.Left);
+ }
+ }
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIpAddressInput/DataGridViewIpAddressInputColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIpAddressInput/DataGridViewIpAddressInputColumn.cs
new file mode 100644
index 00000000..dc546459
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIpAddressInput/DataGridViewIpAddressInputColumn.cs
@@ -0,0 +1,781 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewButtonXColumn), "IpAddressInput.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewIpAddressInputColumn : DataGridViewTextBoxColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ ///
+ /// Occurs right before a IpAddressInput Cell is painted
+ ///
+ [Description("Occurs right before a IpAddressInput Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ ///
+ /// Occurs when Clear button is clicked and allows you
+ /// to cancel the default action performed by the button
+ ///
+ [Description("Occurs when Clear button is clicked and allows you to cancel the default action performed by the button.")]
+ public event EventHandler ButtonClearClick;
+
+ ///
+ /// Occurs when ButtonCustom control is clicked
+ ///
+ [Description("Occurs when ButtonCustom control is clicked.")]
+ public event EventHandler ButtonCustomClick;
+
+ ///
+ /// Occurs when ButtonCustom2 control is clicked
+ ///
+ [Description("Occurs when ButtonCustom2 control is clicked.")]
+ public event EventHandler ButtonCustom2Click;
+
+ ///
+ /// Occurs when Drop-Down button that shows calendar
+ /// is clicked and allows you to cancel showing of the popup
+ ///
+ [Description("Occurs when Drop-Down button that shows calendar is clicked and allows you to cancel showing of the popup.")]
+ public event EventHandler ButtonDropDownClick;
+
+ #endregion
+
+ #region Private variables
+
+ private IpAddressInput _IpAddressInput;
+ private Bitmap _CellBitmap;
+ private bool _DisplayControlForCurrentCellOnly = true;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewIpAddressInputColumn()
+ {
+ CellTemplate = new DataGridViewIpAddressInputCell();
+
+ _IpAddressInput = new IpAddressInput();
+
+ _IpAddressInput.BackgroundStyle.Class = ElementStyleClassKeys.DataGridViewIpAddressBorderKey;
+ }
+
+ #region Internal properties
+
+ #region IpAddressInput
+
+ ///
+ /// Gets the underlying IpAddressInput control
+ ///
+ [Browsable(false)]
+ internal IpAddressInput IpAddressInput
+ {
+ get { return (_IpAddressInput); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region AllowEmptyState
+
+ ///
+ /// Gets or sets whether empty null/nothing state of the control
+ /// is allowed. Default value is true which means that Text property
+ /// may return null if there is no input value.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether empty null/nothing state of the control is allowed.")]
+ public bool AllowEmptyState
+ {
+ get { return (_IpAddressInput.AllowEmptyState); }
+ set { _IpAddressInput.AllowEmptyState = value; }
+ }
+
+ #endregion
+
+ #region AutoOffFreeTextEntry
+
+ ///
+ /// Gets or sets whether free-text entry is automatically
+ /// turned off when control loses input focus. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Free-Text")]
+ [Description("Indicates whether free-text entry is automatically turned off when control loses input focus.")]
+ public bool AutoOffFreeTextEntry
+ {
+ get { return (_IpAddressInput.AutoOffFreeTextEntry); }
+ set { _IpAddressInput.AutoOffFreeTextEntry = value; }
+ }
+
+ #endregion
+
+ #region AutoOverwrite
+
+ ///
+ /// Gets or sets whether auto-overwrite functionality for input
+ /// is enabled. When in auto-overwrite mode input field will erase existing entry
+ /// and start new one if typing is continued after InputComplete method is called.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether auto-overwrite functionality for input is enabled.")]
+ public bool AutoOverwrite
+ {
+ get { return (_IpAddressInput.AutoOverwrite); }
+ set { _IpAddressInput.AutoOverwrite = value; }
+ }
+
+ #endregion
+
+ #region AutoResolveFreeTextEntries
+
+ ///
+ /// Gets or sets whether free text entries are attempted to be
+ /// auto-resolved to IP address as host/domain names. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Free-Text")]
+ [Description("Indicates whether free text entries are attempted to be auto-resolved to IP address as host/domain names.")]
+ public bool AutoResolveFreeTextEntries
+ {
+ get { return (_IpAddressInput.AutoResolveFreeTextEntries); }
+ set { _IpAddressInput.AutoResolveFreeTextEntries = value; }
+ }
+
+ #endregion
+
+ #region BackColor
+
+ ///
+ /// Gets or sets the Background color.
+ ///
+ [Browsable(false)]
+ public Color BackColor
+ {
+ get { return (_IpAddressInput.BackColor); }
+ set { _IpAddressInput.BackColor = value; }
+ }
+
+ #endregion
+
+ #region BackgroundStyle
+
+ ///
+ /// Specifies the background style of the control.
+ ///
+ [Browsable(true), Category("Style")]
+ [Description("Gets or sets control background style.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return (_IpAddressInput.BackgroundStyle); }
+ }
+
+ ///
+ /// Resets style to default value. Used by windows forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackgroundStyle()
+ {
+ _IpAddressInput.ResetBackgroundStyle();
+
+ _IpAddressInput.BackgroundStyle.Class = "TextBoxBorder";
+ _IpAddressInput.BackgroundStyle.CornerType = eCornerType.Square;
+ }
+
+ #endregion
+
+ #region ButtonClear
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that clears the content of the control when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that clears the content of the control when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonClear
+ {
+ get { return (_IpAddressInput.ButtonClear); }
+ }
+
+ #endregion
+
+ #region ButtonCustom
+
+ ///
+ /// Gets the object that describes the settings for the custom button
+ /// that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom
+ {
+ get { return (_IpAddressInput.ButtonCustom); }
+ }
+
+ #endregion
+
+ #region ButtonCustom2
+
+ ///
+ /// Gets the object that describes the settings for the custom button that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom2
+ {
+ get { return (_IpAddressInput.ButtonCustom2); }
+ }
+
+ #endregion
+
+ #region ButtonDropDown
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that shows drop-down when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that shows drop-down when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonDropDown
+ {
+ get { return (_IpAddressInput.ButtonDropDown); }
+ }
+
+ #endregion
+
+ #region DisplayControlForCurrentCellOnly
+
+ ///
+ /// Gets or sets whether the control
+ /// will be displayed for the current cell only.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether the control will be displayed for the current cell only.")]
+ public bool DisplayControlForCurrentCellOnly
+ {
+ get { return (_DisplayControlForCurrentCellOnly); }
+
+ set
+ {
+ if (_DisplayControlForCurrentCellOnly != value)
+ {
+ _DisplayControlForCurrentCellOnly = value;
+ _IpAddressInput.Invalidate();
+ }
+ }
+ }
+
+ #endregion
+
+ #region DropDownControl
+
+ ///
+ /// Gets or sets the reference of the control that will be
+ /// displayed on popup that is shown when the drop-down button is clicked.
+ ///
+ [DefaultValue(null)]
+ [Description("Indicates reference of the control that will be displayed on popup that is shown when the drop-down button is clicked.")]
+ public Control DropDownControl
+ {
+ get { return (_IpAddressInput.DropDownControl); }
+ set { _IpAddressInput.DropDownControl = value; }
+ }
+
+ #endregion
+
+ #region DropDownItems
+
+ ///
+ /// Returns the collection of DropDownItems.
+ ///
+ [Browsable(false), DevCoBrowsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public SubItemsCollection DropDownItems
+ {
+ get { return (_IpAddressInput.DropDownItems); }
+ }
+
+ #endregion
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_IpAddressInput.Enabled); }
+ set { _IpAddressInput.Enabled = value; }
+ }
+
+ #endregion
+
+ #region FocusHighlightColor
+
+ ///
+ /// Gets or sets the color used as background color to highlight
+ /// the text box when it has input focus and FocusHighlight is enabled.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates color used as background color to highlight the text box when it has input focus and FocusHighlight is enabled.")]
+ public Color FocusHighlightColor
+ {
+ get { return (_IpAddressInput.FocusHighlightColor); }
+ set { _IpAddressInput.FocusHighlightColor = value; }
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeFocusHighlightColor()
+ {
+ return (_IpAddressInput.ShouldSerializeFocusHighlightColor());
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetFocusHighlightColor()
+ {
+ _IpAddressInput.ResetFocusHighlightColor();
+ }
+
+ #endregion
+
+ #region FocusHighlightEnabled
+
+ ///
+ /// Gets or sets whether FocusHighlightColor is used as
+ /// background color to highlight the text box when it has
+ /// input focus. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance")]
+ [Description("Indicates whether FocusHighlightColor is used as background color to highlight the text box when it has input focus.")]
+ public bool FocusHighlightEnabled
+ {
+ get { return (_IpAddressInput.FocusHighlightEnabled); }
+ set { _IpAddressInput.FocusHighlightEnabled = value; }
+ }
+
+ #endregion
+
+ #region ForeColor
+
+ ///
+ /// Gets or sets the foreground color.
+ ///
+ [Browsable(false)]
+ public Color ForeColor
+ {
+ get { return (_IpAddressInput.ForeColor); }
+ set { _IpAddressInput.ForeColor = value; }
+ }
+
+ #endregion
+
+ #region FreeTextEntryMode
+
+ ///
+ /// Gets or sets whether control input is in
+ /// free-text input mode. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Free-Text")]
+ [Description("Indicates whether control input is in free-text input mode.")]
+ public bool FreeTextEntryMode
+ {
+ get { return (_IpAddressInput.FreeTextEntryMode); }
+ set { _IpAddressInput.FreeTextEntryMode = value; }
+ }
+
+ #endregion
+
+ #region ImeMode
+
+ ///
+ /// Gets or sets the Input Method Editor (IME) mode of the control.
+ ///
+ [Browsable(true), DefaultValue(ImeMode.Inherit)]
+ [Description("Indicates the Input Method Editor (IME) mode of the control.")]
+ public ImeMode ImeMode
+ {
+ get { return (_IpAddressInput.ImeMode); }
+ set { _IpAddressInput.ImeMode = value; }
+ }
+
+ #endregion
+
+ #region IsInputReadOnly
+
+ ///
+ /// Gets or sets whether input part of the control is read-only. When
+ /// set to true the input part of the control becomes read-only and does
+ /// not allow the typing. However, drop-down part if visible still allows
+ /// user to possibly change the value of the control through the method you
+ /// can provide on drop-down. Use this property to allow change of the value
+ /// through drop-down button only.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether input part of the control is read-only.")]
+ public bool IsInputReadOnly
+ {
+ get { return (_IpAddressInput.IsInputReadOnly); }
+ set { _IpAddressInput.IsInputReadOnly = value; }
+ }
+
+ #endregion
+
+ #region LockUpdateChecked
+
+ ///
+ /// Gets or sets whether check box shown using ShowCheckBox
+ /// property which locks/unlocks the control update is checked.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether check box shown using ShowCheckBox property which locks/unlocks the control update is checked.")]
+ public bool LockUpdateChecked
+ {
+ get { return (_IpAddressInput.LockUpdateChecked); }
+ set { _IpAddressInput.LockUpdateChecked = value; }
+ }
+
+ #endregion
+
+ #region RightToLeft
+
+ ///
+ /// Gets or sets a value indicating whether control's
+ /// elements are aligned to support locales using right-to-left fonts.
+ ///
+ [Browsable(true), DefaultValue(RightToLeft.Inherit)]
+ [Description("Indicates the control's elements are aligned to support locales using right-to-left fonts.")]
+ public RightToLeft RightToLeft
+ {
+ get { return (_IpAddressInput.RightToLeft); }
+ set { _IpAddressInput.RightToLeft = value; }
+ }
+
+ #endregion
+
+ #region SelectNextInputCharacters
+
+ ///
+ /// List of characters that when pressed would select next input field. For example if you are
+ /// allowing time input you could set this property to : so when user presses the : character,
+ /// the input is forwarded to the next input field.
+ ///
+ [DefaultValue("."), Category("Behavior")]
+ [Description("List of characters that when pressed would select next input field.")]
+ public string SelectNextInputCharacters
+ {
+ get { return (_IpAddressInput.SelectNextInputCharacters); }
+ set { _IpAddressInput.SelectNextInputCharacters = value; }
+ }
+
+ #endregion
+
+ #region ShowCheckBox
+
+ ///
+ /// Gets or sets a value indicating whether a check box is displayed to
+ /// the left of the input value. Set to true if a check box is displayed
+ /// to the left of the input value; otherwise, false. The default is false.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether a check box is displayed to the left of the input value which allows locking of the control.")]
+ public bool ShowCheckBox
+ {
+ get { return (_IpAddressInput.ShowCheckBox); }
+ set { _IpAddressInput.ShowCheckBox = value; }
+ }
+
+ #endregion
+
+ #region Text
+
+ ///
+ /// Gets or sets the text as it is currently displayed to the user.
+ ///
+ [Browsable(false)]
+ public string Text
+ {
+ get { return (_IpAddressInput.Text); }
+ set { _IpAddressInput.Text = value; }
+ }
+
+ #endregion
+
+ #region WatermarkColor
+
+ ///
+ /// Gets or sets the watermark text color.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates watermark text color.")]
+ public Color WatermarkColor
+ {
+ get { return (_IpAddressInput.WatermarkColor); }
+ set { _IpAddressInput.WatermarkColor = value; }
+ }
+ ///
+ /// Indicates whether property should be serialized by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeWatermarkColor()
+ {
+ return (_IpAddressInput.ShouldSerializeWatermarkColor());
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetWatermarkColor()
+ {
+ _IpAddressInput.ResetWatermarkColor();
+ }
+
+ #endregion
+
+ #region WatermarkEnabled
+
+ ///
+ /// Gets or sets whether watermark text is
+ /// displayed when control is empty. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether watermark text is displayed when control is empty.")]
+ public virtual bool WatermarkEnabled
+ {
+ get { return (_IpAddressInput.WatermarkEnabled); }
+ set { _IpAddressInput.WatermarkEnabled = value; }
+ }
+
+ #endregion
+
+ #region WatermarkFont
+
+ ///
+ /// Gets or sets the watermark font.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(null)]
+ [Description("Indicates watermark font.")]
+ public Font WatermarkFont
+ {
+ get { return (_IpAddressInput.WatermarkFont); }
+ set { _IpAddressInput.WatermarkFont = value; }
+ }
+
+ #endregion
+
+ #region WatermarkText
+
+ ///
+ /// Gets or sets the watermark (tip) text displayed inside of
+ /// the control when Text is not set and control does not have
+ /// input focus. This property supports text-markup.
+ ///
+ [Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance")]
+ [Description("Indicates watermark text displayed inside of the control when Text is not set and control does not have input focus.")]
+ [Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ public string WatermarkText
+ {
+ get { return (_IpAddressInput.WatermarkText); }
+ set { _IpAddressInput.WatermarkText = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Event processing
+
+ #region DoButtonClearClick
+
+ ///
+ /// DoButtonClearClick
+ ///
+ ///
+ ///
+ internal void DoButtonClearClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonClearClick != null)
+ ButtonClearClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustomClick
+
+ ///
+ /// DoButtonCustomClick
+ ///
+ ///
+ ///
+ internal void DoButtonCustomClick(object sender, EventArgs e)
+ {
+ if (ButtonCustomClick != null)
+ ButtonCustomClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustom2Click
+
+ ///
+ /// DoButtonCustom2Click
+ ///
+ ///
+ ///
+ internal void DoButtonCustom2Click(object sender, EventArgs e)
+ {
+ if (ButtonCustom2Click != null)
+ ButtonCustom2Click(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonDropDownClick
+
+ ///
+ /// DoButtonDropDownClick
+ ///
+ ///
+ ///
+ internal void DoButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonDropDownClick != null)
+ ButtonDropDownClick(this, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewIpAddressInputColumn dc = base.Clone() as DataGridViewIpAddressInputColumn;
+
+ if (dc != null)
+ {
+ dc.AllowEmptyState = AllowEmptyState;
+ dc.AutoOffFreeTextEntry = AutoOffFreeTextEntry;
+ dc.AutoOverwrite = AutoOverwrite;
+ dc.AutoResolveFreeTextEntries = AutoResolveFreeTextEntries;
+ dc.DropDownControl = DropDownControl;
+ dc.Enabled = Enabled;
+ dc.FocusHighlightColor = FocusHighlightColor;
+ dc.FocusHighlightEnabled = FocusHighlightEnabled;
+ dc.FreeTextEntryMode = FreeTextEntryMode;
+ dc.ImeMode = ImeMode;
+ dc.IsInputReadOnly = IsInputReadOnly;
+ dc.LockUpdateChecked = LockUpdateChecked;
+ dc.RightToLeft = RightToLeft;
+ dc.SelectNextInputCharacters = SelectNextInputCharacters;
+ dc.ShowCheckBox = ShowCheckBox;
+ dc.WatermarkColor = WatermarkColor;
+ dc.WatermarkEnabled = WatermarkEnabled;
+ dc.WatermarkFont = WatermarkFont;
+ dc.WatermarkText = WatermarkText;
+
+ dc.DisplayControlForCurrentCellOnly = DisplayControlForCurrentCellOnly;
+
+ dc.BackgroundStyle.ApplyStyle(IpAddressInput.BackgroundStyle);
+ dc.BackgroundStyle.Class = IpAddressInput.BackgroundStyle.Class;
+
+ IpAddressInput.ButtonClear.CopyToItem(dc.IpAddressInput.ButtonClear);
+ IpAddressInput.ButtonDropDown.CopyToItem(dc.IpAddressInput.ButtonDropDown);
+ IpAddressInput.ButtonCustom.CopyToItem(dc.IpAddressInput.ButtonCustom);
+ IpAddressInput.ButtonCustom2.CopyToItem(dc.IpAddressInput.ButtonCustom2);
+ }
+
+ return (dc);
+ }
+
+ #endregion
+
+ #region Dispose
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing == true)
+ _IpAddressInput.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIpAddressInput/DataGridViewIpAddressInputEditingControl.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIpAddressInput/DataGridViewIpAddressInputEditingControl.cs
new file mode 100644
index 00000000..1b7e8b8e
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewIpAddressInput/DataGridViewIpAddressInputEditingControl.cs
@@ -0,0 +1,199 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewIpAddressInputEditingControl : IpAddressInput, IDataGridViewEditingControl
+ {
+ #region Private variables
+
+ private DataGridView _DataGridView;
+
+ private int _RowIndex;
+ private bool _ValueChanged;
+ private bool _EditCancelled;
+
+ #endregion
+
+ #region Internal properties
+
+ ///
+ /// Gets or sets the Edit state
+ ///
+ internal bool EditCancelled
+ {
+ get { return (_EditCancelled); }
+ set { _EditCancelled = value; }
+ }
+
+ #endregion
+
+ #region OnTextChanged
+
+ ///
+ /// Handles OnTextChanged events
+ ///
+ ///
+ protected override void OnTextChanged(EventArgs e)
+ {
+ _ValueChanged = true;
+
+ _DataGridView.NotifyCurrentCellDirty(true);
+
+ base.OnTextChanged(e);
+ }
+
+ #endregion
+
+ #region IDataGridViewEditingControl Members
+
+ #region Public properties
+
+ #region EditingControlDataGridView
+
+ ///
+ /// Gets or sets the DataGridView
+ ///
+ public DataGridView EditingControlDataGridView
+ {
+ get { return (_DataGridView); }
+ set { _DataGridView = value; }
+ }
+
+ #endregion
+
+ #region EditingControlFormattedValue
+
+ ///
+ /// Gets or sets the Control Formatted Value
+ ///
+ public object EditingControlFormattedValue
+ {
+ get { return (Value ?? ""); }
+ set { Value = (string)value; }
+ }
+
+ #endregion
+
+ #region EditingControlRowIndex
+
+ ///
+ /// Gets or sets the Control RoeIndex
+ ///
+ public int EditingControlRowIndex
+ {
+ get { return (_RowIndex); }
+ set { _RowIndex = value; }
+ }
+
+ #endregion
+
+ #region EditingControlValueChanged
+
+ ///
+ /// Gets or sets the Control ValueChanged state
+ ///
+ public bool EditingControlValueChanged
+ {
+ get { return (_ValueChanged); }
+ set { _ValueChanged = value; }
+ }
+
+ #endregion
+
+ #region EditingPanelCursor
+
+ ///
+ /// Gets the Panel Cursor
+ ///
+ public Cursor EditingPanelCursor
+ {
+ get { return (base.Cursor); }
+ }
+
+ #endregion
+
+ #region RepositionEditingControlOnValueChange
+
+ ///
+ /// Gets whether to RepositionEditingControlOnValueChange
+ ///
+ public bool RepositionEditingControlOnValueChange
+ {
+ get { return (false); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region ApplyCellStyleToEditingControl
+
+ ///
+ /// ApplyCellStyleToEditingControl
+ ///
+ ///
+ public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ }
+
+ #endregion
+
+ #region GetEditingControlFormattedValue
+
+ ///
+ /// Gets EditingControlFormattedValue
+ ///
+ ///
+ ///
+ public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
+ {
+ return (EditingControlFormattedValue);
+ }
+
+ #endregion
+
+ #region EditingControlWantsInputKey
+
+ ///
+ /// Gets whether the given key wants to be processed
+ /// by the Control
+ ///
+ ///
+ ///
+ ///
+ public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
+ {
+ if ((keyData & Keys.Right) == Keys.Right)
+ return (true);
+
+ if ((keyData & Keys.Left) == Keys.Left)
+ return (true);
+
+ if ((keyData & Keys.Escape) == Keys.Escape)
+ _EditCancelled = true;
+
+ return (dataGridViewWantsInputKey == false);
+ }
+
+ #endregion
+
+ #region PrepareEditingControlForEdit
+
+ ///
+ /// PrepareEditingControlForEdit
+ ///
+ ///
+ public void PrepareEditingControlForEdit(bool selectAll)
+ {
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewLabelX/DataGridViewLabelXCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewLabelX/DataGridViewLabelXCell.cs
new file mode 100644
index 00000000..b7bb3405
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewLabelX/DataGridViewLabelXCell.cs
@@ -0,0 +1,666 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewLabelXCell : DataGridViewButtonCell
+ {
+ #region Private variables
+
+ private DataGridViewCellStyle _CellStyle;
+
+ #endregion
+
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (null); }
+ }
+
+ #endregion
+
+ #region FormattedValueType
+
+ ///
+ /// FormattedValueType
+ ///
+ public override Type FormattedValueType
+ {
+ get { return (typeof(string)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle, int rowIndex)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetContentBounds(rowIndex);
+
+ if (cellStyle != null)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.TopCenter:
+ editingControlBounds.X += (editingControlBounds.Width - r.Width) / 2;
+ break;
+
+ case DataGridViewContentAlignment.TopRight:
+ editingControlBounds.X = (editingControlBounds.Right - r.Width);
+ break;
+
+ case DataGridViewContentAlignment.MiddleLeft:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height)/2;
+ break;
+
+ case DataGridViewContentAlignment.MiddleCenter:
+ editingControlBounds.X += (editingControlBounds.Width - r.Width)/2;
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height)/2;
+ break;
+
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.X = (editingControlBounds.Right - r.Width);
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height)/2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+
+ case DataGridViewContentAlignment.BottomCenter:
+ editingControlBounds.X += (editingControlBounds.Width - r.Width)/2;
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.X = (editingControlBounds.Right - r.Width);
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ if (editingControlBounds.Y < 1)
+ editingControlBounds.Y = 1;
+
+ editingControlBounds.Width = Math.Max(1, r.Width);
+ editingControlBounds.Height = Math.Max(1, r.Height);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ ///
+ /// GetPreferredSize
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Size GetPreferredSize(Graphics graphics,
+ DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ {
+ Size size = Size.Empty;
+
+ if (DataGridView == null)
+ return new Size(-1, -1);
+
+ DataGridViewLabelXColumn oc = OwningColumn as DataGridViewLabelXColumn;
+
+ if (oc != null)
+ {
+ LabelX lx = oc.LabelX;
+
+ if (oc.LabelX.IsHandleCreated == false)
+ {
+ if (oc.LabelX.Parent == null)
+ {
+ Form form = oc.DataGridView.FindForm();
+
+ if (form != null)
+ oc.LabelX.Parent = form;
+ }
+
+ oc.LabelX.Visible = true;
+ oc.LabelX.Visible = false;
+ }
+
+ FreeDimension fd = GetDFromConstraint(constraintSize);
+
+ if (fd != FreeDimension.Width)
+ constraintSize.Width -= 2;
+
+ lx.Font = cellStyle.Font;
+ lx.WordWrap = GetWordWrap(oc, cellStyle);
+ lx.TextAlignment = GetTextAlignment(cellStyle.Alignment);
+ lx.MaximumSize = Size.Empty;
+ lx.Image = oc.Image;
+
+ string s = lx.Text = @" ";
+
+ if (rowIndex < DataGridView.RowCount)
+ s = GetValue(DataGridView.Rows[rowIndex].Cells[ColumnIndex].Value);
+
+ if (string.IsNullOrEmpty(s) == true)
+ s = " ";
+
+ lx.Text = s;
+
+ size = lx.GetPreferredSize(constraintSize);
+
+ Rectangle stdBorderWidths = BorderWidths(new DataGridViewAdvancedBorderStyle());
+
+ int hpad = (stdBorderWidths.Left + stdBorderWidths.Width) + cellStyle.Padding.Horizontal;
+ int vpad = (stdBorderWidths.Top + stdBorderWidths.Height) + cellStyle.Padding.Vertical;
+
+ switch (fd)
+ {
+ case FreeDimension.Height:
+ size.Width = 0;
+ break;
+
+ case FreeDimension.Width:
+ size.Height = 0;
+ break;
+ }
+
+ if (fd != FreeDimension.Height)
+ size.Width += (hpad + 4);
+
+ if (fd != FreeDimension.Width)
+ size.Height += (vpad + 2);
+ }
+
+ return size;
+ }
+
+ #region GetDFromConstraint
+
+ private enum FreeDimension
+ {
+ Both,
+ Height,
+ Width
+ }
+
+ private FreeDimension GetDFromConstraint(Size constraintSize)
+ {
+ if (constraintSize.Width == 0)
+ {
+ if (constraintSize.Height == 0)
+ return (FreeDimension.Both);
+
+ return (FreeDimension.Width);
+ }
+
+ return (FreeDimension.Height);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState,
+ object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewLabelXColumn oc = (DataGridViewLabelXColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintLabelBackground(g, cellStyle, rBk);
+ PaintLabelContent(cellBounds, rowIndex, formattedValue, cellStyle, paintParts, g);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintLabelBackground
+
+ ///
+ /// Paints the Label background
+ ///
+ ///
+ ///
+ ///
+ private void PaintLabelBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintLabelContent
+
+ ///
+ /// Paints the Label background and content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintLabelContent(Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts, Graphics g)
+ {
+ DataGridViewLabelXColumn oc = (DataGridViewLabelXColumn) OwningColumn;
+ LabelX lx = oc.LabelX;
+
+ _CellStyle = cellStyle;
+
+ string s = GetValue(value);
+
+ oc.InCallBack = true;
+ bool wordWrap = lx.WordWrap;
+ StringAlignment textAlignment = lx.TextAlignment;
+
+ GraphicsState gs = g.Save();
+
+ try
+ {
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ lx.Font = cellStyle.Font;
+ lx.ForeColor = cellStyle.ForeColor;
+ lx.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+
+ lx.WordWrap = GetWordWrap(oc, cellStyle);
+ lx.TextAlignment = GetTextAlignment(cellStyle.Alignment);
+
+ Rectangle r = cellBounds;
+
+ if (rowIndex < DataGridView.RowCount)
+ {
+ lx.Text = s;
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+
+ r = GetAdjustedEditingControlBounds(cellBounds, cellStyle, rowIndex);
+ }
+ else
+ {
+ lx.Text = " ";
+ }
+
+ lx.CallBasePaintBackground = false;
+
+ g.TranslateTransform(r.X, r.Y);
+
+ lx.Bounds = r;
+ lx.RecalcLayout();
+ lx.InternalPaint(new PaintEventArgs(g, Rectangle.Empty));
+ }
+ finally
+ {
+ lx.WordWrap = wordWrap;
+ lx.TextAlignment = textAlignment;
+ oc.InCallBack = false;
+
+ g.Restore(gs);
+ }
+ }
+
+ #region GetWordWrap
+
+ private bool GetWordWrap(DataGridViewLabelXColumn oc, DataGridViewCellStyle cellStyle)
+ {
+ if (oc.WordWrap == true)
+ return (true);
+
+ switch (cellStyle.WrapMode)
+ {
+ case DataGridViewTriState.True:
+ return (true);
+
+ case DataGridViewTriState.False:
+ return (false);
+ }
+
+ return (DataGridView.DefaultCellStyle.WrapMode == DataGridViewTriState.True);
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region Mouse processing
+
+ #region OnMouseEnter
+
+ ///
+ /// OnMouseEnter
+ ///
+ ///
+ protected override void OnMouseEnter(int rowIndex)
+ {
+ base.OnMouseEnter(rowIndex);
+
+ DataGridViewLabelXColumn oc = (DataGridViewLabelXColumn)OwningColumn;
+ LabelX bx = oc.LabelX;
+
+ bx.LabelItem.InternalMouseEnter();
+ }
+
+ #endregion
+
+ #region OnMouseLeave
+
+ ///
+ /// Processes MouseLeave events
+ ///
+ ///
+ protected override void OnMouseLeave(int rowIndex)
+ {
+ base.OnMouseLeave(rowIndex);
+
+ DataGridViewLabelXColumn oc = (DataGridViewLabelXColumn)OwningColumn;
+ LabelX bx = oc.LabelX;
+
+ bx.LabelItem.InternalMouseLeave();
+ }
+
+ #endregion
+
+ #region OnMouseMove
+
+ ///
+ /// Processes MouseMove events
+ ///
+ ///
+ protected override void OnMouseMove(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+
+ DataGridViewLabelXColumn oc = OwningColumn as DataGridViewLabelXColumn;
+
+ if (oc != null)
+ {
+ if ((uint)e.RowIndex < DataGridView.Rows.Count)
+ {
+ Point pt = CellAlignPoint(e);
+
+ oc.LabelX.LabelItem.InternalMouseMove(
+ new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
+ }
+ }
+ }
+
+ #endregion
+
+ #region OnMouseDown
+
+ ///
+ /// Processes MouseDown events
+ ///
+ ///
+ protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+
+ DataGridViewLabelXColumn oc = OwningColumn as DataGridViewLabelXColumn;
+
+ if (oc != null)
+ {
+ Point pt = CellAlignPoint(e);
+
+ oc.LabelX.LabelItem.InternalMouseDown(
+ new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
+
+ RefreshCell(e.ColumnIndex, e.RowIndex);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseUp
+
+ ///
+ /// Processes MouseUp events
+ ///
+ ///
+ protected override void OnMouseUp(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+
+ DataGridViewLabelXColumn oc = OwningColumn as DataGridViewLabelXColumn;
+
+ if (oc != null)
+ {
+ Point pt = CellAlignPoint(e);
+
+ oc.LabelX.LabelItem.InternalMouseUp(
+ new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
+
+ RefreshCell(e.ColumnIndex, e.RowIndex);
+ }
+ }
+
+ #endregion
+
+ #region CellAlignPoint
+
+ ///
+ /// CellAlignPoint
+ ///
+ ///
+ ///
+ private Point CellAlignPoint(DataGridViewCellMouseEventArgs e)
+ {
+ Rectangle bounds = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
+ bounds.Location = new Point(0, 0);
+
+ Rectangle r = GetAdjustedEditingControlBounds(bounds, _CellStyle, e.RowIndex);
+
+ return (new Point(e.X - r.X, e.Y - r.Y));
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewLabelXColumn oc = (DataGridViewLabelXColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetValue
+
+ ///
+ /// GetValue
+ ///
+ ///
+ ///
+ private string GetValue(object value)
+ {
+ return (value != Convert.DBNull ? Convert.ToString(value) : "");
+ }
+
+ #endregion
+
+ #region GetTextAlignment
+
+ ///
+ /// GetHorizontalAlignment
+ ///
+ ///
+ ///
+ private StringAlignment GetTextAlignment(DataGridViewContentAlignment alignment)
+ {
+ switch (alignment)
+ {
+ case DataGridViewContentAlignment.TopCenter:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.BottomCenter:
+ return (StringAlignment.Center);
+
+ case DataGridViewContentAlignment.TopRight:
+ case DataGridViewContentAlignment.MiddleRight:
+ case DataGridViewContentAlignment.BottomRight:
+ return (StringAlignment.Far);
+
+ default:
+ return (StringAlignment.Near);
+ }
+ }
+
+ #endregion
+
+ #region RefreshCell
+
+ ///
+ /// Initiates the refresh of the cell label
+ ///
+ ///
+ ///
+ internal void RefreshCell(int columnIndex, int rowIndex)
+ {
+ DataGridView.InvalidateCell(columnIndex, rowIndex);
+ }
+
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewLabelX/DataGridViewLabelXColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewLabelX/DataGridViewLabelXColumn.cs
new file mode 100644
index 00000000..39a5fb1f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewLabelX/DataGridViewLabelXColumn.cs
@@ -0,0 +1,515 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewLabelXColumn), "Controls.LabelX.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewLabelXColumn : DataGridViewButtonColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ [Description("Occurs right before a LabelX Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ [Description("Occurs when a LabelX Cell is Clicked.")]
+ public event EventHandler Click;
+
+ #endregion
+
+ #region Private variables
+
+ private LabelX _LabelX;
+ private Bitmap _CellBitmap;
+
+ private bool _InCellCallBack;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewLabelXColumn()
+ {
+ CellTemplate = new DataGridViewLabelXCell();
+
+ _LabelX = new LabelX();
+ _LabelX.CreateControl();
+
+ _LabelX.Visible = false;
+
+ HookEvents(true);
+ }
+
+ #region Hidden properties
+
+ ///
+ /// Button FlatStyle
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new FlatStyle FlatStyle
+ {
+ get { return base.FlatStyle; }
+ set { base.FlatStyle = value; }
+ }
+
+ ///
+ /// Button UseColumnTextForButtonValue
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new bool UseColumnTextForButtonValue
+ {
+ get { return base.UseColumnTextForButtonValue; }
+ set { base.UseColumnTextForButtonValue = value; }
+ }
+
+ #endregion
+
+ #region Internal properties
+
+ #region InCallBack
+
+ ///
+ /// InCallBack
+ ///
+ internal bool InCallBack
+ {
+ get { return (_InCellCallBack); }
+ set { _InCellCallBack = value; }
+ }
+
+ #endregion
+
+ #region LabelX
+
+ ///
+ /// Gets the Control LabelX
+ ///
+ internal LabelX LabelX
+ {
+ get { return (_LabelX); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region EnableMarkup
+
+ ///
+ /// Gets or sets whether text-markup support is enabled for items Text property. Default value is true.
+ /// Set this property to false to display HTML or other markup in the item instead of it being parsed as text-markup.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether text-markup support is enabled for the item's Text property.")]
+ public bool EnableMarkup
+ {
+ get { return (_LabelX.EnableMarkup); }
+ set { _LabelX.EnableMarkup = value; }
+ }
+
+ #endregion
+
+ #region FocusCuesEnabled
+
+ ///
+ /// Gets or sets whether control displays focus cues when focused.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Behavior")]
+ [Description("Indicates whether control displays focus cues when focused.")]
+ public bool FocusCuesEnabled
+ {
+ get { return (_LabelX.FocusCuesEnabled); }
+ set { _LabelX.FocusCuesEnabled = value; }
+ }
+
+ #endregion
+
+ #region BorderSide
+
+ ///
+ /// Gets or sets the border sides that are displayed.
+ /// Default value specifies border on all 4 sides.
+ ///
+ [Browsable(false), Category("Appearance"), DefaultValue(LabelItem.DEFAULT_BORDERSIDE)]
+ [Description("Specifies border sides that are displayed.")]
+ public eBorderSide BorderSide
+ {
+ get { return (_LabelX.BorderSide); }
+ set { _LabelX.BorderSide = value; }
+ }
+
+ #endregion
+
+ #region BorderType
+
+ ///
+ /// Gets or sets the type of the border drawn around the label.
+ ///
+ [Browsable(false), Category("Appearance"), DefaultValue(eBorderType.None)]
+ [Description("Indicates the type of the border drawn around the label.")]
+ public eBorderType BorderType
+ {
+ get { return (_LabelX.BorderType); }
+ set { _LabelX.BorderType = value; }
+ }
+
+ #endregion
+
+ #region Image
+
+ ///
+ /// Specifies label image.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(null)]
+ [Description("The image that will be displayed on the face of the item.")]
+ public Image Image
+ {
+ get { return (_LabelX.Image); }
+ set { _LabelX.Image = value; }
+ }
+
+ #endregion
+
+ #region ImagePosition
+
+ ///
+ /// Gets/Sets the image position inside the label.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(eImagePosition.Left)]
+ [Description("The alignment of the image in relation to text displayed by this item.")]
+ public eImagePosition ImagePosition
+ {
+ get { return (_LabelX.ImagePosition); }
+ set { _LabelX.ImagePosition = value; }
+ }
+
+ #endregion
+
+ #region PaddingBottom
+
+ ///
+ /// Gets or sets the bottom padding in pixels.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout")]
+ [Description("Indicates bottom padding in pixels.")]
+ public int PaddingBottom
+ {
+ get { return (_LabelX.PaddingBottom); }
+ set { _LabelX.PaddingBottom = value; }
+ }
+
+ #endregion
+
+ #region PaddingLeft
+
+ ///
+ /// Gets or sets the left padding in pixels.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout")]
+ [Description("Indicates left padding in pixels.")]
+ public int PaddingLeft
+ {
+ get { return (_LabelX.PaddingLeft); }
+ set { _LabelX.PaddingLeft = value; }
+ }
+
+ #endregion
+
+ #region PaddingTop
+
+ ///
+ /// Gets or sets the top padding in pixels.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout")]
+ [Description("Indicates top padding in pixels.")]
+ public int PaddingTop
+ {
+ get { return (_LabelX.PaddingTop); }
+ set { _LabelX.PaddingTop = value; }
+ }
+
+ #endregion
+
+ #region PaddingRight
+
+ ///
+ /// Gets or sets the right padding in pixels.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout")]
+ [Description("Indicates right padding in pixels.")]
+ public int PaddingRight
+ {
+ get { return (_LabelX.PaddingRight); }
+ set { _LabelX.PaddingRight = value; }
+ }
+
+ #endregion
+
+ #region SingleLineColor
+
+ ///
+ /// Gets or sets the border line color when border is single line.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates border line color when border is single line.")]
+ public Color SingleLineColor
+ {
+ get { return (_LabelX.SingleLineColor); }
+ set { _LabelX.SingleLineColor = value; }
+ }
+
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSingleLineColor()
+ {
+ return (_LabelX.ShouldSerializeSingleLineColor());
+ }
+
+ ///
+ /// Resets the SingleLineColor property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSingleLineColor()
+ {
+ _LabelX.ResetSingleLineColor();
+ }
+
+ #endregion
+
+ #region Text
+
+ ///
+ /// Gets or sets the text associated with this item.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ [Description("The text contained in the item.")]
+ public new string Text
+ {
+ get
+ {
+ return (_InCellCallBack == true ?
+ _LabelX.Text : base.Text);
+ }
+
+ set
+ {
+ if (_InCellCallBack == true)
+ _LabelX.Text = value;
+ else
+ base.Text = value;
+ }
+ }
+
+ #endregion
+
+ #region TextAlignment
+
+ ///
+ /// Gets or sets the horizontal text alignment.
+ ///
+ [Browsable(true), DefaultValue(StringAlignment.Near), DevCoBrowsable(true), Category("Layout")]
+ [Description("Indicates the horizontal text alignment.")]
+ public StringAlignment TextAlignment
+ {
+ get { return (_LabelX.TextAlignment); }
+ set { _LabelX.TextAlignment = value; }
+ }
+
+ #endregion
+
+ #region TextLineAlignment
+
+ ///
+ /// Gets or sets the vertical text alignment.
+ ///
+ [Browsable(true), DefaultValue(StringAlignment.Center), DevCoBrowsable(true), Category("Layout")]
+ [Description("Indicates vertical text line alignment.")]
+ public StringAlignment TextLineAlignment
+ {
+ get { return (_LabelX.TextLineAlignment); }
+ set { _LabelX.TextLineAlignment = value; }
+ }
+
+ #endregion
+
+ #region UseMnemonic
+
+ ///
+ /// Gets or sets a value indicating whether the control interprets an
+ /// ampersand character (&) in the control's Text property to be an
+ /// access key prefix character.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether the control interprets an ampersand character (&) in the control's Text property to be an access key prefix character.")]
+ public bool UseMnemonic
+ {
+ get { return (_LabelX.UseMnemonic); }
+ set { _LabelX.UseMnemonic = value; }
+ }
+
+ #endregion
+
+ #region WordWrap
+
+ ///
+ /// Gets or sets a value that determines whether text is displayed in multiple lines or one long line.
+ ///
+ [Browsable(true), Category("Style"), DefaultValue(false)]
+ [Description("Indicates whether text is displayed in multiple lines or one long line.")]
+ public bool WordWrap
+ {
+ get { return (_LabelX.WordWrap); }
+ set { _LabelX.WordWrap = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region HookEvents
+
+ ///
+ /// Hooks or unhooks our system events
+ ///
+ ///
+ private void HookEvents(bool hook)
+ {
+ if (hook == true)
+ {
+ _LabelX.LabelItem.Click += LabelItemClick;
+ }
+ else
+ {
+ _LabelX.LabelItem.Click -= LabelItemClick;
+ }
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region LabelItem_Click
+
+ ///
+ /// LabelItem_Click
+ ///
+ ///
+ ///
+ void LabelItemClick(object sender, EventArgs e)
+ {
+ if (Click != null)
+ Click(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the LabelX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewLabelXColumn bc = base.Clone() as DataGridViewLabelXColumn;
+
+ if (bc != null)
+ {
+ _LabelX.LabelItem.InternalCopyToItem(bc.LabelX.LabelItem);
+
+ bc.FocusCuesEnabled = FocusCuesEnabled;
+ bc.Text = Text;
+ bc.UseMnemonic = UseMnemonic;
+ }
+
+ return (bc);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the ButtonX control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+
+ #region Dispose
+
+ ///
+ /// Dispose
+ ///
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ HookEvents(false);
+
+ if (disposing == true)
+ _LabelX.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewMaskedTextBoxAdv/DataGridViewMaskedTextBoxAdvCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewMaskedTextBoxAdv/DataGridViewMaskedTextBoxAdvCell.cs
new file mode 100644
index 00000000..66d58574
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewMaskedTextBoxAdv/DataGridViewMaskedTextBoxAdvCell.cs
@@ -0,0 +1,790 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewMaskedTextBoxAdvCell : DataGridViewTextBoxCell
+ {
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
+ static extern IntPtr PostMessage(IntPtr hWnd, int msg, int wParam, int lParam);
+
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (typeof(DataGridViewMaskedTextBoxAdvEditingControl)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region InitializeEditingControl
+
+ ///
+ /// InitializeEditingControl
+ ///
+ ///
+ ///
+ ///
+ public override void InitializeEditingControl(int rowIndex,
+ object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ DetachEditingControl();
+
+ base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
+
+ DataGridViewMaskedTextBoxAdvEditingControl ctl =
+ (DataGridViewMaskedTextBoxAdvEditingControl) DataGridView.EditingControl;
+
+ DataGridViewMaskedTextBoxAdvColumn oc = OwningColumn as DataGridViewMaskedTextBoxAdvColumn;
+
+ if (oc != null)
+ {
+ MaskedTextBoxAdv tb = oc.MaskedTextBoxAdv;
+
+ ctl.AllowPromptAsInput = tb.AllowPromptAsInput;
+ ctl.AsciiOnly = tb.AsciiOnly;
+ ctl.BeepOnError = false;
+ ctl.Culture = tb.Culture;
+ ctl.CutCopyMaskFormat = tb.CutCopyMaskFormat;
+ ctl.DropDownControl = tb.DropDownControl;
+ ctl.Enabled = tb.Enabled;
+ ctl.FocusHighlightColor = tb.FocusHighlightColor;
+ ctl.FocusHighlightEnabled = tb.FocusHighlightEnabled;
+ ctl.HidePromptOnLeave = tb.HidePromptOnLeave;
+ ctl.ImeMode = tb.ImeMode;
+ ctl.InsertKeyMode = tb.InsertKeyMode;
+ ctl.Mask = tb.Mask;
+ ctl.PasswordChar = tb.PasswordChar;
+ ctl.PromptChar = tb.PromptChar;
+ ctl.RejectInputOnFirstFailure = tb.RejectInputOnFirstFailure;
+ ctl.ResetOnPrompt = tb.ResetOnPrompt;
+ ctl.ResetOnSpace = tb.ResetOnSpace;
+ ctl.RightToLeft = tb.RightToLeft;
+ ctl.SkipLiterals = tb.SkipLiterals;
+ ctl.TextAlign = GetTextAlignment(dataGridViewCellStyle.Alignment);
+ ctl.TextMaskFormat = tb.TextMaskFormat;
+ ctl.UseSystemPasswordChar = tb.UseSystemPasswordChar;
+ ctl.ValidatingType = tb.ValidatingType;
+ ctl.WatermarkBehavior = tb.WatermarkBehavior;
+ ctl.WatermarkColor = tb.WatermarkColor;
+ ctl.WatermarkEnabled = tb.WatermarkEnabled;
+ ctl.WatermarkFont = tb.WatermarkFont;
+ ctl.WatermarkText = tb.WatermarkText;
+
+ // The underlying MaskedTextBox's MultiLine property
+ // is "not fully supported" - but we'll set it anyway.
+
+ ctl.MaskedTextBox.Multiline = (dataGridViewCellStyle.WrapMode == DataGridViewTriState.True);
+
+ ctl.BackgroundStyle.ApplyStyle(tb.BackgroundStyle);
+ ctl.BackgroundStyle.Class = tb.BackgroundStyle.Class;
+
+ tb.ButtonClear.CopyToItem(ctl.ButtonClear);
+ tb.ButtonCustom.CopyToItem(ctl.ButtonCustom);
+ tb.ButtonCustom2.CopyToItem(ctl.ButtonCustom2);
+ tb.ButtonDropDown.CopyToItem(ctl.ButtonDropDown);
+
+ ctl.ButtonClearClick += ButtonClearClick;
+ ctl.ButtonCustomClick += ButtonCustomClick;
+ ctl.ButtonCustom2Click += ButtonCustom2Click;
+ ctl.ButtonDropDownClick += ButtonDropDownClick;
+ ctl.KeyDown += KeyDown;
+
+ ctl.Text = GetValue(initialFormattedValue);
+
+ ctl.BeepOnError = tb.BeepOnError;
+ }
+ }
+
+ #endregion
+
+ #region DetachEditingControl
+
+ ///
+ /// DetachEditingControl
+ ///
+ public override void DetachEditingControl()
+ {
+ if (DataGridView != null && DataGridView.EditingControl != null)
+ {
+ DataGridViewMaskedTextBoxAdvEditingControl di =
+ DataGridView.EditingControl as DataGridViewMaskedTextBoxAdvEditingControl;
+
+ if (di != null)
+ {
+ di.ButtonClearClick -= ButtonClearClick;
+ di.ButtonCustomClick -= ButtonCustomClick;
+ di.ButtonCustom2Click -= ButtonCustom2Click;
+ di.ButtonDropDownClick -= ButtonDropDownClick;
+ di.KeyDown -= KeyDown;
+ }
+ }
+
+ base.DetachEditingControl();
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region ButtonClearClick
+
+ ///
+ /// ButtonClearClick
+ ///
+ ///
+ ///
+ void ButtonClearClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewMaskedTextBoxAdvColumn)OwningColumn).DoButtonClearClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustomClick
+
+ ///
+ /// ButtonCustomClick
+ ///
+ ///
+ ///
+ void ButtonCustomClick(object sender, EventArgs e)
+ {
+ ((DataGridViewMaskedTextBoxAdvColumn)OwningColumn).DoButtonCustomClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustom2Click
+
+ ///
+ /// ButtonCustom2Click
+ ///
+ ///
+ ///
+ void ButtonCustom2Click(object sender, EventArgs e)
+ {
+ ((DataGridViewMaskedTextBoxAdvColumn)OwningColumn).DoButtonCustom2Click(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonDropDownClick
+
+ ///
+ /// ButtonDropDownClick
+ ///
+ ///
+ ///
+ void ButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewMaskedTextBoxAdvColumn)OwningColumn).DoButtonDropDownClick(sender, e);
+ }
+
+ #endregion
+
+ #region KeyDown
+
+ ///
+ /// KeyDown routine forwards all DataGridView sent keys to
+ /// the underlying focusable control
+ ///
+ ///
+ ///
+ void KeyDown(object sender, KeyEventArgs e)
+ {
+ if (DataGridView != null && DataGridView.EditingControl != null)
+ {
+ DataGridViewMaskedTextBoxAdvEditingControl di =
+ DataGridView.EditingControl as DataGridViewMaskedTextBoxAdvEditingControl;
+
+ if (di != null)
+ {
+ di.MaskedTextBox.SelectAll();
+
+ PostMessage(di.MaskedTextBox.Handle, 256, (int) e.KeyCode, 1);
+ }
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PositionEditingControl
+
+ ///
+ /// PositionEditingControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override void PositionEditingControl(bool setLocation, bool setSize, Rectangle cellBounds,
+ Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded,
+ bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
+ {
+ Rectangle editingControlBounds =
+ PositionEditingPanel(cellBounds, cellClip, cellStyle, singleVerticalBorderAdded,
+ singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow);
+
+ editingControlBounds = GetAdjustedEditingControlBounds(editingControlBounds, cellStyle);
+
+ DataGridView.EditingControl.Location = new Point(editingControlBounds.X, editingControlBounds.Y);
+ DataGridView.EditingControl.Size = new Size(editingControlBounds.Width, editingControlBounds.Height);
+ }
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetCellBounds(editingControlBounds);
+
+ if (cellStyle.WrapMode != DataGridViewTriState.True)
+ {
+ if (r.Height < editingControlBounds.Height)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.MiddleLeft:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height)/2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ editingControlBounds.Height = Math.Max(1, r.Height);
+ }
+
+ editingControlBounds.Width = Math.Max(1, editingControlBounds.Width);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ #region GetPreferredSize
+
+ ///
+ /// GetPreferredSize
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Size GetPreferredSize(Graphics graphics,
+ DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ {
+ if (DataGridView == null)
+ return (new Size(-1, -1));
+
+ Size preferredSize = base.GetPreferredSize(graphics, cellStyle, rowIndex, constraintSize);
+
+ DataGridViewMaskedTextBoxAdvColumn oc = OwningColumn as DataGridViewMaskedTextBoxAdvColumn;
+
+ if (oc != null)
+ {
+ MaskedTextBoxAdv msk = oc.MaskedTextBoxAdv;
+
+ preferredSize.Height = msk.Height;
+
+ if (constraintSize.Width == 0)
+ {
+ preferredSize.Width += GetImageWidth(msk.ButtonClear);
+ preferredSize.Width += GetImageWidth(msk.ButtonCustom);
+ preferredSize.Width += GetImageWidth(msk.ButtonCustom2);
+ preferredSize.Width += GetImageWidth(msk.ButtonDropDown);
+ }
+ }
+
+ return (preferredSize);
+ }
+
+ #endregion
+
+ #region GetFormattedValue
+
+ protected override object GetFormattedValue(object value, int rowIndex,
+ ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter,
+ TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
+ {
+ DataGridViewMaskedTextBoxAdvColumn oc = OwningColumn as DataGridViewMaskedTextBoxAdvColumn;
+
+ if (oc != null)
+ {
+ MaskedTextBoxAdv msk = oc.MaskedTextBoxAdv;
+ msk.Text = GetValue(value);
+
+ return (msk.Text);
+ }
+
+ return (base.GetFormattedValue(value, rowIndex,
+ ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
+ }
+
+ #endregion
+
+ #region GetImageWidth
+
+ private int GetImageWidth(InputButtonSettings ibs)
+ {
+ if (ibs.Visible == true)
+ return (ibs.Image != null ? ibs.Image.Width : 16);
+
+ return (0);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
+ DataGridViewElementStates elementState, object value, object formattedValue,
+ string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle,
+ DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewMaskedTextBoxAdvColumn oc = (DataGridViewMaskedTextBoxAdvColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintCellBackground(g, cellStyle, rBk);
+ PaintCellContent(g, cellBounds, rowIndex, formattedValue, cellStyle, paintParts, bm);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintCellBackground
+
+ ///
+ /// Paints the cell background
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintCellContent
+
+ ///
+ /// Paints the cell content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellContent(Graphics g, Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts, Bitmap bm)
+ {
+ DataGridViewMaskedTextBoxAdvColumn oc = (DataGridViewMaskedTextBoxAdvColumn)OwningColumn;
+ MaskedTextBoxAdv di = oc.MaskedTextBoxAdv;
+
+ Point ptCurrentCell = DataGridView.CurrentCellAddress;
+ bool cellCurrent = ptCurrentCell.X == ColumnIndex && ptCurrentCell.Y == rowIndex;
+ bool cellEdited = cellCurrent && DataGridView.EditingControl != null;
+
+ // If the cell is in editing mode, there is nothing else to paint
+
+ if (cellEdited == false && rowIndex < DataGridView.RowCount)
+ {
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ {
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ di.Font = cellStyle.Font;
+ di.ForeColor = cellStyle.ForeColor;
+ di.BackColor = cellStyle.BackColor;
+
+ di.TextAlign = GetTextAlignment(cellStyle.Alignment);
+ di.Text = GetValue(value);
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+
+ if (oc.DisplayControlForCurrentCellOnly == false)
+ DrawControl(di, cellStyle, r, bm, g, oc);
+ else
+ DrawText(di, cellStyle, r, g);
+ }
+ }
+ }
+
+ #region DrawControl
+
+ ///
+ /// DrawControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void DrawControl(MaskedTextBoxAdv di, DataGridViewCellStyle cellStyle, Rectangle r,
+ Bitmap bm, Graphics g, DataGridViewMaskedTextBoxAdvColumn oc)
+ {
+ if (di.ButtonGroup.Items.Count > 0)
+ {
+ // Determine if we must perform some tom-foolery in order
+ // to get the control to DrawToBitmap correctly in older
+ // Windows versions
+
+ if (MustRenderVisibleControl() == true)
+ {
+ di.Location = oc.DataGridView.Location;
+
+ if (di.Parent == null)
+ {
+ Form form = oc.DataGridView.FindForm();
+
+ if (form != null)
+ di.Parent = form;
+ }
+
+ di.SendToBack();
+ di.Visible = true;
+ }
+
+ using (Bitmap bm2 = new Bitmap(bm))
+ {
+ di.Bounds = r;
+ di.DrawToBitmap(bm2, r);
+
+ foreach (VisualItem item in di.ButtonGroup.Items)
+ {
+ if (item.Visible == true)
+ {
+ Rectangle t = item.RenderBounds;
+ t.X += r.X;
+ t.Y += r.Y;
+
+ g.DrawImage(bm2, t, t, GraphicsUnit.Pixel);
+
+ if (t.Left < r.Right)
+ r.Width -= (r.Right - t.Left - 1);
+ }
+ }
+ }
+
+ di.Visible = false;
+ }
+
+ DrawText(di, cellStyle, r, g);
+ }
+
+ #endregion
+
+ #region DrawText
+
+ ///
+ /// DrawText
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void DrawText(MaskedTextBoxAdv di, DataGridViewCellStyle cellStyle, Rectangle r, Graphics g)
+ {
+ r.Inflate(-2, 0);
+
+ eTextFormat tf = eTextFormat.Default | eTextFormat.NoPrefix;
+
+ switch (di.TextAlign)
+ {
+ case HorizontalAlignment.Center:
+ tf |= eTextFormat.HorizontalCenter;
+ break;
+
+ case HorizontalAlignment.Right:
+ tf |= eTextFormat.Right;
+ break;
+ }
+
+ if (cellStyle.WrapMode == DataGridViewTriState.True)
+ tf |= eTextFormat.WordBreak;
+
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.TopLeft:
+ case DataGridViewContentAlignment.TopCenter:
+ case DataGridViewContentAlignment.TopRight:
+ tf |= eTextFormat.Top;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ tf |= eTextFormat.Bottom;
+ break;
+
+ default:
+ tf |= eTextFormat.VerticalCenter;
+ break;
+ }
+
+ DataGridViewMaskedTextBoxAdvColumn oc = (DataGridViewMaskedTextBoxAdvColumn)OwningColumn;
+
+ string text = di.Text;
+
+ if (oc.PasswordChar != '\0')
+ text = "".PadRight(text.Length, oc.PasswordChar);
+
+ TextDrawing.DrawString(g, text, di.Font, di.ForeColor, r, tf);
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region MustRenderVisibleControl
+
+ ///
+ /// MustRenderVisibleControl
+ ///
+ ///
+ private bool MustRenderVisibleControl()
+ {
+ OperatingSystem osInfo = Environment.OSVersion;
+
+ return (osInfo.Platform == PlatformID.Win32Windows ||
+ (osInfo.Platform == PlatformID.Win32NT && osInfo.Version.Major < 6));
+
+ }
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewMaskedTextBoxAdvColumn oc = (DataGridViewMaskedTextBoxAdvColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+ #endregion
+
+ #region GetCellBounds
+
+ ///
+ /// Gets the button bounds for the given cell
+ ///
+ ///
+ ///
+ private Rectangle GetCellBounds(Rectangle cellBounds)
+ {
+ DataGridViewMaskedTextBoxAdvColumn oc = (DataGridViewMaskedTextBoxAdvColumn)OwningColumn;
+
+ Size size = oc.MaskedTextBoxAdv.PreferredSize;
+
+ cellBounds.Location = new Point(1, 1);
+
+ cellBounds.Width -= oc.DividerWidth;
+ cellBounds.Height = size.Height - 1;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetValue
+
+ ///
+ /// GetValue
+ ///
+ ///
+ ///
+ private string GetValue(object value)
+ {
+ return ((value != Convert.DBNull ? Convert.ToString(value) : ""));
+ }
+
+ #endregion
+
+ #region GetTextAlignment
+
+ ///
+ /// GetTextAlignment
+ ///
+ ///
+ ///
+ private HorizontalAlignment GetTextAlignment(DataGridViewContentAlignment alignment)
+ {
+ switch (alignment)
+ {
+ case DataGridViewContentAlignment.TopCenter:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.BottomCenter:
+ return (HorizontalAlignment.Center);
+
+ case DataGridViewContentAlignment.TopRight:
+ case DataGridViewContentAlignment.MiddleRight:
+ case DataGridViewContentAlignment.BottomRight:
+ return (HorizontalAlignment.Right);
+
+ default:
+ return (HorizontalAlignment.Left);
+ }
+ }
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewMaskedTextBoxAdv/DataGridViewMaskedTextBoxAdvColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewMaskedTextBoxAdv/DataGridViewMaskedTextBoxAdvColumn.cs
new file mode 100644
index 00000000..c5503143
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewMaskedTextBoxAdv/DataGridViewMaskedTextBoxAdvColumn.cs
@@ -0,0 +1,924 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewMaskedTextBoxAdvColumn), "Controls.MaskedTextBoxAdv.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewMaskedTextBoxAdvColumn : DataGridViewTextBoxColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ ///
+ /// Occurs right before a MaskedTextBoxAdv Cell is painted
+ ///
+ [Description("Occurs right before a MaskedTextBoxAdv Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ ///
+ /// Occurs when Clear button is clicked and allows you
+ /// to cancel the default action performed by the button
+ ///
+ [Description("Occurs when Clear button is clicked and allows you to cancel the default action performed by the button.")]
+ public event EventHandler ButtonClearClick;
+
+ ///
+ /// Occurs when ButtonCustom control is clicked
+ ///
+ [Description("Occurs when ButtonCustom control is clicked.")]
+ public event EventHandler ButtonCustomClick;
+
+ ///
+ /// Occurs when ButtonCustom2 control is clicked
+ ///
+ [Description("Occurs when ButtonCustom2 control is clicked.")]
+ public event EventHandler ButtonCustom2Click;
+
+ ///
+ /// Occurs when Drop-Down button is clicked and allows you to cancel showing of the popup
+ ///
+ [Description("Occurs when Drop-Down button is clicked and allows you to cancel showing of the popup.")]
+ public event EventHandler ButtonDropDownClick;
+
+ #endregion
+
+ #region Private variables
+
+ private MaskedTextBoxAdv _MaskedTextBoxAdv;
+ private Bitmap _CellBitmap;
+ private bool _DisplayControlForCurrentCellOnly = true;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewMaskedTextBoxAdvColumn()
+ {
+ CellTemplate = new DataGridViewMaskedTextBoxAdvCell();
+
+ _MaskedTextBoxAdv = new MaskedTextBoxAdv();
+
+ _MaskedTextBoxAdv.BackgroundStyle.Class = ElementStyleClassKeys.DataGridViewBorderKey;
+ }
+
+ #region Internal properties
+
+ #region MaskedTextBoxAdv
+
+ ///
+ /// Gets the underlying MaskedTextBoxAdv control
+ ///
+ [Browsable(false)]
+ internal MaskedTextBoxAdv MaskedTextBoxAdv
+ {
+ get { return (_MaskedTextBoxAdv); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region AllowPromptAsInput
+
+ ///
+ /// Gets or sets a value indicating whether PromptChar can be entered as valid data.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether PromptChar can be entered as valid data.")]
+ public bool AllowPromptAsInput
+ {
+ get { return (_MaskedTextBoxAdv.AllowPromptAsInput); }
+ set { _MaskedTextBoxAdv.AllowPromptAsInput = value; }
+ }
+
+ #endregion
+
+ #region AsciiOnly
+
+ ///
+ /// Gets or sets a value indicating whether characters outside of the ASCII character set will be accepted.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether whether characters outside of the ASCII character set will be accepted.")]
+ public bool AsciiOnly
+ {
+ get { return (_MaskedTextBoxAdv.AsciiOnly); }
+ set { _MaskedTextBoxAdv.AsciiOnly = value; }
+ }
+
+ #endregion
+
+ #region BackColor
+
+ ///
+ /// Gets or sets the Background color.
+ ///
+ [Browsable(false)]
+ public Color BackColor
+ {
+ get { return (_MaskedTextBoxAdv.BackColor); }
+ set { _MaskedTextBoxAdv.BackColor = value; }
+ }
+
+ #endregion
+
+ #region BackgroundStyle
+
+ ///
+ /// Specifies the background style of the control.
+ ///
+ [Browsable(true), Category("Style")]
+ [Description("Gets or sets control background style.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return (_MaskedTextBoxAdv.BackgroundStyle); }
+ }
+
+ ///
+ /// Resets style to default value. Used by windows forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackgroundStyle()
+ {
+ _MaskedTextBoxAdv.ResetBackgroundStyle();
+
+ _MaskedTextBoxAdv.BackgroundStyle.Class = "TextBoxBorder";
+ _MaskedTextBoxAdv.BackgroundStyle.CornerType = eCornerType.Square;
+ }
+
+ #endregion
+
+ #region BeepOnError
+
+ ///
+ /// Gets or sets a value indicating whether the masked text box
+ /// control raises the system beep for each user key stroke that it rejects.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether the masked text box control raises the system beep for each user key stroke that it rejects.")]
+ public bool BeepOnError
+ {
+ get { return (_MaskedTextBoxAdv.BeepOnError); }
+ set { _MaskedTextBoxAdv.BeepOnError = value; }
+ }
+
+ #endregion
+
+ #region ButtonClear
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that clears the content of the control when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that clears the content of the control when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonClear
+ {
+ get { return (_MaskedTextBoxAdv.ButtonClear); }
+ }
+
+ #endregion
+
+ #region ButtonCustom
+
+ ///
+ /// Gets the object that describes the settings for the custom button
+ /// that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom
+ {
+ get { return (_MaskedTextBoxAdv.ButtonCustom); }
+ }
+
+ #endregion
+
+ #region ButtonCustom2
+
+ ///
+ /// Gets the object that describes the settings for the custom button that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom2
+ {
+ get { return (_MaskedTextBoxAdv.ButtonCustom2); }
+ }
+
+ #endregion
+
+ #region ButtonDropDown
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that shows drop-down when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that shows drop-down when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonDropDown
+ {
+ get { return (_MaskedTextBoxAdv.ButtonDropDown); }
+ }
+
+ #endregion
+
+ #region Culture
+
+ ///
+ /// Gets or sets the culture information associated with the masked text box.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates the culture information associated with the masked text box.")]
+ public CultureInfo Culture
+ {
+ get { return (_MaskedTextBoxAdv.Culture); }
+ set { _MaskedTextBoxAdv.Culture = value; }
+ }
+
+ #endregion
+
+ #region CutCopyMaskFormat
+
+ ///
+ /// Gets or sets a value that determines whether
+ /// literals and prompt characters are copied to the clipboard
+ ///
+ [Browsable(true), DefaultValue(MaskFormat.IncludeLiterals)]
+ [Description("Indicates whether literals and prompt characters are copied to the clipboard.")]
+ public MaskFormat CutCopyMaskFormat
+ {
+ get { return (_MaskedTextBoxAdv.CutCopyMaskFormat); }
+ set { _MaskedTextBoxAdv.CutCopyMaskFormat = value; }
+ }
+
+ #endregion
+
+ #region DisplayControlForCurrentCellOnly
+
+ ///
+ /// Gets or sets whether the control
+ /// will be displayed for the current cell only.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether the control will be displayed for the current cell only.")]
+ public bool DisplayControlForCurrentCellOnly
+ {
+ get { return (_DisplayControlForCurrentCellOnly); }
+
+ set
+ {
+ if (_DisplayControlForCurrentCellOnly != value)
+ {
+ _DisplayControlForCurrentCellOnly = value;
+ _MaskedTextBoxAdv.Invalidate();
+ }
+ }
+ }
+
+ #endregion
+
+ #region DropDownControl
+
+ ///
+ /// Gets or sets the reference of the control that will be
+ /// displayed on popup that is shown when the drop-down button is clicked.
+ ///
+ [DefaultValue(null)]
+ [Description("Indicates reference of the control that will be displayed on popup that is shown when the drop-down button is clicked.")]
+ public Control DropDownControl
+ {
+ get { return (_MaskedTextBoxAdv.DropDownControl); }
+ set { _MaskedTextBoxAdv.DropDownControl = value; }
+ }
+
+ #endregion
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_MaskedTextBoxAdv.Enabled); }
+ set { _MaskedTextBoxAdv.Enabled = value; }
+ }
+
+ #endregion
+
+ #region FocusHighlightColor
+
+ ///
+ /// Gets or sets the color used as background color to highlight
+ /// the text box when it has input focus and FocusHighlight is enabled.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates color used as background color to highlight the text box when it has input focus and FocusHighlight is enabled.")]
+ public Color FocusHighlightColor
+ {
+ get { return (_MaskedTextBoxAdv.FocusHighlightColor); }
+ set { _MaskedTextBoxAdv.FocusHighlightColor = value; }
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeFocusHighlightColor()
+ {
+ return (_MaskedTextBoxAdv.ShouldSerializeFocusHighlightColor());
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetFocusHighlightColor()
+ {
+ _MaskedTextBoxAdv.ResetFocusHighlightColor();
+ }
+
+ #endregion
+
+ #region FocusHighlightEnabled
+
+ ///
+ /// Gets or sets whether FocusHighlightColor is used as
+ /// background color to highlight the text box when it has
+ /// input focus. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance")]
+ [Description("Indicates whether FocusHighlightColor is used as background color to highlight the text box when it has input focus.")]
+ public bool FocusHighlightEnabled
+ {
+ get { return (_MaskedTextBoxAdv.FocusHighlightEnabled); }
+ set { _MaskedTextBoxAdv.FocusHighlightEnabled = value; }
+ }
+
+ #endregion
+
+ #region ForeColor
+
+ ///
+ /// Gets or sets the foreground color.
+ ///
+ [Browsable(false)]
+ public Color ForeColor
+ {
+ get { return (_MaskedTextBoxAdv.ForeColor); }
+ set { _MaskedTextBoxAdv.ForeColor = value; }
+ }
+
+ #endregion
+
+ #region HidePromptOnLeave
+
+ ///
+ /// Gets or sets a value indicating whether the prompt characters
+ /// in the input mask are hidden when the masked text box loses focus.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether the prompt characters in the input mask are hidden when the masked text box loses focus.")]
+ public bool HidePromptOnLeave
+ {
+ get { return (_MaskedTextBoxAdv.HidePromptOnLeave); }
+ set { _MaskedTextBoxAdv.HidePromptOnLeave = value; }
+ }
+
+ #endregion
+
+ #region ImeMode
+
+ ///
+ /// Gets or sets the Input Method Editor (IME) mode of the control.
+ ///
+ [Browsable(true), DefaultValue(ImeMode.Inherit)]
+ [Description("Indicates the Input Method Editor (IME) mode of the control.")]
+ public ImeMode ImeMode
+ {
+ get { return (_MaskedTextBoxAdv.ImeMode); }
+ set { _MaskedTextBoxAdv.ImeMode = value; }
+ }
+
+ #endregion
+
+ #region InsertKeyMode
+
+ ///
+ /// Gets or sets the text insertion mode of the masked text box control.
+ ///
+ [Browsable(true), DefaultValue(InsertKeyMode.Default)]
+ [Description("Indicates the text insertion mode of the masked text box control.")]
+ public InsertKeyMode InsertKeyMode
+ {
+ get { return (_MaskedTextBoxAdv.InsertKeyMode); }
+ set { _MaskedTextBoxAdv.InsertKeyMode = value; }
+ }
+
+ #endregion
+
+ #region Mask
+
+ ///
+ /// Gets or sets the input mask to use at run time.
+ ///
+ [Browsable(true), DefaultValue(null)]
+ [Description("Indicates the input mask to use at run time.")]
+ public string Mask
+ {
+ get { return (_MaskedTextBoxAdv.Mask); }
+ set { _MaskedTextBoxAdv.Mask = value; }
+ }
+
+ #endregion
+
+ #region PasswordChar
+
+ ///
+ /// Gets or sets the character to be displayed in substitute for user input.
+ ///
+ [Browsable(true), DefaultValue(null)]
+ [Description("Indicates the character to be displayed in substitute for user input.")]
+ public char PasswordChar
+ {
+ get { return (_MaskedTextBoxAdv.PasswordChar); }
+ set { _MaskedTextBoxAdv.PasswordChar = value; }
+ }
+
+ #endregion
+
+ #region PromptChar
+
+ ///
+ /// Gets or sets the character used to represent the absence of user input.
+ ///
+ [Browsable(true), DefaultValue('_')]
+ [Description("Indicates the character used to represent the absence of user input.")]
+ public char PromptChar
+ {
+ get { return (_MaskedTextBoxAdv.PromptChar); }
+ set { _MaskedTextBoxAdv.PromptChar = value; }
+ }
+
+ #endregion
+
+ #region RejectInputOnFirstFailure
+
+ ///
+ /// Gets or sets a value indicating whether the parsing of
+ /// user input should stop after the first invalid character is reached.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates the parsing of user input should stop after the first invalid character is reached.")]
+ public bool RejectInputOnFirstFailure
+ {
+ get { return (_MaskedTextBoxAdv.RejectInputOnFirstFailure); }
+ set { _MaskedTextBoxAdv.RejectInputOnFirstFailure = value; }
+ }
+
+ #endregion
+
+ #region ResetOnPrompt
+
+ ///
+ /// Gets or sets a value that determines how an input
+ /// character that matches the prompt character should be handled.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates how an input character that matches the prompt character should be handled.")]
+ public bool ResetOnPrompt
+ {
+ get { return (_MaskedTextBoxAdv.ResetOnPrompt); }
+ set { _MaskedTextBoxAdv.ResetOnPrompt = value; }
+ }
+
+ #endregion
+
+ #region ResetOnSpace
+
+ ///
+ /// Gets or sets a value that determines how
+ /// a space input character should be handled.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates how a space input character should be handled.")]
+ public bool ResetOnSpace
+ {
+ get { return (_MaskedTextBoxAdv.ResetOnSpace); }
+ set { _MaskedTextBoxAdv.ResetOnSpace = value; }
+ }
+
+ #endregion
+
+ #region RightToLeft
+
+ ///
+ /// Gets or sets a value indicating whether control's
+ /// elements are aligned to support locales using right-to-left fonts.
+ ///
+ [Browsable(true), DefaultValue(RightToLeft.Inherit)]
+ [Description("Indicates the control's elements are aligned to support locales using right-to-left fonts.")]
+ public RightToLeft RightToLeft
+ {
+ get { return (_MaskedTextBoxAdv.RightToLeft); }
+ set { _MaskedTextBoxAdv.RightToLeft = value; }
+ }
+
+ #endregion
+
+ #region SkipLiterals
+
+ ///
+ /// Gets or sets a value indicating
+ /// whether the user is allowed to reenter literal values.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates the user is allowed to reenter literal values.")]
+ public bool SkipLiterals
+ {
+ get { return (_MaskedTextBoxAdv.SkipLiterals); }
+ set { _MaskedTextBoxAdv.SkipLiterals = value; }
+ }
+
+ #endregion
+
+ #region Text
+
+ ///
+ /// Gets or sets the text as it is currently displayed to the user.
+ ///
+ [Browsable(false)]
+ public string Text
+ {
+ get { return (_MaskedTextBoxAdv.Text); }
+ set { _MaskedTextBoxAdv.Text = value; }
+ }
+
+ #endregion
+
+ #region TextAlign
+
+ ///
+ /// Gets or sets how text is aligned in a masked text box control.
+ ///
+ [Browsable(true), DefaultValue(HorizontalAlignment.Left)]
+ [Description("Indicates how text is aligned in a masked text box control.")]
+ public HorizontalAlignment TextAlign
+ {
+ get { return (_MaskedTextBoxAdv.TextAlign); }
+ set { _MaskedTextBoxAdv.TextAlign = value; }
+ }
+
+ #endregion
+
+ #region TextMaskFormat
+
+ ///
+ /// Gets or sets a value that determines whether literals
+ /// and prompt characters are included in the formatted string.
+ ///
+ [Browsable(true), DefaultValue(MaskFormat.IncludeLiterals)]
+ [Description("Indicates whether literals and prompt characters are included in the formatted string.")]
+ public MaskFormat TextMaskFormat
+ {
+ get { return (_MaskedTextBoxAdv.TextMaskFormat); }
+ set { _MaskedTextBoxAdv.TextMaskFormat = value; }
+ }
+
+ #endregion
+
+ #region UseSystemPasswordChar
+
+ ///
+ /// Gets or sets a value indicating whether
+ /// the operating system-supplied password character should be used.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether the operating system-supplied password character should be used.")]
+ public bool UseSystemPasswordChar
+ {
+ get { return (_MaskedTextBoxAdv.UseSystemPasswordChar); }
+ set { _MaskedTextBoxAdv.UseSystemPasswordChar = value; }
+ }
+
+ #endregion
+
+ #region ValidatingType
+
+ ///
+ /// Gets or sets the data type used to verify the data input by the user.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ [Description("Indicates the data type used to verify the data input by the user.")]
+ public Type ValidatingType
+ {
+ get { return (_MaskedTextBoxAdv.ValidatingType); }
+ set { _MaskedTextBoxAdv.ValidatingType = value; }
+ }
+
+ #endregion
+
+ #region WatermarkBehavior
+
+ ///
+ /// Gets or sets the watermark hiding behaviour. Default value
+ /// indicates that watermark is hidden when control receives input focus.
+ ///
+ [Browsable(true), DefaultValue(eWatermarkBehavior.HideOnFocus), Category("Behavior")]
+ [Description("Indicates watermark hiding behaviour.")]
+ public eWatermarkBehavior WatermarkBehavior
+ {
+ get { return (_MaskedTextBoxAdv.WatermarkBehavior); }
+ set { _MaskedTextBoxAdv.WatermarkBehavior = value; }
+ }
+
+ #endregion
+
+ #region WatermarkColor
+
+ ///
+ /// Gets or sets the watermark text color.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates watermark text color.")]
+ public Color WatermarkColor
+ {
+ get { return (_MaskedTextBoxAdv.WatermarkColor); }
+ set { _MaskedTextBoxAdv.WatermarkColor = value; }
+ }
+ ///
+ /// Indicates whether property should be serialized by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeWatermarkColor()
+ {
+ return (_MaskedTextBoxAdv.ShouldSerializeWatermarkColor());
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetWatermarkColor()
+ {
+ _MaskedTextBoxAdv.ResetWatermarkColor();
+ }
+
+ #endregion
+
+ #region WatermarkEnabled
+
+ ///
+ /// Gets or sets whether watermark text is
+ /// displayed when control is empty. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether watermark text is displayed when control is empty.")]
+ public virtual bool WatermarkEnabled
+ {
+ get { return (_MaskedTextBoxAdv.WatermarkEnabled); }
+ set { _MaskedTextBoxAdv.WatermarkEnabled = value; }
+ }
+
+ #endregion
+
+ #region WatermarkFont
+
+ ///
+ /// Gets or sets the watermark font.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(null)]
+ [Description("Indicates watermark font.")]
+ public Font WatermarkFont
+ {
+ get { return (_MaskedTextBoxAdv.WatermarkFont); }
+ set { _MaskedTextBoxAdv.WatermarkFont = value; }
+ }
+
+ #endregion
+
+ #region WatermarkText
+
+ ///
+ /// Gets or sets the watermark (tip) text displayed inside of
+ /// the control when Text is not set and control does not have
+ /// input focus. This property supports text-markup.
+ ///
+ [Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance")]
+ [Description("Indicates watermark text displayed inside of the control when Text is not set and control does not have input focus.")]
+ [Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ public string WatermarkText
+ {
+ get { return (_MaskedTextBoxAdv.WatermarkText); }
+ set { _MaskedTextBoxAdv.WatermarkText = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Event processing
+
+ #region DoButtonClearClick
+
+ ///
+ /// DoButtonClearClick
+ ///
+ ///
+ ///
+ internal void DoButtonClearClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonClearClick != null)
+ ButtonClearClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustomClick
+
+ ///
+ /// DoButtonCustomClick
+ ///
+ ///
+ ///
+ internal void DoButtonCustomClick(object sender, EventArgs e)
+ {
+ if (ButtonCustomClick != null)
+ ButtonCustomClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustom2Click
+
+ ///
+ /// DoButtonCustom2Click
+ ///
+ ///
+ ///
+ internal void DoButtonCustom2Click(object sender, EventArgs e)
+ {
+ if (ButtonCustom2Click != null)
+ ButtonCustom2Click(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonDropDownClick
+
+ ///
+ /// DoButtonDropDownClick
+ ///
+ ///
+ ///
+ internal void DoButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonDropDownClick != null)
+ ButtonDropDownClick(this, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewMaskedTextBoxAdvColumn dc = base.Clone() as DataGridViewMaskedTextBoxAdvColumn;
+
+ if (dc != null)
+ {
+ dc.AllowPromptAsInput = AllowPromptAsInput;
+ dc.AsciiOnly = AsciiOnly;
+ dc.BeepOnError = BeepOnError;
+ dc.Culture = Culture;
+ dc.CutCopyMaskFormat = CutCopyMaskFormat;
+ dc.DropDownControl = DropDownControl;
+ dc.Enabled = Enabled;
+ dc.FocusHighlightColor = FocusHighlightColor;
+ dc.FocusHighlightEnabled = FocusHighlightEnabled;
+ dc.HidePromptOnLeave = HidePromptOnLeave;
+ dc.ImeMode = ImeMode;
+ dc.InsertKeyMode = InsertKeyMode;
+ dc.Mask = Mask;
+ dc.PasswordChar = PasswordChar;
+ dc.PromptChar = PromptChar;
+ dc.RejectInputOnFirstFailure = RejectInputOnFirstFailure;
+ dc.ResetOnPrompt = ResetOnPrompt;
+ dc.ResetOnSpace = ResetOnSpace;
+ dc.RightToLeft = RightToLeft;
+ dc.SkipLiterals = SkipLiterals;
+ dc.TextAlign = TextAlign;
+ dc.TextMaskFormat = TextMaskFormat;
+ dc.UseSystemPasswordChar = UseSystemPasswordChar;
+ dc.ValidatingType = ValidatingType;
+ dc.WatermarkBehavior = WatermarkBehavior;
+ dc.WatermarkColor = WatermarkColor;
+ dc.WatermarkEnabled = WatermarkEnabled;
+ dc.WatermarkFont = WatermarkFont;
+ dc.WatermarkText = WatermarkText;
+
+ dc.DisplayControlForCurrentCellOnly = DisplayControlForCurrentCellOnly;
+
+ dc.BackgroundStyle.ApplyStyle(MaskedTextBoxAdv.BackgroundStyle);
+ dc.BackgroundStyle.Class = MaskedTextBoxAdv.BackgroundStyle.Class;
+
+ MaskedTextBoxAdv.ButtonClear.CopyToItem(dc.MaskedTextBoxAdv.ButtonClear);
+ MaskedTextBoxAdv.ButtonDropDown.CopyToItem(dc.MaskedTextBoxAdv.ButtonDropDown);
+ MaskedTextBoxAdv.ButtonCustom.CopyToItem(dc.MaskedTextBoxAdv.ButtonCustom);
+ MaskedTextBoxAdv.ButtonCustom2.CopyToItem(dc.MaskedTextBoxAdv.ButtonCustom2);
+ }
+
+ return (dc);
+ }
+
+ #endregion
+
+ #region Dispose
+
+ ///
+ /// Dispose
+ ///
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing == true)
+ _MaskedTextBoxAdv.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewMaskedTextBoxAdv/DataGridViewMaskedTextBoxAdvEditingControl.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewMaskedTextBoxAdv/DataGridViewMaskedTextBoxAdvEditingControl.cs
new file mode 100644
index 00000000..74df2d7f
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewMaskedTextBoxAdv/DataGridViewMaskedTextBoxAdvEditingControl.cs
@@ -0,0 +1,185 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewMaskedTextBoxAdvEditingControl : MaskedTextBoxAdv, IDataGridViewEditingControl
+ {
+ #region Private variables
+
+ private DataGridView _DataGridView;
+
+ private int _RowIndex;
+ private bool _ValueChanged;
+
+ #endregion
+
+ #region OnTextChanged
+
+ ///
+ /// Handles OnTextChanged events
+ ///
+ ///
+ protected override void OnTextChanged(EventArgs e)
+ {
+ _ValueChanged = true;
+
+ _DataGridView.NotifyCurrentCellDirty(true);
+
+ base.OnTextChanged(e);
+ }
+
+ #endregion
+
+ #region IDataGridViewEditingControl Members
+
+ #region Public properties
+
+ #region EditingControlDataGridView
+
+ ///
+ /// Gets or sets the DataGridView
+ ///
+ public DataGridView EditingControlDataGridView
+ {
+ get { return (_DataGridView); }
+ set { _DataGridView = value; }
+ }
+
+ #endregion
+
+ #region EditingControlFormattedValue
+
+ ///
+ /// Gets or sets the Control Formatted Value
+ ///
+ public object EditingControlFormattedValue
+ {
+ get { return (Text); }
+ set { Text = (string) value; }
+ }
+
+ #endregion
+
+ #region EditingControlRowIndex
+
+ ///
+ /// Gets or sets the Control RoeIndex
+ ///
+ public int EditingControlRowIndex
+ {
+ get { return (_RowIndex); }
+ set { _RowIndex = value; }
+ }
+
+ #endregion
+
+ #region EditingControlValueChanged
+
+ ///
+ /// Gets or sets the Control ValueChanged state
+ ///
+ public bool EditingControlValueChanged
+ {
+ get { return (_ValueChanged); }
+ set { _ValueChanged = value; }
+ }
+
+ #endregion
+
+ #region EditingPanelCursor
+
+ ///
+ /// Gets the Panel Cursor
+ ///
+ public Cursor EditingPanelCursor
+ {
+ get { return (base.Cursor); }
+ }
+
+ #endregion
+
+ #region RepositionEditingControlOnValueChange
+
+ ///
+ /// Gets whether to RepositionEditingControlOnValueChange
+ ///
+ public bool RepositionEditingControlOnValueChange
+ {
+ get { return (false); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region ApplyCellStyleToEditingControl
+
+ ///
+ /// ApplyCellStyleToEditingControl
+ ///
+ ///
+ public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ Font = dataGridViewCellStyle.Font;
+
+ ForeColor = dataGridViewCellStyle.ForeColor;
+ BackColor = dataGridViewCellStyle.BackColor;
+ }
+
+ #endregion
+
+ #region GetEditingControlFormattedValue
+
+ ///
+ /// Gets EditingControlFormattedValue
+ ///
+ ///
+ ///
+ public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
+ {
+ return (EditingControlFormattedValue);
+ }
+
+ #endregion
+
+ #region EditingControlWantsInputKey
+
+ ///
+ /// Gets whether the given key wants to be processed
+ /// by the Control
+ ///
+ ///
+ ///
+ ///
+ public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
+ {
+ if ((keyData & Keys.Right) == Keys.Right)
+ return (true);
+
+ if ((keyData & Keys.Left) == Keys.Left)
+ return (true);
+
+ return (dataGridViewWantsInputKey == false);
+ }
+
+ #endregion
+
+ #region PrepareEditingControlForEdit
+
+ ///
+ /// PrepareEditingControlForEdit
+ ///
+ ///
+ public void PrepareEditingControlForEdit(bool selectAll)
+ {
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewProgressBarX/DataGridViewProgressBarXCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewProgressBarX/DataGridViewProgressBarXCell.cs
new file mode 100644
index 00000000..84f3adae
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewProgressBarX/DataGridViewProgressBarXCell.cs
@@ -0,0 +1,402 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewProgressBarXCell : DataGridViewButtonCell
+ {
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (null); }
+ }
+
+ #endregion
+
+ #region FormattedValueType
+
+ ///
+ /// FormattedValueType
+ ///
+ public override Type FormattedValueType
+ {
+ get { return (typeof(string)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState,
+ object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintButtonBackground(g, cellStyle, rBk);
+ PaintButtonContent(cellBounds, rowIndex, formattedValue, cellStyle, paintParts, bm);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintButtonBackground
+
+ ///
+ /// Paints the Button background
+ ///
+ ///
+ ///
+ ///
+ private void PaintButtonBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false,
+ false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintButtonContent
+
+ ///
+ /// Paints the button background and content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintButtonContent(Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts, Bitmap bm)
+ {
+ DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn)OwningColumn;
+ ProgressBarX bx = oc.ProgressBarX;
+
+ Rectangle rBt = GetContentBounds(cellBounds, true);
+
+ if (rBt.Width > 0 && rBt.Height > 0)
+ {
+ string s = oc.Text;
+
+ oc.InCallBack = true;
+
+ try
+ {
+ bx.Font = cellStyle.Font;
+ bx.ForeColor = cellStyle.ForeColor;
+ bx.BackColor = cellStyle.BackColor;
+
+ bx.Value = GetValue(value, bx.Minimum);
+
+ if (rowIndex < DataGridView.RowCount)
+ {
+ bx.Text = s;
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+ }
+ else
+ {
+ bx.Text = "";
+ }
+
+ bx.Bounds = rBt;
+ bx.RecalcLayout();
+ bx.DrawToBitmap(bm, rBt);
+ }
+ finally
+ {
+ oc.InCallBack = false;
+ }
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Mouse processing
+
+ #region OnMouseEnter
+
+ ///
+ /// OnMouseEnter
+ ///
+ ///
+ protected override void OnMouseEnter(int rowIndex)
+ {
+ base.OnMouseEnter(rowIndex);
+
+ DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn) OwningColumn;
+ ProgressBarX bx = oc.ProgressBarX;
+
+ bx.ProgressBarItem.InternalMouseEnter();
+ }
+
+ #endregion
+
+ #region OnMouseLeave
+
+ ///
+ /// Processes MouseLeave events
+ ///
+ ///
+ protected override void OnMouseLeave(int rowIndex)
+ {
+ base.OnMouseLeave(rowIndex);
+
+ DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn)OwningColumn;
+ ProgressBarX bx = oc.ProgressBarX;
+
+ bx.ProgressBarItem.InternalMouseLeave();
+ }
+
+ #endregion
+
+ #region OnMouseMove
+
+ ///
+ /// Processes MouseMove events
+ ///
+ ///
+ protected override void OnMouseMove(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+
+ DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn)OwningColumn;
+ ProgressBarX bx = oc.ProgressBarX;
+
+ bx.ProgressBarItem.InternalMouseMove(
+ new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
+ }
+
+ #endregion
+
+ #region OnMouseDown
+
+ ///
+ /// Processes MouseDown events
+ ///
+ ///
+ protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+
+ DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn)OwningColumn;
+ ProgressBarX bx = oc.ProgressBarX;
+
+ Rectangle cellBounds = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
+ Rectangle rBt = GetContentBounds(cellBounds, false);
+
+ Point pt = e.Location;
+ pt.Offset(rBt.Location);
+
+ if (rBt.Contains(pt) == true)
+ {
+ bx.Bounds = rBt;
+
+ bx.ProgressBarItem.InternalMouseDown(
+ new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
+
+ DataGridView.Invalidate(rBt);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseUp
+
+ ///
+ /// Processes MouseUp events
+ ///
+ ///
+ protected override void OnMouseUp(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+
+ DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn)OwningColumn;
+ ProgressBarX bx = oc.ProgressBarX;
+
+ Rectangle cellBounds = DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
+ Rectangle rBt = GetContentBounds(cellBounds, false);
+
+ bx.Bounds = rBt;
+
+ bx.ProgressBarItem.InternalMouseUp(
+ new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
+
+ DataGridView.Invalidate(rBt);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetContentBounds
+
+ ///
+ /// Gets the content bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetContentBounds(Rectangle cellBounds, bool localize)
+ {
+ DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn)OwningColumn;
+
+ cellBounds.Width -= (oc.DividerWidth + 3);
+ cellBounds.Height -= 3;
+
+ if (localize == true)
+ cellBounds.Location = new Point(0, 0);
+
+ cellBounds.X++;
+ cellBounds.Y++;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetValue
+
+ ///
+ /// GetValue
+ ///
+ ///
+ ///
+ ///
+ private int GetValue(object value, int minimum)
+ {
+ if (value == Convert.DBNull ||
+ (value is string && String.IsNullOrEmpty((string) value) == true))
+ {
+ return (minimum);
+ }
+
+ return (Convert.ToInt32(value));
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewProgressBarX/DataGridViewProgressBarXColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewProgressBarX/DataGridViewProgressBarXColumn.cs
new file mode 100644
index 00000000..67997259
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewProgressBarX/DataGridViewProgressBarXColumn.cs
@@ -0,0 +1,433 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewButtonXColumn), "Controls.ProgressBarX.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewProgressBarXColumn : DataGridViewButtonColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ [Description("Occurs right before a ProgressBarX Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ [Description("Occurs when a ProgressBarX Cell is Clicked.")]
+ public event EventHandler Click;
+
+ #endregion
+
+ #region Private variables
+
+ private ProgressBarX _ProgressBarX;
+ private Bitmap _CellBitmap;
+
+ private bool _InCellCallBack;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewProgressBarXColumn()
+ {
+ CellTemplate = new DataGridViewProgressBarXCell();
+
+ _ProgressBarX = new ProgressBarX();
+ _ProgressBarX.Visible = false;
+
+ HookEvents(true);
+ }
+
+ #region Hidden properties
+
+ ///
+ /// Button FlatStyle
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new FlatStyle FlatStyle
+ {
+ get { return base.FlatStyle; }
+ set { base.FlatStyle = value; }
+ }
+
+ ///
+ /// Button UseColumnTextForButtonValue
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new bool UseColumnTextForButtonValue
+ {
+ get { return base.UseColumnTextForButtonValue; }
+ set { base.UseColumnTextForButtonValue = value; }
+ }
+
+ #endregion
+
+ #region Internal properties
+
+ #region InCallBack
+
+ ///
+ /// InCallBack
+ ///
+ internal bool InCallBack
+ {
+ get { return (_InCellCallBack); }
+ set { _InCellCallBack = value; }
+ }
+
+ #endregion
+
+ #region ProgressBarX
+
+ ///
+ /// Gets the Control ProgressBarX
+ ///
+ internal ProgressBarX ProgressBarX
+ {
+ get { return (_ProgressBarX); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region ChunkColor
+
+ ///
+ /// Gets or sets the color of the progress chunk.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance")]
+ [Description("Gets or sets the color of the progress chunk.")]
+ public Color ChunkColor
+ {
+ get { return (_ProgressBarX.ChunkColor); }
+ set { _ProgressBarX.ChunkColor = value; }
+ }
+
+ ///
+ /// Gets whether ChunkColor property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeChunkColor()
+ {
+ return (_ProgressBarX.ChunkColor.IsEmpty == false);
+ }
+
+ ///
+ /// Resets the ChunkColor property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetChunkColor()
+ {
+ _ProgressBarX.ChunkColor = Color.Empty;
+ }
+
+ #endregion
+
+ #region ChunkColor2
+
+ ///
+ /// Gets or sets the target gradient color of the progress chunk.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Appearance")]
+ [Description("Gets or sets the target gradient color of the progress chunk.")]
+ public Color ChunkColor2
+ {
+ get { return (_ProgressBarX.ChunkColor2); }
+ set { _ProgressBarX.ChunkColor2 = value; }
+ }
+
+ ///
+ /// Gets whether ChunkColor property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeChunkColor2()
+ {
+ return (_ProgressBarX.ChunkColor2.IsEmpty == false);
+ }
+
+ ///
+ /// Resets the ChunkColor property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetChunkColor2()
+ {
+ _ProgressBarX.ChunkColor2 = Color.Empty;
+ }
+
+ #endregion
+
+ #region ChunkGradientAngle
+
+ ///
+ /// Gets or sets the gradient angle of the progress chunk.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(0), Category("Appearance")]
+ [Description("Gets or sets the gradient angle of the progress chunk.")]
+ public int ChunkGradientAngle
+ {
+ get { return (_ProgressBarX.ChunkGradientAngle); }
+ set { _ProgressBarX.ChunkGradientAngle = value; }
+ }
+
+ #endregion
+
+ #region ColorTable
+
+ ///
+ /// Gets or sets the predefined color state table for progress bar. Color
+ /// specified applies to items with Office 2007 style only. It does not have
+ /// any effect on other styles. You can use ColorTable to indicate the state
+ /// of the operation that Progress Bar is tracking. Default value is eProgressBarItemColor.Normal.
+ ///
+ [Browsable(true), DevCoBrowsable(false), DefaultValue(eProgressBarItemColor.Normal), Category("Appearance")]
+ [Description("Indicates predefined color of item when Office 2007 style is used.")]
+ public eProgressBarItemColor ColorTable
+ {
+ get { return (_ProgressBarX.ColorTable); }
+ set { _ProgressBarX.ColorTable = value; }
+ }
+
+ #endregion
+
+ #region Maximum
+
+ ///
+ /// Gets or sets the maximum value of the range of the control.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(100)]
+ [Description("Indicates the maximum value of the range of the control.")]
+ public int Maximum
+ {
+ get { return (_ProgressBarX.Maximum); }
+ set { _ProgressBarX.Maximum = value; }
+ }
+
+ #endregion
+
+ #region Minimum
+
+ ///
+ /// Gets or sets the minimum value of the range of the control.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Behavior"), DefaultValue(0)]
+ [Description("Indicates the minimum value of the range of the control.")]
+ public int Minimum
+ {
+ get { return (_ProgressBarX.Minimum); }
+ set { _ProgressBarX.Minimum = value; }
+ }
+
+ #endregion
+
+ #region Style
+
+ ///
+ /// Gets/Sets the visual style for the control.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(eDotNetBarStyle.Office2007)]
+ [Description("Specifies the visual style of the control.")]
+ public virtual eDotNetBarStyle Style
+ {
+ get { return (_ProgressBarX.Style); }
+ set { _ProgressBarX.Style = value; }
+ }
+
+ #endregion
+
+ #region Text
+
+ ///
+ /// Gets or sets the default Text to display on the Progress Bar
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue("")]
+ [Description("Indicates the default Text to display on the Progress Bar.")]
+ public new string Text
+ {
+ get
+ {
+ return (_InCellCallBack == true ?
+ _ProgressBarX.Text : base.Text);
+ }
+
+ set
+ {
+ if (_InCellCallBack == true)
+ _ProgressBarX.Text = value;
+ else
+ base.Text = value;
+ }
+ }
+
+ #endregion
+
+ #region TextVisible
+
+ ///
+ /// Gets or sets whether the text inside the progress bar is displayed.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(false)]
+ [Description("Gets or sets whether the text inside the progress bar is displayed.")]
+ public bool TextVisible
+ {
+ get { return (_ProgressBarX.TextVisible); }
+ set { _ProgressBarX.TextVisible = value; }
+ }
+
+ #endregion
+
+ #region Value
+
+ ///
+ /// Gets or sets the current position of the progress bar.
+ ///
+ [Browsable(true), DevCoBrowsable(true), Category("Behavior"), DefaultValue(0)]
+ [Description("Indicates the current position of the progress bar.")]
+ public int Value
+ {
+ get { return (_ProgressBarX.Value); }
+ set { _ProgressBarX.Value = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region HookEvents
+
+ ///
+ /// Hooks or unhooks our system events
+ ///
+ ///
+ private void HookEvents(bool hook)
+ {
+ if (hook == true)
+ {
+ _ProgressBarX.ProgressBarItem.Click += ProgressBarItem_Click;
+ }
+ else
+ {
+ _ProgressBarX.ProgressBarItem.Click -= ProgressBarItem_Click;
+ }
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region ProgressBarItem_Click
+
+ ///
+ /// ProgressBarItem_Click
+ ///
+ ///
+ ///
+ void ProgressBarItem_Click(object sender, EventArgs e)
+ {
+ if (Click != null)
+ Click(sender, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewProgressBarXColumn bc = base.Clone() as DataGridViewProgressBarXColumn;
+
+ if (bc != null)
+ _ProgressBarX.ProgressBarItem.InternalCopyToItem(bc.ProgressBarX.ProgressBarItem);
+
+ return (bc);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the ButtonX control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+
+ #region Dispose
+
+ ///
+ /// Dispose
+ ///
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ HookEvents(false);
+
+ if (disposing == true)
+ _ProgressBarX.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewSlider/DataGridViewSliderCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewSlider/DataGridViewSliderCell.cs
new file mode 100644
index 00000000..8f352326
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewSlider/DataGridViewSliderCell.cs
@@ -0,0 +1,604 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewSliderCell : DataGridViewTextBoxCell
+ {
+ #region Private variables
+
+ private DataGridViewCellStyle _CellStyle;
+
+ #endregion
+
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (null); }
+ }
+
+ #endregion
+
+ #region ValueType
+
+ ///
+ /// Gets the type of the underlying data
+ /// (i.e., the type of the cell's Value property)
+ ///
+ public override Type ValueType
+ {
+ get { return (base.ValueType ?? typeof(Int32)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetContentBounds(editingControlBounds);
+
+ if (r.Height < editingControlBounds.Height)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.MiddleLeft:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height) / 2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ editingControlBounds.Width = Math.Max(1, editingControlBounds.Width);
+ editingControlBounds.Height = Math.Max(1, r.Height);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ #region GetPreferredSize
+
+ ///
+ /// GetPreferredSize
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override Size GetPreferredSize(Graphics graphics,
+ DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ {
+ Size preferredSize = new Size(-1, -1);
+
+ if (DataGridView != null)
+ {
+ DataGridViewSliderColumn oc = OwningColumn as DataGridViewSliderColumn;
+
+ if (oc != null)
+ {
+ Slider sc = oc.Slider;
+
+ preferredSize.Height = sc.Height;
+
+ if (constraintSize.Width == 0)
+ {
+ preferredSize.Width += 80;
+
+ if (sc.LabelVisible == true)
+ preferredSize.Width += sc.LabelWidth;
+ }
+ }
+ }
+
+ return (preferredSize);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState,
+ object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewSliderColumn oc = (DataGridViewSliderColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintSliderBackground(g, cellStyle, rBk);
+ PaintSliderContent(cellBounds, rowIndex, formattedValue, cellStyle, paintParts, g);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintSliderBackground
+
+ ///
+ /// Paints the Slider background
+ ///
+ ///
+ ///
+ ///
+ private void PaintSliderBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false, false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintSliderContent
+
+ ///
+ /// Paints the Slider content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintSliderContent(Rectangle cellBounds,
+ int rowIndex, object value, DataGridViewCellStyle cellStyle,
+ DataGridViewPaintParts paintParts, Graphics g)
+ {
+ DataGridViewSliderColumn oc = (DataGridViewSliderColumn) OwningColumn;
+ Slider slider = oc.Slider;
+
+ _CellStyle = cellStyle;
+
+ int saveValue = slider.Value;
+
+ eSliderPart mouseOverPart = slider.SliderItem.MouseOverPart;
+ eSliderPart mouseDownPart = slider.SliderItem.MouseDownPart;
+
+ GraphicsState gs = g.Save();
+
+ try
+ {
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ if (rowIndex != oc.ActiveRowIndex)
+ {
+ slider.SliderItem.MouseOverPart = eSliderPart.None;
+ slider.SliderItem.MouseDownPart = eSliderPart.None;
+ }
+
+ slider.Font = cellStyle.Font;
+ slider.ForeColor = cellStyle.ForeColor;
+ slider.BackColor = Selected ? Color.Transparent : cellStyle.BackColor;
+
+ if (rowIndex < DataGridView.RowCount)
+ {
+ slider.Text = oc.Text;
+
+ if (rowIndex != oc.ActiveRowIndex)
+ slider.Value = GetSliderValue(value);
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+ }
+ else
+ {
+ slider.Text = "";
+ slider.Value = GetSliderValue(value);
+ }
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+
+ g.TranslateTransform(r.X, r.Y);
+
+ slider.CallBasePaintBackground = false;
+
+ slider.Bounds = r;
+ slider.InternalPaint(new PaintEventArgs(g, Rectangle.Empty));
+ }
+ finally
+ {
+ g.Restore(gs);
+
+ slider.Value = saveValue;
+
+ slider.SliderItem.MouseOverPart = mouseOverPart;
+ slider.SliderItem.MouseDownPart = mouseDownPart;
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Mouse processing
+
+ #region OnMouseEnter
+
+ ///
+ /// OnMouseEnter
+ ///
+ ///
+ protected override void OnMouseEnter(int rowIndex)
+ {
+ base.OnMouseEnter(rowIndex);
+
+ DoMouseEnter(rowIndex, true);
+ }
+
+ #region DoMouseEnter
+
+ ///
+ /// Process MouseEnter state
+ ///
+ ///
+ ///
+ private void DoMouseEnter(int rowIndex, bool refresh)
+ {
+ DataGridViewSliderColumn oc = (DataGridViewSliderColumn) OwningColumn;
+ Slider slider = oc.Slider;
+
+ // Work around an issue where we get notified of a mouse enter, but
+ // we will fault if we try to get the Value associated with the cell
+
+ if (Visible == true)
+ {
+ oc.ActiveRowIndex = rowIndex;
+
+ slider.Value = GetSliderValue(Value);
+
+ slider.SliderItem.InternalMouseEnter();
+
+ if (refresh == true)
+ RefreshSlider(ColumnIndex, rowIndex);
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region OnMouseLeave
+
+ ///
+ /// Processes MouseLeave events
+ ///
+ ///
+ protected override void OnMouseLeave(int rowIndex)
+ {
+ base.OnMouseLeave(rowIndex);
+
+ DataGridViewSliderColumn oc = (DataGridViewSliderColumn)OwningColumn;
+ Slider slider = oc.Slider;
+
+ if (oc.ActiveRowIndex >= 0)
+ {
+ oc.ActiveRowIndex = -1;
+
+ slider.SliderItem.InternalMouseLeave();
+
+ Value = slider.Value;
+
+ RefreshSlider(ColumnIndex, rowIndex);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseMove
+
+ ///
+ /// Processes MouseMove events
+ ///
+ ///
+ protected override void OnMouseMove(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+
+ DataGridViewSliderColumn oc = OwningColumn as DataGridViewSliderColumn;
+
+ if (oc != null)
+ {
+ // Work around an issue where we get notified of a mouse enter / move, but
+ // we will fault if we try to get the Value associated with the cell
+
+ if (oc.ActiveRowIndex == -1)
+ DoMouseEnter(e.RowIndex, false);
+
+ if (oc.ActiveRowIndex >= 0)
+ {
+ Point pt = CellAlignPoint(e.X, e.Y);
+
+ oc.Slider.SliderItem.InternalMouseMove(
+ new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
+
+ RefreshSlider(e.ColumnIndex, e.RowIndex);
+ }
+ }
+ }
+
+ #endregion
+
+ #region OnMouseDown
+
+ ///
+ /// Processes MouseDown events
+ ///
+ ///
+ protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+
+ DataGridViewSliderColumn oc = OwningColumn as DataGridViewSliderColumn;
+
+ if (oc != null)
+ {
+ Point pt = CellAlignPoint(e.X, e.Y);
+
+ oc.Slider.SliderItem.InternalMouseDown(
+ new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
+
+ RefreshSlider(e.ColumnIndex, e.RowIndex);
+ }
+ }
+
+ #endregion
+
+ #region OnMouseUp
+
+ ///
+ /// Processes MouseUp events
+ ///
+ ///
+ protected override void OnMouseUp(DataGridViewCellMouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+
+ DataGridViewSliderColumn oc = OwningColumn as DataGridViewSliderColumn;
+
+ if (oc != null)
+ {
+ Point pt = CellAlignPoint(e.X, e.Y);
+
+ oc.Slider.SliderItem.InternalMouseUp(
+ new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta));
+
+ Value = oc.Slider.Value;
+
+ RefreshSlider(e.ColumnIndex, e.RowIndex);
+ }
+ }
+
+ #endregion
+
+ #region CellAlignPoint
+
+ ///
+ /// CellAlignPoint
+ ///
+ ///
+ ///
+ ///
+ private Point CellAlignPoint(int x, int y)
+ {
+ Rectangle r = GetAdjustedEditingControlBounds(ContentBounds, _CellStyle);
+
+ return (new Point(x, y - r.Y));
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetSliderValue
+
+ ///
+ /// GetSliderValue
+ ///
+ ///
+ ///
+ internal int GetSliderValue(object value)
+ {
+ if (value == Convert.DBNull ||
+ (value is string && String.IsNullOrEmpty((string) value) == true))
+ {
+ return (0);
+ }
+
+ return (Convert.ToInt32(value));
+ }
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewSliderColumn oc = (DataGridViewSliderColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetContentBounds
+
+ ///
+ /// Gets the content bounds for the given cell
+ ///
+ ///
+ ///
+ private Rectangle GetContentBounds(Rectangle cellBounds)
+ {
+ DataGridViewSliderColumn oc = (DataGridViewSliderColumn)OwningColumn;
+
+ if (oc.Slider.Parent == null)
+ {
+ Form form = oc.DataGridView.FindForm();
+
+ if (form != null)
+ oc.Slider.Parent = form;
+ }
+
+ oc.Slider.SliderItem.RecalcSize();
+
+ cellBounds.Width -= (oc.DividerWidth + 3);
+ cellBounds.Height = oc.Slider.SliderItem.HeightInternal;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region RefreshSlider
+
+ ///
+ /// Initiates the refresh of the cell slider
+ ///
+ ///
+ ///
+ internal void RefreshSlider(int columnIndex, int rowIndex)
+ {
+ if (DataGridView != null)
+ DataGridView.InvalidateCell(columnIndex, rowIndex);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewSlider/DataGridViewSliderColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewSlider/DataGridViewSliderColumn.cs
new file mode 100644
index 00000000..40ba6be8
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewSlider/DataGridViewSliderColumn.cs
@@ -0,0 +1,462 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewButtonXColumn), "Controls.Slider.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewSliderColumn : DataGridViewTextBoxColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ ///
+ /// Occurs right before a Slider Cell is painted
+ ///
+ [Description("Occurs right before a Slider Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ [Description("Occurs when a Slider Cell is Clicked.")]
+ public event EventHandler Click;
+
+ #endregion
+
+ #region Private variables
+
+ private Slider _Slider;
+ private Bitmap _CellBitmap;
+
+ private int _ActiveRowIndex = -1;
+ private bool _BindingComplete;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewSliderColumn()
+ {
+ CellTemplate = new DataGridViewSliderCell();
+
+ _Slider = new Slider();
+ _Slider.Visible = false;
+
+ HookEvents(true);
+ }
+
+ #region Internal properties
+
+ #region ActiveRowIndex
+
+ ///
+ /// Gets or sets the active row index
+ ///
+ internal int ActiveRowIndex
+ {
+ get { return (_ActiveRowIndex); }
+ set { _ActiveRowIndex = value; }
+ }
+
+ #endregion
+
+ #region BindingComplete
+
+ ///
+ /// Gets or sets the DataBindingComplete state
+ ///
+ internal bool BindingComplete
+ {
+ get { return (_BindingComplete); }
+ set { _BindingComplete = value; }
+ }
+
+ #endregion
+
+ #region Slider
+
+ ///
+ /// Gets the Control Slider
+ ///
+ internal Slider Slider
+ {
+ get { return (_Slider); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_Slider.Enabled); }
+ set { _Slider.Enabled = value; }
+ }
+
+ #endregion
+
+ #region EnableMarkup
+
+ ///
+ /// Gets or sets whether text-markup support is enabled for items Text property. Default value is true.
+ /// Set this property to false to display HTML or other markup in the item instead of it being parsed as text-markup.
+ ///
+ [DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether text-markup support is enabled for items Text property.")]
+ public bool EnableMarkup
+ {
+ get { return (_Slider.EnableMarkup); }
+ set { _Slider.EnableMarkup = value; }
+ }
+
+ #endregion
+
+ #region LabelPosition
+
+ ///
+ /// Gets or sets the text label position in relationship to the slider. Default value is Left.
+ ///
+ [Browsable(true), DefaultValue(eSliderLabelPosition.Left), Category("Layout")]
+ [Description("Indicates text label position in relationship to the slider")]
+ public eSliderLabelPosition LabelPosition
+ {
+ get { return (_Slider.LabelPosition); }
+ set { _Slider.LabelPosition = value; }
+ }
+
+ #endregion
+
+ #region LabelVisible
+
+ ///
+ /// Gets or sets whether the text label next to the slider is displayed.
+ ///
+ [DevCoBrowsable(true), Browsable(true)]
+ [Description("Gets or sets whether the label text is displayed."), Category("Behavior"), DefaultValue(true)]
+ public bool LabelVisible
+ {
+ get { return (_Slider.LabelVisible); }
+ set { _Slider.LabelVisible = value; }
+ }
+
+ #endregion
+
+ #region LabelWidth
+
+ ///
+ /// Gets or sets the width of the label part of the item in pixels. Value must be greater than 0. Default value is 38.
+ ///
+ [Browsable(true), DevCoBrowsable(true), DefaultValue(38), Category("Layout")]
+ [Description("Indicates width of the label part of the item in pixels.")]
+ public int LabelWidth
+ {
+ get { return (_Slider.LabelWidth); }
+ set { _Slider.LabelWidth = value; }
+ }
+
+ #endregion
+
+ #region Maximum
+
+ ///
+ /// Gets or sets the maximum value of the range of the control.
+ ///
+ [DevCoBrowsable(true), Browsable(true), Category("Behavior"), DefaultValue(100)]
+ [Description("Gets or sets the maximum value of the range of the control.")]
+ public int Maximum
+ {
+ get { return (_Slider.Maximum); }
+ set { _Slider.Maximum = value; }
+ }
+
+ #endregion
+
+ #region Minimum
+
+ ///
+ /// Gets or sets the minimum value of the range of the control.
+ ///
+ [DevCoBrowsable(true), Browsable(true), Category("Behavior"), DefaultValue(0)]
+ [Description("Gets or sets the minimum value of the range of the control.")]
+ public int Minimum
+ {
+ get { return (_Slider.Minimum); }
+ set { _Slider.Minimum = value; }
+ }
+
+ #endregion
+
+ #region Step
+
+ ///
+ /// Gets or sets the amount by which a call to the PerformStep method increases the current position of the slider. Value must be greater than 0.
+ ///
+ [DevCoBrowsable(true), Browsable(true), Category("Behavior"), DefaultValue(1)]
+ [Description("Gets or sets the amount by which a call to the PerformStep method increases the current position of the slider.")]
+ public int Step
+ {
+ get { return (_Slider.Step); }
+ set { _Slider.Step = value; }
+ }
+
+ #endregion
+
+ #region Text
+
+ ///
+ /// Gets or sets the text associated with this item.
+ ///
+ [Browsable(false), DevCoBrowsable(false), DefaultValue(""), Category("Appearance")]
+ [Description("The text contained in the item.")]
+ public string Text
+ {
+ get { return (_Slider.Text); }
+ set { _Slider.Text = value; }
+ }
+
+ #endregion
+
+ #region TextColor
+
+ ///
+ /// Gets or sets the color of the label text.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates color of the label text.")]
+ public Color TextColor
+ {
+ get { return (_Slider.TextColor); }
+ set { _Slider.TextColor = value; }
+ }
+
+ ///
+ /// Returns whether property should be serialized. Used by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeTextColor()
+ {
+ return (_Slider.TextColor.IsEmpty == false);
+ }
+
+ ///
+ /// Resets the property to default value. Used by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetTextColor()
+ {
+ _Slider.TextColor = Color.Empty;
+ }
+
+ #endregion
+
+ #region TrackMarker
+
+ ///
+ /// Gets or sets whether vertical line track marker is displayed on the slide line. Default value is true.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(true)]
+ [Description("Indicates whether vertical line track marker is displayed on the slide line.")]
+ public virtual bool TrackMarker
+ {
+ get { return (_Slider.TrackMarker); }
+ set { _Slider.TrackMarker = value; }
+ }
+
+ #endregion
+
+ #region Value
+
+ ///
+ /// Gets or sets the current position of the slider.
+ ///
+ [Browsable(false)]
+ [Description("Indicates the current position of the slider.")]
+ public int Value
+ {
+ get { return (_Slider.Value); }
+ set { _Slider.Value = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region HookEvents
+
+ ///
+ /// Hooks or unhooks our system events
+ ///
+ ///
+ private void HookEvents(bool hook)
+ {
+ if (hook == true)
+ {
+ _Slider.SliderItem.Click += SliderItem_Click;
+ _Slider.SliderItem.ValueChanged += SliderItem_ValueChanged;
+ }
+ else
+ {
+ _Slider.SliderItem.Click -= SliderItem_Click;
+ _Slider.SliderItem.ValueChanged -= SliderItem_ValueChanged;
+ }
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region SliderItem_Click
+
+ ///
+ /// SliderItem_Click
+ ///
+ ///
+ ///
+ void SliderItem_Click(object sender, EventArgs e)
+ {
+ if (Click != null)
+ Click(sender, e);
+ }
+
+ #endregion
+
+ #region SliderItem_ValueChanged
+
+ ///
+ /// SliderItem_ValueChanged
+ ///
+ ///
+ ///
+ void SliderItem_ValueChanged(object sender, EventArgs e)
+ {
+ if (_Slider.SliderItem.MouseDownPart == eSliderPart.IncreaseButton ||
+ _Slider.SliderItem.MouseDownPart == eSliderPart.DecreaseButton)
+ {
+ DataGridViewSliderCell cell = DataGridView.Rows[ActiveRowIndex].Cells[Index] as DataGridViewSliderCell;
+
+ if (cell != null)
+ {
+ int value = cell.GetSliderValue(cell.Value);
+
+ if (value != _Slider.SliderItem.Value)
+ {
+ cell.Value = _Slider.SliderItem.Value;
+ cell.RefreshSlider(Index, ActiveRowIndex);
+
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewSliderColumn sc = base.Clone() as DataGridViewSliderColumn;
+
+ if (sc != null)
+ {
+ _Slider.SliderItem.InternalCopyToItem(sc.Slider.SliderItem);
+
+ sc.Enabled = Enabled;
+ }
+
+ return (sc);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the ButtonX control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+
+ #region Dispose
+
+ ///
+ /// Dispose
+ ///
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ HookEvents(false);
+
+ if (disposing == true)
+ _Slider.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewTextBoxDropDown/DataGridViewTextBoxDropDownCell.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewTextBoxDropDown/DataGridViewTextBoxDropDownCell.cs
new file mode 100644
index 00000000..c067e9fe
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewTextBoxDropDown/DataGridViewTextBoxDropDownCell.cs
@@ -0,0 +1,670 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DataGridViewTextBoxDropDownCell : DataGridViewTextBoxCell
+ {
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
+ static extern IntPtr PostMessage(IntPtr hWnd, int msg, int wParam, int lParam);
+
+ #region Public properties
+
+ #region EditType
+
+ ///
+ /// Gets the Type of the editing control associated with the cell
+ ///
+ public override Type EditType
+ {
+ get { return (typeof(DataGridViewTextBoxDropDownEditingControl)); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region InitializeEditingControl
+
+ ///
+ /// InitializeEditingControl
+ ///
+ ///
+ ///
+ ///
+ public override void InitializeEditingControl(int rowIndex,
+ object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ DetachEditingControl();
+
+ base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
+
+ DataGridViewTextBoxDropDownEditingControl ctl =
+ (DataGridViewTextBoxDropDownEditingControl)DataGridView.EditingControl;
+
+ DataGridViewTextBoxDropDownColumn oc = (DataGridViewTextBoxDropDownColumn)OwningColumn;
+ TextBoxDropDown tb = oc.TextBoxDropDown;
+
+ ctl.AutoCompleteCustomSource = tb.AutoCompleteCustomSource;
+ ctl.AutoCompleteMode = tb.AutoCompleteMode;
+ ctl.AutoCompleteSource = tb.AutoCompleteSource;
+ ctl.BackColor = tb.BackColor;
+ ctl.CharacterCasing = tb.CharacterCasing;
+ ctl.DropDownControl = tb.DropDownControl;
+ ctl.Enabled = tb.Enabled;
+ ctl.FocusHighlightColor = tb.FocusHighlightColor;
+ ctl.FocusHighlightEnabled = tb.FocusHighlightEnabled;
+ ctl.ForeColor = tb.ForeColor;
+ ctl.HideSelection = tb.HideSelection;
+ ctl.ImeMode = tb.ImeMode;
+ ctl.MaxLength = tb.MaxLength;
+ ctl.PasswordChar = tb.PasswordChar;
+ ctl.RightToLeft = tb.RightToLeft;
+ ctl.TextAlign = GetTextAlignment(dataGridViewCellStyle.Alignment);
+ ctl.UseSystemPasswordChar = tb.UseSystemPasswordChar;
+ ctl.WatermarkBehavior = tb.WatermarkBehavior;
+ ctl.WatermarkColor = tb.WatermarkColor;
+ ctl.WatermarkEnabled = tb.WatermarkEnabled;
+ ctl.WatermarkFont = tb.WatermarkFont;
+ ctl.WatermarkText = tb.WatermarkText;
+
+ ctl.TextBox.Multiline = (dataGridViewCellStyle.WrapMode == DataGridViewTriState.True);
+
+ ctl.BackgroundStyle.ApplyStyle(tb.BackgroundStyle);
+ ctl.BackgroundStyle.Class = tb.BackgroundStyle.Class;
+
+ tb.ButtonClear.CopyToItem(ctl.ButtonClear);
+ tb.ButtonCustom.CopyToItem(ctl.ButtonCustom);
+ tb.ButtonCustom2.CopyToItem(ctl.ButtonCustom2);
+ tb.ButtonDropDown.CopyToItem(ctl.ButtonDropDown);
+
+ ctl.ButtonClearClick += ButtonClearClick;
+ ctl.ButtonCustomClick += ButtonCustomClick;
+ ctl.ButtonCustom2Click += ButtonCustom2Click;
+ ctl.ButtonDropDownClick += ButtonDropDownClick;
+ ctl.KeyDown += KeyDown;
+
+ ctl.Text = (initialFormattedValue != null && initialFormattedValue != Convert.DBNull
+ ? Convert.ToString(initialFormattedValue) : "");
+ }
+
+ #endregion
+
+ #region DetachEditingControl
+
+ ///
+ /// DetachEditingControl
+ ///
+ public override void DetachEditingControl()
+ {
+ if (DataGridView != null && DataGridView.EditingControl != null)
+ {
+ DataGridViewTextBoxDropDownEditingControl di =
+ DataGridView.EditingControl as DataGridViewTextBoxDropDownEditingControl;
+
+ if (di != null)
+ {
+ di.ButtonClearClick -= ButtonClearClick;
+ di.ButtonCustomClick -= ButtonCustomClick;
+ di.ButtonCustom2Click -= ButtonCustom2Click;
+ di.ButtonDropDownClick -= ButtonDropDownClick;
+ di.KeyDown -= KeyDown;
+ }
+ }
+
+ base.DetachEditingControl();
+ }
+
+ #endregion
+
+ #region Event processing
+
+ #region ButtonClearClick
+
+ ///
+ /// ButtonClearClick
+ ///
+ ///
+ ///
+ void ButtonClearClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewTextBoxDropDownColumn)OwningColumn).DoButtonClearClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustomClick
+
+ ///
+ /// ButtonCustomClick
+ ///
+ ///
+ ///
+ void ButtonCustomClick(object sender, EventArgs e)
+ {
+ ((DataGridViewTextBoxDropDownColumn)OwningColumn).DoButtonCustomClick(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonCustom2Click
+
+ ///
+ /// ButtonCustom2Click
+ ///
+ ///
+ ///
+ void ButtonCustom2Click(object sender, EventArgs e)
+ {
+ ((DataGridViewTextBoxDropDownColumn)OwningColumn).DoButtonCustom2Click(sender, e);
+ }
+
+ #endregion
+
+ #region ButtonDropDownClick
+
+ ///
+ /// ButtonDropDownClick
+ ///
+ ///
+ ///
+ void ButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ ((DataGridViewTextBoxDropDownColumn)OwningColumn).DoButtonDropDownClick(sender, e);
+ }
+
+ #endregion
+
+ #region KeyDown
+
+ ///
+ /// KeyDown routine forwards all DataGridView sent keys to
+ /// the underlying focusable control
+ ///
+ ///
+ ///
+ void KeyDown(object sender, KeyEventArgs e)
+ {
+ if (DataGridView != null && DataGridView.EditingControl != null)
+ {
+ DataGridViewTextBoxDropDownEditingControl di =
+ DataGridView.EditingControl as DataGridViewTextBoxDropDownEditingControl;
+
+ if (di != null)
+ PostMessage(di.TextBox.Handle, 256, (int) e.KeyCode, 1);
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region PositionEditingControl
+
+ ///
+ /// PositionEditingControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override void PositionEditingControl(bool setLocation, bool setSize, Rectangle cellBounds,
+ Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded,
+ bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
+ {
+ Rectangle editingControlBounds =
+ PositionEditingPanel(cellBounds, cellClip, cellStyle, singleVerticalBorderAdded,
+ singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow);
+
+ editingControlBounds = GetAdjustedEditingControlBounds(editingControlBounds, cellStyle);
+
+ DataGridView.EditingControl.Location = new Point(editingControlBounds.X, editingControlBounds.Y);
+ DataGridView.EditingControl.Size = new Size(editingControlBounds.Width, editingControlBounds.Height);
+ }
+
+ #endregion
+
+ #region GetAdjustedEditingControlBounds
+
+ ///
+ /// GetAdjustedEditingControlBounds
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetAdjustedEditingControlBounds(
+ Rectangle editingControlBounds, DataGridViewCellStyle cellStyle)
+ {
+ // Add a 1 pixel padding around the editing control
+
+ editingControlBounds.X += 1;
+ editingControlBounds.Y += 1;
+ editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 2);
+ editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - 2);
+
+ // Adjust the vertical location of the editing control
+
+ Rectangle r = GetCellBounds(editingControlBounds);
+
+ if (cellStyle.WrapMode != DataGridViewTriState.True)
+ {
+ if (r.Height < editingControlBounds.Height)
+ {
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.MiddleLeft:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.MiddleRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height)/2;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ editingControlBounds.Y += (editingControlBounds.Height - r.Height);
+ break;
+ }
+ }
+
+ editingControlBounds.Height = Math.Max(1, r.Height);
+ }
+
+ editingControlBounds.Width = Math.Max(1, editingControlBounds.Width);
+
+ return (editingControlBounds);
+ }
+
+ #endregion
+
+ #region GetPreferredSize
+
+ /////
+ ///// GetPreferredSize
+ /////
+ /////
+ /////
+ /////
+ /////
+ /////
+ //protected override Size GetPreferredSize(Graphics graphics,
+ // DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+ //{
+ // if (DataGridView == null)
+ // return (new Size(-1, -1));
+
+ // DataGridViewTextBoxDropDownColumn oc = (DataGridViewTextBoxDropDownColumn)OwningColumn;
+
+ // Size size = oc.TextBoxDropDown.PreferredSize;
+ // size.Height += 3;
+
+ // return (size);
+ //}
+
+ #endregion
+
+ #region Paint
+
+ #region Paint
+
+ ///
+ /// Cell painting
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected override void Paint(Graphics graphics,
+ Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
+ DataGridViewElementStates elementState, object value, object formattedValue,
+ string errorText, DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle,
+ DataGridViewPaintParts paintParts)
+ {
+ if (DataGridView != null)
+ {
+ // First paint the borders of the cell
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Border))
+ PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
+
+ // Now paint the background and content
+
+ if (PartsSet(paintParts, DataGridViewPaintParts.Background))
+ {
+ Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle);
+
+ if (rBk.Height > 0 && rBk.Width > 0)
+ {
+ DataGridViewTextBoxDropDownColumn oc = (DataGridViewTextBoxDropDownColumn)OwningColumn;
+ Bitmap bm = oc.GetCellBitmap(cellBounds);
+
+ if (bm != null)
+ {
+ using (Graphics g = Graphics.FromImage(bm))
+ {
+ PaintCellBackground(g, cellStyle, rBk);
+ PaintCellContent(g, cellBounds, rowIndex, formattedValue, cellStyle, paintParts, bm);
+
+ graphics.DrawImageUnscaledAndClipped(bm, rBk);
+ }
+
+ if ((DataGridView.ShowCellErrors == true) &&
+ (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon)
+ {
+ base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region PaintCellBackground
+
+ ///
+ /// Paints the cell background
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellBackground(Graphics g,
+ DataGridViewCellStyle cellStyle, Rectangle rBack)
+ {
+ Rectangle r = rBack;
+ r.Location = new Point(0, 0);
+
+ DataGridViewX dx = DataGridView as DataGridViewX;
+
+ if (dx != null && dx.Enabled == true && Selected == true &&
+ dx.PaintEnhancedSelection == true)
+ {
+ Office2007ButtonItemPainter.PaintBackground(g, dx.ButtonStateColorTable,
+ r, RoundRectangleShapeDescriptor.RectangleShape, false, false);
+ }
+ else
+ {
+ Color color = (Selected == true)
+ ? cellStyle.SelectionBackColor : cellStyle.BackColor;
+
+ using (Brush br = new SolidBrush(color))
+ g.FillRectangle(br, r);
+ }
+ }
+
+ #endregion
+
+ #region PaintCellContent
+
+ ///
+ /// Paints the cell content
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void PaintCellContent(Graphics g, Rectangle cellBounds, int rowIndex, object value,
+ DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts, Bitmap bm)
+ {
+ DataGridViewTextBoxDropDownColumn oc = (DataGridViewTextBoxDropDownColumn)OwningColumn;
+ TextBoxDropDown di = oc.TextBoxDropDown;
+
+ Point ptCurrentCell = DataGridView.CurrentCellAddress;
+ bool cellCurrent = ptCurrentCell.X == ColumnIndex && ptCurrentCell.Y == rowIndex;
+ bool cellEdited = cellCurrent && DataGridView.EditingControl != null;
+
+ // If the cell is in editing mode, there is nothing else to paint
+
+ if (cellEdited == false && rowIndex < DataGridView.RowCount)
+ {
+ if (PartsSet(paintParts, DataGridViewPaintParts.ContentForeground))
+ {
+ cellBounds.X = 0;
+ cellBounds.Y = 0;
+ cellBounds.Width -= (oc.DividerWidth + 1);
+ cellBounds.Height -= 1;
+
+ di.Font = cellStyle.Font;
+ di.ForeColor = cellStyle.ForeColor;
+ di.BackColor = cellStyle.BackColor;
+
+ di.TextAlign = GetTextAlignment(cellStyle.Alignment);
+ di.Text = GetValue(value);
+
+ oc.OnBeforeCellPaint(rowIndex, ColumnIndex);
+
+ Rectangle r = GetAdjustedEditingControlBounds(cellBounds, cellStyle);
+
+ if (oc.DisplayControlForCurrentCellOnly == false)
+ DrawControl(di, cellStyle, r, bm, g);
+ else
+ DrawText(di, cellStyle, r, g);
+ }
+ }
+ }
+
+ #region DrawControl
+
+ ///
+ /// DrawControl
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void DrawControl(TextBoxDropDown di, DataGridViewCellStyle cellStyle, Rectangle r, Bitmap bm, Graphics g)
+ {
+ if (di.ButtonGroup.Items.Count > 0)
+ {
+ using (Bitmap bm2 = new Bitmap(bm))
+ {
+ di.Bounds = r;
+ di.DrawToBitmap(bm2, r);
+
+ foreach (VisualItem item in di.ButtonGroup.Items)
+ {
+ if (item.Visible == true)
+ {
+ Rectangle t = item.RenderBounds;
+ t.X += r.X;
+ t.Y += r.Y;
+
+ g.DrawImage(bm2, t, t, GraphicsUnit.Pixel);
+
+ if (t.Left < r.Right)
+ r.Width -= (r.Right - t.Left - 1);
+ }
+ }
+ }
+ }
+
+ DrawText(di, cellStyle, r, g);
+ }
+
+ #endregion
+
+ #region DrawText
+
+ ///
+ /// DrawText
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void DrawText(TextBoxDropDown di, DataGridViewCellStyle cellStyle, Rectangle r, Graphics g)
+ {
+ r.Inflate(-2, 0);
+
+ eTextFormat tf = eTextFormat.Default | eTextFormat.NoPrefix;
+
+ switch (di.TextAlign)
+ {
+ case HorizontalAlignment.Center:
+ tf |= eTextFormat.HorizontalCenter;
+ break;
+
+ case HorizontalAlignment.Right:
+ tf |= eTextFormat.Right;
+ break;
+ }
+
+ if (cellStyle.WrapMode == DataGridViewTriState.True)
+ tf |= eTextFormat.WordBreak;
+
+ switch (cellStyle.Alignment)
+ {
+ case DataGridViewContentAlignment.TopLeft:
+ case DataGridViewContentAlignment.TopCenter:
+ case DataGridViewContentAlignment.TopRight:
+ tf |= eTextFormat.Top;
+ break;
+
+ case DataGridViewContentAlignment.BottomLeft:
+ case DataGridViewContentAlignment.BottomCenter:
+ case DataGridViewContentAlignment.BottomRight:
+ tf |= eTextFormat.Bottom;
+ break;
+
+ default:
+ tf |= eTextFormat.VerticalCenter;
+ break;
+ }
+
+ TextDrawing.DrawString(g, di.Text, di.Font, di.ForeColor, r, tf);
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region GetBackBounds
+
+ ///
+ /// Gets the background bounds for the given cell
+ ///
+ ///
+ ///
+ ///
+ private Rectangle GetBackBounds(
+ Rectangle cellBounds, DataGridViewAdvancedBorderStyle advancedBorderStyle)
+ {
+ DataGridViewTextBoxDropDownColumn oc = (DataGridViewTextBoxDropDownColumn)OwningColumn;
+
+ Rectangle r = BorderWidths(advancedBorderStyle);
+
+ cellBounds.Offset(r.X, r.Y);
+ cellBounds.Width -= r.Right;
+ cellBounds.Height -= r.Bottom;
+
+ if (Selected == true)
+ cellBounds.Width += oc.DividerWidth;
+
+ return (cellBounds);
+ }
+ #endregion
+
+ #region GetCellBounds
+
+ ///
+ /// Gets the button bounds for the given cell
+ ///
+ ///
+ ///
+ private Rectangle GetCellBounds(Rectangle cellBounds)
+ {
+ DataGridViewTextBoxDropDownColumn oc = (DataGridViewTextBoxDropDownColumn)OwningColumn;
+
+ Size size = oc.TextBoxDropDown.PreferredSize;
+
+ cellBounds.Location = new Point(1, 1);
+
+ cellBounds.Width -= oc.DividerWidth;
+ cellBounds.Height = size.Height - 1;
+
+ return (cellBounds);
+ }
+
+ #endregion
+
+ #region GetValue
+
+ ///
+ /// GetValue
+ ///
+ ///
+ ///
+ private string GetValue(object value)
+ {
+ return (value != Convert.DBNull ? Convert.ToString(value) : "");
+ }
+
+ #endregion
+
+ #region GetTextAlignment
+
+ ///
+ /// GetTextAlignment
+ ///
+ ///
+ ///
+ private HorizontalAlignment GetTextAlignment(DataGridViewContentAlignment alignment)
+ {
+ switch (alignment)
+ {
+ case DataGridViewContentAlignment.TopCenter:
+ case DataGridViewContentAlignment.MiddleCenter:
+ case DataGridViewContentAlignment.BottomCenter:
+ return (HorizontalAlignment.Center);
+
+ case DataGridViewContentAlignment.TopRight:
+ case DataGridViewContentAlignment.MiddleRight:
+ case DataGridViewContentAlignment.BottomRight:
+ return (HorizontalAlignment.Right);
+
+ default:
+ return (HorizontalAlignment.Left);
+ }
+ }
+
+ #endregion
+
+ #region PartsSet
+
+ ///
+ /// Determines if the given part is set
+ ///
+ ///
+ ///
+ ///
+ private bool PartsSet(DataGridViewPaintParts paintParts, DataGridViewPaintParts parts)
+ {
+ return ((paintParts & parts) == parts);
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewTextBoxDropDown/DataGridViewTextBoxDropDownColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewTextBoxDropDown/DataGridViewTextBoxDropDownColumn.cs
new file mode 100644
index 00000000..e6ea6117
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewTextBoxDropDown/DataGridViewTextBoxDropDownColumn.cs
@@ -0,0 +1,1058 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Design;
+using System.Runtime.InteropServices;
+using System.Security.Permissions;
+using System.Windows.Forms;
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.Editors;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(DataGridViewTextBoxDropDownColumn), "Controls.TextBoxDropDown.ico"), ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewTextBoxDropDownColumn : DataGridViewTextBoxColumn, IDataGridViewColumn
+ {
+ #region Events
+
+ ///
+ /// Occurs right before a TextBoxDropDown Cell is painted
+ ///
+ [Description("Occurs right before a TextBoxDropDown Cell is painted.")]
+ public event EventHandler BeforeCellPaint;
+
+ ///
+ /// Occurs when Clear button is clicked and allows you
+ /// to cancel the default action performed by the button
+ ///
+ [Description("Occurs when Clear button is clicked and allows you to cancel the default action performed by the button.")]
+ public event EventHandler ButtonClearClick;
+
+ ///
+ /// Occurs when ButtonCustom control is clicked
+ ///
+ [Description("Occurs when ButtonCustom control is clicked.")]
+ public event EventHandler ButtonCustomClick;
+
+ ///
+ /// Occurs when ButtonCustom2 control is clicked
+ ///
+ [Description("Occurs when ButtonCustom2 control is clicked.")]
+ public event EventHandler ButtonCustom2Click;
+
+ ///
+ /// Occurs when Drop-Down button is clicked and allows you to cancel showing of the popup
+ ///
+ [Description("Occurs when Drop-Down button is clicked and allows you to cancel showing of the popup.")]
+ public event EventHandler ButtonDropDownClick;
+
+ #endregion
+
+ #region Private variables
+
+ private TextBoxDropDown _TextBoxDropDown;
+ private Bitmap _CellBitmap;
+ private bool _DisplayControlForCurrentCellOnly = true;
+
+ #endregion
+
+ ///
+ /// Constructor
+ ///
+ public DataGridViewTextBoxDropDownColumn()
+ {
+ CellTemplate = new DataGridViewTextBoxDropDownCell();
+
+ _TextBoxDropDown = new TextBoxDropDown();
+
+ _TextBoxDropDown.BackgroundStyle.Class = ElementStyleClassKeys.DataGridViewIpAddressBorderKey;
+ }
+
+ #region Internal properties
+
+ #region TextBoxDropDown
+
+ ///
+ /// Gets the underlying TextBoxDropDown control
+ ///
+ [Browsable(false)]
+ internal TextBoxDropDown TextBoxDropDown
+ {
+ get { return (_TextBoxDropDown); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Public properties
+
+ #region AutoCompleteCustomSource
+
+ ///
+ /// Gets or sets a custom StringCollection to use when
+ /// the AutoCompleteSource property is set to CustomSource.
+ /// A StringCollection to use with AutoCompleteSource.
+ ///
+ [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Localizable(true)]
+ [Description("Indicates custom StringCollection to use when the AutoCompleteSource property is set to CustomSource.")]
+ [Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version= 2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
+ public AutoCompleteStringCollection AutoCompleteCustomSource
+ {
+ get { return (_TextBoxDropDown.AutoCompleteCustomSource); }
+ set { _TextBoxDropDown.AutoCompleteCustomSource = value; }
+ }
+
+ #endregion
+
+ #region AutoCompleteMode
+
+ ///
+ /// Gets or sets an option that controls
+ /// how automatic completion works for the TextBox.
+ /// One of the values of AutoCompleteMode. The values are Append,
+ /// None, Suggest, and SuggestAppend. The default is None.
+ ///
+ [Browsable(true), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(0)]
+ [Description("Gets or sets an option that controls how automatic completion works for the TextBox.")]
+ public AutoCompleteMode AutoCompleteMode
+ {
+ get { return (_TextBoxDropDown.AutoCompleteMode); }
+ set { _TextBoxDropDown.AutoCompleteMode = value; }
+ }
+
+ #endregion
+
+ #region AutoCompleteSource
+
+ ///
+ /// Gets or sets a value specifying the source of complete strings used for automatic completion.
+ /// One of the values of AutoCompleteSource. The options are AllSystemSources, AllUrl, FileSystem, HistoryList, RecentlyUsedList, CustomSource, and None. The default is None.
+ ///
+ [ Browsable(true), DefaultValue(0x80), TypeConverter(typeof(TextBoxAutoCompleteSourceConverter))]
+ [EditorBrowsable(EditorBrowsableState.Always)]
+ [Description("Gets or sets a value specifying the source of complete strings used for automatic completion.")]
+ public AutoCompleteSource AutoCompleteSource
+ {
+ get { return (_TextBoxDropDown.AutoCompleteSource); }
+ set { _TextBoxDropDown.AutoCompleteSource = value; }
+ }
+
+ #endregion
+
+ #region BackColor
+
+ ///
+ /// Gets or sets the Background color.
+ ///
+ [Browsable(false)]
+ public Color BackColor
+ {
+ get { return (_TextBoxDropDown.BackColor); }
+ set { _TextBoxDropDown.BackColor = value; }
+ }
+
+ #endregion
+
+ #region BackgroundStyle
+
+ ///
+ /// Specifies the background style of the control.
+ ///
+ [Browsable(true), Category("Style")]
+ [Description("Gets or sets control background style.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public ElementStyle BackgroundStyle
+ {
+ get { return (_TextBoxDropDown.BackgroundStyle); }
+ }
+
+ ///
+ /// Resets style to default value. Used by windows forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackgroundStyle()
+ {
+ _TextBoxDropDown.ResetBackgroundStyle();
+
+ _TextBoxDropDown.BackgroundStyle.Class = "TextBoxBorder";
+ _TextBoxDropDown.BackgroundStyle.CornerType = eCornerType.Square;
+ }
+
+ #endregion
+
+ #region ButtonClear
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that clears the content of the control when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that clears the content of the control when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonClear
+ {
+ get { return (_TextBoxDropDown.ButtonClear); }
+ }
+
+ #endregion
+
+ #region ButtonCustom
+
+ ///
+ /// Gets the object that describes the settings for the custom button
+ /// that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom
+ {
+ get { return (_TextBoxDropDown.ButtonCustom); }
+ }
+
+ #endregion
+
+ #region ButtonCustom2
+
+ ///
+ /// Gets the object that describes the settings for the custom button that can execute an custom action of your choosing when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the custom button that can execute an custom action of your choosing when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonCustom2
+ {
+ get { return (_TextBoxDropDown.ButtonCustom2); }
+ }
+
+ #endregion
+
+ #region ButtonDropDown
+
+ ///
+ /// Gets the object that describes the settings for the button
+ /// that shows drop-down when clicked.
+ ///
+ [Browsable(true), Category("Buttons")]
+ [Description("Describes the settings for the button that shows drop-down when clicked.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public InputButtonSettings ButtonDropDown
+ {
+ get { return (_TextBoxDropDown.ButtonDropDown); }
+ }
+
+ #endregion
+
+ #region CharacterCasing
+
+ ///
+ /// Gets or sets whether the TextBox control
+ /// modifies the case of characters as they are typed.
+ /// One of the CharacterCasing enumeration values that specifies
+ /// whether the TextBox control modifies the case of characters.
+ /// The default is CharacterCasing.Normal.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(0)]
+ [Description("Indicates whether the TextBox control modifies the case of characters as they are typed.")]
+ public CharacterCasing CharacterCasing
+ {
+ get { return (_TextBoxDropDown.CharacterCasing); }
+ set { _TextBoxDropDown.CharacterCasing = value; }
+ }
+
+ #endregion
+
+ #region DisplayControlForCurrentCellOnly
+
+ ///
+ /// Gets or sets whether the control
+ /// will be displayed for the current cell only.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance")]
+ [Description("Indicates whether the control will be displayed for the current cell only.")]
+ public bool DisplayControlForCurrentCellOnly
+ {
+ get { return (_DisplayControlForCurrentCellOnly); }
+
+ set
+ {
+ if (_DisplayControlForCurrentCellOnly != value)
+ {
+ _DisplayControlForCurrentCellOnly = value;
+ _TextBoxDropDown.Invalidate();
+ }
+ }
+ }
+
+ #endregion
+
+ #region DropDownControl
+
+ ///
+ /// Gets or sets the reference of the control that will be
+ /// displayed on popup that is shown when the drop-down button is clicked.
+ ///
+ [DefaultValue(null)]
+ [Description("Indicates reference of the control that will be displayed on popup that is shown when the drop-down button is clicked.")]
+ public Control DropDownControl
+ {
+ get { return (_TextBoxDropDown.DropDownControl); }
+ set { _TextBoxDropDown.DropDownControl = value; }
+ }
+
+ #endregion
+
+ #region Enabled
+
+ ///
+ /// Gets or sets whether the control can respond to user interaction
+ ///
+ [Browsable(true), DefaultValue(true), Category("Behavior")]
+ [Description("Indicates whether the control can respond to user interaction.")]
+ public bool Enabled
+ {
+ get { return (_TextBoxDropDown.Enabled); }
+ set { _TextBoxDropDown.Enabled = value; }
+ }
+
+ #endregion
+
+ #region FocusHighlightColor
+
+ ///
+ /// Gets or sets the color used as background color to highlight
+ /// the text box when it has input focus and FocusHighlight is enabled.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates color used as background color to highlight the text box when it has input focus and FocusHighlight is enabled.")]
+ public Color FocusHighlightColor
+ {
+ get { return (_TextBoxDropDown.FocusHighlightColor); }
+ set { _TextBoxDropDown.FocusHighlightColor = value; }
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeFocusHighlightColor()
+ {
+ return (_TextBoxDropDown.ShouldSerializeFocusHighlightColor());
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetFocusHighlightColor()
+ {
+ _TextBoxDropDown.ResetFocusHighlightColor();
+ }
+
+ #endregion
+
+ #region FocusHighlightEnabled
+
+ ///
+ /// Gets or sets whether FocusHighlightColor is used as
+ /// background color to highlight the text box when it has
+ /// input focus. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance")]
+ [Description("Indicates whether FocusHighlightColor is used as background color to highlight the text box when it has input focus.")]
+ public bool FocusHighlightEnabled
+ {
+ get { return (_TextBoxDropDown.FocusHighlightEnabled); }
+ set { _TextBoxDropDown.FocusHighlightEnabled = value; }
+ }
+
+ #endregion
+
+ #region ForeColor
+
+ ///
+ /// Gets or sets the foreground color.
+ ///
+ [Browsable(false)]
+ public Color ForeColor
+ {
+ get { return (_TextBoxDropDown.ForeColor); }
+ set { _TextBoxDropDown.ForeColor = value; }
+ }
+
+ #endregion
+
+ #region HideSelection
+
+ ///
+ /// Gets or sets a value indicating whether the selected text in
+ /// the text box control remains highlighted when the control loses focus.
+ /// true if the selected text does not appear highlighted when the
+ /// text box control loses focus; false, if the selected text remains
+ /// highlighted when the text box control loses focus. The default is true.
+ ///
+ [Browsable(true), Category("Behavior"), DefaultValue(true)]
+ [Description("Gets or sets a value indicating whether the selected text in the text box control remains highlighted when the control loses focus.")]
+ public bool HideSelection
+ {
+ get { return (_TextBoxDropDown.HideSelection); }
+ set { _TextBoxDropDown.HideSelection = value; }
+ }
+
+ #endregion
+
+ #region ImeMode
+
+ ///
+ /// Gets or sets the Input Method Editor (IME) mode of the control.
+ ///
+ [Browsable(true), DefaultValue(ImeMode.Inherit)]
+ [Description("Indicates the Input Method Editor (IME) mode of the control.")]
+ public ImeMode ImeMode
+ {
+ get { return (_TextBoxDropDown.ImeMode); }
+ set { _TextBoxDropDown.ImeMode = value; }
+ }
+
+ #endregion
+
+ #region MaxLength
+
+ ///
+ /// Gets or sets the maximum number of characters the user can type or paste into the text box control.
+ /// The number of characters that can be entered into the control. The default is 32767.
+ ///
+ [Category("Behavior"), DefaultValue(0x7fff), Localizable(true)]
+ [Description("Gets or sets the maximum number of characters the user can type or paste into the text box control.")]
+ public int MaxLength
+ {
+ get { return (_TextBoxDropDown.MaxLength); }
+ set { _TextBoxDropDown.MaxLength = value; }
+ }
+
+ #endregion
+
+ #region PasswordChar
+
+ ///
+ /// Gets or sets the character to be displayed in substitute for user input.
+ ///
+ [Browsable(true), DefaultValue(null)]
+ [Description("Indicates the character to be displayed in substitute for user input.")]
+ public char PasswordChar
+ {
+ get { return (_TextBoxDropDown.PasswordChar); }
+ set { _TextBoxDropDown.PasswordChar = value; }
+ }
+
+ #endregion
+
+ #region RightToLeft
+
+ ///
+ /// Gets or sets a value indicating whether control's
+ /// elements are aligned to support locales using right-to-left fonts.
+ ///
+ [Browsable(true), DefaultValue(RightToLeft.Inherit)]
+ [Description("Indicates the control's elements are aligned to support locales using right-to-left fonts.")]
+ public RightToLeft RightToLeft
+ {
+ get { return (_TextBoxDropDown.RightToLeft); }
+ set { _TextBoxDropDown.RightToLeft = value; }
+ }
+
+ #endregion
+
+ #region SelectedText
+
+ ///
+ /// Gets or sets a value indicating the currently selected text in the control.
+ /// A string that represents the currently selected text in the text box.
+ ///
+ [Browsable(false), Category("Appearance"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [Description("Gets or sets a value indicating the currently selected text in the control.")]
+ public virtual string SelectedText
+ {
+ get { return (_TextBoxDropDown.SelectedText); }
+ set { _TextBoxDropDown.SelectedText = value; }
+ }
+
+ #endregion
+
+ #region SelectionLength
+
+ ///
+ /// Gets or sets the number of characters selected in the text box.
+ /// The number of characters selected in the text box.
+ ///
+ [Browsable(false), Category("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [Description("Gets or sets the number of characters selected in the text box.")]
+ public int SelectionLength
+ {
+ get { return (_TextBoxDropDown.SelectionLength); }
+ set { _TextBoxDropDown.SelectionLength = value; }
+ }
+
+ #endregion
+
+ #region SelectionStart
+
+ ///
+ /// Gets or sets the starting point of text selected in the text box.
+ /// The starting position of text selected in the text box.
+ ///
+ [Browsable(false), Category("Appearance")]
+ [Description("Gets or sets the starting point of text selected in the text box.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int SelectionStart
+ {
+ get { return (_TextBoxDropDown.SelectionStart); }
+ set { _TextBoxDropDown.SelectionStart = value; }
+ }
+
+ #endregion
+
+ #region Text
+
+ ///
+ /// Gets or sets the text as it is currently displayed to the user.
+ ///
+ [Browsable(false)]
+ public string Text
+ {
+ get { return (_TextBoxDropDown.Text); }
+ set { _TextBoxDropDown.Text = value; }
+ }
+
+ #endregion
+
+ #region TextAlign
+
+ ///
+ /// Gets or sets how text is aligned in a masked text box control.
+ ///
+ [Browsable(true), DefaultValue(HorizontalAlignment.Left)]
+ [Description("Indicates how text is aligned in a masked text box control.")]
+ public HorizontalAlignment TextAlign
+ {
+ get { return (_TextBoxDropDown.TextAlign); }
+ set { _TextBoxDropDown.TextAlign = value; }
+ }
+
+ #endregion
+
+ #region TextLength
+
+ ///
+ /// Gets the length of text in the control.
+ /// Returns number of characters contained in the text of the control.
+ ///
+ [Browsable(false)]
+ public virtual int TextLength
+ {
+ get { return (_TextBoxDropDown.TextLength); }
+ }
+
+ #endregion
+
+ #region UseSystemPasswordChar
+
+ ///
+ /// Gets or sets a value indicating whether
+ /// the operating system-supplied password character should be used.
+ ///
+ [Browsable(true), DefaultValue(false)]
+ [Description("Indicates whether the operating system-supplied password character should be used.")]
+ public bool UseSystemPasswordChar
+ {
+ get { return (_TextBoxDropDown.UseSystemPasswordChar); }
+ set { _TextBoxDropDown.UseSystemPasswordChar = value; }
+ }
+
+ #endregion
+
+ #region WatermarkBehavior
+
+ ///
+ /// Gets or sets the watermark hiding behaviour. Default value
+ /// indicates that watermark is hidden when control receives input focus.
+ ///
+ [Browsable(true), DefaultValue(eWatermarkBehavior.HideOnFocus), Category("Behavior")]
+ [Description("Indicates watermark hiding behaviour.")]
+ public eWatermarkBehavior WatermarkBehavior
+ {
+ get { return (_TextBoxDropDown.WatermarkBehavior); }
+ set { _TextBoxDropDown.WatermarkBehavior = value; }
+ }
+
+ #endregion
+
+ #region WatermarkColor
+
+ ///
+ /// Gets or sets the watermark text color.
+ ///
+ [Browsable(true), Category("Appearance")]
+ [Description("Indicates watermark text color.")]
+ public Color WatermarkColor
+ {
+ get { return (_TextBoxDropDown.WatermarkColor); }
+ set { _TextBoxDropDown.WatermarkColor = value; }
+ }
+ ///
+ /// Indicates whether property should be serialized by Windows Forms designer.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeWatermarkColor()
+ {
+ return (_TextBoxDropDown.ShouldSerializeWatermarkColor());
+ }
+ ///
+ /// Resets the property to default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetWatermarkColor()
+ {
+ _TextBoxDropDown.ResetWatermarkColor();
+ }
+
+ #endregion
+
+ #region WatermarkEnabled
+
+ ///
+ /// Gets or sets whether watermark text is
+ /// displayed when control is empty. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true)]
+ [Description("Indicates whether watermark text is displayed when control is empty.")]
+ public virtual bool WatermarkEnabled
+ {
+ get { return (_TextBoxDropDown.WatermarkEnabled); }
+ set { _TextBoxDropDown.WatermarkEnabled = value; }
+ }
+
+ #endregion
+
+ #region WatermarkFont
+
+ ///
+ /// Gets or sets the watermark font.
+ ///
+ [Browsable(true), Category("Appearance"), DefaultValue(null)]
+ [Description("Indicates watermark font.")]
+ public Font WatermarkFont
+ {
+ get { return (_TextBoxDropDown.WatermarkFont); }
+ set { _TextBoxDropDown.WatermarkFont = value; }
+ }
+
+ #endregion
+
+ #region WatermarkText
+
+ ///
+ /// Gets or sets the watermark (tip) text displayed inside of
+ /// the control when Text is not set and control does not have
+ /// input focus. This property supports text-markup.
+ ///
+ [Browsable(true), DefaultValue(""), Localizable(true), Category("Appearance")]
+ [Description("Indicates watermark text displayed inside of the control when Text is not set and control does not have input focus.")]
+ [Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(UITypeEditor))]
+ public string WatermarkText
+ {
+ get { return (_TextBoxDropDown.WatermarkText); }
+ set { _TextBoxDropDown.WatermarkText = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Method forwarding
+
+ #region AppendText
+
+ ///
+ /// Appends text to the current text of a text box.
+ ///
+ /// The text to append to the current contents of the text box.
+ public void AppendText(string text)
+ {
+ _TextBoxDropDown.AppendText(text);
+ }
+
+ #endregion
+
+ #region Clear
+
+ ///
+ /// Clears all text from the text box control.
+ ///
+ public void Clear()
+ {
+ _TextBoxDropDown.Clear();
+ }
+
+ #endregion
+
+ #region ClearUndo
+
+ ///
+ /// Clears information about the most recent operation from the undo buffer of the text box.
+ ///
+ public void ClearUndo()
+ {
+ _TextBoxDropDown.ClearUndo();
+ }
+
+ #endregion
+
+ #region Copy
+
+ ///
+ /// Copies the current selection in the text box to the Clipboard.
+ ///
+ [UIPermission(SecurityAction.Demand, Clipboard = UIPermissionClipboard.OwnClipboard)]
+ public void Copy()
+ {
+ _TextBoxDropDown.Copy();
+ }
+
+ #endregion
+
+ #region Cut
+
+ ///
+ /// Moves the current selection in the text box to the Clipboard.
+ ///
+ public void Cut()
+ {
+ _TextBoxDropDown.Cut();
+ }
+
+ #endregion
+
+ #region DeselectAll
+
+ ///
+ /// Specifies that the value of the SelectionLength
+ /// property is zero so that no characters are selected in the control.
+ ///
+ public void DeselectAll()
+ {
+ _TextBoxDropDown.DeselectAll();
+ }
+
+ #endregion
+
+ #region GetCharFromPosition
+
+ ///
+ /// Retrieves the character that is closest to the specified location within the control.
+ ///
+ /// The location from which to seek the nearest character.
+ /// The character at the specified location.
+ public char GetCharFromPosition(Point pt)
+ {
+ return (_TextBoxDropDown.GetCharFromPosition(pt));
+ }
+
+ #endregion
+
+ #region GetCharIndexFromPosition
+
+ ///
+ /// Retrieves the index of the character nearest to the specified location.
+ ///
+ /// The location to search.
+ /// The zero-based character index at the specified location.
+ public int GetCharIndexFromPosition(Point pt)
+ {
+ return (_TextBoxDropDown.GetCharIndexFromPosition(pt));
+ }
+
+ #endregion
+
+ #region GetFirstCharIndexFromLine
+
+ ///
+ /// Retrieves the index of the first character of a given line.
+ ///
+ /// The line for which to get the index of its first character.
+ /// The zero-based character index in the specified line.
+ public int GetFirstCharIndexFromLine(int lineNumber)
+ {
+ return (_TextBoxDropDown.GetFirstCharIndexFromLine(lineNumber));
+ }
+
+ #endregion
+
+ #region GetFirstCharIndexOfCurrentLine
+
+ ///
+ /// Retrieves the index of the first character of the current line.
+ ///
+ /// The zero-based character index in the current line.
+ public int GetFirstCharIndexOfCurrentLine()
+ {
+ return (_TextBoxDropDown.GetFirstCharIndexOfCurrentLine());
+ }
+
+ #endregion
+
+ #region GetLineFromCharIndex
+
+ ///
+ /// Retrieves the line number from the specified character position within the text of the control.
+ ///
+ /// The character index position to search.
+ /// The zero-based line number in which the character index is located.
+ public int GetLineFromCharIndex(int index)
+ {
+ return (_TextBoxDropDown.GetLineFromCharIndex(index));
+ }
+
+ ///
+ /// Retrieves the location within the control at the specified character index.
+ ///
+ /// The index of the character for which to retrieve the location.
+ /// The location of the specified character.
+ public virtual Point GetPositionFromCharIndex(int index)
+ {
+ return _TextBoxDropDown.GetPositionFromCharIndex(index);
+ }
+
+ ///
+ /// Replaces the current selection in the text box with the contents of the Clipboard.
+ ///
+ [UIPermission(SecurityAction.Demand, Clipboard = UIPermissionClipboard.OwnClipboard)]
+ public void Paste()
+ {
+ _TextBoxDropDown.Paste();
+ }
+
+ ///
+ /// Selects a range of text in the text box.
+ ///
+ /// The position of the first character in the current text selection within the text box.
+ /// The number of characters to select.
+ public void Select(int start, int length)
+ {
+ _TextBoxDropDown.Select(start, length);
+ }
+
+ ///
+ /// Selects all text in the text box.
+ ///
+ public void SelectAll()
+ {
+ _TextBoxDropDown.SelectAll();
+ }
+
+ ///
+ /// Undoes the last edit operation in the text box.
+ ///
+ public void Undo()
+ {
+ _TextBoxDropDown.Undo();
+ }
+
+ ///
+ /// Replaces the specified selection in the TextBox with the contents of the Clipboard.
+ ///
+ /// The text to replace.
+ public void Paste(string text)
+ {
+ _TextBoxDropDown.Paste(text);
+ }
+ #endregion
+
+ #endregion
+
+ #region Event processing
+
+ #region DoButtonClearClick
+
+ ///
+ /// DoButtonClearClick
+ ///
+ ///
+ ///
+ internal void DoButtonClearClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonClearClick != null)
+ ButtonClearClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustomClick
+
+ ///
+ /// DoButtonCustomClick
+ ///
+ ///
+ ///
+ internal void DoButtonCustomClick(object sender, EventArgs e)
+ {
+ if (ButtonCustomClick != null)
+ ButtonCustomClick(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonCustom2Click
+
+ ///
+ /// DoButtonCustom2Click
+ ///
+ ///
+ ///
+ internal void DoButtonCustom2Click(object sender, EventArgs e)
+ {
+ if (ButtonCustom2Click != null)
+ ButtonCustom2Click(this, e);
+ }
+
+ #endregion
+
+ #region DoButtonDropDownClick
+
+ ///
+ /// DoButtonDropDownClick
+ ///
+ ///
+ ///
+ internal void DoButtonDropDownClick(object sender, CancelEventArgs e)
+ {
+ if (ButtonDropDownClick != null)
+ ButtonDropDownClick(this, e);
+ }
+
+ #endregion
+
+ #endregion
+
+ #region GetCellBitmap
+
+ ///
+ /// Gets the cell paint bitmap
+ ///
+ ///
+ ///
+ internal Bitmap GetCellBitmap(Rectangle cellBounds)
+ {
+ if (_CellBitmap == null ||
+ (_CellBitmap.Width != cellBounds.Width || _CellBitmap.Height < cellBounds.Height))
+ {
+ if (_CellBitmap != null)
+ _CellBitmap.Dispose();
+
+ _CellBitmap = new Bitmap(cellBounds.Width, cellBounds.Height);
+ }
+
+ return (_CellBitmap);
+ }
+
+ #endregion
+
+ #region OnBeforeCellPaint
+
+ ///
+ /// Invokes BeforeCellPaint user events
+ ///
+ /// Row index
+ /// Column index
+ internal void OnBeforeCellPaint(int rowIndex, int columnIndex)
+ {
+ if (BeforeCellPaint != null)
+ BeforeCellPaint(this, new BeforeCellPaintEventArgs(rowIndex, columnIndex));
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ ///
+ /// Clones the ButtonX Column
+ ///
+ ///
+ public override object Clone()
+ {
+ DataGridViewTextBoxDropDownColumn dc = base.Clone() as DataGridViewTextBoxDropDownColumn;
+
+ if (dc != null)
+ {
+ dc.AutoCompleteCustomSource = AutoCompleteCustomSource;
+ dc.AutoCompleteMode = AutoCompleteMode;
+ dc.AutoCompleteSource = AutoCompleteSource;
+ dc.BackColor = BackColor;
+ dc.CharacterCasing = CharacterCasing;
+ dc.DropDownControl = DropDownControl;
+ dc.Enabled = Enabled;
+ dc.FocusHighlightColor = FocusHighlightColor;
+ dc.FocusHighlightEnabled = FocusHighlightEnabled;
+ dc.ForeColor = ForeColor;
+ dc.HideSelection = HideSelection;
+ dc.ImeMode = ImeMode;
+ dc.MaxLength = MaxLength;
+ dc.PasswordChar = PasswordChar;
+ dc.RightToLeft = RightToLeft;
+ dc.TextAlign = TextAlign;
+ dc.UseSystemPasswordChar = UseSystemPasswordChar;
+ dc.WatermarkBehavior = WatermarkBehavior;
+ dc.WatermarkColor = WatermarkColor;
+ dc.WatermarkEnabled = WatermarkEnabled;
+ dc.WatermarkFont = WatermarkFont;
+ dc.WatermarkText = WatermarkText;
+
+ dc.DisplayControlForCurrentCellOnly = DisplayControlForCurrentCellOnly;
+
+ dc.BackgroundStyle.ApplyStyle(TextBoxDropDown.BackgroundStyle);
+ dc.BackgroundStyle.Class = TextBoxDropDown.BackgroundStyle.Class;
+
+ TextBoxDropDown.ButtonClear.CopyToItem(dc.TextBoxDropDown.ButtonClear);
+ TextBoxDropDown.ButtonDropDown.CopyToItem(dc.TextBoxDropDown.ButtonDropDown);
+ TextBoxDropDown.ButtonCustom.CopyToItem(dc.TextBoxDropDown.ButtonCustom);
+ TextBoxDropDown.ButtonCustom2.CopyToItem(dc.TextBoxDropDown.ButtonCustom2);
+ }
+
+ return (dc);
+ }
+
+ #endregion
+
+ #region Dispose
+
+ ///
+ /// Dispose
+ ///
+ ///
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing == true)
+ _TextBoxDropDown.Dispose();
+
+ if (_CellBitmap != null)
+ {
+ _CellBitmap.Dispose();
+ _CellBitmap = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #endregion
+
+ #region IDataGridViewColumn Members
+
+ ///
+ /// Gets the Cell paint setting for the control
+ ///
+ [Browsable(false)]
+ public bool OwnerPaintCell
+ {
+ get { return (true); }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewTextBoxDropDown/DataGridViewTextBoxDropDownEditingControl.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewTextBoxDropDown/DataGridViewTextBoxDropDownEditingControl.cs
new file mode 100644
index 00000000..3b0bab39
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/DataGridViewTextBoxDropDown/DataGridViewTextBoxDropDownEditingControl.cs
@@ -0,0 +1,185 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxItem(false), ComVisible(false)]
+ public class DataGridViewTextBoxDropDownEditingControl : TextBoxDropDown, IDataGridViewEditingControl
+ {
+ #region Private variables
+
+ private DataGridView _DataGridView;
+
+ private int _RowIndex;
+ private bool _ValueChanged;
+
+ #endregion
+
+ #region OnTextChanged
+
+ ///
+ /// Handles OnTextChanged events
+ ///
+ ///
+ protected override void OnTextChanged(EventArgs e)
+ {
+ _ValueChanged = true;
+
+ _DataGridView.NotifyCurrentCellDirty(true);
+
+ base.OnTextChanged(e);
+ }
+
+ #endregion
+
+ #region IDataGridViewEditingControl Members
+
+ #region Public properties
+
+ #region EditingControlDataGridView
+
+ ///
+ /// Gets or sets the DataGridView
+ ///
+ public DataGridView EditingControlDataGridView
+ {
+ get { return (_DataGridView); }
+ set { _DataGridView = value; }
+ }
+
+ #endregion
+
+ #region EditingControlFormattedValue
+
+ ///
+ /// Gets or sets the Control Formatted Value
+ ///
+ public object EditingControlFormattedValue
+ {
+ get { return (Text); }
+ set { Text = (string)value; }
+ }
+
+ #endregion
+
+ #region EditingControlRowIndex
+
+ ///
+ /// Gets or sets the Control RoeIndex
+ ///
+ public int EditingControlRowIndex
+ {
+ get { return (_RowIndex); }
+ set { _RowIndex = value; }
+ }
+
+ #endregion
+
+ #region EditingControlValueChanged
+
+ ///
+ /// Gets or sets the Control ValueChanged state
+ ///
+ public bool EditingControlValueChanged
+ {
+ get { return (_ValueChanged); }
+ set { _ValueChanged = value; }
+ }
+
+ #endregion
+
+ #region EditingPanelCursor
+
+ ///
+ /// Gets the Panel Cursor
+ ///
+ public Cursor EditingPanelCursor
+ {
+ get { return (base.Cursor); }
+ }
+
+ #endregion
+
+ #region RepositionEditingControlOnValueChange
+
+ ///
+ /// Gets whether to RepositionEditingControlOnValueChange
+ ///
+ public bool RepositionEditingControlOnValueChange
+ {
+ get { return (false); }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region ApplyCellStyleToEditingControl
+
+ ///
+ /// ApplyCellStyleToEditingControl
+ ///
+ ///
+ public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
+ {
+ Font = dataGridViewCellStyle.Font;
+
+ ForeColor = dataGridViewCellStyle.ForeColor;
+ BackColor = dataGridViewCellStyle.BackColor;
+ }
+
+ #endregion
+
+ #region GetEditingControlFormattedValue
+
+ ///
+ /// Gets EditingControlFormattedValue
+ ///
+ ///
+ ///
+ public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
+ {
+ return (EditingControlFormattedValue);
+ }
+
+ #endregion
+
+ #region EditingControlWantsInputKey
+
+ ///
+ /// Gets whether the given key wants to be processed
+ /// by the Control
+ ///
+ ///
+ ///
+ ///
+ public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
+ {
+ if ((keyData & Keys.Right) == Keys.Right)
+ return (true);
+
+ if ((keyData & Keys.Left) == Keys.Left)
+ return (true);
+
+ return (dataGridViewWantsInputKey == false);
+ }
+
+ #endregion
+
+ #region PrepareEditingControlForEdit
+
+ ///
+ /// PrepareEditingControlForEdit
+ ///
+ ///
+ public void PrepareEditingControlForEdit(bool selectAll)
+ {
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DataGridViewX/IDataGridViewColumn.cs b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/IDataGridViewColumn.cs
new file mode 100644
index 00000000..8414b50e
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DataGridViewX/IDataGridViewColumn.cs
@@ -0,0 +1,14 @@
+namespace DevComponents.DotNetBar.Controls
+{
+ internal interface IDataGridViewColumn
+ {
+ ///
+ /// Gets whether the Column cells will fully paint
+ /// their cell background and content
+ ///
+ bool OwnerPaintCell
+ {
+ get;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DesktopAlert/DesktopAlert.cs b/PROMS/DotNetBar Source Code/Controls/DesktopAlert/DesktopAlert.cs
new file mode 100644
index 00000000..0bdc9a82
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DesktopAlert/DesktopAlert.cs
@@ -0,0 +1,511 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Displays the desktop alerts with optional image or symbol. Text on alerts supports text-markup.
+ ///
+ public static class DesktopAlert
+ {
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ public static void Show(string text)
+ {
+ Show(text, _AlertColor, _AlertPosition, null);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Specifies reference control which is used to find target screen alert is displayed on.
+ public static void Show(string text, Control referenceControl)
+ {
+ Show(text, _AlertColor, _AlertPosition, null, referenceControl);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Text-markup link click event handler.
+ public static void Show(string text, MarkupLinkClickEventHandler markupLinkClickHandler)
+ {
+ Show(text, _AlertColor, _AlertPosition, markupLinkClickHandler);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Specifies alert color.
+ public static void Show(string text, eDesktopAlertColor alertColor)
+ {
+ Show(text, alertColor, _AlertPosition, null);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Specifies alert color.
+ /// Specifies reference control which is used to find target screen alert is displayed on.
+ public static void Show(string text, eDesktopAlertColor alertColor, Control referenceControl)
+ {
+ Show(text, alertColor, _AlertPosition, null, referenceControl);
+ }
+
+ ///
+ /// Shows desktop alert at specific screen position.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Alert position on the screen.
+ public static void Show(string text, eAlertPosition position)
+ {
+ Show(text, _AlertColor, position, null);
+ }
+
+ ///
+ /// Shows desktop alert at specific screen position.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Alert position on the screen.
+ /// Specifies reference control which is used to find target screen alert is displayed on.
+ public static void Show(string text, eAlertPosition position, Control referenceControl)
+ {
+ Show(text, _AlertColor, position, null, referenceControl);
+ }
+
+ ///
+ /// Shows desktop alert at specific screen position.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Image to display on alert.
+ public static void Show(string text, Image image)
+ {
+ Show(text, image, _AlertColor, _AlertPosition, _AutoCloseTimeOut, 0, null);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Alert color.
+ /// Alert position on the screen.
+ public static void Show(string text, eDesktopAlertColor alertColor, eAlertPosition position)
+ {
+ Show(text, alertColor, position, null);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Alert color
+ /// Alert position on the screen
+ /// Text-markup link click event handler.
+ /// Specifies reference control which is used to find target screen alert is displayed on.
+ public static void Show(string text, eDesktopAlertColor alertColor, eAlertPosition position, MarkupLinkClickEventHandler markupLinkClickHandler, Control referenceControl)
+ {
+ DesktopAlertWindow alert = new DesktopAlertWindow();
+ alert.Text = text;
+ alert.MaximumSize = Dpi.Size(_MaximumAlertSize);
+ alert.AlertPosition = position;
+ alert.AutoCloseTimeOut = _AutoCloseTimeOut;
+ alert.TextMarkupEnabled = _TextMarkupEnabled;
+ if (markupLinkClickHandler != null)
+ alert.MarkupLinkClick += markupLinkClickHandler;
+ alert.AlertAnimationDuration = _AlertAnimationDuration;
+ alert.PlaySound = _PlaySound;
+ alert.ReferenceControl = referenceControl;
+ SetColors(alert, alertColor);
+ alert.Show();
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Alert color
+ /// Alert position on the screen
+ /// Text-markup link click event handler.
+ public static void Show(string text, eDesktopAlertColor alertColor, eAlertPosition position, MarkupLinkClickEventHandler markupLinkClickHandler)
+ {
+ Show(text, alertColor, position, markupLinkClickHandler, null);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Alert ID used to recognize alert if clicked and specified Action is called
+ /// Action method to call if alert is clicked.
+ public static void Show(string text, long alertId, Action alertClickAction)
+ {
+ Show(text, null, _AlertColor, _AlertPosition, _AutoCloseTimeOut, alertId, alertClickAction);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Alert color
+ /// Alert ID used to recognize alert if clicked and specified Action is called
+ /// Action method to call if alert is clicked.
+ public static void Show(string text, eDesktopAlertColor alertColor, long alertId, Action alertClickAction)
+ {
+ Show(text, null, alertColor, _AlertPosition, _AutoCloseTimeOut, alertId, alertClickAction);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Symbol to show on the alert, see http://www.devcomponents.com/kb2/?p=1347
+ /// Symbol set to use
+ /// Symbol color or Color.Empty to use default text color
+ /// Alert color
+ /// Alert position on the screen
+ /// Duration of alert in the seconds.
+ /// Alert ID used to recognize alert if clicked and specified Action is called
+ /// Action method to call if alert is clicked.
+ public static void Show(string text, string symbol, eSymbolSet symbolSet, Color symbolColor, eDesktopAlertColor alertColor, eAlertPosition position,
+ int alertDurationSeconds, long alertId, Action alertClickAction)
+ {
+ Show(text, symbol, symbolSet, symbolColor, alertColor,position, alertDurationSeconds, alertId, alertClickAction, null);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Symbol to show on the alert, see http://www.devcomponents.com/kb2/?p=1347
+ /// Symbol set to use
+ /// Symbol color or Color.Empty to use default text color
+ /// Alert position on the screen
+ /// Alert color
+ /// Duration of alert in the seconds.
+ /// Alert ID used to recognize alert if clicked and specified Action is called
+ /// Action method to call if alert is clicked.
+ /// Text-markup link click event handler.
+ public static void Show(string text, string symbol, eSymbolSet symbolSet, Color symbolColor, eDesktopAlertColor alertColor, eAlertPosition position,
+ int alertDurationSeconds, long alertId, Action alertClickAction, MarkupLinkClickEventHandler markupLinkClickHandler)
+ {
+ Show(text, symbol, symbolSet, symbolColor, alertColor, position, alertDurationSeconds, alertId, alertClickAction, markupLinkClickHandler, null);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Symbol to show on the alert, see http://www.devcomponents.com/kb2/?p=1347
+ /// Symbol set to use
+ /// Symbol color or Color.Empty to use default text color
+ /// Alert position on the screen
+ /// Alert color
+ /// Duration of alert in the seconds.
+ /// Alert ID used to recognize alert if clicked and specified Action is called
+ /// Action method to call if alert is clicked.
+ /// Text-markup link click event handler.
+ /// Specifies reference control which is used to find target screen alert is displayed on.
+ public static void Show(string text, string symbol, eSymbolSet symbolSet, Color symbolColor, eDesktopAlertColor alertColor, eAlertPosition position,
+ int alertDurationSeconds, long alertId, Action alertClickAction, MarkupLinkClickEventHandler markupLinkClickHandler, Control referenceControl)
+ {
+ DesktopAlertWindow alert = new DesktopAlertWindow();
+ alert.Text = text;
+ alert.MaximumSize = Dpi.Size(_MaximumAlertSize);
+ alert.AlertPosition = position;
+ alert.Symbol = symbol;
+ alert.SymbolSet = symbolSet;
+ alert.SymbolColor = symbolColor;
+ alert.AlertId = alertId;
+ alert.ClickAction = alertClickAction;
+ alert.AutoCloseTimeOut = alertDurationSeconds;
+ alert.TextMarkupEnabled = _TextMarkupEnabled;
+ if (markupLinkClickHandler != null)
+ alert.MarkupLinkClick += markupLinkClickHandler;
+ alert.AlertAnimationDuration = _AlertAnimationDuration;
+ alert.PlaySound = _PlaySound;
+ alert.ReferenceControl = referenceControl;
+ SetColors(alert, alertColor);
+ alert.Show();
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Image to display on the alert
+ /// Alert screen position
+ /// Alert color
+ /// Duration of alert in seconds
+ /// Alert ID used to recognize alert if clicked and specified Action is called
+ /// Action method to call if alert is clicked.
+ public static void Show(string text, Image image, eDesktopAlertColor alertColor, eAlertPosition position,
+ int alertDurationSeconds, long alertId, Action alertClickAction)
+ {
+ Show(text, image, alertColor, position, alertDurationSeconds, alertId, alertClickAction, null);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Image to display on the alert
+ /// Alert screen position
+ /// Alert color
+ /// Duration of alert in seconds
+ /// Alert ID used to recognize alert if clicked and specified Action is called
+ /// Action method to call if alert is clicked.
+ /// Text-markup link click event handler.
+ public static void Show(string text, Image image, eDesktopAlertColor alertColor, eAlertPosition position,
+ int alertDurationSeconds, long alertId, Action alertClickAction, MarkupLinkClickEventHandler markupLinkClickHandler)
+ {
+ Show(text, image, alertColor, position, alertDurationSeconds, alertId, alertClickAction, markupLinkClickHandler, null);
+ }
+
+ ///
+ /// Shows desktop alert.
+ ///
+ /// Text to show on the alert. Text supports text-markup.
+ /// Image to display on the alert
+ /// Alert screen position
+ /// Alert color
+ /// Duration of alert in seconds
+ /// Alert ID used to recognize alert if clicked and specified Action is called
+ /// Action method to call if alert is clicked.
+ /// Text-markup link click event handler.
+ /// Specifies reference control which is used to find target screen alert is displayed on.
+ public static void Show(string text, Image image, eDesktopAlertColor alertColor, eAlertPosition position,
+ int alertDurationSeconds, long alertId, Action alertClickAction, MarkupLinkClickEventHandler markupLinkClickHandler, Control referenceControl)
+ {
+ DesktopAlertWindow alert = new DesktopAlertWindow();
+ alert.Text = text;
+ alert.MaximumSize = Dpi.Size(_MaximumAlertSize);
+ alert.AlertPosition = position;
+ alert.Image = image;
+ alert.AlertId = alertId;
+ alert.ClickAction = alertClickAction;
+ alert.AutoCloseTimeOut = alertDurationSeconds;
+ alert.TextMarkupEnabled = _TextMarkupEnabled;
+ if (markupLinkClickHandler != null)
+ alert.MarkupLinkClick += markupLinkClickHandler;
+ alert.AlertAnimationDuration = _AlertAnimationDuration;
+ alert.PlaySound = _PlaySound;
+ alert.ReferenceControl = referenceControl;
+ SetColors(alert, alertColor);
+ alert.Show();
+ }
+
+ private static void SetColors(DesktopAlertWindow w, eDesktopAlertColor c)
+ {
+ if (c == eDesktopAlertColor.Default)
+ {
+ w.BackColor = ColorScheme.GetColor(0x0078D7);
+ w.ForeColor = Color.White;
+ }
+ else if (c == eDesktopAlertColor.Black)
+ {
+ w.BackColor = Color.Black;
+ w.ForeColor = Color.White;
+ }
+ else if (c == eDesktopAlertColor.Blue)
+ {
+ w.BackColor = ColorScheme.GetColor(0x5B9BD5);
+ w.ForeColor = Color.White;
+ }
+ else if (c == eDesktopAlertColor.BlueGray)
+ {
+ w.BackColor = ColorScheme.GetColor(0x44546A);
+ w.ForeColor = Color.White;
+ }
+ else if (c == eDesktopAlertColor.DarkBlue)
+ {
+ w.BackColor = ColorScheme.GetColor(0x4472C4);
+ w.ForeColor = Color.White;
+ }
+ else if (c == eDesktopAlertColor.DarkRed)
+ {
+ w.BackColor = ColorScheme.GetColor(0xC00000);
+ w.ForeColor = Color.White;
+ }
+ else if (c == eDesktopAlertColor.Gold)
+ {
+ w.BackColor = ColorScheme.GetColor(0xFFC000);
+ w.ForeColor = Color.Black;
+ }
+ else if (c == eDesktopAlertColor.Gray)
+ {
+ w.BackColor = ColorScheme.GetColor(0xE7E6E6);
+ w.ForeColor = Color.Black;
+ }
+ else if (c == eDesktopAlertColor.Green)
+ {
+ w.BackColor = ColorScheme.GetColor(0x375623);
+ w.ForeColor = Color.White;
+ }
+ else if (c == eDesktopAlertColor.Orange)
+ {
+ w.BackColor = ColorScheme.GetColor(0xCA5010);
+ w.ForeColor = Color.White;
+ }
+ else if (c == eDesktopAlertColor.Red)
+ {
+ w.BackColor = ColorScheme.GetColor(0xE81123);
+ w.ForeColor = Color.White;
+ }
+ }
+
+ private static Size _MaximumAlertSize = new Size(400, 128);
+ ///
+ /// Indicates maximum alert size.
+ ///
+ public static Size MaximumAlertSize
+ {
+ get { return _MaximumAlertSize; }
+ set { _MaximumAlertSize = value; }
+ }
+
+ private static eAlertPosition _AlertPosition = eAlertPosition.BottomRight;
+ ///
+ /// Specifies default alert screen position.
+ ///
+ public static eAlertPosition AlertPosition
+ {
+ get { return _AlertPosition; }
+ set { _AlertPosition = value; }
+ }
+
+ private static eDesktopAlertColor _AlertColor = eDesktopAlertColor.Default;
+ ///
+ /// Specifies default alert color.
+ ///
+ public static eDesktopAlertColor AlertColor
+ {
+ get { return _AlertColor; }
+ set { _AlertColor = value; }
+ }
+
+ private static int _AlertAnimationDuration = 200;
+ ///
+ /// Gets or sets the total time in milliseconds alert animation takes.
+ /// Default value is 200.
+ ///
+ public static int AlertAnimationDuration
+ {
+ get { return _AlertAnimationDuration; }
+ set { _AlertAnimationDuration = value; }
+ }
+
+ private static int _AutoCloseTimeOut = 6;
+ ///
+ /// Gets or sets time period in seconds after alert closes automatically.
+ ///
+ public static int AutoCloseTimeOut
+ {
+ get { return _AutoCloseTimeOut; }
+ set { _AutoCloseTimeOut = value; }
+ }
+
+ private static bool _TextMarkupEnabled = true;
+ ///
+ /// Gets or sets whether text-markup can be used in alert text, default value is true.
+ ///
+ public static bool TextMarkupEnabled
+ {
+ get { return _TextMarkupEnabled; }
+ set { _TextMarkupEnabled = value; }
+ }
+
+ private static bool _PlaySound = true;
+ ///
+ /// Indicates whether alert plays exclamation sound when shown.
+ ///
+ public static bool PlaySound
+ {
+ get { return _PlaySound; }
+ set { _PlaySound = value; }
+ }
+
+ ///
+ /// Occurs before alert is displayed and allows access to the alert Window through sender.
+ ///
+ [Description("Occurs before alert is displayed and allows access to the alert Window through sender.")]
+ public static event EventHandler BeforeAlertDisplayed;
+
+ ///
+ /// Raises BeforeAlertDisplayed event.
+ ///
+ /// Provides event arguments.
+ internal static void OnBeforeAlertDisplayed(DesktopAlertWindow w, EventArgs e)
+ {
+ EventHandler h = BeforeAlertDisplayed;
+ if (h != null)
+ h(w, e);
+ }
+
+ ///
+ /// Occurs after alert as been closed.
+ ///
+ [Description("Occurs after alert has been closed.")]
+ public static event AlertClosedEventHandler AlertClosed;
+
+ ///
+ /// Raises RemovingToken event.
+ ///
+ /// Provides event arguments.
+ internal static void OnAlertClosed(object sender, AlertClosedEventArgs e)
+ {
+ AlertClosedEventHandler handler = AlertClosed;
+ if (handler != null)
+ handler(sender, e);
+ }
+ }
+
+ ///
+ /// Defines delegate for AlertClosed event.
+ ///
+ /// Sender.
+ /// Event arguments
+ public delegate void AlertClosedEventHandler(object sender, AlertClosedEventArgs args);
+ ///
+ /// Defines event arguments for AlertClosed event.
+ ///
+ public class AlertClosedEventArgs : EventArgs
+ {
+ ///
+ /// Specifies alert closure source.
+ ///
+ public readonly eAlertClosureSource ClosureSource;
+
+ public AlertClosedEventArgs(eAlertClosureSource source)
+ {
+ ClosureSource = source;
+ }
+ }
+
+ ///
+ /// Defines predefined desktop alert colors.
+ ///
+ public enum eDesktopAlertColor
+ {
+ Default,
+ DarkRed,
+ Black,
+ Gray,
+ BlueGray,
+ Blue,
+ Orange,
+ Gold,
+ DarkBlue,
+ Green,
+ Red
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/DesktopAlert/DesktopAlertWindow.cs b/PROMS/DotNetBar Source Code/Controls/DesktopAlert/DesktopAlertWindow.cs
new file mode 100644
index 00000000..f2460c19
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/DesktopAlert/DesktopAlertWindow.cs
@@ -0,0 +1,1478 @@
+using DevComponents.DotNetBar.Rendering;
+using DevComponents.DotNetBar.TextMarkup;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+using System.Windows.Forms.VisualStyles;
+using DevComponents.DotNetBar.Metro.Helpers;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public class DesktopAlertWindow : Form
+ {
+ #region Constructor
+ public DesktopAlertWindow()
+ {
+ this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque |
+ ControlStyles.ResizeRedraw | ControlStyles.DoubleBuffer, true);
+
+ this.AccessibleRole = System.Windows.Forms.AccessibleRole.Alert;
+ this.ClientSize = DefaultAlertSizeValue;
+ this.AutoScaleDimensions = new SizeF(96f, 96f);
+ this.AutoScaleMode = AutoScaleMode.Dpi;
+ this.ControlBox = false;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.ShowInTaskbar = false;
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+ this.StartPosition = FormStartPosition.Manual;
+ this.Padding = new System.Windows.Forms.Padding(8);
+ this.Font = new Font("Segoe UI", 10.125F);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ DestroyAutoCloseTimer();
+ base.Dispose(disposing);
+ }
+ #endregion
+
+ #region Implementation
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+ Color backColor = this.BackColor;
+ Color foreColor = this.ForeColor;
+
+ using (SolidBrush brush = new SolidBrush(backColor))
+ g.FillRectangle(brush, this.ClientRectangle);
+
+ if (_CloseButtonVisible)
+ {
+ Font symFont = Symbols.GetFont(12f, eSymbolSet.Material);
+ TextDrawing.DrawStringLegacy(g, "\uE14C", symFont,
+ (_CloseButtonMouseOver ? ColorHelpers.GetShadeColor(foreColor) : foreColor),
+ _CloseButtonBounds,
+ eTextFormat.Default | eTextFormat.NoClipping);
+ }
+
+ if (!string.IsNullOrEmpty(_SymbolRealized))
+ {
+ Font symFont = Symbols.GetFont(_SymbolSize, _SymbolSet);
+
+ TextDrawing.DrawStringLegacy(g, _SymbolRealized, symFont, _SymbolColor.IsEmpty ? foreColor : _SymbolColor,
+ _ImageBounds,
+ eTextFormat.Default | eTextFormat.NoClipping | eTextFormat.VerticalCenter);
+ }
+ else if (_Image != null)
+ {
+ g.DrawImage(_Image, _ImageBounds);
+ }
+
+ Rectangle r = _TextBounds;
+ if (r.Bottom > this.ClientRectangle.Bottom - this.Padding.Bottom)
+ r.Height -= (r.Bottom - (this.ClientRectangle.Bottom - this.Padding.Bottom));
+ eTextFormat format = TextFormat;
+ if (_TextMarkup == null)
+ {
+ if (this.RightToLeft == RightToLeft.Yes) format |= eTextFormat.RightToLeft;
+ if (UseTextRenderer)
+ {
+ TextRenderer.DrawText(g, Text, Font, r, foreColor, backColor,
+ TextDrawing.GetTextFormatFlags(format));
+ }
+ else
+ TextDrawing.DrawString(g, Text, this.Font, foreColor, r, format);
+ }
+ else
+ {
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, this.Font, foreColor,
+ (this.RightToLeft == RightToLeft.Yes), r, true);
+ Size markupSize = _TextMarkup.Bounds.Size;
+ if (!markupSize.IsEmpty && (format & eTextFormat.VerticalCenter) == eTextFormat.VerticalCenter && r.Height>markupSize.Height)
+ {
+ r.Y += (r.Height - markupSize.Height) / 2;
+ r.Height = markupSize.Height;
+ }
+ _TextMarkup.Arrange(r, d);
+ _TextMarkup.Render(d);
+ }
+
+ base.OnPaint(e);
+ }
+ private eTextFormat TextFormat
+ {
+ get
+ {
+ return eTextFormat.Default | eTextFormat.WordBreak | eTextFormat.VerticalCenter | eTextFormat.EndEllipsis;
+ }
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ if (_AutoClose && _AutoCloseTimer != null)
+ _AutoCloseTimer.Enabled = false;
+ base.OnMouseEnter(e);
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ if (_TextMarkup != null)
+ _TextMarkup.MouseLeave(this);
+ if (_AutoClose && _AutoCloseTimer != null)
+ _AutoCloseTimer.Enabled = true;
+ base.OnMouseLeave(e);
+ }
+
+ private bool _CloseButtonMouseOver = false;
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ if (_CloseButtonVisible && _CloseButtonBounds.Contains(e.Location))
+ {
+ _CloseButtonMouseOver = true;
+ Invalidate(_CloseButtonBounds);
+ }
+ else if (_CloseButtonMouseOver)
+ {
+ _CloseButtonMouseOver = false;
+ Invalidate(_CloseButtonBounds);
+ }
+
+ if (_TextMarkup != null)
+ _TextMarkup.MouseMove(this, e);
+
+ base.OnMouseMove(e);
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ if (_TextMarkup != null)
+ _TextMarkup.MouseDown(this, e);
+ base.OnMouseDown(e);
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ if (_TextMarkup != null)
+ _TextMarkup.MouseUp(this, e);
+
+ if (_CloseButtonMouseOver && e.Button == MouseButtons.Left)
+ this.HideAlert(eAlertClosureSource.CloseButton);
+ base.OnMouseUp(e);
+ }
+
+ private bool _AutoSize = true;
+ [DefaultValue(true)]
+ public override bool AutoSize
+ {
+ get
+ {
+ return _AutoSize;
+ }
+ set
+ {
+ _AutoSize = value;
+ }
+ }
+
+ private Rectangle _ImageBounds = Rectangle.Empty;
+ private Rectangle _TextBounds = Rectangle.Empty;
+ private Rectangle _CloseButtonBounds = Rectangle.Empty;
+ ///
+ /// Sets alert size based on its content, it respects MinimumSize and MaximumSize property settings.
+ ///
+ public void PerformAutoSize()
+ {
+ Size size = Dpi.Size(_DefaultAlertSize);
+ if (!this.MinimumSize.IsEmpty)
+ size = Dpi.Size(this.MinimumSize);
+
+ if (!this.IsHandleCreated)
+ this.CreateHandle();
+
+ size = LayoutAlert(size);
+
+ Size maximumSize = this.MaximumSize;
+ if (!maximumSize.IsEmpty)
+ {
+ if (maximumSize.Width > 0 && size.Width > maximumSize.Width)
+ size.Width = maximumSize.Width;
+ if (maximumSize.Height > 0 && size.Height > maximumSize.Height)
+ size.Height = maximumSize.Height;
+ size = LayoutAlert(size);
+ }
+
+ this.Size = size;
+ }
+
+ private Size LayoutAlert(Size size)
+ {
+ Rectangle r = new Rectangle(Point.Empty, size);
+ r.X += Dpi.Width(this.Padding.Left);
+ r.Width -= Dpi.Width(this.Padding.Horizontal);
+ r.Y += Dpi.Height(this.Padding.Top);
+ r.Height -= Dpi.Height(this.Padding.Vertical);
+
+ if (!string.IsNullOrEmpty(Text) || !string.IsNullOrEmpty(_SymbolRealized) || _Image != null)
+ {
+ using (Graphics g = BarFunctions.CreateGraphics(this))
+ {
+ if (_CloseButtonVisible)
+ {
+ Font symFont = Symbols.GetFont(12f, eSymbolSet.Material);
+ Size closeSize = TextDrawing.MeasureString(g, "\uE14C", symFont); // Need to do this to get consistent size for the symbol since they are not all the same width we pick widest
+ _CloseButtonBounds = new Rectangle(r.Right - closeSize.Width - Dpi.Width4, r.Y + Dpi.Height4, closeSize.Width, closeSize.Height);
+ r.Width -= closeSize.Width + Dpi.Width8;
+ }
+
+
+ _ImageBounds = Rectangle.Empty;
+ if (!string.IsNullOrEmpty(_SymbolRealized))
+ {
+ Size symSize = GetSymbolSize(g);
+ symSize.Width += Dpi.Width2;
+ _ImageBounds = new Rectangle(r.X, r.Y, symSize.Width, symSize.Height);
+ r.X += symSize.Width + _ImageTextPadding;
+ r.Width -= symSize.Width + _ImageTextPadding;
+ if (symSize.Height > r.Height)
+ {
+ size.Height += (symSize.Height - r.Height);
+ r.Height = symSize.Height;
+ }
+ else
+ {
+ _ImageBounds.Height = r.Height;
+ }
+ }
+ else if (_Image != null)
+ {
+ _ImageBounds = new Rectangle(r.X, r.Y, _Image.Width, _Image.Height);
+ r.X += _Image.Width + _ImageTextPadding;
+ r.Width -= _Image.Width + _ImageTextPadding;
+ if (_Image.Height > r.Height)
+ {
+ size.Height += (_Image.Height - r.Height);
+ r.Height = _Image.Height;
+ }
+ }
+
+ _TextBounds = Rectangle.Empty;
+
+ if (_TextMarkup != null)
+ {
+ MarkupDrawContext dc = GetMarkupDrawContext(g);
+ _TextMarkup.Measure(r.Size, dc);
+ Size sz = _TextMarkup.Bounds.Size;
+ _TextMarkup.Arrange(new Rectangle(r.Location, sz), dc);
+ if (sz.Width > r.Width)
+ {
+ size.Width += (sz.Width - r.Width);
+ r.Width = size.Width;
+ }
+ if (sz.Height > r.Height)
+ {
+ size.Height += (sz.Height - r.Height);
+ r.Height = size.Height;
+ }
+ _TextBounds = r;
+ }
+ else if (!string.IsNullOrEmpty(this.Text))
+ {
+ Size sz = (UseTextRenderer ? TextRenderer.MeasureText(g, this.Text, this.Font, r.Size, TextDrawing.GetTextFormatFlags(TextFormat)) : TextDrawing.MeasureString(g, this.Text, this.Font, size, TextFormat));
+ if (sz.Width > r.Width)
+ {
+ size.Width += (sz.Width - r.Width);
+ r.Width = size.Width;
+ }
+ if (sz.Height > r.Height)
+ {
+ size.Height += (sz.Height - r.Height);
+ r.Height = size.Height;
+ }
+ _TextBounds = r;
+ }
+ }
+ }
+
+ return size;
+ }
+
+ private MarkupDrawContext GetMarkupDrawContext(Graphics g)
+ {
+ return new MarkupDrawContext(g, this.Font, this.ForeColor, this.RightToLeft == RightToLeft.Yes);
+ }
+ private Size GetSymbolSize(Graphics g)
+ {
+ Size symbolSize = Size.Empty;
+ if (g == null || string.IsNullOrEmpty(_Symbol)) return symbolSize;
+ Font symFont = Symbols.GetFont(this.SymbolSize, this.SymbolSet);
+ symbolSize = TextDrawing.MeasureString(g, "\uF00A", symFont); // Need to do this to get consistent size for the symbol since they are not all the same width we pick widest
+ //int descent = (int)Math.Ceiling((symFont.FontFamily.GetCellDescent(symFont.Style) *
+ // symFont.Size / symFont.FontFamily.GetEmHeight(symFont.Style)));
+ //symbolSize.Height -= descent;
+ return symbolSize;
+ }
+
+ //private Color[] _BackColors = null;
+ /////
+ ///// Indicates the array of colors that when set are used to draw the background of the alert.
+ /////
+ //[DefaultValue(null), Category("Appearance"), Description("Indicates the array of colors that when set are used to draw the background of the alert."), TypeConverter(typeof(ArrayConverter))]
+ //public Color[] BackColors
+ //{
+ // get
+ // {
+ // return _BackColors;
+ // }
+ // set
+ // {
+ // if (_BackColors != value)
+ // {
+ // _BackColors = value;
+ // this.Invalidate();
+ // }
+ // }
+ //}
+
+ //private Color[] _BorderColors = null;
+ /////
+ ///// Indicates the array of colors that when set are used to draw the border of the alert.
+ /////
+ //[DefaultValue(null), Category("Appearance"), Description("Indicates the array of colors that when set are used to draw the border of the alert."), TypeConverter(typeof(ArrayConverter))]
+ //public Color[] BorderColors
+ //{
+ // get
+ // {
+ // return _BorderColors;
+ // }
+ // set
+ // {
+ // if (_BorderColors != value)
+ // {
+ // _BorderColors = value;
+ // //OnPropertyChanged(new PropertyChangedEventArgs("Colors"));
+ // this.Invalidate();
+ // }
+ // }
+ //}
+
+ private Color _SymbolColor = Color.Empty;
+ ///
+ /// Gets or sets the color of the Symbol.
+ ///
+ [Category("Appearance"), Description("Indicates color of the Symbol.")]
+ public Color SymbolColor
+ {
+ get { return _SymbolColor; }
+ set { _SymbolColor = value; this.Invalidate(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSymbolColor()
+ {
+ return !_SymbolColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSymbolColor()
+ {
+ this.SymbolColor = Color.Empty;
+ }
+
+ ///
+ /// Gets the realized symbol string.
+ ///
+ [Browsable(false)]
+ public string SymbolRealized
+ {
+ get { return _SymbolRealized; }
+ }
+ private string _Symbol = "", _SymbolRealized = "";
+ ///
+ /// Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the image setting.
+ ///
+ [DefaultValue(""), Category("Appearance"), Description("Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the 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 != _Symbol)
+ {
+ string oldValue = _Symbol;
+ _Symbol = value;
+ OnSymbolChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when Symbol property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnSymbolChanged(string oldValue, string newValue)
+ {
+ if (string.IsNullOrEmpty(newValue))
+ _SymbolRealized = "";
+ else
+ _SymbolRealized = Symbols.GetSymbol(newValue);
+ this.Invalidate();
+ }
+
+ private eSymbolSet _SymbolSet = eSymbolSet.Awesome;
+ ///
+ /// Gets or sets the symbol set used to represent the Symbol.
+ ///
+ [Browsable(false), DefaultValue(eSymbolSet.Awesome)]
+ public eSymbolSet SymbolSet
+ {
+ get { return _SymbolSet; }
+ set
+ {
+ if (_SymbolSet != value)
+ {
+ eSymbolSet oldValue = _SymbolSet;
+ _SymbolSet = value;
+ OnSymbolSetChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when SymbolSet property value changes.
+ ///
+ /// Indciates old value
+ /// Indicates new value
+ protected virtual void OnSymbolSetChanged(eSymbolSet oldValue, eSymbolSet newValue)
+ {
+ this.Invalidate();
+ this.Refresh();
+ }
+
+
+ private float _SymbolSize = 22f;
+ ///
+ /// Indicates the size of the symbol in points.
+ ///
+ [DefaultValue(22f), Category("Appearance"), Description("Indicates the size of the symbol in points.")]
+ public float SymbolSize
+ {
+ get { return _SymbolSize; }
+ set
+ {
+ if (value != _SymbolSize)
+ {
+ float oldValue = _SymbolSize;
+ _SymbolSize = value;
+ OnSymbolSizeChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when SymbolSize property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnSymbolSizeChanged(float oldValue, float newValue)
+ {
+ this.Invalidate();
+ }
+
+ private Image _Image = null;
+ ///
+ /// Indicates image displayed on alert.
+ ///
+ [DefaultValue(null), Category("Appearance"), Description("Indicates image displayed on alert.")]
+ public Image Image
+ {
+ get { return _Image; }
+ set
+ {
+ _Image = value;
+ this.Invalidate();
+ }
+ }
+
+ protected override void OnTextChanged(EventArgs e)
+ {
+ // Markup support
+ MarkupTextChanged();
+ base.OnTextChanged(e);
+ }
+
+ //private string _TitleText = "";
+ /////
+ ///// Gets or sets the tile title text displayed by default in lower left corner.
+ /////
+ //[DefaultValue(""), Category("Appearance"), Description("Indicates tile title text displayed by default in lower left corner"), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
+ //public string TitleText
+ //{
+ // get { return _TitleText; }
+ // set
+ // {
+ // if (value != _TitleText)
+ // {
+ // string oldValue = _TitleText;
+ // _TitleText = value;
+ // OnTitleTextChanged(oldValue, value);
+ // }
+ // }
+ //}
+ /////
+ ///// Called when TitleText property has changed.
+ /////
+ ///// Old property value
+ ///// New property value
+ //protected virtual void OnTitleTextChanged(string oldValue, string newValue)
+ //{
+ // TitleTextMarkupUpdate();
+ // this.Invalidate();
+ // //OnPropertyChanged(new PropertyChangedEventArgs("TitleText"));
+ //}
+ /////
+ ///// Gets reference to parsed markup body element if text was markup otherwise returns null.
+ /////
+ //internal TextMarkup.BodyElement TitleTextMarkupBody
+ //{
+ // get { return _TitleTextMarkup; }
+ //}
+ //private TextMarkup.BodyElement _TitleTextMarkup = null;
+ //private void TitleTextMarkupUpdate()
+ //{
+ // if (_TitleTextMarkup != null)
+ // _TitleTextMarkup.HyperLinkClick -= TitleTextMarkupLinkClicked;
+ // _TitleTextMarkup = null;
+
+ // if (!_TextMarkupEnabled)
+ // return;
+
+ // if (!TextMarkup.MarkupParser.IsMarkup(ref _TitleText))
+ // return;
+
+ // _TitleTextMarkup = TextMarkup.MarkupParser.Parse(_TitleText);
+
+ // if (_TitleTextMarkup != null)
+ // _TitleTextMarkup.HyperLinkClick += TitleTextMarkupLinkClicked;
+ //}
+ //private void TitleTextMarkupLinkClicked(object sender, EventArgs e)
+ //{
+ // DevComponents.DotNetBar.TextMarkup.HyperLink link = sender as DevComponents.DotNetBar.TextMarkup.HyperLink;
+
+ // if (link != null)
+ // OnTitleTextMarkupLinkClick(new MarkupLinkClickEventArgs(link.Name, link.HRef));
+ // else
+ // OnTitleTextMarkupLinkClick(e);
+ //}
+ /////
+ ///// Occurs when an hyperlink in title text markup is clicked.
+ /////
+ //public event EventHandler TitleTextMarkupLinkClick;
+ /////
+ ///// Raises TitleTextMarkupLinkClick event.
+ /////
+ ///// Provides event arguments.
+ //protected virtual void OnTitleTextMarkupLinkClick(EventArgs e)
+ //{
+ // EventHandler handler = TitleTextMarkupLinkClick;
+ // if (handler != null)
+ // handler(this, e);
+ //}
+
+
+ //private Font _TitleTextFont = null;
+ /////
+ ///// Gets or sets the title text font.
+ /////
+ //[DefaultValue(null), Category("Appearance"), Description("Gets or sets the title text font.")]
+ //public Font TitleTextFont
+ //{
+ // get { return _TitleTextFont; }
+ // set
+ // {
+ // if (value != _TitleTextFont)
+ // {
+ // Font oldValue = _TitleTextFont;
+ // _TitleTextFont = value;
+ // OnTitleTextFontChanged(oldValue, value);
+ // }
+ // }
+ //}
+ /////
+ ///// Called when TitleTextFont property has changed.
+ /////
+ ///// Old property value
+ ///// New property value
+ //protected virtual void OnTitleTextFontChanged(Font oldValue, Font newValue)
+ //{
+ // this.Invalidate();
+ // //OnPropertyChanged(new PropertyChangedEventArgs("TitleTextFont"));
+ //}
+ //private Rectangle _TitleTextBounds = Rectangle.Empty;
+ //internal Rectangle TitleTextBounds
+ //{
+ // get
+ // {
+ // return _TitleTextBounds;
+ // }
+ // set
+ // {
+ // _TitleTextBounds = value;
+ // }
+ //}
+
+ //private Color _TitleTextColor = Color.Empty;
+ /////
+ ///// Gets or sets the color of the title text.
+ /////
+ //[Category("Columns"), Description("Indicates color of title text.")]
+ //public Color TitleTextColor
+ //{
+ // get { return _TitleTextColor; }
+ // set
+ // {
+ // if (_TitleTextColor != value)
+ // {
+ // Color oldValue = _TitleTextColor;
+ // _TitleTextColor = value;
+ // OnTitleTextColorChanged(oldValue, value);
+ // }
+ // }
+ //}
+ /////
+ ///// Called when TitleTextColor property has changed.
+ /////
+ ///// Old property value
+ ///// New property value
+ //protected virtual void OnTitleTextColorChanged(Color oldValue, Color newValue)
+ //{
+ // this.Invalidate();
+ // //OnPropertyChanged(new PropertyChangedEventArgs("TitleTextColor"));
+ //}
+ /////
+ ///// Gets whether property should be serialized.
+ /////
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public bool ShouldSerializeTitleTextColor()
+ //{
+ // return !_TitleTextColor.IsEmpty;
+ //}
+ /////
+ ///// Resets property to its default value.
+ /////
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //public void ResetTitleTextColor()
+ //{
+ // this.TitleTextColor = Color.Empty;
+ //}
+
+ //private ContentAlignment _TitleTextAlignment = ContentAlignment.BottomLeft;
+ /////
+ ///// Gets or sets title text alignment.
+ /////
+ //[DefaultValue(ContentAlignment.BottomLeft), Category("Appearance"), Description("Indicates title text alignment.")]
+ //public ContentAlignment TitleTextAlignment
+ //{
+ // get { return _TitleTextAlignment; }
+ // set
+ // {
+ // if (value != _TitleTextAlignment)
+ // {
+ // ContentAlignment oldValue = _TitleTextAlignment;
+ // _TitleTextAlignment = value;
+ // OnTitleTextAlignmentChanged(oldValue, value);
+ // }
+ // }
+ //}
+ /////
+ ///// Called when TitleTextAlignment property has changed.
+ /////
+ ///// Old property value
+ ///// New property value
+ //protected virtual void OnTitleTextAlignmentChanged(ContentAlignment oldValue, ContentAlignment newValue)
+ //{
+ // //OnPropertyChanged(new PropertyChangedEventArgs("TitleTextAlignment"));
+ // this.Invalidate();
+ //}
+
+ protected override void OnClick(EventArgs e)
+ {
+ if (_TextMarkup != null && _TextMarkup.MouseOverElement is HyperLink)
+ {
+ _TextMarkup.Click(this);
+ base.OnClick(e);
+ return;
+ }
+ else if (_CloseButtonMouseOver)
+ {
+ base.OnClick(e);
+ return;
+ }
+
+ if (_ClickAction != null)
+ {
+ _ClickAction.Invoke(_AlertId);
+ this.HideAlert(eAlertClosureSource.AlertClicked);
+ }
+ base.OnClick(e);
+ }
+
+ private long _AlertId = 0;
+ ///
+ /// Indicates optional Alert Id.
+ ///
+ [Browsable(false), DefaultValue(0)]
+ public long AlertId {
+ get { return _AlertId; }
+ set { _AlertId = value; }
+ }
+
+ private Action _ClickAction = null;
+ ///
+ /// Indicates the method that will be invoked if user clicks the alert.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public Action ClickAction
+ {
+ get { return _ClickAction; }
+ set { _ClickAction = value; }
+ }
+
+ private bool _TextMarkupEnabled = true;
+ ///
+ /// Gets or sets whether text-markup can be used in Text property.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether text-markup can be used in Text property.")]
+ public bool TextMarkupEnabled
+ {
+ get { return _TextMarkupEnabled; }
+ set
+ {
+ if (value != _TextMarkupEnabled)
+ {
+ bool oldValue = _TextMarkupEnabled;
+ _TextMarkupEnabled = value;
+ OnTextMarkupEnabledChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when TextMarkupEnabled property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnTextMarkupEnabledChanged(bool oldValue, bool newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("TextMarkupEnabled"));
+ this.Invalidate();
+ }
+ #endregion
+
+ #region Markup Implementation
+ private TextMarkup.BodyElement _TextMarkup = null;
+
+ private void MarkupTextChanged()
+ {
+ if (_TextMarkup != null)
+ _TextMarkup.HyperLinkClick -= TextMarkupLinkClick;
+
+ _TextMarkup = null;
+
+ if (!_TextMarkupEnabled)
+ return;
+ string text = this.Text;
+ if (!TextMarkup.MarkupParser.IsMarkup(ref text))
+ return;
+
+ _TextMarkup = TextMarkup.MarkupParser.Parse(text);
+
+ if (_TextMarkup != null)
+ _TextMarkup.HyperLinkClick += TextMarkupLinkClick;
+ }
+
+ ///
+ /// Occurs when text markup link is clicked.
+ ///
+ protected virtual void TextMarkupLinkClick(object sender, EventArgs e)
+ {
+ TextMarkup.HyperLink link = sender as TextMarkup.HyperLink;
+ if (link != null)
+ OnMarkupLinkClick(new MarkupLinkClickEventArgs(link.Name, link.HRef));
+ }
+ ///
+ /// Occurs when text markup link is clicked. Markup links can be created using "a" tag, for example:
+ /// Markup link
+ ///
+ [Description("Occurs when text markup link is clicked. Markup links can be created using a tag.")]
+ public event MarkupLinkClickEventHandler MarkupLinkClick;
+ ///
+ /// Raises MarkupLinkClick event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnMarkupLinkClick(MarkupLinkClickEventArgs e)
+ {
+ MarkupLinkClickEventHandler handler = MarkupLinkClick;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Gets reference to parsed markup body element if text was markup otherwise returns null.
+ ///
+ internal TextMarkup.BodyElement TextMarkupBody
+ {
+ get { return _TextMarkup; }
+ }
+
+ internal static Size MeasureText(DesktopAlertWindow item, Graphics g, int containerWidth, Font font, eTextFormat stringFormat, bool rightToLeft)
+ {
+ if (item.Text == "" && item.TextMarkupBody == null) return Size.Empty;
+
+ Size textSize = Size.Empty;
+
+ if (item.TextMarkupBody == null)
+ {
+ textSize = TextDrawing.MeasureString(g, ButtonItemPainter.GetDrawText(item.Text), font, containerWidth, stringFormat);
+ }
+ else
+ {
+ Size availSize = new Size(containerWidth, 1);
+ if (containerWidth == 0)
+ availSize.Width = 1600;
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, Color.Empty, false);
+ item.TextMarkupBody.Measure(availSize, d);
+ availSize = item.TextMarkupBody.Bounds.Size;
+ if (containerWidth != 0)
+ availSize.Width = containerWidth;
+ d.RightToLeft = rightToLeft;
+ item.TextMarkupBody.Arrange(new Rectangle(0, 0, availSize.Width, availSize.Height), d);
+
+ textSize = item.TextMarkupBody.Bounds.Size;
+ }
+
+ return textSize;
+ }
+
+ private static readonly Size DefaultAlertSizeValue = new Size(360, 64);
+ private Size _DefaultAlertSize = DefaultAlertSizeValue;
+ ///
+ /// Gets or sets the default alert size.
+ ///
+ [Category("Appearance"), Description("Indicates default alert size.")]
+ public Size DefaultAlertSize
+ {
+ get { return _DefaultAlertSize; }
+ set
+ {
+ if (value != _DefaultAlertSize)
+ {
+ Size oldValue = _DefaultAlertSize;
+ _DefaultAlertSize = value;
+ OnDefaultAlertSizeChanged(oldValue, value);
+ }
+ }
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeDefaultAlertSize()
+ {
+ return _DefaultAlertSize.Width != DefaultAlertSizeValue.Width || _DefaultAlertSize.Height != DefaultAlertSizeValue.Height;
+ }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetDefaultAlertSize()
+ {
+ DefaultAlertSize = DefaultAlertSizeValue;
+ }
+ private void OnDefaultAlertSizeChanged(Size oldValue, Size newValue)
+ {
+ if (_AutoSize && this.IsHandleCreated)
+ PerformAutoSize();
+ }
+
+ //private eAlertAnimation _AlertAnimation = eAlertAnimation.RightToLeft;
+ /////
+ ///// Gets or sets the animation type used to display Alert.
+ /////
+ //[Browsable(true), Description("Gets or sets the animation type used to display Alert."), Category("Behavior"), DefaultValue(eAlertAnimation.RightToLeft)]
+ //public eAlertAnimation AlertAnimation
+ //{
+ // get { return _AlertAnimation; }
+ // set { _AlertAnimation = value; }
+ //}
+
+ private int _AlertAnimationDuration = 200;
+ ///
+ /// Gets or sets the total time in milliseconds alert animation takes.
+ /// Default value is 200.
+ ///
+ [Browsable(true), Description("Gets or sets the total time in milliseconds alert animation takes."), Category("Behavior"), DefaultValue(200)]
+ public int AlertAnimationDuration
+ {
+ get { return _AlertAnimationDuration; }
+ set { _AlertAnimationDuration = value; }
+ }
+
+ private bool _AutoClose = true;
+ ///
+ /// Gets or sets whether balloon will close automatically when user click the close button.
+ ///
+ [Description("Indicates whether balloon will close automatically when user click the close button."), Category("Behavior"), DefaultValue(true)]
+ public bool AutoClose
+ {
+ get { return _AutoClose; }
+ set { _AutoClose = value; }
+ }
+
+ private int _AutoCloseTimeOut = 6;
+ ///
+ /// Gets or sets time period in seconds after alert closes automatically.
+ ///
+ [Description("Indicates time period in seconds after balloon closes automatically."), Category("Behavior"), DefaultValue(6)]
+ public int AutoCloseTimeOut
+ {
+ get { return _AutoCloseTimeOut; }
+ set
+ {
+ _AutoCloseTimeOut = value;
+ OnAutoCloseTimeOutChanged();
+ }
+ }
+
+ private System.Windows.Forms.Timer _AutoCloseTimer = null;
+ protected void OnAutoCloseTimeOutChanged()
+ {
+ if (_AutoCloseTimeOut > 0 && !this.DesignMode)
+ {
+ StartAutoCloseTimer();
+ }
+ else
+ {
+ DestroyAutoCloseTimer();
+ }
+ }
+
+ private void StartAutoCloseTimer()
+ {
+ if (_AutoCloseTimer == null)
+ {
+ _AutoCloseTimer = new System.Windows.Forms.Timer();
+ _AutoCloseTimer.Enabled = false;
+ _AutoCloseTimer.Tick += new EventHandler(this.AutoCloseTimeOutEllapsed);
+ }
+ _AutoCloseTimer.Interval = _AutoCloseTimeOut * 1000;
+ if (this.Visible)
+ {
+ _AutoCloseTimer.Enabled = true;
+ _AutoCloseTimer.Start();
+ }
+ }
+
+ protected virtual void AutoCloseTimeOutEllapsed(object sender, EventArgs e)
+ {
+ if (this.IsDisposed)
+ return;
+ DestroyAutoCloseTimer();
+ this.HideAlert(eAlertClosureSource.Timeout);
+ this.Close();
+ }
+
+ private void DestroyAutoCloseTimer()
+ {
+ if (_AutoCloseTimer != null)
+ {
+ _AutoCloseTimer.Enabled = false;
+ _AutoCloseTimer.Tick -= new EventHandler(this.AutoCloseTimeOutEllapsed);
+ _AutoCloseTimer.Dispose();
+ _AutoCloseTimer = null;
+ }
+ }
+
+ protected override void OnVisibleChanged(EventArgs e)
+ {
+ base.OnVisibleChanged(e);
+ if (this.Visible)
+ {
+ if (_AutoCloseTimeOut > 0)
+ StartAutoCloseTimer();
+
+ if (_AutoCloseTimer != null && !_AutoCloseTimer.Enabled)
+ {
+ _AutoCloseTimer.Enabled = true;
+ _AutoCloseTimer.Start();
+ }
+ }
+ else
+ {
+ if (_AutoCloseTimer != null && _AutoCloseTimer.Enabled)
+ {
+ _AutoCloseTimer.Stop();
+ _AutoCloseTimer.Enabled = false;
+ }
+ }
+ }
+
+ private Control _ReferenceControl = null;
+ ///
+ /// Specifies the reference control which is used to find which screen the alert is displayed on. If not specified alert is displayed on primary screen.
+ ///
+ [DefaultValue(null), Browsable(false)]
+ public Control ReferenceControl
+ {
+ get { return _ReferenceControl; }
+ set { _ReferenceControl = value; }
+ }
+
+ private static Semaphore _DisplayPositionsSemaphore = new Semaphore(1, 1);
+ private static List _DisplayPositions = new List();
+ private Rectangle GetAlertBounds()
+ {
+ Rectangle r = this.Bounds;
+
+ ScreenInformation si = null;
+ if (_ReferenceControl == null)
+ si = BarFunctions.PrimaryScreen;
+ else
+ si = BarFunctions.ScreenFromControl(_ReferenceControl);
+
+ if (_AlertPosition == eAlertPosition.BottomRight)
+ {
+ r = new Rectangle(si.WorkingArea.Right - this.Width, si.WorkingArea.Bottom - this.Height - Dpi.Height12, this.Width, this.Height);
+ }
+ else if (_AlertPosition == eAlertPosition.BottomLeft)
+ {
+ r = new Rectangle(si.WorkingArea.Left, si.WorkingArea.Bottom - this.Height - Dpi.Height12, this.Width, this.Height);
+ }
+ else if (_AlertPosition == eAlertPosition.TopRight)
+ {
+ r = new Rectangle(si.WorkingArea.Right - this.Width, si.WorkingArea.Top + Dpi.Height12, this.Width, this.Height);
+ }
+ else if (_AlertPosition == eAlertPosition.TopLeft)
+ {
+ r = new Rectangle(si.WorkingArea.Left, si.WorkingArea.Top + Dpi.Height12, this.Width, this.Height);
+ }
+
+ // Now adjust display position
+ if (_DisplayPositions.Count > 0)
+ {
+ if(_AlertPosition == eAlertPosition.TopLeft || _AlertPosition == eAlertPosition.TopRight)
+ _DisplayPositions.Sort(_RectangleComparer);
+ else
+ _DisplayPositions.Sort(_RectangleReverseComparer);
+ Rectangle originalBounds = r;
+ for (int i = 0; i < _DisplayPositions.Count; i++)
+ {
+ if (_DisplayPositions[i].IntersectsWith(r))
+ {
+ if (_AlertPosition == eAlertPosition.BottomLeft || _AlertPosition == eAlertPosition.BottomRight)
+ r.Y -= _DisplayPositions[i].Height + _AlertsSpacing;
+ else
+ r.Y += _DisplayPositions[i].Height + _AlertsSpacing;
+ }
+ else
+ break;
+ if (!si.WorkingArea.Contains(r))
+ {
+ r = originalBounds;
+ break;
+ }
+ if (i == _DisplayPositions.Count - 1)
+ break;
+ }
+ }
+
+ _DisplayPositionsSemaphore.WaitOne();
+ try
+ {
+ _DisplayPositions.Add(r);
+ }
+ finally
+ {
+ _DisplayPositionsSemaphore.Release();
+ }
+ return r;
+ }
+
+ private static readonly RectangleComparer _RectangleComparer = new RectangleComparer();
+ private static readonly RectangleReverseComparer _RectangleReverseComparer = new RectangleReverseComparer();
+ private class RectangleComparer : IComparer
+ {
+ public int Compare(Rectangle x, Rectangle y)
+ {
+ return x.Y - y.Y;
+ }
+ }
+ private class RectangleReverseComparer : IComparer
+ {
+ public int Compare(Rectangle x, Rectangle y)
+ {
+ return y.Y - x.Y;
+ }
+ }
+
+ protected override void OnClosed(EventArgs e)
+ {
+ _DisplayPositionsSemaphore.WaitOne();
+ try
+ {
+ for (int i = _DisplayPositions.Count - 1; i >= 0; i--)
+ {
+ if (_DisplayPositions[i] == this.Bounds)
+ {
+ _DisplayPositions.RemoveAt(i);
+ break;
+ }
+ }
+ }
+ finally
+ {
+ _DisplayPositionsSemaphore.Release();
+ }
+ base.OnClosed(e);
+ }
+
+ ///
+ /// Display balloon.
+ ///
+ /// Indicates whether alert receives input focus upon showing.
+ public void Show(bool focusAlert)
+ {
+ PerformAutoSize();
+
+ this.Bounds = GetAlertBounds();
+ Rectangle rEnd = this.Bounds;
+
+ DesktopAlert.OnBeforeAlertDisplayed(this, EventArgs.Empty);
+ if(this.IsDisposed)
+ return;
+
+ if (ShouldAnimate())
+ {
+ try
+ {
+ _AnimationInProgress = true;
+ eAlertAnimation alertAnimation = GetAlertAnimation();
+ if (alertAnimation == eAlertAnimation.RightToLeft)
+ NativeFunctions.AnimateWindow(this.Handle, _AlertAnimationDuration, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_HOR_NEGATIVE));
+ else if (alertAnimation == eAlertAnimation.LeftToRight)
+ NativeFunctions.AnimateWindow(this.Handle, _AlertAnimationDuration, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_HOR_POSITIVE));
+ else if (alertAnimation == eAlertAnimation.BottomToTop)
+ NativeFunctions.AnimateWindow(this.Handle, _AlertAnimationDuration, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_VER_NEGATIVE));
+ else if (alertAnimation == eAlertAnimation.TopToBottom)
+ NativeFunctions.AnimateWindow(this.Handle, _AlertAnimationDuration, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_VER_POSITIVE));
+ }
+ finally
+ {
+ _AnimationInProgress = false;
+ }
+ }
+ base.Show();
+
+ if (_TopMost)
+ NativeFunctions.SetWindowPos(this.Handle,
+ new IntPtr(NativeFunctions.HWND_TOPMOST), 0, 0, 0, 0,
+ NativeFunctions.SWP_NOACTIVATE | NativeFunctions.SWP_NOMOVE | NativeFunctions.SWP_NOSIZE);
+ //this.Visible = true;
+
+ if (_PlaySound)
+ System.Media.SystemSounds.Beep.Play();
+ }
+
+ protected override bool ShowWithoutActivation
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ private eAlertAnimation GetAlertAnimation()
+ {
+ if (_AlertPosition == eAlertPosition.TopLeft || _AlertPosition == eAlertPosition.BottomLeft)
+ return eAlertAnimation.LeftToRight;
+ else
+ return eAlertAnimation.RightToLeft;
+ }
+
+ ///
+ /// Displays balloon.
+ ///
+ public new void Show()
+ {
+ this.Show(false);
+ }
+
+ private bool _AnimationInProgress = false;
+ ///
+ /// Called when alert needs to be hidden.
+ ///
+ protected virtual void HideAlert(eAlertClosureSource source)
+ {
+ DestroyAutoCloseTimer();
+ if (ShouldAnimate())
+ {
+ Rectangle rStart = this.Bounds;
+ //Rectangle rEnd = GetAnimationRectangle();
+ try
+ {
+ _AnimationInProgress = true;
+ eAlertAnimation alertAnimation = GetAlertAnimation();
+ if (alertAnimation == eAlertAnimation.RightToLeft)
+ NativeFunctions.AnimateWindow(this.Handle, _AlertAnimationDuration, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_HOR_POSITIVE | NativeFunctions.AW_HIDE));
+ else if (alertAnimation == eAlertAnimation.LeftToRight)
+ NativeFunctions.AnimateWindow(this.Handle, _AlertAnimationDuration, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_HOR_NEGATIVE | NativeFunctions.AW_HIDE));
+ else if (alertAnimation == eAlertAnimation.BottomToTop)
+ NativeFunctions.AnimateWindow(this.Handle, _AlertAnimationDuration, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_VER_POSITIVE | NativeFunctions.AW_HIDE));
+ else if (alertAnimation == eAlertAnimation.TopToBottom)
+ NativeFunctions.AnimateWindow(this.Handle, _AlertAnimationDuration, (NativeFunctions.AW_SLIDE | NativeFunctions.AW_VER_NEGATIVE | NativeFunctions.AW_HIDE));
+ }
+ finally
+ {
+ _AnimationInProgress = false;
+ }
+ }
+ else
+ base.Hide();
+ this.Close();
+ DesktopAlert.OnAlertClosed(this, new AlertClosedEventArgs(source));
+ _ClickAction = null;
+ this.Dispose();
+ }
+
+ ///
+ /// Hides balloon.
+ ///
+ public new void Hide()
+ {
+ HideAlert(eAlertClosureSource.Timeout);
+ }
+
+ private bool ShouldAnimate()
+ {
+ if (_AlertAnimationDuration > 0 && !this.DesignMode && !this.IsDisposed)
+ return true;
+ return false;
+ }
+
+ private int _AlertsSpacing = 8;
+ ///
+ /// Indicates spacing between alerts on the screen
+ ///
+ [DefaultValue(8), Category("Behavior"), Description("Indicates spacing between alerts on the screen")]
+ public int AlertsSpacing
+ {
+ get { return _AlertsSpacing; }
+ set
+ {
+ if (_AlertsSpacing != value)
+ {
+ int oldValue = _AlertsSpacing;
+ _AlertsSpacing = value;
+ OnAlertsSpacingChanged(value, oldValue);
+ }
+ }
+ }
+
+ protected virtual void OnAlertsSpacingChanged(int newValue, int oldValue)
+ {
+ throw new NotImplementedException();
+ }
+
+ //private Rectangle GetAnimationRectangle()
+ //{
+ // Rectangle r = new Rectangle(this.Location, this.Size);
+ // if (_AlertAnimation == eAlertAnimation.BottomToTop)
+ // {
+ // r.Y = r.Bottom - 1;
+ // r.Height = 1;
+ // }
+ // else if (_AlertAnimation == eAlertAnimation.TopToBottom)
+ // {
+ // r.Height = 1;
+ // }
+ // else if (_AlertAnimation == eAlertAnimation.LeftToRight)
+ // {
+ // r.Width = 2;
+ // }
+ // else if (_AlertAnimation == eAlertAnimation.RightToLeft)
+ // {
+ // r.X = r.Right - 1;
+ // r.Width = 1;
+ // }
+ // return r;
+ //}
+
+ private eAlertPosition _AlertPosition = eAlertPosition.BottomRight;
+ ///
+ /// Indicates the request screen position for the alert
+ ///
+ [DefaultValue(eAlertPosition.BottomRight), Category("Behavior"), Description("Indicates the request screen position for the alert")]
+ public eAlertPosition AlertPosition
+ {
+ get { return _AlertPosition; }
+ set
+ {
+ if (_AlertPosition != value)
+ {
+ eAlertPosition oldValue = _AlertPosition;
+ _AlertPosition = value;
+ OnAlertPositionChanged(value, oldValue);
+ }
+ }
+ }
+ protected virtual void OnAlertPositionChanged(eAlertPosition newValue, eAlertPosition oldValue)
+ {
+ //throw new NotImplementedException();
+ }
+
+ private bool _TopMost = true;
+ [DefaultValue(true)]
+ public new bool TopMost
+ {
+ get { return _TopMost; }
+ set
+ {
+ if (_TopMost != value)
+ {
+ bool oldValue = _TopMost;
+ _TopMost = value;
+ OnTopMostChanged(value, oldValue);
+ }
+ }
+ }
+
+ protected virtual void OnTopMostChanged(bool newValue, bool oldValue)
+ {
+ if (IsHandleCreated && Visible)
+ NativeFunctions.SetWindowPos(this.Handle,
+ new IntPtr(newValue ? NativeFunctions.HWND_TOPMOST : NativeFunctions.HWND_NOTOPMOST), 0, 0, 0, 0,
+ NativeFunctions.SWP_NOACTIVATE | NativeFunctions.SWP_NOMOVE | NativeFunctions.SWP_NOSIZE);
+ }
+
+ private int _ImageTextPadding = 11;
+ ///
+ /// Indicates spacing in pixels between image and text
+ ///
+ [DefaultValue(11), Category("Appearance"), Description("Indicates spacing in pixels between image and text")]
+ public int ImageTextPadding
+ {
+ get { return _ImageTextPadding; }
+ set
+ {
+ if (_ImageTextPadding != value)
+ {
+ int oldValue = _ImageTextPadding;
+ _ImageTextPadding = value;
+ OnImageTextPaddingChanged(value, oldValue);
+ }
+ }
+ }
+
+ protected virtual void OnImageTextPaddingChanged(int newValue, int oldValue)
+ {
+
+ }
+
+ private bool UseTextRenderer
+ {
+ get { return true; /*_BackColors == null || _BackColors.Length < 2;*/ }
+ }
+
+ private bool _PlaySound = true;
+ ///
+ /// Indicates whether alert plays exclamation sound when shown.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether alert plays exclamation sound when shown.")]
+ public bool PlaySound
+ {
+ get { return _PlaySound; }
+ set
+ {
+ if (_PlaySound != value)
+ {
+ bool oldValue = _PlaySound;
+ _PlaySound = value;
+ OnPlaySoundChanged(value, oldValue);
+ }
+ }
+ }
+
+ protected virtual void OnPlaySoundChanged(bool newValue, bool oldValue)
+ {
+ //throw new NotImplementedException();
+ }
+
+ private bool _CloseButtonVisible = true;
+ ///
+ /// Indicates whether close button on alert is visible
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether close button on alert is visible")]
+ public bool CloseButtonVisible
+ {
+ get { return _CloseButtonVisible; }
+ set
+ {
+ if (_CloseButtonVisible != value)
+ {
+ bool oldValue = _CloseButtonVisible;
+ _CloseButtonVisible = value;
+ OnCloseButtonVisibleChanged(value, oldValue);
+ }
+ }
+ }
+
+ protected virtual void OnCloseButtonVisibleChanged(bool newValue, bool oldValue)
+ {
+ //throw new NotImplementedException();
+ }
+ #endregion
+ }
+
+ ///
+ /// Defines the alert positions.
+ ///
+ public enum eAlertPosition
+ {
+ ///
+ /// Top-left screen position.
+ ///
+ TopLeft,
+ ///
+ /// Top-right screen position.
+ ///
+ TopRight,
+ ///
+ /// Bottom-right screen position.
+ ///
+ BottomRight,
+ ///
+ /// Bottom left screen position.
+ ///
+ BottomLeft
+ }
+ ///
+ /// Defines closure sources for the alert.
+ ///
+ public enum eAlertClosureSource
+ {
+ ///
+ /// Alert is closed becouse of timeout
+ ///
+ Timeout,
+ ///
+ /// Alert is closed becouse user clicked close button.
+ ///
+ CloseButton,
+ ///
+ /// Alert is closed becouse user clicked on the alert.
+ ///
+ AlertClicked
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/Flyout.ico b/PROMS/DotNetBar Source Code/Controls/Flyout.ico
new file mode 100644
index 00000000..f6992446
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/Flyout.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/Flyout/Flyout.cs b/PROMS/DotNetBar Source Code/Controls/Flyout/Flyout.cs
new file mode 100644
index 00000000..e5c0fea0
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/Flyout/Flyout.cs
@@ -0,0 +1,1342 @@
+using DevComponents.DotNetBar;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// Component to display flyout popup.
+ ///
+ [ToolboxBitmap(typeof(Flyout), "Controls.Flyout.ico")]
+ [ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.FlyoutDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ [DefaultEvent("PrepareContent")]
+ public partial class Flyout : Component, IMessageHandlerClient
+ {
+ #region Constructor
+ public Flyout()
+ {
+ InitializeComponent();
+ }
+
+ public Flyout(IContainer container)
+ {
+ container.Add(this);
+
+ InitializeComponent();
+ }
+ #endregion
+
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ Close();
+ if (_MessageHandlerInstalled)
+ {
+ MessageHandler.UnregisterMessageClient(this);
+ _MessageHandlerInstalled = false;
+ }
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+
+ #region Implementation
+ private bool _DropShadow;
+ private bool _TopMost;
+ private Control _Content = null;
+ ///
+ /// Indicates a control, usually panel with other controls inside of it, that is displayed on the flyout popup.
+ ///
+ [DefaultValue(null), Category("Appearance"), Description("Indicates a control, usually panel with other controls inside of it, that is displayed on the flyout popup.")]
+ public Control Content
+ {
+ get { return _Content; }
+ set
+ {
+ if (value != _Content)
+ {
+ Control oldValue = _Content;
+ _Content = value;
+ OnContentChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when Content property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnContentChanged(Control oldValue, Control newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("Content"));
+
+ }
+
+ private ePointerSide _PointerSide = ePointerSide.Bottom;
+ ///
+ /// Indicates the side of the flyout triangle pointer is displayed on.
+ ///
+ [DefaultValue(ePointerSide.Bottom), Category("Appearance"), Description("Indicates the side of the flyout triangle pointer is displayed on.")]
+ public ePointerSide PointerSide
+ {
+ get { return _PointerSide; }
+ set
+ {
+ if (value != _PointerSide)
+ {
+ ePointerSide oldValue = _PointerSide;
+ _PointerSide = value;
+ OnPointerSideChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when PointerSide property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnPointerSideChanged(ePointerSide oldValue, ePointerSide newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("PointerSide"));
+ }
+
+ private Control _TargetControl = null;
+ ///
+ /// Indicates the target control for the flyout display and positioning.
+ ///
+ [DefaultValue(null), Category("Behavior"), Description("Indicates the target control for the flyout display and positioning.")]
+ public Control TargetControl
+ {
+ get { return _TargetControl; }
+ set
+ {
+ if (value != _TargetControl)
+ {
+ Control oldValue = _TargetControl;
+ _TargetControl = value;
+ OnTargetControlChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when TargetControl property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnTargetControlChanged(Control oldValue, Control newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("TargetControl"));
+ if (!this.DesignMode)
+ {
+ DetachFromControl(oldValue, _DisplayMode, _DeepIntegration);
+ AttachToControl(newValue, _DisplayMode, _DeepIntegration);
+ }
+ }
+
+ private void AttachToControl(Control c, eFlyoutDisplayMode displayMode, bool deepIntegration)
+ {
+ if (c == null) return;
+ if (displayMode == eFlyoutDisplayMode.MouseClick)
+ {
+ if (deepIntegration && c is SuperTabControl)
+ {
+ SuperTabControl tab = (SuperTabControl)c;
+ tab.TabStrip.ItemClick += TabStripMouseEvent;
+ }
+ else if (deepIntegration && c is AdvTree.AdvTree)
+ {
+ AdvTree.AdvTree tree = (AdvTree.AdvTree)c;
+ tree.NodeClick += TreeMouseEvent;
+ }
+ else if (deepIntegration && c is TokenEditor)
+ {
+ TokenEditor token = (TokenEditor)c;
+ token.TokenMouseClick += TokenMouseEvent;
+ }
+ else if (deepIntegration && c is TabStrip)
+ {
+ TabStrip strip = (TabStrip)c;
+ strip.TabMouseClick += TabItemMouseEvent;
+ }
+ else if (deepIntegration && c is TabControl)
+ {
+ TabControl strip = (TabControl)c;
+ strip.TabStrip.TabMouseClick += TabItemMouseEvent;
+ }
+ else if (deepIntegration && c is Bar)
+ {
+ Bar bar = (Bar)c;
+ bar.ItemClick += BaseItemMouseEvent;
+ }
+ else
+ c.MouseClick += TargetMouseClick;
+ }
+ else if (displayMode == eFlyoutDisplayMode.MouseHover)
+ {
+ if (deepIntegration && c is SuperTabControl)
+ {
+ SuperTabControl tab = (SuperTabControl)c;
+ tab.TabStrip.MouseHover += TabStripMouseEvent;
+ tab.TabStrip.MouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is AdvTree.AdvTree)
+ {
+ AdvTree.AdvTree tree = (AdvTree.AdvTree)c;
+ tree.NodeMouseHover += TreeMouseEvent;
+ tree.NodeMouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TokenEditor)
+ {
+ TokenEditor token = (TokenEditor)c;
+ token.TokenMouseHover += TokenMouseEvent;
+ token.TokenMouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TabStrip)
+ {
+ TabStrip tab = (TabStrip)c;
+ tab.TabMouseHover += TabItemMouseEvent;
+ tab.TabMouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TabControl)
+ {
+ TabControl tab = (TabControl)c;
+ tab.TabStrip.TabMouseHover += TabItemMouseEvent;
+ tab.TabStrip.TabMouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is Bar)
+ {
+ Bar bar = (Bar)c;
+ bar.MouseHover += BaseItemMouseEvent;
+ bar.MouseLeave += TargetMouseLeave;
+ }
+ else
+ c.MouseHover += TargetMouseHover;
+ }
+ else if (displayMode == eFlyoutDisplayMode.MouseOver)
+ {
+ if (deepIntegration && c is SuperTabControl)
+ {
+ SuperTabControl tab = (SuperTabControl)c;
+ tab.TabStrip.MouseEnter += TabStripMouseEvent;
+ tab.TabStrip.MouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is AdvTree.AdvTree)
+ {
+ AdvTree.AdvTree tree = (AdvTree.AdvTree)c;
+ tree.NodeMouseEnter += TreeMouseEvent;
+ tree.NodeMouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TokenEditor)
+ {
+ TokenEditor token = (TokenEditor)c;
+ token.TokenMouseEnter += TokenMouseEvent;
+ token.TokenMouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TabStrip)
+ {
+ TabStrip tab = (TabStrip)c;
+ tab.TabMouseEnter += TabItemMouseEvent;
+ tab.TabMouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TabControl)
+ {
+ TabControl tab = (TabControl)c;
+ tab.TabStrip.TabMouseEnter += TabItemMouseEvent;
+ tab.TabStrip.TabMouseLeave += TargetMouseLeave;
+ }
+ else if (deepIntegration && c is Bar)
+ {
+ Bar bar = (Bar)c;
+ bar.MouseMove += BaseItemMouseEvent;
+ bar.MouseLeave += TargetMouseLeave;
+ }
+ else
+ c.MouseEnter += TargetMouseEnter;
+ }
+ c.Leave += TargetLeaveFocus;
+ c.VisibleChanged += TargetVisibleChanged;
+ }
+
+ private void DetachFromControl(Control c, eFlyoutDisplayMode displayMode, bool deepIntegration)
+ {
+ if (c == null) return;
+ if (displayMode == eFlyoutDisplayMode.MouseClick)
+ {
+ if (deepIntegration && c is SuperTabControl)
+ {
+ SuperTabControl tab = (SuperTabControl)c;
+ tab.TabStrip.ItemClick -= TabStripMouseEvent;
+ }
+ else if (deepIntegration && c is AdvTree.AdvTree)
+ {
+ AdvTree.AdvTree tree = (AdvTree.AdvTree)c;
+ tree.NodeClick -= TreeMouseEvent;
+ }
+ else if (deepIntegration && c is TokenEditor)
+ {
+ TokenEditor token = (TokenEditor)c;
+ token.TokenMouseClick -= TokenMouseEvent;
+ }
+ else if (deepIntegration && c is TabStrip)
+ {
+ TabStrip strip = (TabStrip)c;
+ strip.TabMouseClick -= TabItemMouseEvent;
+ }
+ else if (deepIntegration && c is TabControl)
+ {
+ TabControl strip = (TabControl)c;
+ strip.TabStrip.TabMouseClick -= TabItemMouseEvent;
+ }
+ else if (deepIntegration && c is Bar)
+ {
+ Bar bar = (Bar)c;
+ bar.ItemClick -= BaseItemMouseEvent;
+ }
+ else
+ c.MouseClick -= TargetMouseClick;
+ }
+ else if (displayMode == eFlyoutDisplayMode.MouseHover)
+ {
+ if (deepIntegration && c is SuperTabControl)
+ {
+ SuperTabControl tab = (SuperTabControl)c;
+ tab.TabStrip.MouseHover -= TabStripMouseEvent;
+ tab.TabStrip.MouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is AdvTree.AdvTree)
+ {
+ AdvTree.AdvTree tree = (AdvTree.AdvTree)c;
+ tree.NodeMouseHover -= TreeMouseEvent;
+ tree.NodeMouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TokenEditor)
+ {
+ TokenEditor token = (TokenEditor)c;
+ token.TokenMouseHover -= TokenMouseEvent;
+ token.TokenMouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TabStrip)
+ {
+ TabStrip tab = (TabStrip)c;
+ tab.TabMouseHover -= TabItemMouseEvent;
+ tab.TabMouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TabControl)
+ {
+ TabControl tab = (TabControl)c;
+ tab.TabStrip.TabMouseHover -= TabItemMouseEvent;
+ tab.TabStrip.TabMouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is Bar)
+ {
+ Bar bar = (Bar)c;
+ bar.MouseHover -= BaseItemMouseEvent;
+ bar.MouseLeave -= TargetMouseLeave;
+ }
+ else
+ c.MouseHover -= TargetMouseHover;
+ }
+ else if (displayMode == eFlyoutDisplayMode.MouseOver)
+ {
+ if (deepIntegration && c is SuperTabControl)
+ {
+ SuperTabControl tab = (SuperTabControl)c;
+ tab.TabStrip.MouseEnter -= TabStripMouseEvent;
+ tab.TabStrip.MouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is AdvTree.AdvTree)
+ {
+ AdvTree.AdvTree tree = (AdvTree.AdvTree)c;
+ tree.NodeMouseEnter -= TreeMouseEvent;
+ tree.NodeMouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TokenEditor)
+ {
+ TokenEditor token = (TokenEditor)c;
+ token.TokenMouseEnter -= TokenMouseEvent;
+ token.TokenMouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TabStrip)
+ {
+ TabStrip tab = (TabStrip)c;
+ tab.TabMouseEnter -= TabItemMouseEvent;
+ tab.TabMouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is TabControl)
+ {
+ TabControl tab = (TabControl)c;
+ tab.TabStrip.TabMouseEnter -= TabItemMouseEvent;
+ tab.TabStrip.TabMouseLeave -= TargetMouseLeave;
+ }
+ else if (deepIntegration && c is Bar)
+ {
+ Bar bar = (Bar)c;
+ bar.MouseEnter -= BaseItemMouseEvent;
+ bar.MouseLeave -= TargetMouseLeave;
+ }
+ else
+ c.MouseEnter -= TargetMouseEnter;
+ }
+ c.Leave -= TargetLeaveFocus;
+ c.VisibleChanged -= TargetVisibleChanged;
+ }
+ private bool _CloseDelayed = false;
+ private void TargetMouseLeave(object sender, EventArgs e)
+ {
+ if (_IsFlyoutFormShown)
+ {
+ _CloseDelayed = true;
+ BarUtilities.InvokeDelayed(new MethodInvoker(delegate { CloseFlyoutDelayed(); }), 1000);
+ //Close();
+ }
+ }
+ private void CloseFlyoutDelayed()
+ {
+ if (!_CloseDelayed) return;
+ _CloseDelayed = false;
+ if (_IsFlyoutFormShown && _Flyout!=null && !_Flyout.Bounds.Contains(Control.MousePosition) &&
+ _TargetControl!=null && !(new Rectangle(_TargetControl.PointToScreen(_TargetControl.Location), _TargetControl.Size).Contains(Control.MousePosition)))
+ {
+ Close();
+ }
+ }
+ private void TokenMouseEvent(object sender, EventArgs e)
+ {
+ if (_IsFlyoutFormShown)
+ Close();
+ Show(sender);
+ }
+ private void TreeMouseEvent(object sender, AdvTree.TreeNodeMouseEventArgs e)
+ {
+ if (_IsFlyoutFormShown)
+ Close();
+ Show(e.Node);
+ }
+ private void TabItemMouseEvent(object sender, EventArgs e)
+ {
+ if (sender is TabItem)
+ {
+ if (_IsFlyoutFormShown)
+ Close();
+ if (!_IsFlyoutFormShown)
+ {
+ Show(sender);
+ }
+ }
+ else
+ Close();
+ }
+ private void BaseItemMouseEvent(object sender, EventArgs e)
+ {
+ if (sender is BaseItem)
+ {
+ if (_IsFlyoutFormShown)
+ Close();
+ if (!_IsFlyoutFormShown)
+ {
+ Show(sender);
+ }
+ }
+ else if (sender is Bar)
+ {
+ Bar bar = (Bar)sender;
+ Point p = bar.PointToClient(Control.MousePosition);
+ BaseItem item = bar.ItemsContainer.ItemAtLocation(p.X, p.Y);
+ if (item != null)
+ {
+ if (_TargetItem != null && _TargetItem.IsAlive && _TargetItem.Target == item)
+ return;
+
+ if (_IsFlyoutFormShown)
+ Close();
+
+ if (!_IsFlyoutFormShown)
+ {
+ Show(item);
+ }
+ }
+ else
+ Close();
+ }
+ else
+ Close();
+ }
+ private void TabStripMouseEvent(object sender, EventArgs e)
+ {
+ if (sender is SuperTabItem)
+ {
+ if (_IsFlyoutFormShown)
+ Close();
+ if (!_IsFlyoutFormShown)
+ {
+ Show(sender);
+ }
+ }
+ else
+ Close();
+ }
+
+ private bool _DeepIntegration = true;
+ ///
+ /// Indicates whether Flyout integrates on item level with DotNetBar controls it recognizes like SuperTabControl, AdvTree etc.
+ ///
+ [DefaultValue(true), Category("Behavior"), Description("Indicates whether Flyout integrates on item level with DotNetBar controls it recognizes like SuperTabControl, AdvTree etc.")]
+ public bool DeepIntegration
+ {
+ get { return _DeepIntegration; }
+ set
+ {
+ if (value != _DeepIntegration)
+ {
+ bool oldValue = _DeepIntegration;
+ _DeepIntegration = value;
+ OnDeepControlIntegrationChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when DeepControlIntegration property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnDeepControlIntegrationChanged(bool oldValue, bool newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("DeepControlIntegration"));
+ DetachFromControl(_TargetControl, _DisplayMode, oldValue);
+ AttachToControl(_TargetControl, _DisplayMode, newValue);
+ }
+
+ private void TargetVisibleChanged(object sender, EventArgs e)
+ {
+ if ((_CloseMode & eFlyoutCloseMode.TargetControlHidden) == eFlyoutCloseMode.TargetControlHidden && _TargetControl != null && !_TargetControl.Visible)
+ Close();
+ }
+ void TargetLeaveFocus(object sender, EventArgs e)
+ {
+ if ((_CloseMode & eFlyoutCloseMode.TargetControlLostFocus) == eFlyoutCloseMode.TargetControlLostFocus)
+ Close();
+ }
+
+ void TargetMouseEnter(object sender, EventArgs e)
+ {
+ if (!_IsFlyoutFormShown)
+ Show();
+ }
+
+ void TargetMouseHover(object sender, EventArgs e)
+ {
+ if (!_IsFlyoutFormShown)
+ Show();
+ }
+ private void TargetMouseClick(object sender, MouseEventArgs e)
+ {
+ if (!_IsFlyoutFormShown)
+ Show();
+ }
+ private eFlyoutDisplayMode _DisplayMode = eFlyoutDisplayMode.MouseOver;
+ ///
+ /// Specifies when the flyout is displayed.
+ ///
+ [DefaultValue(eFlyoutDisplayMode.MouseOver), Category("Behavior"), Description("Specifies when the flyout is displayed.")]
+ public eFlyoutDisplayMode DisplayMode
+ {
+ get { return _DisplayMode; }
+ set
+ {
+ if (value != _DisplayMode)
+ {
+ eFlyoutDisplayMode oldValue = _DisplayMode;
+ _DisplayMode = value;
+ OnDisplayModeChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when DisplayMode property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnDisplayModeChanged(eFlyoutDisplayMode oldValue, eFlyoutDisplayMode newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("DisplayMode"));
+ DetachFromControl(_TargetControl, oldValue, _DeepIntegration);
+ AttachToControl(_TargetControl, newValue, _DeepIntegration);
+ }
+
+ private eFlyoutCloseMode _CloseMode = eFlyoutCloseMode.ClickOutside | eFlyoutCloseMode.ParentFormDeactivate;
+ ///
+ /// Indicates when Flyout is automatically closed.
+ ///
+ [DefaultValue(eFlyoutCloseMode.ClickOutside | eFlyoutCloseMode.ParentFormDeactivate), Category("Behavior"), Description("Indicates when Flyout is automatically closed.")]
+ public eFlyoutCloseMode CloseMode
+ {
+ get { return _CloseMode; }
+ set
+ {
+ if (value != _CloseMode)
+ {
+ eFlyoutCloseMode oldValue = _CloseMode;
+ _CloseMode = value;
+ OnCloseModeChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when CloseMode property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnCloseModeChanged(eFlyoutCloseMode oldValue, eFlyoutCloseMode newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("CloseMode"));
+
+ }
+
+ private Rectangle GetTargetBounds(object targetItem)
+ {
+ if (targetItem is BaseItem)
+ {
+ BaseItem item = (BaseItem)targetItem;
+ return new Rectangle(_TargetControl.PointToScreen(item.Bounds.Location), item.Bounds.Size);
+ }
+ else if (targetItem is DevComponents.AdvTree.Node)
+ {
+ DevComponents.AdvTree.Node node = (DevComponents.AdvTree.Node)targetItem;
+ return new Rectangle(_TargetControl.PointToScreen(node.Bounds.Location), node.Bounds.Size);
+ }
+ else if(targetItem is EditToken)
+ {
+ EditToken token = (EditToken)targetItem;
+ return new Rectangle(_TargetControl.PointToScreen(token.Bounds.Location), token.Bounds.Size);
+ }
+ else if (targetItem is TabItem)
+ {
+ TabItem tab = (TabItem)targetItem;
+ return new Rectangle(_TargetControl.PointToScreen(tab.DisplayRectangle.Location), tab.DisplayRectangle.Size);
+ }
+
+ return new Rectangle(_TargetControl.PointToScreen(Point.Empty), _TargetControl.Size);
+ }
+
+ ///
+ /// Occurs before the flyout is shown for specific target and allows you to prepare Content for it. Sender of event will be the targeted control or item.
+ ///
+ [Description("Occurs before the flyout is shown for specific target and allows you to prepare Content for it. Sender of event will be the targeted control or item.")]
+ public event EventHandler PrepareContent;
+ ///
+ /// Raises PrepareContent event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnPrepareContent(object sender, EventArgs e)
+ {
+ EventHandler handler = PrepareContent;
+ if (handler != null)
+ handler(sender, e);
+ }
+
+ public virtual void Show(object targetItem)
+ {
+ OnPrepareContent(targetItem, EventArgs.Empty);
+
+ Rectangle r = new Rectangle();
+ ePointerSide pointerSide = _PointerSide;
+ int pointerOffset = 10;
+
+ if (_TargetControl != null)
+ {
+ Rectangle targetBounds = GetTargetBounds(targetItem ?? _TargetControl);
+ ScreenInformation si = BarFunctions.ScreenFromControl(_TargetControl);
+ if (pointerSide == ePointerSide.Top)
+ {
+ // Displaying callout below the control
+ r.Size = GetFlyoutFormSize();
+ if (targetBounds.Bottom + r.Height > si.WorkingArea.Bottom)
+ {
+ // Move flyout above the control
+ pointerSide = ePointerSide.Bottom;
+ r.Location = new Point(targetBounds.X, targetBounds.Y - r.Height);
+ }
+ else
+ r.Location = new Point(targetBounds.X, targetBounds.Bottom);
+ if (targetBounds.Width > r.Width)
+ r.X += (targetBounds.Width - r.Width) / 2;
+ else if (targetBounds.Width < r.Width)
+ r.X -= (r.Width - targetBounds.Width) / 2;
+ if (r.X < si.WorkingArea.X)
+ r.X = si.WorkingArea.X;
+ else if (r.Right > si.WorkingArea.Right)
+ r.X = si.WorkingArea.Right - r.Width;
+ Rectangle intersect = Rectangle.Intersect(r, new Rectangle(targetBounds.X, r.Y, targetBounds.Width, r.Height));
+ if (intersect.IsEmpty)
+ pointerOffset = (Math.Min(targetBounds.Width, r.Width) - FlyoutForm.PointerSize.Width) / 2;
+ else
+ pointerOffset = Math.Abs(intersect.X - r.X) + (intersect.Width - FlyoutForm.PointerSize.Width) / 2;
+ }
+ else if (pointerSide == ePointerSide.Bottom)
+ {
+ // Displaying callout above the control
+ r.Size = GetFlyoutFormSize();
+ if (targetBounds.Y - r.Height < si.WorkingArea.Y)
+ {
+ // Move flyout below the control
+ pointerSide = ePointerSide.Top;
+ r.Location = new Point(targetBounds.X, targetBounds.Bottom);
+ }
+ else
+ r.Location = new Point(targetBounds.X, targetBounds.Y - r.Height);
+ if (targetBounds.Width > r.Width)
+ r.X += (targetBounds.Width - r.Width) / 2;
+ else if (targetBounds.Width < r.Width)
+ r.X -= (r.Width - targetBounds.Width) / 2;
+ if (r.X < si.WorkingArea.X)
+ r.X = si.WorkingArea.X;
+ else if (r.Right > si.WorkingArea.Right)
+ r.X = si.WorkingArea.Right - r.Width;
+ Rectangle intersect = Rectangle.Intersect(r, new Rectangle(targetBounds.X, r.Y, targetBounds.Width, r.Height));
+ if (intersect.IsEmpty)
+ pointerOffset = (Math.Min(targetBounds.Width, r.Width) - FlyoutForm.PointerSize.Width) / 2;
+ else
+ pointerOffset = Math.Abs(intersect.X - r.X) + (intersect.Width - FlyoutForm.PointerSize.Width) / 2;
+ }
+ else if (pointerSide == ePointerSide.Left)
+ {
+ // Displaying callout to the right of the target control
+ r.Size = GetFlyoutFormSize();
+ if (targetBounds.Right + r.Width > si.WorkingArea.Right)
+ {
+ // Move flyout to the left of the control
+ pointerSide = ePointerSide.Right;
+ r.Location = new Point(targetBounds.X - r.Width, targetBounds.Y);
+ }
+ else
+ r.Location = new Point(targetBounds.Right, targetBounds.Y);
+
+ if (targetBounds.Height > r.Height)
+ r.Y += (targetBounds.Height - r.Height) / 2;
+ pointerOffset = (Math.Min(targetBounds.Height, r.Height) - FlyoutForm.PointerSize.Width) / 2;
+ }
+ else if (pointerSide == ePointerSide.Right)
+ {
+ // Displaying callout to the Left of the target control
+ r.Size = GetFlyoutFormSize();
+ if (targetBounds.X - r.Width < si.WorkingArea.X)
+ {
+ // Move flyout to the right of the control
+ pointerSide = ePointerSide.Left;
+ r.Location = new Point(targetBounds.Right, targetBounds.Y);
+ }
+ else
+ r.Location = new Point(targetBounds.X - r.Width, targetBounds.Y);
+
+ if (targetBounds.Height > r.Height)
+ r.Y += (targetBounds.Height - r.Height) / 2;
+ pointerOffset = (Math.Min(targetBounds.Height, r.Height) - FlyoutForm.PointerSize.Width) / 2;
+ }
+ }
+ Show(r, pointerSide, pointerOffset, targetItem);
+ }
+
+ ///
+ /// Shows flyout with the Content.
+ ///
+ public virtual void Show()
+ {
+ Show(_TargetControl);
+ }
+
+ ///
+ /// Returns the flyout size based on Content size.
+ ///
+ /// Proposed flyout size.
+ public virtual Size GetFlyoutFormSize()
+ {
+ if (_Content != null)
+ {
+ Size size = _Content.Size;
+ if (_PointerSide == ePointerSide.Bottom || _PointerSide == ePointerSide.Top)
+ {
+ size.Height += FlyoutForm.PointerSize.Height + 4;
+ size.Width += 2;
+ }
+ else
+ {
+ size.Width += FlyoutForm.PointerSize.Height + 4;
+ size.Height += 2;
+ }
+ return size;
+ }
+ return new Size(100, 100);
+ }
+ ///
+ /// Shows flyout at specified location and with specified size. Size can be empty (0,0) and flyout will be automatically sized based on the content.
+ ///
+ ///
+ public virtual void Show(Rectangle screenFlyoutBounds)
+ {
+ Show(screenFlyoutBounds, _PointerSide, 10, _TargetControl);
+ }
+ [Description("Occurs before the flyout form is shown and allows you to cancel the showing.")]
+ public event FlyoutShowingEventHandler FlyoutShowing;
+ ///
+ /// Raises FlyoutShowing event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnFlyoutShowing(FlyoutShowingEventArgs e)
+ {
+ FlyoutShowingEventHandler handler = FlyoutShowing;
+ if (handler != null)
+ handler(this, e);
+ }
+ ///
+ /// Occurs after flyout has been shown.
+ ///
+ [Description("Occurs after flyout has been shown.")]
+ public event EventHandler FlyoutShown;
+ ///
+ /// Raises FlyoutShown event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnFlyoutShown(EventArgs e)
+ {
+ EventHandler handler = FlyoutShown;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ ///
+ /// Provides opportunity to cancel showing of the flyout before any objects are created and allocated. This is preferred event to cancel flyout showing.
+ ///
+ [Description("Provides opportunity to cancel showing of the flyout before any objects are created and allocated. This is preferred event to cancel flyout showing.")]
+ public event CancelEventHandler QueryShowFlyout;
+ ///
+ /// Raises QueryShowFlyout event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnQueryShowFlyout(object sender, CancelEventArgs e)
+ {
+ CancelEventHandler handler = QueryShowFlyout;
+ if (handler != null)
+ handler(sender, e);
+ }
+
+ private bool _IsFlyoutFormShown = false;
+ private Control _OldContentParent = null;
+ private WeakReference _TargetItem = null;
+ private FlyoutForm _Flyout = null;
+
+ ///
+ /// Gets reference to active FlyoutForm or return null/nothing if flyout is not currently shown.
+ ///
+ [Browsable(false)]
+ public FlyoutForm FlyoutForm
+ {
+ get { return _Flyout; }
+ }
+
+ ///
+ /// Shows flyout at specified location and with specified size. Size can be empty (0,0) and flyout will be automatically sized based on the content.
+ ///
+ /// Screen bounds to display flyout at.
+ /// Side of the flyout which will have pointer triangle
+ /// Pointer position either x or y depending on which side pointer is displayed on.
+ /// Target item for the flyout.
+ public virtual void Show(Rectangle screenFlyoutBounds, ePointerSide pointerSide, int pointerOffset, object targetItem)
+ {
+ _CloseDelayed = false;
+ if (_IsFlyoutFormShown)
+ {
+ if (_Flyout != null) _Flyout.Activate();
+ return;
+ }
+
+ CancelEventArgs cancelShow = new CancelEventArgs();
+ OnQueryShowFlyout(targetItem??_TargetControl,cancelShow);
+ if (cancelShow.Cancel) return;
+
+ FlyoutForm form = new FlyoutForm();
+ if (!_BorderColor.IsEmpty)
+ form.BorderColor = _BorderColor;
+ if (!_BackColor.IsEmpty)
+ form.BackColor = _BackColor;
+ form.PointerSide = pointerSide;
+ form.ActivateOnShow = _ActivateOnShow;
+ form.TopMost = _TopMost;
+ form.DropShadow = _DropShadow;
+ form.PointerOffset = pointerOffset;
+ if (_Content != null)
+ {
+ if (screenFlyoutBounds.Size.IsEmpty)
+ {
+ screenFlyoutBounds.Size = GetFlyoutFormSize();
+ }
+
+ if (_Content.Parent != null)
+ {
+ _OldContentParent = _Content.Parent;
+ _OldContentParent.Controls.Remove(_Content);
+ }
+
+ form.Controls.Add(_Content);
+ _Content.Location = new Point(
+ (pointerSide == ePointerSide.Left) ? FlyoutForm.PointerSize.Height + 1 : 1,
+ (pointerSide == ePointerSide.Top) ? FlyoutForm.PointerSize.Height + 1 : 1);
+ _Content.Visible = true;
+ }
+
+ form.Size = Size.Empty;
+ form.Location = screenFlyoutBounds.Location;
+ form.FormClosed += FlyoutFormClosed;
+ form.FormClosing += FlyoutFormClosing;
+ FlyoutShowingEventArgs eargs = new FlyoutShowingEventArgs(form, targetItem);
+ OnFlyoutShowing(eargs);
+ if (eargs.Cancel)
+ {
+ FlyoutCloseCleanup(form);
+ form.Close();
+ form.Dispose();
+ return;
+ }
+ _IsFlyoutFormShown = true;
+ form.Visible = true;
+ form.Size = screenFlyoutBounds.Size;
+ _Flyout = form;
+ _TargetItem = new WeakReference(targetItem);
+ OnFlyoutShown(EventArgs.Empty);
+
+ if (!_MessageHandlerInstalled && (_CloseMode & eFlyoutCloseMode.ClickOutside) == eFlyoutCloseMode.ClickOutside)
+ {
+ MessageHandler.RegisterMessageClient(this);
+ _MessageHandlerInstalled = true;
+ }
+
+ if (_Parent != null && (_CloseMode & eFlyoutCloseMode.ParentFormDeactivate) == eFlyoutCloseMode.ParentFormDeactivate)
+ {
+ Form parentForm = null;
+ if (_Parent is Form)
+ parentForm = (Form)_Parent;
+ else
+ parentForm = _Parent.FindForm();
+ if (parentForm != null)
+ {
+ parentForm.Deactivate += ParentFormDeactivate;
+ _ParentForm = parentForm;
+ }
+ }
+ }
+
+ ///
+ /// Occurs before flyout is closed and allows you to cancel the closing.
+ ///
+ [Description("Occurs before flyout is closed and allows you to cancel the closing.")]
+ public event FormClosingEventHandler FlyoutClosing;
+ ///
+ /// Raises FlyoutClosing event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnFlyoutClosing(FormClosingEventArgs e)
+ {
+ FormClosingEventHandler handler = FlyoutClosing;
+ if (handler != null)
+ handler(this, e);
+ }
+ private void FlyoutFormClosing(object sender, FormClosingEventArgs e)
+ {
+ OnFlyoutClosing(e);
+ }
+
+ ///
+ /// Occurs after flyout is closed.
+ ///
+ [Description("Occurs after flyout is closed.")]
+ public event FormClosedEventHandler FlyoutClosed;
+ ///
+ /// Raises FlyoutClosed event.
+ ///
+ /// Provides event arguments.
+ protected virtual void OnFlyoutClosed(FormClosedEventArgs e)
+ {
+ FormClosedEventHandler handler = FlyoutClosed;
+ if (handler != null)
+ handler(this, e);
+ }
+
+ private Form _ParentForm = null;
+ void ParentFormDeactivate(object sender, EventArgs e)
+ {
+ if (_Flyout != null && _Flyout.Bounds.Contains(Control.MousePosition))
+ return;
+ Close();
+ }
+
+ ///
+ /// Closes the flyout form if it was open.
+ ///
+ public virtual void Close()
+ {
+ FlyoutForm flyout = _Flyout;
+ if (flyout != null)
+ {
+ flyout.Close();
+ flyout.Dispose();
+ }
+ }
+
+ private void FlyoutCloseCleanup(FlyoutForm form)
+ {
+ _TargetItem = null;
+ _IsFlyoutFormShown = false;
+ form.FormClosed -= FlyoutFormClosed;
+ form.Controls.Remove(_Content);
+ if (_OldContentParent != null)
+ {
+ _Content.Visible = false;
+ _OldContentParent.Controls.Add(_Content);
+ _OldContentParent = null;
+ }
+ _Flyout = null;
+ if (_ParentForm != null)
+ {
+ _ParentForm.Deactivate -= ParentFormDeactivate;
+ _ParentForm = null;
+ }
+ }
+ private void FlyoutFormClosed(object sender, FormClosedEventArgs e)
+ {
+ FlyoutForm form = (FlyoutForm)sender;
+ OnFlyoutClosed(e);
+ FlyoutCloseCleanup(form);
+ }
+
+ private bool _ActivateOnShow = false;
+ ///
+ /// Indicates whether flyout is active/focused when its shown, default value is false.
+ ///
+ [DefaultValue(false), Category("Behavior"), Description("Indicates whether flyout is active/focused when its shown, default value is false.")]
+ public bool ActivateOnShow
+ {
+ get { return _ActivateOnShow; }
+ set
+ {
+ if (value != _ActivateOnShow)
+ {
+ bool oldValue = _ActivateOnShow;
+ _ActivateOnShow = value;
+ OnActivateOnShowChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when ActivateOnShow property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnActivateOnShowChanged(bool oldValue, bool newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("ActivateOnShow"));
+
+ }
+
+ ///
+ /// Indicates whether flyout is made top-most window when shown
+ ///
+ [DefaultValue(false), Category("Behavior"), Description("Indicates whether flyout is made top-most window when shown.")]
+ public bool TopMost
+ {
+ get { return _TopMost; }
+ set
+ {
+ if (value != _TopMost)
+ {
+ bool oldValue = _TopMost;
+ _TopMost = value;
+ OnTopMostChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when TopMost property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnTopMostChanged(bool oldValue, bool newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("TopMost"));
+
+ }
+
+ private Color _BackColor = Color.Empty;
+ ///
+ /// Gets or sets the background flyout color. Default value is Color.Empty which indicates that current color scheme will be used.
+ ///
+ [Category("Columns"), Description("Indicates background flyout color. Default value is Color.Empty which indicates that current color scheme will be used.")]
+ public Color BackColor
+ {
+ get { return _BackColor; }
+ set { _BackColor = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBackColor()
+ {
+ return !_BackColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBackColor()
+ {
+ this.BackColor = Color.Empty;
+ }
+
+ private Color _BorderColor = Color.Empty;
+ ///
+ /// Gets or sets the flyout border color. Default value of Color.Empty indicates that color scheme will be used.
+ ///
+ [Category("Columns"), Description("Indicates flyout border color. Default value of Color.Empty indicates that color scheme will be used.")]
+ public Color BorderColor
+ {
+ get { return _BorderColor; }
+ set { _BorderColor = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBorderColor()
+ {
+ return !_BorderColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBorderColor()
+ {
+ this.BorderColor = Color.Empty;
+ }
+
+ ///
+ /// Indicates whether flyout displays drop shadow.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether flyout displays drop shadow")]
+ public bool DropShadow
+ {
+ get { return _DropShadow; }
+ set
+ {
+ if (value != _DropShadow)
+ {
+ bool oldValue = _DropShadow;
+ _DropShadow = value;
+ OnDropShadowChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when DropShadow property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnDropShadowChanged(bool oldValue, bool newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("DropShadow"));
+
+ }
+
+ private Control _Parent = null;
+ ///
+ /// Gets or sets the parent control for the Flyout. Parent is used to find the parent form so flyout can be closed when form is de-activated.
+ ///
+ [Browsable(false), DefaultValue(null)]
+ public Control Parent
+ {
+ get { return _Parent; }
+ set
+ {
+ if (value != _Parent)
+ {
+ Control oldValue = _Parent;
+ _Parent = value;
+ OnParentChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when Parent property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnParentChanged(Control oldValue, Control newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("Parent"));
+ }
+ #endregion
+
+ #region IMessageHandlerClient
+ private bool _MessageHandlerInstalled = false;
+ bool IMessageHandlerClient.OnSysKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+
+ bool IMessageHandlerClient.OnSysKeyUp(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+
+ bool IMessageHandlerClient.OnKeyDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+
+ bool IMessageHandlerClient.OnMouseDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ if ((_CloseMode & eFlyoutCloseMode.ClickOutside) == eFlyoutCloseMode.ClickOutside)
+ {
+ FlyoutForm form = _Flyout;
+ if (form != null && form.Visible)
+ {
+ if (!form.Bounds.Contains(Control.MousePosition))
+ {
+ // Ignore clicks on ComboBox popup
+ string s = NativeFunctions.GetClassName(hWnd);
+ s = s.ToLower();
+ if (s.IndexOf("combolbox") < 0)
+ Close();
+ }
+ }
+ }
+ return false;
+ }
+
+ bool IMessageHandlerClient.OnMouseMove(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+
+ bool IMessageHandlerClient.OnMouseWheel(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
+ {
+ return false;
+ }
+
+ bool IMessageHandlerClient.IsModal
+ {
+ get { return false; }
+ }
+ #endregion
+ }
+ ///
+ /// Defines delegate for the FlyoutShowing event.
+ ///
+ ///
+ ///
+ public delegate void FlyoutShowingEventHandler(object sender, FlyoutShowingEventArgs e);
+ public class FlyoutShowingEventArgs : EventArgs
+ {
+ ///
+ /// Gets the reference to the flyout form.
+ ///
+ public FlyoutForm Flyout;
+ ///
+ /// Gets the reference to the flyout target usually TargetControl.
+ ///
+ public object Target;
+ ///
+ /// Allows you to cancel showing of the flyout by setting this value to true.
+ ///
+ public bool Cancel;
+ ///
+ /// Initializes a new instance of the FlyoutShowingEventArgs class.
+ ///
+ ///
+ ///
+ public FlyoutShowingEventArgs(FlyoutForm flyout, object target)
+ {
+ Flyout = flyout;
+ Target = target;
+ }
+ }
+
+ ///
+ /// Defines the modes for Flyout display.
+ ///
+ public enum eFlyoutDisplayMode
+ {
+ ///
+ /// Flyout is displayed manually using flyout.Show() method.
+ ///
+ Manual,
+ ///
+ /// Flyout is displayed when mouse is over TargetControl.
+ ///
+ MouseOver,
+ ///
+ /// Flyout is displayed when mouse is hovering over TargetControl.
+ ///
+ MouseHover,
+ ///
+ /// Flyout is displayed when left mouse button is clicked on TargetControl.
+ ///
+ MouseClick
+ }
+
+ ///
+ /// Defines Flyout closing condition.
+ ///
+ [Flags()]
+ public enum eFlyoutCloseMode
+ {
+ ///
+ /// Flyout is closed manually using flyout.Close() method.
+ ///
+ Manual,
+ ///
+ /// Flyout is closed when user clicks outside of flyout bounds.
+ ///
+ ClickOutside,
+ ///
+ /// Flyout is closed when TargetControl is hidden.
+ ///
+ TargetControlHidden,
+ ///
+ /// Flyout is closed when TargetControl loses focus.
+ ///
+ TargetControlLostFocus,
+ ///
+ /// Flyout is closed when parent forms deactivates.
+ ///
+ ParentFormDeactivate
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutColorTable.cs b/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutColorTable.cs
new file mode 100644
index 00000000..b51be9a0
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutColorTable.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Text;
+
+namespace DevComponents.DotNetBar.Rendering
+{
+ ///
+ /// Defines colors for the Flyout control.
+ ///
+ public class FlyoutColorTable
+ {
+ ///
+ /// Specifies Flyout background color.
+ ///
+ public Color BackColor = Color.White;
+ ///
+ /// Specifies Flyout border color.
+ ///
+ public Color BorderColor = ColorScheme.GetColor(0x2B579A);
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutForm.Designer.cs b/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutForm.Designer.cs
new file mode 100644
index 00000000..75850a60
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutForm.Designer.cs
@@ -0,0 +1,53 @@
+namespace DevComponents.DotNetBar.Controls
+{
+ partial class FlyoutForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.SuspendLayout();
+ //
+ // FlyoutForm
+ //
+
+ this.ControlBox = false;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "FlyoutForm";
+ this.ShowInTaskbar = false;
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
+ this.Load += new System.EventHandler(this.Form1_Load);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ }
+}
+
diff --git a/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutForm.cs b/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutForm.cs
new file mode 100644
index 00000000..d12d80ec
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutForm.cs
@@ -0,0 +1,323 @@
+using DevComponents.DotNetBar.Rendering;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ public partial class FlyoutForm : Form
+ {
+ public FlyoutForm()
+ {
+ this.SetStyle(ControlStyles.UserPaint, true);
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ this.SetStyle(ControlStyles.ResizeRedraw, true);
+ this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
+
+ InitializeComponent();
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.BackColor = Color.White;
+
+ //_PointerSide = ePointerSide.Top;
+ _PointerOffset = this.Width-50;
+ }
+
+ private int _PointerOffset;
+ private const int CS_DROPSHADOW = 0x00020000;
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ // add the drop shadow flag for automatically drawing
+ // a drop shadow around the form
+ CreateParams cp = base.CreateParams;
+ if(_DropShadow)
+ cp.ClassStyle |= CS_DROPSHADOW;
+ return cp;
+ }
+ }
+ protected override bool ShowWithoutActivation
+ {
+ get
+ {
+ return !_ActivateOnShow;
+ }
+ }
+
+ private bool _DropShadow = true;
+ ///
+ /// Indicates whether flyout displays a drop shadow.
+ ///
+ [DefaultValue(true)]
+ public bool DropShadow
+ {
+ get { return _DropShadow; }
+ set
+ {
+ _DropShadow = value;
+ }
+ }
+
+
+ private bool _ActivateOnShow = false;
+ ///
+ /// Gets or sets whether form is made active/focused when shown.
+ ///
+ [DefaultValue(false)]
+ public bool ActivateOnShow
+ {
+ get { return _ActivateOnShow; }
+ set
+ {
+ _ActivateOnShow = value;
+ }
+ }
+
+ private GraphicsPath GetFormPath(Rectangle r)
+ {
+ return GetFormPath(r, false);
+ }
+
+ private static readonly Size _PointerSize = new Size(24, 12);
+ internal static Size PointerSize
+ {
+ get
+ {
+ return _PointerSize;
+ }
+ }
+ private GraphicsPath GetFormPath(Rectangle r, bool isBorder)
+ {
+ Size calloutSize = _PointerSize; // new Size(24, 12);
+ GraphicsPath path = new GraphicsPath();
+
+ if (_PointerSide == ePointerSide.Top)
+ {
+ int cX = Math.Min(Math.Max(3, _PointerOffset), r.Width - calloutSize.Width + 3); //r.Right - (calloutSize.Width + 10);
+ path.AddLine(r.X, r.Y + calloutSize.Height, cX + (isBorder ? 1 : 0), r.Y + calloutSize.Height);
+ path.AddLine(cX, r.Y + calloutSize.Height, cX + calloutSize.Width / 2, r.Y);
+ path.AddLine(cX + calloutSize.Width / 2, r.Y, cX + calloutSize.Width, r.Y + calloutSize.Height);
+ path.AddLine(cX + calloutSize.Width, r.Y + calloutSize.Height, r.Right, r.Y + calloutSize.Height);
+ path.AddLine(r.Right, r.Y + calloutSize.Height, r.Right, r.Bottom);
+ path.AddLine(r.Right, r.Bottom, r.X, r.Bottom);
+ path.AddLine(r.X, r.Bottom, r.X, r.Y + calloutSize.Height);
+ path.CloseAllFigures();
+ }
+ else if (_PointerSide == ePointerSide.Bottom)
+ {
+ int cX = Math.Min(Math.Max(3, _PointerOffset), r.Width - calloutSize.Width + 3); //r.Right - (calloutSize.Width + 10);
+ path.AddLine(r.X, r.Bottom - calloutSize.Height, cX + (isBorder ? 1 : 0), r.Bottom - calloutSize.Height);
+ path.AddLine(cX, r.Bottom - calloutSize.Height, cX + calloutSize.Width / 2, r.Bottom);
+ path.AddLine(cX + calloutSize.Width / 2, r.Bottom, cX + calloutSize.Width, r.Bottom - calloutSize.Height);
+ path.AddLine(cX + calloutSize.Width, r.Bottom - calloutSize.Height, r.Right, r.Bottom - calloutSize.Height);
+ path.AddLine(r.Right, r.Bottom - calloutSize.Height, r.Right, r.Y);
+ path.AddLine(r.Right, r.Y, r.X, r.Y);
+ path.AddLine(r.X, r.Y, r.X, r.Bottom - calloutSize.Height);
+ path.CloseAllFigures();
+ }
+ else if (_PointerSide == ePointerSide.Left)
+ {
+ int cY = Math.Min(Math.Max(3, _PointerOffset), r.Height - calloutSize.Width + 3); //r.Bottom - (calloutSize.Width + 10);
+ path.AddLine(r.X + calloutSize.Height, r.Bottom, r.X + calloutSize.Height, cY + (isBorder ? 1 : 0));
+ path.AddLine(r.X + calloutSize.Height, cY + (isBorder ? 1 : 0), r.X, cY + calloutSize.Width / 2);
+ path.AddLine(r.X, cY + calloutSize.Width / 2, r.X + calloutSize.Height, cY + calloutSize.Width);
+ path.AddLine(r.X + calloutSize.Height, cY + calloutSize.Width, r.X + calloutSize.Height, r.Y);
+ path.AddLine(r.X + calloutSize.Height, r.Y, r.Right, r.Y);
+ path.AddLine(r.Right, r.Y, r.Right, r.Bottom);
+ path.AddLine(r.Right, r.Bottom, r.X + calloutSize.Height, r.Bottom);
+ path.CloseAllFigures();
+ }
+ else if (_PointerSide == ePointerSide.Right)
+ {
+ int cY = Math.Min(Math.Max(3, _PointerOffset), r.Width - calloutSize.Height + 3); //r.Bottom - (calloutSize.Width + 10);
+ path.AddLine(r.Right - calloutSize.Height, r.Y, r.Right - calloutSize.Height, cY + (isBorder ? 1 : 0));
+ path.AddLine(r.Right - calloutSize.Height, cY + (isBorder ? 1 : 0), r.Right - (isBorder ? 1 : 0), cY + calloutSize.Width / 2);
+ path.AddLine(r.Right - (isBorder ? 1 : 0), cY + calloutSize.Width / 2, r.Right - calloutSize.Height, cY + calloutSize.Width);
+ path.AddLine(r.Right - calloutSize.Height, cY + calloutSize.Width, r.Right - calloutSize.Height, r.Bottom);
+ path.AddLine(r.Right - calloutSize.Height, r.Bottom, r.X, r.Bottom);
+ path.AddLine(r.X, r.Bottom, r.X, r.Y);
+ path.AddLine(r.X, r.Y, r.Right - calloutSize.Height, r.Y);
+ path.CloseAllFigures();
+ }
+
+ return path;
+ }
+ private Region GetFormRegion()
+ {
+ return new Region(GetFormPath(this.ClientRectangle));
+ }
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ Rectangle r = this.ClientRectangle;
+ r.Inflate(-1, -1);
+
+ FlyoutColorTable table = GetColorTable();
+
+ Color backColor = this.BackColor;
+ if (backColor.IsEmpty)
+ backColor = table.BackColor;
+ Color borderColor = _BorderColor;
+ if(borderColor == Color.Empty)
+ {
+ borderColor = table.BorderColor;
+ }
+
+ using (GraphicsPath path = GetFormPath(r, true))
+ {
+ using(SolidBrush borderBrush=new SolidBrush(borderColor))
+ e.Graphics.FillRectangle(borderBrush, this.ClientRectangle);
+ e.Graphics.SetClip(path);
+ using (SolidBrush brush = new SolidBrush(backColor))
+ e.Graphics.FillRectangle(brush, this.ClientRectangle);
+ e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
+ //e.Graphics.DrawPath(Pens.Red, path);
+ }
+ //base.OnPaint(e);
+ }
+ private FlyoutColorTable GetColorTable()
+ {
+ return ((Office2007Renderer)GlobalManager.Renderer).ColorTable.Flyout;
+ }
+ private void Form1_Load(object sender, EventArgs e)
+ {
+ //UpdateFormRegion();
+ }
+
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ UpdateFormRegion();
+ base.OnHandleCreated(e);
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ UpdateFormRegion();
+ base.OnResize(e);
+ }
+
+ private void UpdateFormRegion()
+ {
+ this.Region = GetFormRegion();
+ }
+
+ ///
+ /// Gets or sets the pointer offset from the top-left corner
+ ///
+ public int PointerOffset
+ {
+ get { return _PointerOffset; }
+ set
+ {
+ if (value !=_PointerOffset)
+ {
+ int oldValue = _PointerOffset;
+ _PointerOffset = value;
+ OnPointerOffsetChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when PointerOffset property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnPointerOffsetChanged(int oldValue, int newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("PointerOffset"));
+ if (this.IsHandleCreated)
+ UpdateFormRegion();
+ }
+
+ private ePointerSide _PointerSide = ePointerSide.Bottom;
+ ///
+ /// Gets or sets the side pointer triangle is displayed on.
+ ///
+ public ePointerSide PointerSide
+ {
+ get { return _PointerSide; }
+ set
+ {
+ if (value != _PointerSide)
+ {
+ ePointerSide oldValue = _PointerSide;
+ _PointerSide = value;
+ OnPointerSideChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when PointerSide property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnPointerSideChanged(ePointerSide oldValue, ePointerSide newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("PointerSide"));
+ if (this.IsHandleCreated)
+ UpdateFormRegion();
+ }
+
+ private Color _BorderColor = Color.Empty;
+ ///
+ /// Gets or sets the flyout border color. Default value of Color.Empty indicates that color scheme will be used.
+ ///
+ [Category("Columns"), Description("Indicates flyout border color. Default value of Color.Empty indicates that color scheme will be used.")]
+ public Color BorderColor
+ {
+ get { return _BorderColor; }
+ set { _BorderColor = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeBorderColor()
+ {
+ return !_BorderColor.IsEmpty;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetBorderColor()
+ {
+ this.BorderColor = Color.Empty;
+ }
+
+ private bool _IsActive = false;
+ protected override void OnActivated(EventArgs e)
+ {
+ _IsActive = true;
+ base.OnActivated(e);
+ }
+
+ protected override void OnDeactivate(EventArgs e)
+ {
+ _IsActive = false;
+ base.OnDeactivate(e);
+ }
+ [Browsable(false)]
+ public bool IsActive
+ {
+ get
+ {
+ return _IsActive;
+ }
+ }
+ }
+ ///
+ /// Defines the side of triangle pointer displayed on flyout popup.
+ ///
+ public enum ePointerSide
+ {
+ Top,
+ Bottom,
+ Left,
+ Right
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutForm.resx b/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutForm.resx
new file mode 100644
index 00000000..1af7de15
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/Flyout/FlyoutForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PROMS/DotNetBar Source Code/Controls/GroupPanel.cs b/PROMS/DotNetBar Source Code/Controls/GroupPanel.cs
new file mode 100644
index 00000000..d4ee18ab
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/GroupPanel.cs
@@ -0,0 +1,837 @@
+using System;
+using System.Text;
+using System.Windows.Forms;
+using System.Drawing;
+using System.ComponentModel;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+using System.ComponentModel.Design;
+using System.Reflection;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ [ToolboxBitmap(typeof(GroupPanel), "Controls.GroupPanel.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.GroupPanelDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+ public class GroupPanel : PanelControl, INonClientControl
+ {
+ #region Private Variables
+ private NonClientPaintHandler m_NCPainter = null;
+ private Image m_TitleImage = null;
+ private eTitleImagePosition m_TitleImagePosition = eTitleImagePosition.Left;
+ private bool m_DrawTitleBox = true;
+ private bool m_IsShadowEnabled = false;
+ #endregion
+
+ #region Constructor
+ public GroupPanel()
+ {
+ m_NCPainter = new NonClientPaintHandler(this, eScrollBarSkin.Optimized);
+ m_NCPainter.BeforeBorderPaint += new CustomNCPaintEventHandler(NCBeforeBorderPaint);
+ m_NCPainter.AfterBorderPaint += new CustomNCPaintEventHandler(NCAfterBorderPaint);
+
+ this.SetStyle(ControlStyles.StandardDoubleClick, true);
+ }
+ #endregion
+
+ #region Internal Implementation
+ private ePanelColorTable _ColorTable = ePanelColorTable.Default;
+ ///
+ /// Gets or sets the panel color scheme.
+ ///
+ [DefaultValue(ePanelColorTable.Default), Category("Appearance"), Description("Indicates panel color scheme.")]
+ public ePanelColorTable ColorTable
+ {
+ get { return _ColorTable; }
+ set
+ {
+ _ColorTable = value;
+ SetColorTable(value);
+ }
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ InvalidateNonClient();
+ base.OnResize(e);
+ }
+ ///
+ /// Gets or sets the image that appears in title with text.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Visual"), Description("Indicates image that appears in title with text.")]
+ public Image TitleImage
+ {
+ get { return m_TitleImage; }
+ set
+ {
+ m_TitleImage = value;
+ RefreshTextClientRectangle();
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// Gets or sets the position of the title image. Default value is left.
+ ///
+ [Browsable(true), DefaultValue(eTitleImagePosition.Left), Category("Visual"), Description("Indicates position of the title image.")]
+ public eTitleImagePosition TitleImagePosition
+ {
+ get { return m_TitleImagePosition; }
+ set
+ {
+ m_TitleImagePosition = value;
+ RefreshTextClientRectangle();
+ this.Invalidate();
+ }
+ }
+
+ [Browsable(true), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public override Color BackColor
+ {
+ get { return base.BackColor; }
+ set { base.BackColor = value; }
+ }
+
+ ///
+ /// Gets or sets the scrollbar skining type when control is using Office 2007 style.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public eScrollBarSkin ScrollbarSkin
+ {
+ get { return m_NCPainter.SkinScrollbars; }
+ set { m_NCPainter.SkinScrollbars = value; }
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (m_NCPainter != null)
+ {
+ m_NCPainter.Dispose();
+ //m_NCPainter = null;
+ }
+ if (BarUtilities.DisposeItemImages && !this.DesignMode)
+ {
+ BarUtilities.DisposeImage(ref m_TitleImage);
+ }
+ base.Dispose(disposing);
+ }
+ ///
+ /// Specifies whether item is drawn using Themes when running on OS that supports themes like Windows XP.
+ ///
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DefaultValue(false), Category("Appearance"), Description("Specifies whether item is drawn using Themes when running on OS that supports themes like Windows XP.")]
+ public override bool ThemeAware
+ {
+ get
+ {
+ return base.ThemeAware;
+ }
+ set
+ {
+ base.ThemeAware = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether box around the title of the group is drawn. Default value is true.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("")]
+ public bool DrawTitleBox
+ {
+ get { return m_DrawTitleBox; }
+ set
+ {
+ if (m_DrawTitleBox != value)
+ {
+ m_DrawTitleBox = value;
+ this.InvalidateNonClient();
+ }
+ }
+ }
+
+ ///
+ /// Invalidates non-client area of the control.
+ ///
+ public void InvalidateNonClient()
+ {
+ if (!BarFunctions.IsHandleValid(this)) return;
+ const int RDW_INVALIDATE = 0x0001;
+ const int RDW_FRAME = 0x0400;
+ NativeFunctions.RECT r = new NativeFunctions.RECT(0, 0, this.Width, this.Height);
+ NativeFunctions.RedrawWindow(this.Handle, ref r, IntPtr.Zero, RDW_INVALIDATE | RDW_FRAME);
+ }
+
+ ///
+ /// Paints insides of the control.
+ ///
+ /// Paint event arguments.
+ protected override void PaintInnerContent(PaintEventArgs e, ElementStyle style, bool paintText)
+ {
+ Graphics g = e.Graphics;
+ if (this.TextMarkupElement == null)
+ RefreshTextClientRectangle();
+ Rectangle r = this.DisplayRectangle;
+#if FRAMEWORK20
+ r.X -= this.Padding.Left;
+ r.Y -= this.Padding.Top;
+ r.Width += this.Padding.Horizontal;
+ r.Height += this.Padding.Vertical;
+#else
+ r.X -= this.DockPadding.Left;
+ r.Y -= this.DockPadding.Top;
+ r.Width += this.DockPadding.Left + this.DockPadding.Right;
+ r.Height += this.DockPadding.Top + this.DockPadding.Bottom;
+#endif
+ r.Inflate(2, 2);
+ ElementStyleDisplayInfo info = new ElementStyleDisplayInfo(style, g, r);
+ info.RightToLeft = (this.RightToLeft == RightToLeft.Yes);
+ ElementStyleDisplay.PaintBackground(info, false);
+ if (style.BackgroundImage != null) ElementStyleDisplay.PaintBackgroundImage(info);
+ if (!m_IsShadowEnabled) return;
+ ShadowPaintInfo pi = new ShadowPaintInfo();
+ pi.Graphics = g;
+ pi.Size = 6;
+ foreach (Control c in this.Controls)
+ {
+ if (!c.Visible || c.BackColor == Color.Transparent && !(c is GroupPanel)) continue;
+ if (c is GroupPanel)
+ {
+ GroupPanel p = c as GroupPanel;
+ pi.Rectangle = new Rectangle(c.Bounds.X, c.Bounds.Y + p.GetInternalClientRectangle().Y / 2, c.Bounds.Width, c.Bounds.Height - p.GetInternalClientRectangle().Y / 2);
+ }
+ else
+ pi.Rectangle = c.Bounds;
+ ShadowPainter.Paint2(pi);
+ }
+ }
+
+ private void NCAfterBorderPaint(object sender, CustomNCPaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+
+ TextRenderingHint th = g.TextRenderingHint;
+ SmoothingMode sm = g.SmoothingMode;
+ if (this.AntiAlias)
+ {
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+ }
+ g.ResetClip();
+ ElementStyle style = this.Style;
+
+ if (!this.Enabled)
+ {
+ style = style.Copy();
+ style.TextColor = GetColorScheme().ItemDisabledText;
+ }
+
+ if (m_DrawTitleBox && !m_TitleArea.IsEmpty)
+ {
+ DisplayHelp.FillRoundedRectangle(g, m_TitleArea, 2, style.BackColor, style.BackColor2, -90);
+ DisplayHelp.DrawRoundedRectangle(g, this.Style.BorderColor, m_TitleArea, 2);
+ }
+
+ Rectangle rText = new Rectangle(m_NCPainter.ClientRectangle.X + 4, 1, this.ClientRectangle.Width - 8, m_NCPainter.ClientRectangle.Y - 1);
+ if (m_TitleImage != null)
+ {
+ Size textSize = GetAutoSize(rText.Width);
+ if (m_TitleImagePosition == eTitleImagePosition.Left && this.RightToLeft == RightToLeft.No || m_TitleImagePosition == eTitleImagePosition.Right && this.RightToLeft == RightToLeft.Yes)
+ {
+ g.DrawImage(m_TitleImage, rText.X - 1, rText.Y, m_TitleImage.Width, m_TitleImage.Height);
+ rText.X += m_TitleImage.Width;
+ rText.Width -= m_TitleImage.Width;
+ }
+ else if (m_TitleImagePosition == eTitleImagePosition.Right && this.RightToLeft == RightToLeft.No || m_TitleImagePosition == eTitleImagePosition.Left && this.RightToLeft == RightToLeft.Yes)
+ {
+ g.DrawImage(m_TitleImage, rText.Right - m_TitleImage.Width, rText.Y, m_TitleImage.Width, m_TitleImage.Height);
+ rText.Width -= m_TitleImage.Width;
+ }
+ else if (m_TitleImagePosition == eTitleImagePosition.Center)
+ {
+ g.DrawImage(m_TitleImage, rText.X + (rText.Width - m_TitleImage.Width) / 2, rText.Y, m_TitleImage.Width, m_TitleImage.Height);
+ }
+ rText.Y = rText.Bottom - textSize.Height - 2;
+ }
+
+ // Paint text
+ if (this.TextMarkupElement == null)
+ {
+ ElementStyleDisplayInfo info = new ElementStyleDisplayInfo(style, g, rText);
+ info.RightToLeft = (this.RightToLeft == RightToLeft.Yes);
+ ElementStyleDisplay.PaintText(info, this.Text, this.Font);
+ }
+ else
+ {
+ TextRenderingHint tr = g.TextRenderingHint;
+ if (this.AntiAlias)
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, this.Font, style.TextColor, (this.RightToLeft == RightToLeft.Yes), Rectangle.Empty, true);
+ Rectangle r = this.TextMarkupElement.Bounds;
+ if (style.TextAlignment == eStyleTextAlignment.Center)
+ this.TextMarkupElement.Bounds = new Rectangle(this.TextMarkupElement.Bounds.X + (rText.Width - this.TextMarkupElement.Bounds.Width) / 2, this.TextMarkupElement.Bounds.Y,
+ this.TextMarkupElement.Bounds.Width, this.TextMarkupElement.Bounds.Height);
+ else if(style.TextAlignment == eStyleTextAlignment.Far && this.RightToLeft == RightToLeft.No || this.RightToLeft == RightToLeft.Yes && style.TextAlignment== eStyleTextAlignment.Near)
+ this.TextMarkupElement.Bounds = new Rectangle(rText.Right - this.TextMarkupElement.Bounds.Width, this.TextMarkupElement.Bounds.Y,
+ this.TextMarkupElement.Bounds.Width, this.TextMarkupElement.Bounds.Height);
+ this.TextMarkupElement.Render(d);
+ g.TextRenderingHint = tr;
+ this.TextMarkupElement.Bounds = r;
+ }
+
+ g.TextRenderingHint = th;
+ g.SmoothingMode = sm;
+ }
+ private Rectangle m_TitleArea = Rectangle.Empty;
+ private void NCBeforeBorderPaint(object sender, CustomNCPaintEventArgs e)
+ {
+ m_TitleArea = Rectangle.Empty;
+ // Exclude text area from border rendering
+ if (this.Text != null && this.Text.Length > 0)
+ {
+ Size s = GetAutoSize(this.ClientRectangle.Width - 8);
+ Rectangle r = new Rectangle(m_NCPainter.ClientRectangle.X + 3, 0, s.Width, m_NCPainter.ClientRectangle.Y);
+ Size availSize = new Size(m_NCPainter.ClientRectangle.Width - 8, m_NCPainter.ClientRectangle.Y);
+
+ if (m_TitleImage != null && (m_TitleImagePosition == eTitleImagePosition.Left && this.RightToLeft == RightToLeft.Yes ||
+ m_TitleImagePosition == eTitleImagePosition.Right && this.RightToLeft == RightToLeft.No))
+ {
+ //r.X -= m_TitleImage.Width;
+ availSize.Width -= m_TitleImage.Width;
+ }
+ else if (m_TitleImage != null && (m_TitleImagePosition == eTitleImagePosition.Right && this.RightToLeft == RightToLeft.Yes ||
+ m_TitleImagePosition == eTitleImagePosition.Left && this.RightToLeft == RightToLeft.No))
+ {
+ r.X += m_TitleImage.Width;
+ availSize.Width -= m_TitleImage.Width;
+ }
+ //if (this.TextMarkupElement == null)
+ {
+ if (this.Style.TextAlignment == eStyleTextAlignment.Center)
+ {
+ //r.X = m_NCPainter.ClientRectangle.X;
+ r.X += (availSize.Width - r.Width) / 2;
+ }
+ else if (this.Style.TextAlignment == eStyleTextAlignment.Far || this.RightToLeft == RightToLeft.Yes && this.Style.TextAlignment == eStyleTextAlignment.Near)
+ {
+ r.X = r.X + (availSize.Width - r.Width);
+ }
+ }
+
+ if (!r.IsEmpty)
+ {
+ r.Inflate(3, 0);
+ r.Width += 3;
+ }
+
+ e.Graphics.SetClip(r, System.Drawing.Drawing2D.CombineMode.Exclude);
+ m_TitleArea = r;
+ }
+
+ if (m_TitleImage != null)
+ {
+ Rectangle r = new Rectangle(m_NCPainter.ClientRectangle.X + 3, 0, m_TitleImage.Width, m_TitleImage.Height);
+ if (m_TitleImagePosition == eTitleImagePosition.Left && this.RightToLeft == RightToLeft.Yes ||
+ m_TitleImagePosition == eTitleImagePosition.Right && this.RightToLeft == RightToLeft.No)
+ {
+ r.X = m_NCPainter.ClientRectangle.Right - r.Width - 4;
+ }
+ else if (m_TitleImagePosition == eTitleImagePosition.Center)
+ {
+ r.X = m_NCPainter.ClientRectangle.X;
+ r.X += (m_NCPainter.ClientRectangle.Width - r.Width) / 2;
+ }
+
+ e.Graphics.SetClip(r, System.Drawing.Drawing2D.CombineMode.Exclude);
+ if (m_TitleArea.IsEmpty)
+ m_TitleArea = r;
+ else
+ m_TitleArea = Rectangle.Union(r, m_TitleArea);
+ }
+ }
+
+ ///
+ /// Returns the size of the panel calculated based on the text assigned.
+ ///
+ /// Calculated size of the panel or Size.Empty if panel size cannot be calculated.
+ private Size GetAutoSize(int preferedWidth)
+ {
+ Size size = Size.Empty;
+ if (!this.IsHandleCreated) return size;
+
+ if (TextMarkupElement != null)
+ {
+ if (preferedWidth == 0)
+ {
+ size = TextMarkupElement.Bounds.Size;
+ }
+ else
+ {
+ size = GetMarkupSize(preferedWidth);
+ }
+ size.Width += 4;
+ //size.Height += 1;
+ }
+ else if (this.Text.Length > 0)
+ {
+ Font font = this.Font;
+ if (this.Style.Font != null) font = this.Style.Font;
+ eTextFormat tf = eTextFormat.Default | eTextFormat.SingleLine | eTextFormat.NoPrefix;
+ using (Graphics g = BarFunctions.CreateGraphics(this))
+ {
+ if (preferedWidth <= 0)
+ size = TextDrawing.MeasureString(g, this.Text, font, 0, tf);
+ else
+ size = TextDrawing.MeasureString(g, this.Text, font, preferedWidth, tf);
+ }
+ size.Width += 2;
+ size.Height += 2;
+ }
+
+ if (size.IsEmpty) return size;
+
+ size.Width += this.Style.MarginLeft + this.Style.MarginRight;
+ size.Height += this.Style.MarginTop + this.Style.MarginBottom;
+
+ return size;
+ }
+
+ private Size GetMarkupSize(int proposedWidth)
+ {
+ Size size = Size.Empty;
+ if (TextMarkupElement != null)
+ {
+ Rectangle r = new Rectangle(0, 0, proposedWidth, 500);
+ r.Inflate(-2, -2);
+ Graphics g = this.CreateGraphics();
+ TextMarkup.BodyElement markup = TextMarkup.MarkupParser.Parse(this.Text);
+ try
+ {
+ if (AntiAlias)
+ {
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
+ }
+ TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, this.Font, SystemColors.Control, (this.RightToLeft == RightToLeft.Yes));
+ markup.Measure(r.Size, d);
+ size = markup.Bounds.Size;
+ }
+ finally
+ {
+ g.Dispose();
+ }
+ }
+
+ return size;
+ }
+
+ protected override void RefreshTextClientRectangle()
+ {
+ if (m_NCPainter != null)
+ {
+ Rectangle r = new Rectangle(m_NCPainter.ClientRectangle.X, 0, m_NCPainter.ClientRectangle.Width, this.Height / 2);
+ r.Inflate(-2, 0);
+ if (m_TitleImage != null)
+ {
+ if (m_TitleImagePosition == eTitleImagePosition.Left && this.RightToLeft == RightToLeft.No ||
+ m_TitleImagePosition == eTitleImagePosition.Right && this.RightToLeft == RightToLeft.Yes)
+ {
+ r.X += m_TitleImage.Width;
+ r.Width -= m_TitleImage.Width;
+ }
+ else if (m_TitleImagePosition == eTitleImagePosition.Left && this.RightToLeft == RightToLeft.Yes ||
+ m_TitleImagePosition == eTitleImagePosition.Right && this.RightToLeft == RightToLeft.No)
+ {
+ r.Width -= m_TitleImage.Width;
+ }
+ Size s = GetMarkupSize(r.Width);
+ r.Y = Math.Max(0, m_NCPainter.ClientRectangle.Y - s.Height - 4);
+ }
+ this.ClientTextRectangle = r;
+ }
+ else
+ this.ClientTextRectangle = this.ClientRectangle;
+
+ ResizeMarkup();
+ }
+
+ ///
+ /// Gets or sets whether text rectangle painted on panel is considering docked controls inside the panel.
+ ///
+ [Browsable(false), DefaultValue(true), Category("Appearance"), Description("Indicates whether text rectangle painted on panel is considering docked controls inside the panel.")]
+ public override bool TextDockConstrained
+ {
+ get { return base.TextDockConstrained; }
+ set { base.TextDockConstrained = value; }
+
+ }
+
+ ///
+ /// Gets or sets whether panel automatically provides shadows for child controls. Default value is false.
+ ///
+ [Browsable(true), DefaultValue(false), Category("Appearance"), Description("Indicates whether panel automatically provides shadows for child controls.")]
+ public bool IsShadowEnabled
+ {
+ get { return m_IsShadowEnabled; }
+ set
+ {
+ if (m_IsShadowEnabled != value)
+ {
+ m_IsShadowEnabled = value;
+ this.Invalidate();
+ }
+ }
+ }
+ ///
+ /// Applies color scheme to the panel.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetColorTable(ePanelColorTable colorScheme)
+ {
+ GroupPanel p = this;
+ DevComponents.DotNetBar.Rendering.ColorFactory factory = DevComponents.DotNetBar.Rendering.ColorFactory.Empty;
+ p.CanvasColor = SystemColors.Control;
+ p.ResetStyle();
+ p.ColorSchemeStyle = eDotNetBarStyle.Office2007;
+
+ if (colorScheme == ePanelColorTable.Default)
+ SetDefaultPanelStyle();
+ else if (colorScheme == ePanelColorTable.Green)
+ {
+ p.Style.BackColor2 = factory.GetColor(0x9CBF8B);
+ p.Style.BackColorGradientAngle = 90;
+ p.Style.BackColor = factory.GetColor(0xC3D9B9);
+ p.Style.Border = DevComponents.DotNetBar.eStyleBorderType.Solid;
+ p.Style.BorderWidth = 1;
+ p.Style.BorderColor = factory.GetColor(0x72A45A);
+ p.Style.CornerDiameter = 4;
+ p.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
+ p.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
+ p.Style.TextColor = factory.GetColor(0x3C4A1F);
+ p.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
+ }
+ else if (colorScheme == ePanelColorTable.Orange)
+ {
+ p.Style.BackColor = factory.GetColor(0xFAC08F);
+ p.Style.BackColor2 = factory.GetColor(0xF79646);
+ p.Style.BorderColor = factory.GetColor(0x974806);
+ p.Style.TextColor = factory.GetColor(0x7F3D06);
+ p.Style.BackColorGradientAngle = 90;
+ p.Style.Border = DevComponents.DotNetBar.eStyleBorderType.Solid;
+ p.Style.BorderWidth = 1;
+ p.Style.CornerDiameter = 4;
+ p.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
+ p.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
+ p.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
+ }
+ else if (colorScheme == ePanelColorTable.Red)
+ {
+ p.Style.BackColor = factory.GetColor(0xE5BFBF);
+ p.Style.BackColor2 = factory.GetColor(0xD39696);
+ p.Style.BorderColor = factory.GetColor(0x953734);
+ p.Style.TextColor = factory.GetColor(0x632423);
+ p.Style.BackColorGradientAngle = 90;
+ p.Style.Border = DevComponents.DotNetBar.eStyleBorderType.Solid;
+ p.Style.BorderWidth = 1;
+ p.Style.CornerDiameter = 4;
+ p.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
+ p.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
+ p.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
+ }
+ else if (colorScheme == ePanelColorTable.Yellow)
+ {
+ p.Style.BackColor = factory.GetColor(0xFFF3B2);
+ p.Style.BackColor2 = factory.GetColor(0xFAD945);
+ p.Style.BorderColor = factory.GetColor(0xEE9311);
+ p.Style.TextColor = factory.GetColor(0x3F3F00);
+ p.Style.BackColorGradientAngle = 90;
+ p.Style.Border = DevComponents.DotNetBar.eStyleBorderType.Solid;
+ p.Style.BorderWidth = 1;
+ p.Style.CornerDiameter = 4;
+ p.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
+ p.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
+ p.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
+ }
+ else if (colorScheme == ePanelColorTable.Magenta)
+ {
+ p.Style.BackColor = factory.GetColor(0xEF91B4);
+ p.Style.BackColor2 = factory.GetColor(0xE66896);
+ p.Style.BorderColor = factory.GetColor(0xB12753);
+ p.Style.TextColor = factory.GetColor(0x8E2648);
+ p.Style.BackColorGradientAngle = 90;
+ p.Style.Border = DevComponents.DotNetBar.eStyleBorderType.Solid;
+ p.Style.BorderWidth = 1;
+ p.Style.CornerDiameter = 4;
+ p.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
+ p.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
+ p.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
+ }
+ }
+
+ ///
+ /// Applies default group panel style to the control.
+ ///
+ public void SetDefaultPanelStyle()
+ {
+ GroupPanel p = this;
+
+ p.CanvasColor = SystemColors.Control;
+ p.ResetStyle();
+ p.ColorSchemeStyle = eDotNetBarStyle.Office2007;
+ p.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
+ p.Style.BackColorGradientAngle = 90;
+ p.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
+ p.Style.Border = DevComponents.DotNetBar.eStyleBorderType.Solid;
+ p.Style.BorderWidth = 1;
+ p.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
+ p.Style.CornerDiameter = 4;
+ p.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
+ p.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
+ p.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
+ p.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
+ }
+
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ base.SetBoundsCore(x, y, width, height, specified);
+
+ UpdateInternalClientSize(width, height, specified);
+ }
+
+ protected override void OnTextChanged(EventArgs e)
+ {
+ if (IsHandleCreated)
+ {
+ UpdateInternalClientSize(this.Width, this.Height, BoundsSpecified.Width | BoundsSpecified.Height);
+ InvalidateNonClient();
+ }
+ base.OnTextChanged(e);
+ }
+
+ private void UpdateInternalClientSize(int width, int height, BoundsSpecified specified)
+ {
+ if (((specified & BoundsSpecified.Height) == BoundsSpecified.Height || (specified & BoundsSpecified.Width) == BoundsSpecified.Width))
+ {
+ ElementStyle style = this.Style;
+ Rectangle r = new Rectangle(0, 0, width, height);
+ if (m_NCPainter != null)
+ {
+ Rectangle cr = m_NCPainter.GetClientRectangleForBorderStyle(r, style);
+ if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height)
+ height = cr.Height;
+ if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width)
+ width = cr.Width;
+
+ Type type = typeof(Control);
+ try // try with ignore catch is bad idea but in this case its for future proofing, just in case M$ removes these members
+ {
+ type.InvokeMember("clientWidth", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetField, null, this, new object[] { width });
+ type.InvokeMember("clientHeight", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetField, null, this, new object[] { height });
+ }
+ catch { }
+ }
+ }
+ }
+
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool AutoScroll
+ {
+ get
+ {
+ return base.AutoScroll;
+ }
+ set
+ {
+ base.AutoScroll = value;
+ }
+ }
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
+ public override Point AutoScrollOffset
+ {
+ get
+ {
+ return base.AutoScrollOffset;
+ }
+ set
+ {
+ base.AutoScrollOffset = value;
+ }
+ }
+ #endregion
+
+ #region INonClientControl Members
+
+ protected override void WndProc(ref System.Windows.Forms.Message m)
+ {
+ if (m_NCPainter == null)
+ {
+ base.WndProc(ref m);
+ return;
+ }
+
+ if (m.Msg == (int)WinApi.WindowsMessages.WM_HSCROLL || m.Msg == (int)WinApi.WindowsMessages.WM_VSCROLL ||
+ m.Msg == (int)WinApi.WindowsMessages.WM_MOUSEWHEEL)
+ {
+ //Region reg = new Region(new Rectangle(0, 0, this.Width, this.Height));
+ //SuspendPaint = true;
+ //try
+ //{
+ bool callBase = m_NCPainter.WndProc(ref m);
+ if (callBase)
+ BaseWndProc(ref m);
+ //}
+ //finally
+ //{
+ //SuspendPaint = false;
+ //}
+ //foreach (Control c in this.Controls)
+ //{
+ // if (c.Visible)
+ // reg.Exclude(c.Bounds);
+ //}
+ RefreshTextClientRectangle();
+ //this.Invalidate(reg, false);
+ //if (this.Controls.Count > 0)
+ // this.Update();
+ //reg.Dispose();
+ }
+ else
+ {
+ bool callBase = m_NCPainter.WndProc(ref m);
+ //if (m.Msg == (int)WinApi.WindowsMessages.WM_NCCALCSIZE)
+ // UpdateInternalClientSize(this.Width, this.Height, BoundsSpecified.Width | BoundsSpecified.Height);
+ if (callBase)
+ BaseWndProc(ref m);
+ }
+ }
+
+ void INonClientControl.BaseWndProc(ref Message m)
+ {
+ BaseWndProc(ref m);
+ }
+
+ ///
+ /// Returns the renderer control will be rendered with.
+ ///
+ /// The current renderer.
+ public virtual Rendering.BaseRenderer GetRenderer()
+ {
+ if (Rendering.GlobalManager.Renderer != null)
+ return Rendering.GlobalManager.Renderer;
+ return null;
+ }
+
+ ItemPaintArgs INonClientControl.GetItemPaintArgs(System.Drawing.Graphics g)
+ {
+ ItemPaintArgs pa = new ItemPaintArgs(this as IOwner, this, g, GetColorScheme());
+ pa.Renderer = this.GetRenderer();
+ pa.DesignerSelection = false; // m_DesignerSelection;
+ pa.GlassEnabled = !this.DesignMode && WinApi.IsGlassEnabled;
+ return pa;
+ }
+
+ ElementStyle INonClientControl.BorderStyle
+ {
+ get { return this.Style; }
+ }
+
+ void INonClientControl.PaintBackground(PaintEventArgs e)
+ {
+ base.OnPaintBackground(e);
+ }
+
+ IntPtr INonClientControl.Handle
+ {
+ get { return this.Handle; }
+ }
+
+ int INonClientControl.Width
+ {
+ get { return this.Width; }
+ }
+
+ int INonClientControl.Height
+ {
+ get { return this.Height; }
+ }
+
+ bool INonClientControl.IsHandleCreated
+ {
+ get { return this.IsHandleCreated; }
+ }
+
+ System.Drawing.Point INonClientControl.PointToScreen(System.Drawing.Point client)
+ {
+ return this.PointToScreen(client);
+ }
+
+ System.Drawing.Color INonClientControl.BackColor
+ {
+ get { return this.BackColor; }
+ }
+
+ void DevComponents.DotNetBar.Controls.INonClientControl.RenderNonClient(Graphics g) { }
+
+ void DevComponents.DotNetBar.Controls.INonClientControl.AdjustClientRectangle(ref Rectangle r)
+ {
+ Size textSize = GetAutoSize(r.Width);
+ if (m_TitleImage != null)
+ {
+ textSize.Height = Math.Max(m_TitleImage.Height, textSize.Height);
+ }
+ if (textSize.Height > r.Height) textSize.Height = r.Height - 8;
+ r.Y += textSize.Height;
+ r.Height -= textSize.Height;
+ }
+
+ void INonClientControl.AdjustBorderRectangle(ref Rectangle r)
+ {
+ if (this.Text != "")
+ {
+ int h = GetNonClientTopHeight();
+ r.Y += h;
+ r.Height -= h;
+ }
+ }
+
+ private int GetNonClientTopHeight()
+ {
+ Font f = this.Font;
+ if (this.Style.Font != null)
+ f = this.Style.Font;
+ int h = (int)(f.Height * .7f);
+ if (m_TitleImage != null)
+ {
+ h = Math.Max(m_TitleImage.Height - (f.Height - h - 1), h);
+ }
+ return h;
+ }
+ internal Rectangle GetInternalClientRectangle()
+ {
+ return m_NCPainter.ClientRectangle;
+ }
+ private Color _DisabledBackColor = Color.Empty;
+ ///
+ /// Specifies back color when Enabled=false
+ ///
+ [Browsable(false), Category("Appearance"), Description("Specifies back color when Enabled=false")]
+ public Color DisabledBackColor
+ {
+ get { return _DisabledBackColor; }
+ set
+ {
+ _DisabledBackColor = value;
+ if (!Enabled) this.Invalidate();
+ }
+ }
+ #endregion
+ }
+ ///
+ /// Defines predefined color schemes for panel control.
+ ///
+ public enum ePanelColorTable
+ {
+ Default,
+ Green,
+ Orange,
+ Red,
+ Yellow,
+ Magenta
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/GroupPanel.ico b/PROMS/DotNetBar Source Code/Controls/GroupPanel.ico
new file mode 100644
index 00000000..d810f802
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/GroupPanel.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/LabelX.cs b/PROMS/DotNetBar Source Code/Controls/LabelX.cs
new file mode 100644
index 00000000..1fe70dc2
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/LabelX.cs
@@ -0,0 +1,696 @@
+using System;
+using System.Text;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Drawing;
+using System.Security.Permissions;
+
+namespace DevComponents.DotNetBar
+{
+#if FRAMEWORK20
+ [Designer("DevComponents.DotNetBar.Design.LabelXDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
+#endif
+ [ToolboxBitmap(typeof(LabelX), "Controls.LabelX.ico"), ToolboxItem(true), System.Runtime.InteropServices.ComVisible(false)]
+ public class LabelX : BaseItemControl, ICommandSource
+ {
+ #region Private Variables
+ private LabelItem m_Label = null;
+ private bool m_UseMnemonic = true;
+ private Size m_PreferredSize = Size.Empty;
+ #endregion
+
+ #region Events
+ ///
+ /// Occurs when text markup link is clicked. Markup links can be created using "a" tag, for example:
+ /// Markup link
+ ///
+ public event MarkupLinkClickEventHandler MarkupLinkClick;
+ #endregion
+
+ #region Constructor, Dispose
+ public LabelX()
+ {
+ m_Label = new LabelItem();
+ m_Label.Style = eDotNetBarStyle.Office2007;
+ m_Label.MarkupLinkClick += new MarkupLinkClickEventHandler(LabelMarkupLinkClick);
+ this.FocusCuesEnabled = false;
+ this.HostItem = m_Label;
+ this.TabStop = false;
+ this.SetStyle(ControlStyles.Selectable, false);
+ }
+ #endregion
+
+ #region Internal Implementation
+ ///
+ /// Specifies spacing between label image and text.
+ ///
+ [DefaultValue(2), Category("Appearance"), Description("Specifies spacing between label image and text.")]
+ public int ImageTextSpacing
+ {
+ get { return m_Label.ImageTextSpacing; }
+ set { m_Label.ImageTextSpacing = value; }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
+ protected string PlainText
+ {
+ get
+ {
+ return m_Label.PlainText;
+ }
+ }
+
+ ///
+ /// Gets or sets whether text-markup support is enabled for controls Text property. Default value is true.
+ /// Set this property to false to display HTML or other markup in the control instead of it being parsed as text-markup.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates whether text-markup support is enabled for controls Text property.")]
+ public bool EnableMarkup
+ {
+ get { return m_Label.EnableMarkup; }
+ set
+ {
+ m_Label.EnableMarkup = value;
+ }
+ }
+
+ ///
+ /// Gets or sets whether control displays focus cues when focused.
+ ///
+ [DefaultValue(false), Category("Behavior"), Description("Indicates whether control displays focus cues when focused.")]
+ public override bool FocusCuesEnabled
+ {
+ get
+ {
+ return base.FocusCuesEnabled;
+ }
+ set
+ {
+ base.FocusCuesEnabled = value;
+ }
+ }
+ protected override void OnHandleCreated(EventArgs e)
+ {
+#if FRAMEWORK20
+ if (this.AutoSize)
+ this.AdjustSize();
+#endif
+ this.RecalcLayout();
+ base.OnHandleCreated(e);
+ }
+ ///
+ /// Recalculates the size of the internal item.
+ ///
+ protected override void RecalcSize()
+ {
+ m_Label.SuspendPaint = true;
+ m_Label.Width = Dpi.DescaleWidth(m_Label.Bounds.Width);
+ m_Label.Height = Dpi.DescaleHeight(m_Label.Bounds.Height);
+ m_Label.SuspendPaint = false;
+ base.RecalcSize();
+ }
+
+ protected override void OnBackColorChanged(EventArgs e)
+ {
+ m_Label.BackColor = this.BackColor;
+ base.OnBackColorChanged(e);
+ }
+
+ protected override void OnForeColorChanged(EventArgs e)
+ {
+ if (this.ForeColor == SystemColors.ControlText)
+ m_Label.ForeColor = Color.Empty;
+ else
+ m_Label.ForeColor = this.ForeColor;
+ base.OnForeColorChanged(e);
+ }
+
+ ///
+ /// Gets or sets the border sides that are displayed. Default value specifies border on all 4 sides.
+ ///
+ [Browsable(false), Category("Appearance"), DefaultValue(LabelItem.DEFAULT_BORDERSIDE), Description("Specifies border sides that are displayed.")]
+ public eBorderSide BorderSide
+ {
+ get { return m_Label.BorderSide; }
+ set { m_Label.BorderSide = value; InvalidateAutoSize(); }
+ }
+
+ ///
+ /// Gets or sets the type of the border drawn around the label.
+ ///
+ [Browsable(false), Category("Appearance"), DefaultValue(eBorderType.None), Description("Indicates the type of the border drawn around the label.")]
+ public eBorderType BorderType
+ {
+ get { return m_Label.BorderType; }
+ set { m_Label.BorderType = value; InvalidateAutoSize(); }
+ }
+
+ ///
+ /// Specifies label image.
+ ///
+ [Browsable(true), Category("Appearance"), Description("The image that will be displayed on the face of the item."), DefaultValue(null)]
+ public System.Drawing.Image Image
+ {
+ get { return m_Label.Image; }
+ set { m_Label.Image = value; InvalidateAutoSize(); }
+ }
+
+ ///
+ /// Gets/Sets the image position inside the label.
+ ///
+ [Browsable(true), Category("Appearance"), Description("The alignment of the image in relation to text displayed by this item."), DefaultValue(eImagePosition.Left)]
+ public eImagePosition ImagePosition
+ {
+ get { return m_Label.ImagePosition; }
+ set { m_Label.ImagePosition = value; InvalidateAutoSize(); }
+ }
+
+ ///
+ /// Gets or sets the border line color when border is single line.
+ ///
+ [Browsable(true), Category("Appearance"), Description("Indicates border line color when border is single line.")]
+ public Color SingleLineColor
+ {
+ get { return m_Label.SingleLineColor; }
+ set { m_Label.SingleLineColor = value; }
+ }
+
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSingleLineColor()
+ {
+ return m_Label.ShouldSerializeSingleLineColor();
+ }
+
+ ///
+ /// Resets the SingleLineColor property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSingleLineColor()
+ {
+ m_Label.ResetSingleLineColor();
+ }
+
+ ///
+ /// Gets or sets the text associated with this item.
+ ///
+ [Browsable(true), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), Category("Appearance"), Description("The text contained in the item.")]
+ public override string Text
+ {
+ get { return base.Text; }
+ set { base.Text = value; }
+ }
+
+ ///
+ /// Gets or sets the horizontal text alignment.
+ ///
+ [Browsable(true), DefaultValue(StringAlignment.Near), DevCoBrowsable(true), Category("Layout"), Description("Indicates text alignment.")]
+ public System.Drawing.StringAlignment TextAlignment
+ {
+ get { return m_Label.TextAlignment; }
+ set
+ {
+ m_Label.TextAlignment = value;
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets the text vertical alignment.
+ ///
+ [Browsable(true), DefaultValue(System.Drawing.StringAlignment.Center), DevCoBrowsable(true), Category("Layout"), Description("Indicates text line alignment.")]
+ public System.Drawing.StringAlignment TextLineAlignment
+ {
+ get { return m_Label.TextLineAlignment; }
+ set
+ {
+ m_Label.TextLineAlignment = value;
+ this.RecalcLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets a value that determines whether text is displayed in multiple lines or one long line.
+ ///
+ [Browsable(true), Category("Style"), DefaultValue(false), Description("Gets or sets a value that determines whether text is displayed in multiple lines or one long line.")]
+ public bool WordWrap
+ {
+ get { return m_Label.WordWrap; }
+ set { m_Label.WordWrap = value; RecalcLayout(); }
+ }
+
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public new bool TabStop
+ {
+ get { return base.TabStop; }
+ set { base.TabStop = value; }
+ }
+
+ ///
+ /// Gets or sets the left padding in pixels.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout"), Description("Indicates left padding in pixels.")]
+ public int PaddingLeft
+ {
+ get { return m_Label.PaddingLeft; }
+ set { m_Label.PaddingLeft = value; InvalidateAutoSize(); }
+ }
+
+ ///
+ /// Gets or sets the right padding in pixels.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout"), Description("Indicates right padding in pixels.")]
+ public int PaddingRight
+ {
+ get
+ {
+ return m_Label.PaddingRight;
+ }
+ set
+ {
+ m_Label.PaddingRight = value;
+ InvalidateAutoSize();
+ }
+ }
+
+ ///
+ /// Gets or sets the top padding in pixels.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout"), Description("Indicates top padding in pixels.")]
+ public int PaddingTop
+ {
+ get
+ {
+ return m_Label.PaddingTop;
+ }
+ set
+ {
+ m_Label.PaddingTop = value;
+ InvalidateAutoSize();
+ }
+ }
+
+ ///
+ /// Gets or sets the bottom padding in pixels.
+ ///
+ [Browsable(true), DefaultValue(0), Category("Layout"), Description("Indicates bottom padding in pixels.")]
+ public int PaddingBottom
+ {
+ get
+ {
+ return m_Label.PaddingBottom;
+ }
+ set
+ {
+ m_Label.PaddingBottom = value;
+ InvalidateAutoSize();
+ }
+ }
+
+ private void LabelMarkupLinkClick(object sender, MarkupLinkClickEventArgs e)
+ {
+ OnMarkupLinkClick(e);
+ }
+
+ ///
+ /// Invokes the MarkupLinkClick event.
+ ///
+ /// Provides additional data about event.
+ protected virtual void OnMarkupLinkClick(MarkupLinkClickEventArgs e)
+ {
+ if (MarkupLinkClick != null)
+ MarkupLinkClick(this, e);
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the control interprets an ampersand character (&) in the control's Text property to be an access key prefix character.
+ ///
+ [Browsable(true), DefaultValue(true), Category("Appearance"), Description("Indicates whether the control interprets an ampersand character (&) in the control's Text property to be an access key prefix character.")]
+ public bool UseMnemonic
+ {
+ get { return m_UseMnemonic; }
+ set
+ {
+ m_UseMnemonic = value;
+ InvalidateAutoSize();
+ this.Invalidate();
+ }
+ }
+
+ protected void InvalidateAutoSize()
+ {
+ m_PreferredSize = Size.Empty;
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (m_UseMnemonic)
+ m_Label.ShowPrefix = true;
+ else
+ m_Label.ShowPrefix = false;
+
+ if (m_Label.NeedRecalcSize) m_Label.RecalcSize();
+
+ base.OnPaint(e);
+ }
+
+ private bool CanProcessMnemonic()
+ {
+ if (!this.Enabled || !this.Visible)
+ return false;
+ return true;
+ }
+
+ [UIPermission(SecurityAction.LinkDemand, Window = UIPermissionWindow.AllWindows)]
+ protected override bool ProcessMnemonic(char charCode)
+ {
+ if ((!this.UseMnemonic || !Control.IsMnemonic(charCode, this.Text)) || !this.CanProcessMnemonic() || Control.ModifierKeys != Keys.Alt || m_Label.IsUsingTextMarkup)
+ {
+ return false;
+ }
+ Control parent = this.Parent;
+ if (parent != null)
+ {
+ if (parent.SelectNextControl(this, true, false, true, false) && !parent.ContainsFocus)
+ {
+ parent.Focus();
+ }
+ }
+ return true;
+ }
+
+#if FRAMEWORK20
+ [Localizable(true), Browsable(false)]
+ public new System.Windows.Forms.Padding Padding
+ {
+ get { return base.Padding; }
+ set { base.Padding = value; }
+ }
+
+ internal bool IsUsingTextMarkup
+ {
+ get
+ {
+ if (m_Label != null)
+ return m_Label.TextMarkupBody != null;
+ return false;
+ }
+ }
+
+ public override Size GetPreferredSize(Size proposedSize)
+ {
+ if (!m_PreferredSize.IsEmpty && (proposedSize.Width == m_PreferredSize.Width || proposedSize.Width == 0 || this.AutoSize)) return m_PreferredSize;
+
+ if (!BarFunctions.IsHandleValid(this) || this.DesignMode && !this.AutoSize)
+ return base.GetPreferredSize(proposedSize);
+ if (this.Text.Length == 0)
+ return base.GetPreferredSize(proposedSize);
+
+ int oldWidth = m_Label.Width, oldHeight = m_Label.Height;
+ m_Label.SuspendPaint = true;
+ m_Label.Width = 0;
+ m_Label.Height = 0;
+ if ((proposedSize.Width > 0 && proposedSize.Width < 500000 || this.MaximumSize.Width > 0) && m_Label.TextMarkupBody != null)
+ {
+ if (TextOrientation == eOrientation.Horizontal)
+ m_Label.RecalcSizeMarkup((this.MaximumSize.Width > 0 ? this.MaximumSize.Width : proposedSize.Width));
+ else
+ m_Label.RecalcSizeMarkup((this.MaximumSize.Height > 0 ? this.MaximumSize.Height : proposedSize.Height));
+ }
+ else
+ {
+ m_Label.RecalcSize();
+ if (this.WordWrap && m_Label.WidthInternal > this.MaximumSize.Width && this.MaximumSize.Width > 0)
+ {
+ m_Label.Height = 0;
+ m_Label.Width = Dpi.DescaleWidth(this.MaximumSize.Width);
+ m_Label.RecalcSize();
+ }
+ else if (this.WordWrap && m_Label.WidthInternal > proposedSize.Width && proposedSize.Width > 0)
+ {
+ m_Label.Height = 0;
+ m_Label.Width = Dpi.DescaleWidth(proposedSize.Width);
+ m_Label.RecalcSize();
+ }
+ }
+ Size s = m_Label.Size;
+ s.Height += 2;
+ if (this.TextOrientation == eOrientation.Vertical)
+ {
+ s.Width += Dpi.Width2;
+ }
+ if (this.Font.Size > 13)
+ s.Height += 2;
+ m_Label.Width = oldWidth;
+ m_Label.Height = oldHeight;
+ m_Label.SuspendPaint = false;
+ m_PreferredSize = s;
+
+ return m_PreferredSize;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the control is automatically resized to display its entire contents. You can set MaximumSize.Width property to set the maximum width used by the control.
+ ///
+ [Browsable(true), DefaultValue(false), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public override bool AutoSize
+ {
+ get
+ {
+ return base.AutoSize;
+ }
+ set
+ {
+ if (this.AutoSize != value)
+ {
+ base.AutoSize = value;
+ AdjustSize();
+ }
+ }
+ }
+
+ protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ if (this.AutoSize)
+ {
+ Size preferredSize = Size.Empty;
+ if (width != m_PreferredSize.Width && width > 0)
+ {
+ InvalidateAutoSize();
+ preferredSize = this.GetPreferredSize(new Size(width, 0));
+ }
+ else
+ preferredSize = this.PreferredSize;
+ width = preferredSize.Width;
+ height = preferredSize.Height;
+ }
+ base.SetBoundsCore(x, y, width, height, specified);
+ }
+
+ private void AdjustSize()
+ {
+ if (this.AutoSize)
+ {
+ this.Size = base.PreferredSize;
+ }
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ InvalidateAutoSize();
+ base.OnFontChanged(e);
+ }
+
+ protected override void OnTextChanged(EventArgs e)
+ {
+ InvalidateAutoSize();
+ base.OnTextChanged(e);
+ this.AdjustSize();
+ }
+#endif
+ ///
+ /// Gets or sets text-orientation. Default is horizontal.
+ ///
+ [DefaultValue(eOrientation.Horizontal), Category("Appearance"), Description("Indicates text-orientation")]
+ public eOrientation TextOrientation
+ {
+ get { return m_Label.TextOrientation; }
+ set
+ {
+ m_Label.TextOrientation = value;
+ InvalidateAutoSize();
+ this.AdjustSize();
+ }
+ }
+
+ ///
+ /// Gets or sets how vertical text is rotated when TextOrientation = Vertical.
+ ///
+ [DefaultValue(true), Category("Appearance"), Description("Indicates how vertical text is rotated when TextOrientation = Vertical.")]
+ public bool VerticalTextTopUp
+ {
+ get { return m_Label.VerticalTextTopUp; }
+ set
+ {
+ m_Label.VerticalTextTopUp = value;
+ if (TextOrientation == eOrientation.Vertical)
+ {
+ this.Invalidate();
+ }
+ }
+ }
+
+ ///
+ /// Gets the underlying LabelItem
+ ///
+ internal LabelItem LabelItem
+ {
+ get { return (m_Label); }
+ }
+
+ ///
+ /// Indicates the symbol displayed on label instead of the image. Setting the symbol overrides the image setting.
+ ///
+ [DefaultValue(""), Category("Appearance"), Description("Indicates the symbol displayed on face of the tile instead of the image. Setting the symbol overrides the 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 m_Label.Symbol; }
+ set { m_Label.Symbol = value; }
+ }
+ ///
+ /// Gets or sets the symbol set used to represent the Symbol.
+ ///
+ [Browsable(false), DefaultValue(eSymbolSet.Awesome)]
+ public eSymbolSet SymbolSet
+ {
+ get { return m_Label.SymbolSet; }
+ set { m_Label.SymbolSet = value; }
+ }
+ ///
+ /// Indicates the size of the symbol in points.
+ ///
+ [DefaultValue(0f), Category("Appearance"), Description("Indicates the size of the symbol in points.")]
+ public float SymbolSize
+ {
+ get { return m_Label.SymbolSize; }
+ set { m_Label.SymbolSize = value; }
+ }
+ ///
+ /// Gets or sets the color of the symbol.
+ ///
+ [Category("Appearance"), Description("Indicates color of the symbol.")]
+ public Color SymbolColor
+ {
+ get { return m_Label.SymbolColor; }
+ set { m_Label.SymbolColor = value; }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeSymbolColor()
+ {
+ return m_Label.ShouldSerializeSymbolColor();
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetSymbolColor()
+ {
+ m_Label.ResetSymbolColor();
+ }
+
+ ///
+ /// Indicates whether label text is rendered using bold font unless the Font property is specifically set to different font.
+ ///
+ [DefaultValue(false), Category("Appearance"), Description("Indicates whether label text is rendered using bold font unless the Font property is specifically set to different font.")]
+ public bool FontBold
+ {
+ get { return m_Label.FontBold; }
+ set
+ {
+ if (m_Label.FontBold != value)
+ {
+ m_Label.FontBold = value;
+ this.Invalidate();
+ }
+ }
+ }
+ #endregion
+
+ #region ICommandSource Members
+ protected virtual void ExecuteCommand()
+ {
+ if (_Command == null) return;
+ CommandManager.ExecuteCommand(this);
+ }
+
+ ///
+ /// Gets or sets the command assigned to the item. Default value is null.
+ /// Note that if this property is set to null Enabled property will be set to false automatically to disable the item.
+ ///
+ [DefaultValue(null), Category("Commands"), Description("Indicates the command assigned to the item.")]
+ public Command Command
+ {
+ get { return (Command)((ICommandSource)this).Command; }
+ set
+ {
+ ((ICommandSource)this).Command = value;
+ }
+ }
+
+ private ICommand _Command = null;
+ //[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ ICommand ICommandSource.Command
+ {
+ get
+ {
+ return _Command;
+ }
+ set
+ {
+ bool changed = false;
+ if (_Command != value)
+ changed = true;
+
+ if (_Command != null)
+ CommandManager.UnRegisterCommandSource(this, _Command);
+ _Command = value;
+ if (value != null)
+ CommandManager.RegisterCommand(this, value);
+ if (changed)
+ OnCommandChanged();
+ }
+ }
+
+ ///
+ /// Called when Command property value changes.
+ ///
+ protected virtual void OnCommandChanged()
+ {
+ }
+
+ private object _CommandParameter = null;
+ ///
+ /// Gets or sets user defined data value that can be passed to the command when it is executed.
+ ///
+ [Browsable(true), DefaultValue(null), Category("Commands"), Description("Indicates user defined data value that can be passed to the command when it is executed."), System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter)), System.ComponentModel.Localizable(true)]
+ public object CommandParameter
+ {
+ get
+ {
+ return _CommandParameter;
+ }
+ set
+ {
+ _CommandParameter = value;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/LabelX.ico b/PROMS/DotNetBar Source Code/Controls/LabelX.ico
new file mode 100644
index 00000000..4e97915d
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/LabelX.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/Line.cs b/PROMS/DotNetBar Source Code/Controls/Line.cs
new file mode 100644
index 00000000..9c978945
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/Line.cs
@@ -0,0 +1,489 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace DevComponents.DotNetBar.Controls
+{
+ ///
+ /// A single horizontal or vertical line control.
+ ///
+ [ToolboxBitmap(typeof(Line), "Controls.Line.ico"), ToolboxItem(true), Description("Horizontal or Vertical Line Control")]
+ public class Line : Control
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the Line class.
+ ///
+ public Line()
+ {
+ this.SetStyle(ControlStyles.AllPaintingInWmPaint
+ | ControlStyles.OptimizedDoubleBuffer
+ | ControlStyles.UserPaint
+ | ControlStyles.SupportsTransparentBackColor
+ , true);
+ }
+ #endregion
+
+ #region Implementation
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ Graphics g = e.Graphics;
+ SmoothingMode sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.None;
+
+ using (Pen pen = new Pen(ForeColor, _Thickness))
+ {
+ pen.DashStyle = _DashStyle;
+ pen.DashOffset = _DashOffset;
+
+ Point lineStart = LineStartPoint;
+ Point lineEnd = LineEndPoint;
+
+ if (_StartLineCap != eLineEndType.None && _Thickness > 1)
+ {
+ if (_VerticalLine)
+ lineStart.Y += _StartLineCapSize.Height / 2;
+ else
+ lineStart.X += _StartLineCapSize.Width / 2;
+ }
+ if (_EndLineCap != eLineEndType.None && _Thickness > 1)
+ {
+ if (_VerticalLine)
+ lineEnd.Y -= _EndLineCapSize.Height / 2;
+ else
+ lineEnd.X -= _EndLineCapSize.Width / 2;
+ }
+
+ g.DrawLine(pen, lineStart, lineEnd);
+ }
+
+ if (_StartLineCap != eLineEndType.None && _StartLineCapSize.Width > 0 && _StartLineCapSize.Height > 0)
+ DrawLineCap(g, LineStartPoint, _StartLineCap, _StartLineCapSize, true);
+
+ if (_EndLineCap != eLineEndType.None && _EndLineCapSize.Width > 0 && _EndLineCapSize.Height > 0)
+ DrawLineCap(g, LineEndPoint, _EndLineCap, _EndLineCapSize, false);
+
+ g.SmoothingMode = sm;
+
+ base.OnPaint(e);
+ }
+ private void DrawLineCap(Graphics g, Point linePoint, eLineEndType lineCap, Size capSize, bool isStartCap)
+ {
+ if (lineCap == eLineEndType.Arrow)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.HighQuality;
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ if (isStartCap)
+ {
+ if (VerticalLine)
+ path.AddLines(new Point[] {
+ new Point(linePoint.X, linePoint.Y),
+ new Point(linePoint.X - capSize.Width/2, linePoint.Y+capSize.Height),
+ new Point(linePoint.X+capSize.Width / 2, linePoint.Y+capSize.Height)});
+ else
+ path.AddLines(new Point[] {
+ new Point(linePoint.X, linePoint.Y),
+ new Point(linePoint.X + capSize.Width, linePoint.Y-capSize.Height/2),
+ new Point(linePoint.X+capSize.Width, linePoint.Y+ capSize.Height/2)});
+ }
+ else
+ {
+ if (VerticalLine)
+ path.AddLines(new Point[] {
+ new Point(linePoint.X, linePoint.Y),
+ new Point(linePoint.X + capSize.Width / 2, linePoint.Y - capSize.Height),
+ new Point(linePoint.X - capSize.Width / 2, linePoint.Y - capSize.Height)});
+ else
+ path.AddLines(new Point[] {
+ new Point(linePoint.X, linePoint.Y),
+ new Point(linePoint.X - capSize.Width, linePoint.Y + capSize.Height / 2),
+ new Point(linePoint.X - capSize.Width, linePoint.Y - capSize.Height/2)});
+ }
+ path.CloseAllFigures();
+ using (SolidBrush brush = new SolidBrush(ForeColor))
+ g.FillPath(brush, path);
+ }
+ g.SmoothingMode = sm;
+ }
+ else if (lineCap == eLineEndType.Circle)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.HighQuality;
+ using (SolidBrush brush = new SolidBrush(ForeColor))
+ {
+ if (VerticalLine && isStartCap)
+ g.FillEllipse(brush, new Rectangle(linePoint.X - capSize.Width/2, linePoint.Y , capSize.Width, capSize.Height));
+ else if (VerticalLine)
+ g.FillEllipse(brush, new Rectangle(linePoint.X - capSize.Width/2, linePoint.Y - capSize.Height - 1, capSize.Width, capSize.Height));
+ else if (isStartCap)
+ g.FillEllipse(brush, new Rectangle(linePoint.X, linePoint.Y - capSize.Height / 2, capSize.Width, capSize.Height));
+ else
+ g.FillEllipse(brush, new Rectangle(linePoint.X - capSize.Width - 1, linePoint.Y - capSize.Height / 2, capSize.Width, capSize.Height));
+ }
+ g.SmoothingMode = sm;
+ }
+ else if (lineCap == eLineEndType.Diamond)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.HighQuality;
+ using (GraphicsPath path = new GraphicsPath())
+ {
+ if (isStartCap)
+ {
+ if (VerticalLine)
+ path.AddLines(new Point[] {
+ new Point(linePoint.X, linePoint.Y),
+ new Point(linePoint.X - capSize.Width/2, linePoint.Y+capSize.Height / 2),
+ new Point(linePoint.X, linePoint.Y+capSize.Height),
+ new Point(linePoint.X+capSize.Width / 2, linePoint.Y+capSize.Height / 2)});
+ else
+ path.AddLines(new Point[] {
+ new Point(linePoint.X, linePoint.Y),
+ new Point(linePoint.X + capSize.Width/2, linePoint.Y-capSize.Height/2),
+ new Point(linePoint.X + capSize.Width, linePoint.Y),
+ new Point(linePoint.X+capSize.Width / 2, linePoint.Y+ capSize.Height/2)});
+ }
+ else
+ {
+ if (VerticalLine)
+ {
+ linePoint.Y--;
+ path.AddLines(new Point[] {
+ new Point(linePoint.X, linePoint.Y),
+ new Point(linePoint.X + capSize.Width / 2, linePoint.Y - capSize.Height / 2),
+ new Point(linePoint.X, linePoint.Y - capSize.Height),
+ new Point(linePoint.X - capSize.Width / 2, linePoint.Y - capSize.Height / 2)});
+ }
+ else
+ {
+ linePoint.X--;
+ path.AddLines(new Point[] {
+ new Point(linePoint.X, linePoint.Y),
+ new Point(linePoint.X - capSize.Width / 2, linePoint.Y - capSize.Height / 2),
+ new Point(linePoint.X - capSize.Width, linePoint.Y),
+ new Point(linePoint.X - capSize.Width / 2, linePoint.Y + capSize.Height/2)});
+ }
+ }
+ path.CloseAllFigures();
+ using (SolidBrush brush = new SolidBrush(ForeColor))
+ g.FillPath(brush, path);
+ }
+ g.SmoothingMode = sm;
+ }
+ else if (lineCap == eLineEndType.Rectangle)
+ {
+ SmoothingMode sm = g.SmoothingMode;
+ g.SmoothingMode = SmoothingMode.HighQuality;
+ using (SolidBrush brush = new SolidBrush(ForeColor))
+ {
+ if (VerticalLine && isStartCap)
+ g.FillRectangle(brush, new Rectangle(linePoint.X - capSize.Width / 2, linePoint.Y, capSize.Width, capSize.Height));
+ else if (VerticalLine)
+ g.FillRectangle(brush, new Rectangle(linePoint.X - capSize.Width / 2, linePoint.Y - capSize.Height - 1, capSize.Width, capSize.Height));
+ else if (isStartCap)
+ g.FillRectangle(brush, new Rectangle(linePoint.X, linePoint.Y - capSize.Height / 2, capSize.Width, capSize.Height));
+ else
+ g.FillRectangle(brush, new Rectangle(linePoint.X - capSize.Width - 1, linePoint.Y - capSize.Height / 2, capSize.Width, capSize.Height));
+ }
+ g.SmoothingMode = sm;
+ }
+ }
+ private Point LineStartPoint
+ {
+ get
+ {
+ if (!_VerticalLine)
+ {
+ if (_LineAlignment == eItemAlignment.Center)
+ return new Point(0, this.Height / 2);
+ else if (_LineAlignment == eItemAlignment.Near)
+ return new Point(0, _Thickness / 2 + ((_StartLineCap != eLineEndType.None) ? _StartLineCapSize.Height / 2 : 0));
+ else if (_LineAlignment == eItemAlignment.Far)
+ return new Point(0, this.Height - _Thickness / 2 - ((_StartLineCap != eLineEndType.None) ? _StartLineCapSize.Height / 2 : 0));
+ }
+ else
+ {
+ if (_LineAlignment == eItemAlignment.Center)
+ return new Point(this.Width / 2, 0);
+ else if (_LineAlignment == eItemAlignment.Near)
+ {
+ return new Point(_Thickness / 2 + ((_EndLineCap != eLineEndType.None) ? _EndLineCapSize.Width / 2 : 0), 0);
+ }
+ else if (_LineAlignment == eItemAlignment.Far)
+ return new Point(this.Width - _Thickness / 2 - ((_EndLineCap != eLineEndType.None) ? _EndLineCapSize.Width / 2 : 0), 0);
+ }
+ return Point.Empty;
+ }
+ }
+ private Point LineEndPoint
+ {
+ get
+ {
+ if (!_VerticalLine)
+ {
+ return new Point(this.Width, LineStartPoint.Y);
+ }
+ else
+ {
+ return new Point(LineStartPoint.X, this.Height);
+ }
+
+ }
+ }
+
+ private eItemAlignment _LineAlignment = eItemAlignment.Center;
+ ///
+ /// Specifies the line alignment within control bounds.
+ ///
+ [DefaultValue(eItemAlignment.Center), Category("Appearance"), Description("Specifies the line alignment within control bounds.")]
+ public eItemAlignment LineAlignment
+ {
+ get { return _LineAlignment; }
+ set { _LineAlignment = value; this.Invalidate(); }
+ }
+
+ private float _DashOffset;
+ ///
+ /// Specifies distance from the start of a line to the beginning of a dash pattern.
+ ///
+ [DefaultValue(0f), Category("Appearance"), Description("Specifies distance from the start of a line to the beginning of a dash pattern.")]
+ public float DashOffset
+ {
+ get { return _DashOffset; }
+ set { _DashOffset = value; this.Invalidate(); }
+ }
+
+ private DashStyle _DashStyle = DashStyle.Solid;
+ ///
+ /// Specifies the line dash style.
+ ///
+ [DefaultValue(DashStyle.Solid), Category("Appearance"), Description("Specifies the line dash style.")]
+ public DashStyle DashStyle
+ {
+ get { return _DashStyle; }
+ set { _DashStyle = value; this.Invalidate(); }
+ }
+
+ //private LineCap _LineCap = System.Drawing.Drawing2D.LineCap.Round;
+ /////
+ ///// Gets or sets the line cap i.e. line ending.
+ /////
+ //[DefaultValue(LineCap.Round), Category("Appearance"), Description("Specifies line cap i.e. line ending.")]
+ //public LineCap LineCap
+ //{
+ // get { return _LineCap; }
+ // set { _LineCap = value; this.Invalidate(); }
+ //}
+
+ private int _Thickness = 1;
+ ///
+ /// Gets or sets the line thickness in pixels.
+ ///
+ [DefaultValue(1), Category("Appearance"), Description("Indicates line thickness in pixels.")]
+ public int Thickness
+ {
+ get { return _Thickness; }
+ set
+ {
+ _Thickness = value;
+ this.Invalidate();
+ if (this.AutoSize) AdjustSize();
+ }
+ }
+
+
+ private bool _VerticalLine = false;
+ ///
+ /// Gets or sets whether vertical line is drawn. Default value is false which means horizontal line is drawn.
+ ///
+ [DefaultValue(false), Category("Appearance"), Description("Indicates whether vertical line is drawn.")]
+ public bool VerticalLine
+ {
+ get { return _VerticalLine; }
+ set
+ {
+ _VerticalLine = value;
+ this.Invalidate();
+ }
+ }
+ ///
+ /// Gets or sets a value indicating whether the control is automatically resized to display its entire contents. You can set MaximumSize.Width property to set the maximum width used by the control.
+ ///
+ [Browsable(true), DefaultValue(false), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public override bool AutoSize
+ {
+ get
+ {
+ return base.AutoSize;
+ }
+ set
+ {
+ if (this.AutoSize != value)
+ {
+ base.AutoSize = value;
+ AdjustSize();
+ }
+ }
+ }
+ private void AdjustSize()
+ {
+ this.Size = GetPreferredSize(this.Size);
+ }
+ public override Size GetPreferredSize(Size proposedSize)
+ {
+ if (this.VerticalLine)
+ return new Size(_Thickness, this.Height);
+ else
+ return new Size(this.Width, _Thickness);
+ //return base.GetPreferredSize(proposedSize);
+ }
+
+ private eLineEndType _StartLineCap = eLineEndType.None;
+ ///
+ /// Indicates the start of the line cap.
+ ///
+ [DefaultValue(eLineEndType.None), Category("Appearance"), Description("Indicates the start of the line cap.")]
+ public eLineEndType StartLineCap
+ {
+ get { return _StartLineCap; }
+ set
+ {
+ if (value != _StartLineCap)
+ {
+ eLineEndType oldValue = _StartLineCap;
+ _StartLineCap = value;
+ OnStartLineCapChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when StartLineCap property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnStartLineCapChanged(eLineEndType oldValue, eLineEndType newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("StartLineCap"));
+ this.Refresh();
+ }
+ private static readonly Size DefaultCapSize = new Size(6, 6);
+ private Size _StartLineCapSize = DefaultCapSize;
+ ///
+ /// Indicates the size of the start cap.
+ ///
+ [Category("Appearance"), Description("Indicates the size of the start cap.")]
+ public Size StartLineCapSize
+ {
+ get { return _StartLineCapSize; }
+ set
+ {
+ if (value != _StartLineCapSize)
+ {
+ Size oldValue = _StartLineCapSize;
+ _StartLineCapSize = value;
+ OnStartLineCapSizeChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when StartLineCapSize property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnStartLineCapSizeChanged(Size oldValue, Size newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("StartLineCapSize"));
+ this.Refresh();
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeStartLineCapSize()
+ {
+ return _StartLineCapSize != DefaultCapSize;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetStartLineCapSize()
+ {
+ this.StartLineCapSize = DefaultCapSize;
+ }
+
+ private eLineEndType _EndLineCap = eLineEndType.None;
+ ///
+ /// Indicates the start of the line cap.
+ ///
+ [DefaultValue(eLineEndType.None), Category("Appearance"), Description("Indicates the start of the line cap.")]
+ public eLineEndType EndLineCap
+ {
+ get { return _EndLineCap; }
+ set
+ {
+ if (value != _EndLineCap)
+ {
+ eLineEndType oldValue = _EndLineCap;
+ _EndLineCap = value;
+ OnEndLineCapChanged(oldValue, value);
+ }
+ }
+ }
+ ///
+ /// Called when EndLineCap property has changed.
+ ///
+ /// Old property value
+ /// New property value
+ protected virtual void OnEndLineCapChanged(eLineEndType oldValue, eLineEndType newValue)
+ {
+ //OnPropertyChanged(new PropertyChangedEventArgs("EndLineCap"));
+ this.Refresh();
+ }
+
+ private Size _EndLineCapSize = DefaultCapSize;
+ ///
+ /// Indicates end line cap size.
+ ///
+ [Category("Appearance"), Description("Indicates end line cap size.")]
+ public Size EndLineCapSize
+ {
+ get { return _EndLineCapSize; }
+ set { _EndLineCapSize = value; this.Refresh(); }
+ }
+ ///
+ /// Gets whether property should be serialized.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ShouldSerializeEndLineCapSize()
+ {
+ return _EndLineCapSize != DefaultCapSize;
+ }
+ ///
+ /// Resets property to its default value.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetEndLineCapSize()
+ {
+ this.EndLineCapSize = DefaultCapSize;
+ }
+ #endregion
+ }
+ ///
+ /// Defined line end types.
+ ///
+ public enum eLineEndType
+ {
+ None,
+ Arrow,
+ Rectangle,
+ Circle,
+ Diamond
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/Line.ico b/PROMS/DotNetBar Source Code/Controls/Line.ico
new file mode 100644
index 00000000..074e3392
Binary files /dev/null and b/PROMS/DotNetBar Source Code/Controls/Line.ico differ
diff --git a/PROMS/DotNetBar Source Code/Controls/ListBoxAdv/CheckStateConvertEventArgs.cs b/PROMS/DotNetBar Source Code/Controls/ListBoxAdv/CheckStateConvertEventArgs.cs
new file mode 100644
index 00000000..9b757274
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/ListBoxAdv/CheckStateConvertEventArgs.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+
+namespace DevComponents.DotNetBar
+{
+ ///
+ /// Provides data for CheckStateConvert event.
+ ///
+ public class CheckStateConvertEventArgs : EventArgs
+ {
+ public readonly object Value;
+ public CheckState? CheckState = null;
+ ///
+ /// Initializes a new instance of the CheckStateConvertEventArgs class.
+ ///
+ ///
+ public CheckStateConvertEventArgs(object value)
+ {
+ Value = value;
+ }
+ }
+}
diff --git a/PROMS/DotNetBar Source Code/Controls/ListBoxAdv/ListBoxAdv.cs b/PROMS/DotNetBar Source Code/Controls/ListBoxAdv/ListBoxAdv.cs
new file mode 100644
index 00000000..5c77e9b5
--- /dev/null
+++ b/PROMS/DotNetBar Source Code/Controls/ListBoxAdv/ListBoxAdv.cs
@@ -0,0 +1,1051 @@
+using System;
+using System.Text;
+using System.Windows.Forms;
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+using System.Collections;
+using DevComponents.DotNetBar.Primitives;
+using System.Drawing.Design;
+
+namespace DevComponents.DotNetBar
+{
+ [ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.ListBoxAdvDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false)]
+ [ToolboxBitmap(typeof(ToolboxIconResFinder), "ListBoxAdv.ico")]
+ public class ListBoxAdv : ItemPanelBase
+ {
+ #region Constructor
+ ///
+ /// Initializes a new instance of the ListBoxAdv class.
+ ///
+ public ListBoxAdv()
+ {
+ _SelectedItems = new CustomCollection();
+ m_ItemContainer.LayoutOrientation = eOrientation.Vertical;
+ EnsureBindingGenerator();
+ ItemVisualGenerator generator = ItemGenerator;
+ generator.CustomCollectionBinding = true;
+ generator.DataSource = _Items;
+ }
+ #endregion
+
+ #region Implementation
+ private string _CheckStateMember;
+ private CustomCollection