DotNet 4.8.1 build of DotNetBar
This commit is contained in:
663
PROMS/DotNetBar Source Code/CrumbBar/CrumbBar.cs
Normal file
663
PROMS/DotNetBar Source Code/CrumbBar/CrumbBar.cs
Normal file
@@ -0,0 +1,663 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents compact tree bread-crumb control.
|
||||
/// </summary>
|
||||
[ToolboxBitmap(typeof(CrumbBar), "CrumbBar.CrumbBar.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.CrumbBarDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false), DefaultEvent("SelectedItemChanged")]
|
||||
public class CrumbBar : ItemControl
|
||||
{
|
||||
#region Private Variables
|
||||
private CrumbBarItemsCollection _Items = null;
|
||||
private CrumbBarViewContainer _ViewContainer = null;
|
||||
private Office2007Renderer _VistaRenderer = null;
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// Occurs before SelectedItem has changed and provides opportunity to cancel the change. Set Cancel property on event arguments to true to cancel the change.
|
||||
/// </summary>
|
||||
[Description("Occurs before SelectedItem has changed and provides opportunity to cancel the change.")]
|
||||
public event CrumBarSelectionEventHandler SelectedItemChanging;
|
||||
/// <summary>
|
||||
/// Occurs after SelectedItem has changed. The change of the selected item at this point cannot be canceled. For that use SelectedItemChanging event.
|
||||
/// </summary>
|
||||
public event CrumBarSelectionEventHandler SelectedItemChanged;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CrumbBar class.
|
||||
/// </summary>
|
||||
public CrumbBar()
|
||||
: base()
|
||||
{
|
||||
_Items = new CrumbBarItemsCollection(this);
|
||||
|
||||
_ViewContainer = new CrumbBarViewContainer();
|
||||
_ViewContainer.GlobalItem = false;
|
||||
_ViewContainer.ContainerControl = this;
|
||||
_ViewContainer.Displayed = true;
|
||||
_ViewContainer.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
this.ColorScheme.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
_ViewContainer.SetOwner(this);
|
||||
InitializeVistaRenderer();
|
||||
this.SetBaseItemContainer(_ViewContainer);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
private CrumbBarItem FindCrumbBarItem(IList subitems, string name)
|
||||
{
|
||||
foreach (CrumbBarItem item in subitems)
|
||||
{
|
||||
if (item.Name == name)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
CrumbBarItem childItem = FindCrumbBarItem(item.SubItems, name);
|
||||
if ((childItem != null)) return childItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Finds CrumbBarItem with specified name.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of item to look for</param>
|
||||
/// <returns>Item or null if no item was found.</returns>
|
||||
public CrumbBarItem FindByName(string name)
|
||||
{
|
||||
return FindCrumbBarItem(this.Items, name);
|
||||
}
|
||||
|
||||
|
||||
private CrumbBarItem _SelectedItem;
|
||||
/// <summary>
|
||||
/// Gets or sets currently selected item.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance"), Description("Indicates currently selected item")]
|
||||
public CrumbBarItem SelectedItem
|
||||
{
|
||||
get { return _SelectedItem; }
|
||||
set
|
||||
{
|
||||
SetSelectedItem(value, eEventSource.Code);
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnItemsCleared()
|
||||
{
|
||||
this.SelectedItem = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the currently selected item in the control.
|
||||
/// </summary>
|
||||
/// <param name="selection">Reference to selected item.</param>
|
||||
/// <param name="source">Source of the event.</param>
|
||||
public void SetSelectedItem(CrumbBarItem selection, eEventSource source)
|
||||
{
|
||||
bool raiseChangedEvents = selection != _SelectedItem;
|
||||
|
||||
if (raiseChangedEvents)
|
||||
{
|
||||
CrumbBarSelectionEventArgs eventArgs = new CrumbBarSelectionEventArgs(selection);
|
||||
OnSelectedItemChanging(eventArgs);
|
||||
if (eventArgs.Cancel) return;
|
||||
selection = eventArgs.NewSelectedItem;
|
||||
}
|
||||
|
||||
if (_SelectedItem != null)
|
||||
_SelectedItem.IsSelected = false;
|
||||
|
||||
ArrayList newItems = new ArrayList();
|
||||
if (selection == null)
|
||||
selection = GetFirstVisibleItem();
|
||||
_ViewContainer.Expanded = false; // closes any open popups
|
||||
_ViewContainer.RestoreOverflowItems();
|
||||
|
||||
if (selection != null)
|
||||
{
|
||||
CrumbBarItem current = selection;
|
||||
while (current != null)
|
||||
{
|
||||
newItems.Insert(0, GetItemView(current, true));
|
||||
current = current.Parent as CrumbBarItem;
|
||||
}
|
||||
|
||||
UpdateSelectedItemImage(selection);
|
||||
}
|
||||
else
|
||||
UpdateSelectedItemImage(null);
|
||||
|
||||
// Remove current view items
|
||||
_ViewContainer.ClearViewItems();
|
||||
if (selection != null)
|
||||
{
|
||||
_ViewContainer.SubItems.AddRange((BaseItem[])newItems.ToArray(typeof(BaseItem)));
|
||||
}
|
||||
_ViewContainer.NeedRecalcSize = true;
|
||||
|
||||
_SelectedItem = selection;
|
||||
if (_SelectedItem != null)
|
||||
_SelectedItem.IsSelected = true;
|
||||
|
||||
this.RecalcLayout();
|
||||
|
||||
if (raiseChangedEvents)
|
||||
{
|
||||
CrumbBarSelectionEventArgs eventArgs = new CrumbBarSelectionEventArgs(selection);
|
||||
OnSelectedItemChanged(eventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
internal void RefreshView()
|
||||
{
|
||||
UpdateSelectedItemImage(_SelectedItem);
|
||||
}
|
||||
|
||||
private void UpdateSelectedItemImage(CrumbBarItem selection)
|
||||
{
|
||||
if (selection == null)
|
||||
{
|
||||
_ViewContainer.ImageLabel.Visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
CompositeImage image = selection.GetImage();
|
||||
if (image != null)
|
||||
{
|
||||
_ViewContainer.ImageLabel.Visible = true;
|
||||
if (image.IsIcon)
|
||||
_ViewContainer.ImageLabel.Icon = image.Icon;
|
||||
else
|
||||
_ViewContainer.ImageLabel.Image = image.Image;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ViewContainer.ImageLabel.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the selected item popup menu if it has menu items.
|
||||
/// </summary>
|
||||
/// <returns>true if popup was shown otherwise false</returns>
|
||||
public bool ShowSelectedItemPopupMenu()
|
||||
{
|
||||
CrumbBarItem selectedItem = this.SelectedItem;
|
||||
if (selectedItem == null) throw new NullReferenceException("SelectedItem is null");
|
||||
CrumbBarItemView view = GetItemView(selectedItem, false) as CrumbBarItemView;
|
||||
if (view != null && !view.Expanded && view.AttachedItem != null && view.AttachedItem.SubItems.Count > 0)
|
||||
{
|
||||
view.Expanded = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private object GetItemView(CrumbBarItem current, bool canCreateNewView)
|
||||
{
|
||||
for (int i = 2; i < _ViewContainer.SubItems.Count; i++)
|
||||
{
|
||||
CrumbBarItemView view = _ViewContainer.SubItems[i] as CrumbBarItemView;
|
||||
if (view != null && view.AttachedItem == current) return view;
|
||||
}
|
||||
if(canCreateNewView)
|
||||
return CrumbBarItemView.CreateViewForItem(current);
|
||||
return null;
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public CrumbBarItem GetFirstVisibleItem()
|
||||
{
|
||||
foreach (CrumbBarItem crumbBarItem in Items)
|
||||
{
|
||||
if (crumbBarItem.Visible) return crumbBarItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether an item is in selected path to the currently selected item as either one of the parents of selected item
|
||||
/// or selected item itself.
|
||||
/// </summary>
|
||||
/// <param name="item">Item to test.</param>
|
||||
/// <returns>true if item is in selected path otherwise false.</returns>
|
||||
public bool GetIsInSelectedPath(CrumbBarItem item)
|
||||
{
|
||||
for (int i = 2; i < _ViewContainer.SubItems.Count; i++)
|
||||
{
|
||||
CrumbBarItemView view = _ViewContainer.SubItems[i] as CrumbBarItemView;
|
||||
if (view != null && view.AttachedItem == item) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets collection of items assigned to the control.
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Editor("DevComponents.DotNetBar.Design.CrumbBarItemCollectionEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
|
||||
#if FRAMEWORK20
|
||||
[Browsable(false)]
|
||||
#else
|
||||
[Browsable(true)]
|
||||
#endif
|
||||
public CrumbBarItemsCollection Items
|
||||
{
|
||||
get { return _Items; }
|
||||
}
|
||||
|
||||
private eCrumbBarStyle _Style = eCrumbBarStyle.Vista;
|
||||
/// <summary>
|
||||
/// Gets or sets the visual style of the control. Default value is Windows Vista style.
|
||||
/// </summary>
|
||||
[DefaultValue(eCrumbBarStyle.Vista), Category("Appearance"), Description("Indicates visual style of the control.")]
|
||||
public eCrumbBarStyle Style
|
||||
{
|
||||
get { return _Style; }
|
||||
set
|
||||
{
|
||||
if (value != _Style)
|
||||
{
|
||||
eCrumbBarStyle oldValue = _Style;
|
||||
_Style = value;
|
||||
OnStyleChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected virtual void OnStyleChanged(eCrumbBarStyle oldValue, eCrumbBarStyle newValue)
|
||||
{
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color table used by the Vista style renderer.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public Office2007ColorTable VistaColorTable
|
||||
{
|
||||
get { return _VistaRenderer.ColorTable; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the renderer control will be rendered with.
|
||||
/// </summary>
|
||||
/// <returns>The current renderer.</returns>
|
||||
public override Rendering.BaseRenderer GetRenderer()
|
||||
{
|
||||
if (this.RenderMode == eRenderMode.Global && _Style == eCrumbBarStyle.Vista)
|
||||
return _VistaRenderer;
|
||||
return base.GetRenderer();
|
||||
}
|
||||
|
||||
private void InitializeVistaRenderer()
|
||||
{
|
||||
_VistaRenderer = new Office2007Renderer();
|
||||
Office2007ColorTable colorTable = _VistaRenderer.ColorTable;
|
||||
colorTable.CrumbBarItemView = GetCrumbBarVistaColorTable();
|
||||
// Popup menu style
|
||||
colorTable.Menu.Background = new LinearGradientColorTable(ColorScheme.GetColor("FFF0F0F0"));
|
||||
colorTable.Menu.Border = new LinearGradientColorTable(ColorScheme.GetColor("FF646464"));
|
||||
colorTable.Menu.Side = new LinearGradientColorTable(ColorScheme.GetColor("FFF1F1F1"));
|
||||
colorTable.Menu.SideBorder = new LinearGradientColorTable(ColorScheme.GetColor("FFE2E3E3"));
|
||||
colorTable.Menu.SideBorderLight = new LinearGradientColorTable(ColorScheme.GetColor("FFFFFFFF"));
|
||||
Office2007ButtonItemColorTable menu = colorTable.ButtonItemColors[0];
|
||||
menu.Default.Text = Color.Black;
|
||||
menu.MouseOver.Background = new LinearGradientColorTable(ColorScheme.GetColor("34C5EBFF"), ColorScheme.GetColor("7081D8FF"), 90);
|
||||
menu.MouseOver.OuterBorder = new LinearGradientColorTable(ColorScheme.GetColor("FF96DBFA"));
|
||||
menu.MouseOver.InnerBorder = new LinearGradientColorTable(ColorScheme.GetColor("A0FFFFFF"));
|
||||
menu.MouseOver.Text = Color.Black;
|
||||
menu.Pressed = menu.MouseOver;
|
||||
}
|
||||
|
||||
private CrumbBarItemViewColorTable GetCrumbBarVistaColorTable()
|
||||
{
|
||||
return GetCrumbBarVistaColorTable(new ColorFactory());
|
||||
}
|
||||
|
||||
internal static CrumbBarItemViewColorTable GetCrumbBarVistaColorTable(ColorFactory factory)
|
||||
{
|
||||
CrumbBarItemViewColorTable viewColorTable = new CrumbBarItemViewColorTable();
|
||||
CrumbBarItemViewStateColorTable crumbBarViewTable = new CrumbBarItemViewStateColorTable();
|
||||
viewColorTable.Default = crumbBarViewTable;
|
||||
crumbBarViewTable.Foreground = Color.Black;
|
||||
crumbBarViewTable = new CrumbBarItemViewStateColorTable();
|
||||
viewColorTable.MouseOver = crumbBarViewTable;
|
||||
crumbBarViewTable.Foreground = Color.Black;
|
||||
crumbBarViewTable.Background = new BackgroundColorBlendCollection();
|
||||
crumbBarViewTable.Background.AddRange(new BackgroundColorBlend[]{
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("EAF6FD")), 0f),
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("D7EFFC")), .5f),
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("BDE6FD")), .5f),
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("A6D9F4")), 1f)});
|
||||
crumbBarViewTable.Border = factory.GetColor(ColorScheme.GetColor("3C7FB1"));
|
||||
crumbBarViewTable.BorderLight = factory.GetColor(ColorScheme.GetColor("E0FFFFFF"));
|
||||
crumbBarViewTable = new CrumbBarItemViewStateColorTable();
|
||||
viewColorTable.MouseOverInactive = crumbBarViewTable;
|
||||
crumbBarViewTable.Foreground = Color.Black;
|
||||
crumbBarViewTable.Background = new BackgroundColorBlendCollection();
|
||||
crumbBarViewTable.Background.AddRange(new BackgroundColorBlend[]{
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFF2F2F2")), 0f),
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFEAEAEA")), .5f),
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFDCDCDC")), .5f),
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFCFCFCF")), 1f)});
|
||||
crumbBarViewTable.Border = factory.GetColor(ColorScheme.GetColor("FF8E8F8F"));
|
||||
crumbBarViewTable.BorderLight = factory.GetColor(ColorScheme.GetColor("E0FFFFFF"));
|
||||
crumbBarViewTable = new CrumbBarItemViewStateColorTable();
|
||||
viewColorTable.Pressed = crumbBarViewTable;
|
||||
crumbBarViewTable.Foreground = Color.Black;
|
||||
crumbBarViewTable.Background = new BackgroundColorBlendCollection();
|
||||
crumbBarViewTable.Background.AddRange(new BackgroundColorBlend[]{
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFC2E4F6")), 0f),
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFC2E4F6")), .5f),
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFA9D9F2")), .5f),
|
||||
new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FF90CBEB")), 1f)});
|
||||
crumbBarViewTable.Border = factory.GetColor(ColorScheme.GetColor("FF6E8D9F"));
|
||||
crumbBarViewTable.BorderLight = factory.GetColor(ColorScheme.GetColor("906E8D9F"));
|
||||
|
||||
return viewColorTable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the SelectedItemChanging event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnSelectedItemChanging(CrumbBarSelectionEventArgs e)
|
||||
{
|
||||
CrumBarSelectionEventHandler eh = SelectedItemChanging;
|
||||
if (eh != null) eh(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the SelectedItemChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnSelectedItemChanged(CrumbBarSelectionEventArgs e)
|
||||
{
|
||||
CrumBarSelectionEventHandler eh = SelectedItemChanged;
|
||||
if (eh != null) eh(this, e);
|
||||
}
|
||||
|
||||
protected override Size DefaultSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Size(200, 22);
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
|
||||
private Size _PreferredSize = Size.Empty;
|
||||
[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 (!_PreferredSize.IsEmpty) return _PreferredSize;
|
||||
|
||||
if (!BarFunctions.IsHandleValid(this))
|
||||
return base.GetPreferredSize(proposedSize);
|
||||
|
||||
if (this.Items.Count == 0 || !BarFunctions.IsHandleValid(this) || _ViewContainer.SubItems.Count == 0)
|
||||
return new Size(base.GetPreferredSize(proposedSize).Width, 22);
|
||||
|
||||
int height = ElementStyleLayout.VerticalStyleWhiteSpace(this.GetBackgroundStyle());
|
||||
height += _ViewContainer.CalculatedHeight > 0 ? _ViewContainer.CalculatedHeight : 20;
|
||||
|
||||
_PreferredSize = new Size(proposedSize.Width, height);
|
||||
return _PreferredSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InvalidateAutoSize()
|
||||
{
|
||||
_PreferredSize = Size.Empty;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void AdjustSize()
|
||||
{
|
||||
if (this.AutoSize)
|
||||
{
|
||||
System.Drawing.Size prefSize = base.PreferredSize;
|
||||
if (prefSize.Width > 0 && prefSize.Height > 0)
|
||||
this.Size = base.PreferredSize;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override Image BackgroundImage
|
||||
{
|
||||
get { return base.BackgroundImage; }
|
||||
set { base.BackgroundImage = value; }
|
||||
}
|
||||
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
base.OnHandleCreated(e);
|
||||
#if FRAMEWORK20
|
||||
if (this.AutoSize)
|
||||
this.AdjustSize();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
private string _PathSeparator = System.IO.Path.PathSeparator.ToString();
|
||||
/// <summary>
|
||||
/// Gets or sets the delimiter string that the tree node path uses.
|
||||
/// </summary>
|
||||
[DefaultValue("\\"), Browsable(false), Description("Indicates the delimiter string that the tree node path uses.")]
|
||||
public string PathSeparator
|
||||
{
|
||||
get { return _PathSeparator; }
|
||||
set { _PathSeparator = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns full path to the given node.
|
||||
/// </summary>
|
||||
/// <param name="item">Node to return path to.</param>
|
||||
/// <returns>Full path to the node.</returns>
|
||||
internal static string GetFullPath(CrumbBarItem item, string pathSeparator)
|
||||
{
|
||||
if (item == null)
|
||||
throw new ArgumentNullException("node");
|
||||
|
||||
StringBuilder sb = new StringBuilder(item.Text);
|
||||
item = item.Parent as CrumbBarItem;
|
||||
while (item != null)
|
||||
{
|
||||
sb.Insert(0, item.Text + pathSeparator);
|
||||
item = item.Parent as CrumbBarItem;
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Property Hiding
|
||||
[Browsable(false)]
|
||||
public override eBarImageSize ImageSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImageSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImageSize = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override System.Windows.Forms.ImageList ImagesLarge
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImagesLarge;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImagesLarge = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override System.Windows.Forms.ImageList ImagesMedium
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImagesMedium;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImagesMedium = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override Font KeyTipsFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.KeyTipsFont;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.KeyTipsFont = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override bool ShowShortcutKeysInToolTips
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ShowShortcutKeysInToolTips;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ShowShortcutKeysInToolTips = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override bool ThemeAware
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ThemeAware;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ThemeAware = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
}
|
||||
}
|
||||
#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
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
#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
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Event support
|
||||
/// <summary>
|
||||
/// Defines delegate for CrumbBar selection events.
|
||||
/// </summary>
|
||||
public delegate void CrumBarSelectionEventHandler(object sender, CrumbBarSelectionEventArgs e);
|
||||
/// <summary>
|
||||
/// Provides data for CrumbBar selection events.
|
||||
/// </summary>
|
||||
public class CrumbBarSelectionEventArgs : CancelEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets newly selected item.
|
||||
/// </summary>
|
||||
public CrumbBarItem NewSelectedItem = null;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CrumbBarSelectionEventArgs class.
|
||||
/// </summary>
|
||||
/// <param name="newSelectedItem"></param>
|
||||
public CrumbBarSelectionEventArgs(CrumbBarItem newSelectedItem)
|
||||
{
|
||||
NewSelectedItem = newSelectedItem;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
BIN
PROMS/DotNetBar Source Code/CrumbBar/CrumbBar.ico
Normal file
BIN
PROMS/DotNetBar Source Code/CrumbBar/CrumbBar.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarIcon.psd
Normal file
BIN
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarIcon.psd
Normal file
Binary file not shown.
713
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarItem.cs
Normal file
713
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarItem.cs
Normal file
@@ -0,0 +1,713 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an item for CrumbBar control.
|
||||
/// </summary>
|
||||
[Designer("DevComponents.DotNetBar.Design.CrumbBarItemDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), ToolboxItem(false), DesignTimeVisible(false)]
|
||||
public class CrumbBarItem : ButtonItem
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override void OnClick()
|
||||
{
|
||||
Select(eEventSource.Mouse);
|
||||
base.OnClick();
|
||||
}
|
||||
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool ShowSubItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ShowSubItems = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _IsSelected = false;
|
||||
/// <summary>
|
||||
/// Gets whether item is selected item in CrumbBar control.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _IsSelected; }
|
||||
#if FRAMEWORK20
|
||||
internal set
|
||||
#else
|
||||
set
|
||||
#endif
|
||||
{
|
||||
_IsSelected = value;
|
||||
if (_IsSelected)
|
||||
this.FontBold = true;
|
||||
else
|
||||
this.FontBold = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Select(eEventSource source)
|
||||
{
|
||||
CrumbBar bar = this.GetOwner() as CrumbBar;
|
||||
if (bar != null) bar.SetSelectedItem(this, source);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the collection of sub items.
|
||||
/// </summary>
|
||||
[Browsable(false), Editor("DevComponents.DotNetBar.Design.CrumbBarItemCollectionEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)]
|
||||
public override SubItemsCollection SubItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.SubItems;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnImageChanged()
|
||||
{
|
||||
base.OnImageChanged();
|
||||
CrumbBar bar = this.GetOwner() as CrumbBar;
|
||||
if (bar != null && bar.SelectedItem == this)
|
||||
{
|
||||
bar.RefreshView();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnParentChanged()
|
||||
{
|
||||
CrumbBar bar = this.GetOwner() as CrumbBar;
|
||||
if (bar != null)
|
||||
{
|
||||
if (bar.SelectedItem == this || bar.GetIsInSelectedPath(this))
|
||||
bar.SetSelectedItem(bar.SelectedItem, eEventSource.Code);
|
||||
}
|
||||
base.OnParentChanged();
|
||||
}
|
||||
|
||||
protected internal override void OnAfterItemRemoved(BaseItem objItem, int itemIndex)
|
||||
{
|
||||
if (objItem is CrumbBarItem && ((CrumbBarItem)objItem).IsSelected)
|
||||
{
|
||||
CrumbBar bar = this.GetOwner() as CrumbBar;
|
||||
if (bar != null)
|
||||
bar.SetSelectedItem(this, eEventSource.Code);
|
||||
}
|
||||
base.OnAfterItemRemoved(objItem, itemIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string FullPath
|
||||
{
|
||||
get
|
||||
{
|
||||
CrumbBar bar = this.GetOwner() as CrumbBar;
|
||||
if (bar == null)
|
||||
return "";
|
||||
return CrumbBar.GetFullPath(this, bar.PathSeparator);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Property Hiding
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override string AlternateShortCutText
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.AlternateShortCutText;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.AlternateShortCutText = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool AutoCheckOnClick
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.AutoCheckOnClick;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.AutoCheckOnClick = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool AutoCollapseOnClick
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.AutoCollapseOnClick;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.AutoCollapseOnClick = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool AutoExpandOnClick
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.AutoExpandOnClick;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.AutoExpandOnClick = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool BeginGroup
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.BeginGroup;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.BeginGroup = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override eButtonStyle ButtonStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ButtonStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ButtonStyle = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool CanCustomize
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.CanCustomize;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.CanCustomize = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override string Category
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Category;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Category = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool Checked
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Checked;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Checked = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool ClickAutoRepeat
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ClickAutoRepeat;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ClickAutoRepeat = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override int ClickRepeatInterval
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ClickRepeatInterval;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ClickRepeatInterval = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override eButtonColor ColorTable
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ColorTable;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ColorTable = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override string CustomColorName
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.CustomColorName;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.CustomColorName = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Description;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Description = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool FontBold
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.FontBold;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.FontBold = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool FontItalic
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.FontItalic;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.FontItalic = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool FontUnderline
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.FontUnderline;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.FontUnderline = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool GlobalItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.GlobalItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.GlobalItem = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override string GlobalName
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.GlobalName;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.GlobalName = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool HotFontBold
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.HotFontBold;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.HotFontBold = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool HotFontUnderline
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.HotFontUnderline;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.HotFontUnderline = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override eHotTrackingStyle HotTrackingStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.HotTrackingStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.HotTrackingStyle = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override System.Drawing.Image HoverImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.HoverImage;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.HoverImage = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override int HoverImageIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.HoverImageIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.HoverImageIndex = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override System.Drawing.Icon Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Icon;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Icon = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override eButtonImageListSelection ImageListSizeSelection
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImageListSizeSelection;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImageListSizeSelection = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override int ImagePaddingHorizontal
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImagePaddingHorizontal;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImagePaddingHorizontal = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override int ImagePaddingVertical
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImagePaddingVertical;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImagePaddingVertical = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override eImagePosition ImagePosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImagePosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImagePosition = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override System.Drawing.Image ImageSmall
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImageSmall;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImageSmall = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override eItemAlignment ItemAlignment
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ItemAlignment;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ItemAlignment = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override string KeyTips
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.KeyTips;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.KeyTips = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override eMenuVisibility MenuVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.MenuVisibility;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.MenuVisibility = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override string OptionGroup
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.OptionGroup;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.OptionGroup = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override ePersonalizedMenus PersonalizedMenus
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PersonalizedMenus;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PersonalizedMenus = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override ePopupSide PopupSide
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PopupSide;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PopupSide = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override ePopupType PopupType
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PopupType;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PopupType = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override int PopupWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PopupWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PopupWidth = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override System.Drawing.Image PressedImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PressedImage;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PressedImage = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override int PressedImageIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PressedImageIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PressedImageIndex = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool RibbonWordWrap
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.RibbonWordWrap;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.RibbonWordWrap = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override ShapeDescriptor Shape
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Shape;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Shape = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool SplitButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.SplitButton;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.SplitButton = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool Stretch
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Stretch;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Stretch = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override int SubItemsExpandWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.SubItemsExpandWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.SubItemsExpandWidth = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool ThemeAware
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ThemeAware;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ThemeAware = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override System.Drawing.Size FixedSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.FixedSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.FixedSize = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override int PulseSpeed
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PulseSpeed;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PulseSpeed = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool StopPulseOnMouseOver
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.StopPulseOnMouseOver;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.StopPulseOnMouseOver = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
235
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarItemView.cs
Normal file
235
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarItemView.cs
Normal file
@@ -0,0 +1,235 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a view of CrumbBarItem displayed inside of CrumbBar control.
|
||||
/// </summary>
|
||||
public class CrumbBarItemView : ButtonItem
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CrumbBarItemView class.
|
||||
/// </summary>
|
||||
public CrumbBarItemView():base()
|
||||
{
|
||||
this.SubItemsExpandWidth = 15;
|
||||
this.HorizontalPadding = 2;
|
||||
}
|
||||
|
||||
private CrumbBarItem _AttachedItem;
|
||||
/// <summary>
|
||||
/// Gets the item attached to the view.
|
||||
/// </summary>
|
||||
public CrumbBarItem AttachedItem
|
||||
{
|
||||
get { return _AttachedItem; }
|
||||
internal set
|
||||
{
|
||||
if (_AttachedItem != null)
|
||||
{
|
||||
_AttachedItem.TextChanged -= new EventHandler(AttachedItemTextChanged);
|
||||
_AttachedItem.SubItemsChanged -= new System.ComponentModel.CollectionChangeEventHandler(AttachedItemSubItemsChanged);
|
||||
_AttachedItem.PopupClose -= new EventHandler(AttachedItemPopupClose);
|
||||
}
|
||||
_AttachedItem = value;
|
||||
|
||||
if (_AttachedItem != null)
|
||||
{
|
||||
this.Text = _AttachedItem.Text;
|
||||
this.Cursor = _AttachedItem.Cursor;
|
||||
this.ForeColor = _AttachedItem.ForeColor;
|
||||
this.HotForeColor = _AttachedItem.HotForeColor;
|
||||
this.Tooltip = _AttachedItem.Tooltip;
|
||||
|
||||
_AttachedItem.TextChanged += new EventHandler(AttachedItemTextChanged);
|
||||
_AttachedItem.SubItemsChanged += new System.ComponentModel.CollectionChangeEventHandler(AttachedItemSubItemsChanged);
|
||||
_AttachedItem.PopupClose += new EventHandler(AttachedItemPopupClose);
|
||||
if (AnyVisibleItems)
|
||||
this.PopupType = ePopupType.Container;
|
||||
else
|
||||
this.PopupType = ePopupType.Menu;
|
||||
}
|
||||
else
|
||||
this.PopupType = ePopupType.Menu;
|
||||
}
|
||||
}
|
||||
|
||||
private DateTime _PopupCloseTime = DateTime.MinValue;
|
||||
private void AttachedItemPopupClose(object sender, EventArgs e)
|
||||
{
|
||||
_Expanded = false;
|
||||
CrumbBarViewContainer c = this.Parent as CrumbBarViewContainer;
|
||||
if (c != null)
|
||||
c.OnSubItemExpandChange(this);
|
||||
|
||||
_PopupCloseTime = DateTime.Now;
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
public override void InternalMouseDown(MouseEventArgs objArg)
|
||||
{
|
||||
if (_PopupCloseTime != DateTime.MinValue && DateTime.Now.Subtract(_PopupCloseTime).TotalMilliseconds < 200)
|
||||
{
|
||||
_PopupCloseTime = DateTime.MinValue;
|
||||
return;
|
||||
}
|
||||
base.InternalMouseDown(objArg);
|
||||
}
|
||||
|
||||
public override void InternalMouseEnter()
|
||||
{
|
||||
CrumbBarViewContainer parent = this.Parent as CrumbBarViewContainer;
|
||||
if (parent != null && parent.Expanded && AnyVisibleItems)
|
||||
{
|
||||
parent.Expanded = false;
|
||||
this.Expanded = true;
|
||||
}
|
||||
base.InternalMouseEnter();
|
||||
}
|
||||
|
||||
private bool AnyVisibleItems
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_AttachedItem != null)
|
||||
{
|
||||
foreach (BaseItem item in _AttachedItem.SubItems)
|
||||
{
|
||||
if (item.Visible) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void AttachedItemSubItemsChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e)
|
||||
{
|
||||
UpdatePopupType();
|
||||
}
|
||||
|
||||
private void UpdatePopupType()
|
||||
{
|
||||
if (AnyVisibleItems && !(this.Parent is CrumbBarOverflowButton))
|
||||
this.PopupType = ePopupType.Container;
|
||||
else
|
||||
this.PopupType = ePopupType.Menu;
|
||||
}
|
||||
|
||||
protected override void OnParentChanged()
|
||||
{
|
||||
UpdatePopupType();
|
||||
base.OnParentChanged();
|
||||
}
|
||||
|
||||
void AttachedItemTextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.Text = _AttachedItem.Text;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
this.AttachedItem = null;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
internal static object CreateViewForItem(CrumbBarItem item)
|
||||
{
|
||||
CrumbBarItemView view = new CrumbBarItemView();
|
||||
view.AttachedItem = item;
|
||||
return view;
|
||||
}
|
||||
|
||||
private bool _Expanded = false;
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), System.ComponentModel.DefaultValue(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
|
||||
public override bool Expanded
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Expanded;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Expanded != value)
|
||||
{
|
||||
_Expanded = value;
|
||||
InternalExpandedChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InternalExpandedChanged()
|
||||
{
|
||||
if (!_Expanded)
|
||||
{
|
||||
_AttachedItem.Expanded = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Control parent=this.ContainerControl as Control;
|
||||
if(parent==null) return;
|
||||
Point p = new Point(this.SubItemsRect.X - 10, this.SubItemsRect.Bottom - 1);
|
||||
p.Offset(this.DisplayRectangle.Location.X, this.DisplayRectangle.Location.Y);
|
||||
p = parent.PointToScreen(p);
|
||||
_AttachedItem.PopupMenu(p);
|
||||
}
|
||||
|
||||
CrumbBarViewContainer c = this.Parent as CrumbBarViewContainer;
|
||||
if (c != null)
|
||||
c.OnSubItemExpandChange(this);
|
||||
}
|
||||
|
||||
protected override void OnClick()
|
||||
{
|
||||
CrumbBar bar = this.ContainerControl as CrumbBar;
|
||||
if (bar == null) bar = this.GetOwner() as CrumbBar;
|
||||
|
||||
base.OnClick();
|
||||
|
||||
if (bar != null)
|
||||
{
|
||||
bar.SelectedItem = _AttachedItem;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RenderButton(ItemPaintArgs p)
|
||||
{
|
||||
if (!p.IsOnMenu)
|
||||
{
|
||||
Rendering.BaseRenderer renderer = p.Renderer;
|
||||
if (renderer != null)
|
||||
{
|
||||
p.ButtonItemRendererEventArgs.Graphics = p.Graphics;
|
||||
p.ButtonItemRendererEventArgs.ButtonItem = this;
|
||||
p.ButtonItemRendererEventArgs.ItemPaintArgs = p;
|
||||
renderer.DrawCrumbBarItemView(p.ButtonItemRendererEventArgs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
base.RenderButton(p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of ExplorerBarContainerItem item
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
CrumbBarItemView objCopy = new CrumbBarItemView();
|
||||
this.CopyToItem(objCopy);
|
||||
return objCopy;
|
||||
}
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
CrumbBarItemView objCopy = copy as CrumbBarItemView;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
253
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarItemViewPainter.cs
Normal file
253
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarItemViewPainter.cs
Normal file
@@ -0,0 +1,253 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
internal class CrumbBarItemViewPainter: IOffice2007Painter
|
||||
{
|
||||
#region IOffice2007Painter
|
||||
private Office2007ColorTable _ColorTable = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets color table used by renderer.
|
||||
/// </summary>
|
||||
public Office2007ColorTable ColorTable
|
||||
{
|
||||
get { return _ColorTable; }
|
||||
set { _ColorTable = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public void Paint(ButtonItem item, ItemPaintArgs pa)
|
||||
{
|
||||
Paint(item, pa, _ColorTable.CrumbBarItemView);
|
||||
}
|
||||
|
||||
public void Paint(ButtonItem item, ItemPaintArgs pa, CrumbBarItemViewColorTable itemColorTable)
|
||||
{
|
||||
Graphics g =pa.Graphics;
|
||||
|
||||
CrumbBarItemViewStateColorTable stateTable = itemColorTable.Default;
|
||||
CrumbBarItemViewStateColorTable stateTable2 = null;
|
||||
bool isPressed = false;
|
||||
if (item.IsMouseDown || item.Expanded)
|
||||
{
|
||||
stateTable = itemColorTable.Pressed;
|
||||
isPressed = true;
|
||||
}
|
||||
else if (item.IsMouseOverExpand)
|
||||
{
|
||||
stateTable = itemColorTable.MouseOverInactive;
|
||||
stateTable2 = itemColorTable.MouseOver;
|
||||
}
|
||||
else if (item.IsMouseOver)
|
||||
stateTable = itemColorTable.MouseOver;
|
||||
|
||||
Rectangle rect = item.DisplayRectangle;
|
||||
rect.Width--;
|
||||
rect.Height--;
|
||||
Rectangle expandRect = item.GetTotalSubItemsRect();
|
||||
if (!expandRect.IsEmpty)
|
||||
{
|
||||
expandRect.Offset(rect.Location);
|
||||
expandRect.Width--;
|
||||
expandRect.Height--;
|
||||
}
|
||||
|
||||
PaintBackground(item, g, stateTable, stateTable2, isPressed, ref rect, ref expandRect);
|
||||
|
||||
Color textColor = stateTable.Foreground;
|
||||
if (!item.ForeColor.IsEmpty)
|
||||
textColor = item.ForeColor;
|
||||
if (!textColor.IsEmpty)
|
||||
{
|
||||
// Render text
|
||||
Font font = item.GetFont(pa, false);
|
||||
bool rightToLeft = pa.RightToLeft;
|
||||
rect = GetTextRectangle(item);
|
||||
eTextFormat stringFormat = eTextFormat.Left | eTextFormat.VerticalCenter | eTextFormat.HidePrefix;
|
||||
if (item.TextMarkupBody == null)
|
||||
{
|
||||
TextDrawing.DrawString(g, ButtonItemPainter.GetDrawText(item.Text), font, textColor, rect, stringFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, textColor, rightToLeft);
|
||||
d.HotKeyPrefixVisible = !((stringFormat & eTextFormat.HidePrefix) == eTextFormat.HidePrefix);
|
||||
d.ContextObject = item;
|
||||
Rectangle mr = new Rectangle(rect.X, rect.Y + (rect.Height - item.TextMarkupBody.Bounds.Height) / 2 + 1, item.TextMarkupBody.Bounds.Width, item.TextMarkupBody.Bounds.Height);
|
||||
item.TextMarkupBody.Bounds = mr;
|
||||
item.TextMarkupBody.Render(d);
|
||||
}
|
||||
|
||||
if ((item.SubItems.Count > 0 || item.PopupType == ePopupType.Container) && item.ShowSubItems)
|
||||
{
|
||||
// Render expand sign
|
||||
GraphicsPath path = GetExpandPath(item, expandRect);
|
||||
if (path != null)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
using(Brush brush=new SolidBrush(stateTable.Foreground))
|
||||
g.FillPath(brush, path);
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void PaintBackground(ButtonItem item, Graphics g, CrumbBarItemViewStateColorTable stateTable, CrumbBarItemViewStateColorTable stateTable2, bool isPressed, ref Rectangle rect, ref Rectangle expandRect)
|
||||
{
|
||||
if (stateTable.Background != null && stateTable.Background.Count > 0)
|
||||
{
|
||||
using (Brush brush = DisplayHelp.CreateBrush(rect, stateTable.Background, 90, eGradientType.Linear))
|
||||
g.FillRectangle(brush, rect);
|
||||
if (item.IsMouseOverExpand && stateTable2 != null && stateTable2.Background != null && stateTable2.Background.Count > 0)
|
||||
{
|
||||
using (Brush brush = DisplayHelp.CreateBrush(rect, stateTable2.Background, 90, eGradientType.Linear))
|
||||
g.FillRectangle(brush, expandRect);
|
||||
}
|
||||
}
|
||||
|
||||
if (!stateTable.Border.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(stateTable.Border, 1))
|
||||
{
|
||||
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);
|
||||
Pen pen2 = stateTable2 != null ? new Pen(stateTable2.Border, 1) : pen;
|
||||
if (!expandRect.IsEmpty)
|
||||
{
|
||||
g.DrawLine(pen2, expandRect.X, expandRect.Y, expandRect.X, expandRect.Bottom);
|
||||
}
|
||||
if (isPressed)
|
||||
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
|
||||
|
||||
g.DrawLine(pen2, rect.Right, rect.Y, rect.Right, rect.Bottom);
|
||||
if (stateTable2 != null) pen2.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (!stateTable.BorderLight.IsEmpty)
|
||||
{
|
||||
Rectangle rectLight = rect;
|
||||
if (!expandRect.IsEmpty)
|
||||
rectLight.Width -= expandRect.Width;
|
||||
rectLight.Inflate(-1, 0);
|
||||
using (Pen pen = new Pen(stateTable.BorderLight, 1))
|
||||
{
|
||||
if (isPressed)
|
||||
{
|
||||
g.DrawLine(pen, rectLight.X, rectLight.Y, rectLight.Right, rectLight.Y);
|
||||
g.DrawLine(pen, rectLight.X, rectLight.Y, rectLight.X, rectLight.Bottom);
|
||||
if (!expandRect.IsEmpty)
|
||||
{
|
||||
rectLight = expandRect;
|
||||
rectLight.Inflate(-1, 0);
|
||||
g.DrawLine(pen, rectLight.X, rectLight.Y, rectLight.Right, rectLight.Y);
|
||||
g.DrawLine(pen, rectLight.X, rectLight.Y, rectLight.X, rectLight.Bottom);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawRectangle(pen, rectLight);
|
||||
if (!expandRect.IsEmpty)
|
||||
{
|
||||
rectLight = expandRect;
|
||||
rectLight.Inflate(-1, 0);
|
||||
g.DrawRectangle(pen, rectLight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GraphicsPath GetExpandPath(ButtonItem item, Rectangle expandRect)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
if (item.Expanded)
|
||||
{
|
||||
Point p = new Point(expandRect.X + (expandRect.Width - Dpi.Width6) / 2, expandRect.Y + (expandRect.Height - 1) / 2);
|
||||
if (item.IsMouseDown) p.Offset(1, 1);
|
||||
path.AddLine(p.X, p.Y, p.X + Dpi.Width8, p.Y);
|
||||
path.AddLine(p.X + Dpi.Width8, p.Y, p.X + Dpi.Width4, p.Y + Dpi.Height4);
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
else
|
||||
{
|
||||
Point p = new Point(expandRect.X + (expandRect.Width - Dpi.Width2) / 2, expandRect.Y + (expandRect.Height - Dpi.Height7) / 2);
|
||||
if (item.IsMouseDown) p.Offset(1, 1);
|
||||
path.AddLine(p.X, p.Y, p.X, p.Y + Dpi.Height8);
|
||||
path.AddLine(p.X, p.Y + Dpi.Height8, p.X + Dpi.Width4, p.Y + Dpi.Height4);
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
protected virtual Rectangle GetTextRectangle(ButtonItem button)
|
||||
{
|
||||
Rectangle itemRect = button.DisplayRectangle;
|
||||
Rectangle textRect = button.TextDrawRect;
|
||||
//Rectangle imageRect = button.ImageDrawRect;
|
||||
|
||||
textRect.Offset(itemRect.Left, itemRect.Top);
|
||||
|
||||
if (textRect.Right > itemRect.Right)
|
||||
textRect.Width = itemRect.Right - textRect.Left;
|
||||
textRect.X += 2;
|
||||
textRect.Y--;
|
||||
if (button.IsMouseDown) textRect.Offset(1, 1);
|
||||
return textRect;
|
||||
}
|
||||
|
||||
public void PaintOverflowButton(ButtonItem item, ItemPaintArgs pa)
|
||||
{
|
||||
PaintOverflowButton(item, pa, _ColorTable.CrumbBarItemView);
|
||||
}
|
||||
|
||||
public void PaintOverflowButton(ButtonItem item, ItemPaintArgs pa, CrumbBarItemViewColorTable itemColorTable)
|
||||
{
|
||||
Graphics g =pa.Graphics;
|
||||
|
||||
CrumbBarItemViewStateColorTable stateTable = itemColorTable.Default;
|
||||
CrumbBarItemViewStateColorTable stateTable2 = null;
|
||||
bool isPressed = false;
|
||||
if (item.IsMouseDown || item.Expanded)
|
||||
{
|
||||
stateTable = itemColorTable.Pressed;
|
||||
isPressed = true;
|
||||
}
|
||||
else if (item.IsMouseOver)
|
||||
stateTable = itemColorTable.MouseOver;
|
||||
|
||||
Rectangle rect = item.DisplayRectangle;
|
||||
rect.Width--;
|
||||
rect.Height--;
|
||||
Rectangle expandRect = Rectangle.Empty;
|
||||
|
||||
PaintBackground(item, g, stateTable, stateTable2, isPressed, ref rect, ref expandRect);
|
||||
|
||||
Color textColor = stateTable.Foreground;
|
||||
if (!textColor.IsEmpty)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
Point p = new Point(rect.X + (rect.Width - 7) / 2, rect.Y + (rect.Height - 5) / 2);
|
||||
if (isPressed)
|
||||
p.Offset(1, 1);
|
||||
using (Pen pen = new Pen(textColor, 1))
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
g.DrawLine(pen, p.X + 3, p.Y, p.X, p.Y + 2);
|
||||
g.DrawLine(pen, p.X, p.Y + 2, p.X + 3, p.Y + 4);
|
||||
p.X += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
203
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarItemsCollection.cs
Normal file
203
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarItemsCollection.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents collection of CrumbBarItem buttons.
|
||||
/// </summary>
|
||||
public class CrumbBarItemsCollection : CollectionBase
|
||||
{
|
||||
#region Private Variables
|
||||
private CrumbBar _Parent = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CrumbBarItemsCollection class.
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
public CrumbBarItemsCollection(CrumbBar parent)
|
||||
{
|
||||
_Parent = parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the node this collection is associated with.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public CrumbBar Parent
|
||||
{
|
||||
get { return _Parent; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the node collection belongs to.
|
||||
/// </summary>
|
||||
/// <param name="parent">CrumbBarItem that is parent of this collection.</param>
|
||||
internal void SetParent(CrumbBar parent)
|
||||
{
|
||||
_Parent = parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds new object to the collection.
|
||||
/// </summary>
|
||||
/// <param name="ch">Object to add.</param>
|
||||
/// <returns>Index of newly added object.</returns>
|
||||
public int Add(CrumbBarItem ch)
|
||||
{
|
||||
return List.Add(ch);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns reference to the object in collection based on it's index.
|
||||
/// </summary>
|
||||
public CrumbBarItem this[int index]
|
||||
{
|
||||
get { return (CrumbBarItem)(List[index]); }
|
||||
set { List[index] = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns reference to the object in collection based on it's name.
|
||||
/// </summary>
|
||||
public CrumbBarItem this[string name]
|
||||
{
|
||||
get { return GetByName(name); }
|
||||
set
|
||||
{
|
||||
int index = GetIndexByName(name);
|
||||
if (index == -1)
|
||||
throw new ArgumentException("name cannot be found in this collection");
|
||||
|
||||
List[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts new object into the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">Position of the object.</param>
|
||||
/// <param name="value">Object to insert.</param>
|
||||
public void Insert(int index, CrumbBarItem value)
|
||||
{
|
||||
List.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns index of the object inside of the collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Reference to the object.</param>
|
||||
/// <returns>Index of the object.</returns>
|
||||
public int IndexOf(CrumbBarItem value)
|
||||
{
|
||||
return List.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether collection contains specified object.
|
||||
/// </summary>
|
||||
/// <param name="value">Object to look for.</param>
|
||||
/// <returns>true if object is part of the collection, otherwise false.</returns>
|
||||
public bool Contains(CrumbBarItem value)
|
||||
{
|
||||
return List.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes specified object from the collection.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void Remove(CrumbBarItem value)
|
||||
{
|
||||
List.Remove(value);
|
||||
}
|
||||
|
||||
protected override void OnSet(int index, object oldValue, object newValue)
|
||||
{
|
||||
CrumbBarItem item = (CrumbBarItem)oldValue;
|
||||
item.SetOwner(null);
|
||||
item = (CrumbBarItem)newValue;
|
||||
item.SetOwner(_Parent);
|
||||
|
||||
base.OnSet(index, oldValue, newValue);
|
||||
}
|
||||
|
||||
protected override void OnRemoveComplete(int index, object value)
|
||||
{
|
||||
CrumbBarItem item = (CrumbBarItem)value;
|
||||
item.SetOwner(null);
|
||||
if (item.IsSelected)
|
||||
_Parent.SetSelectedItem(null, eEventSource.Code);
|
||||
|
||||
base.OnRemoveComplete(index, value);
|
||||
}
|
||||
protected override void OnInsertComplete(int index, object value)
|
||||
{
|
||||
CrumbBarItem item = (CrumbBarItem)value;
|
||||
item.SetOwner(_Parent);
|
||||
item.ContainerControl = _Parent;
|
||||
item.Style = eDotNetBarStyle.Office2007;
|
||||
base.OnInsertComplete(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies collection into the specified array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to copy collection to.</param>
|
||||
/// <param name="index">Starting index.</param>
|
||||
public void CopyTo(CrumbBarItem[] array, int index)
|
||||
{
|
||||
List.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies contained items to the CrumbBarItem array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to copy to.</param>
|
||||
internal void CopyTo(CrumbBarItem[] array)
|
||||
{
|
||||
List.CopyTo(array, 0);
|
||||
}
|
||||
|
||||
protected override void OnClear()
|
||||
{
|
||||
foreach (CrumbBarItem item in List)
|
||||
{
|
||||
item.SetOwner(null);
|
||||
}
|
||||
|
||||
base.OnClear();
|
||||
}
|
||||
|
||||
protected override void OnClearComplete()
|
||||
{
|
||||
if (_Parent != null)
|
||||
_Parent.OnItemsCleared();
|
||||
base.OnClearComplete();
|
||||
}
|
||||
|
||||
private CrumbBarItem GetByName(string name)
|
||||
{
|
||||
foreach (CrumbBarItem d in this.List)
|
||||
{
|
||||
if (d.Name == name)
|
||||
return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int GetIndexByName(string name)
|
||||
{
|
||||
for (int i = 0; i < this.List.Count; i++)
|
||||
{
|
||||
CrumbBarItem item = this[i];
|
||||
if (item.Name == name)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
public class CrumbBarOverflowButton : ButtonItem
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override void RenderButton(ItemPaintArgs p)
|
||||
{
|
||||
if (!p.IsOnMenu)
|
||||
{
|
||||
Rendering.BaseRenderer renderer = p.Renderer;
|
||||
if (renderer != null)
|
||||
{
|
||||
p.ButtonItemRendererEventArgs.Graphics = p.Graphics;
|
||||
p.ButtonItemRendererEventArgs.ButtonItem = this;
|
||||
p.ButtonItemRendererEventArgs.ItemPaintArgs = p;
|
||||
renderer.DrawCrumbBarOverflowItem(p.ButtonItemRendererEventArgs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
base.RenderButton(p);
|
||||
}
|
||||
|
||||
public override void RecalcSize()
|
||||
{
|
||||
m_Rect.Width = 16;
|
||||
m_Rect.Height = 11;
|
||||
m_NeedRecalcSize = false;
|
||||
}
|
||||
|
||||
public override void InternalMouseEnter()
|
||||
{
|
||||
CrumbBarViewContainer parent = this.Parent as CrumbBarViewContainer;
|
||||
if (parent != null && parent.Expanded)
|
||||
{
|
||||
parent.Expanded = false;
|
||||
this.Expanded = true;
|
||||
}
|
||||
base.InternalMouseEnter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of BaseItem.
|
||||
/// </summary>
|
||||
public CrumbBarOverflowButton():this("","") {}
|
||||
/// <summary>
|
||||
/// Creates new instance of BaseItem and assigns item name.
|
||||
/// </summary>
|
||||
/// <param name="sItemName">Item name.</param>
|
||||
public CrumbBarOverflowButton(string sItemName) : this(sItemName, "") { }
|
||||
/// <summary>
|
||||
/// Creates new instance of BaseItem and assigns item name and item text.
|
||||
/// </summary>
|
||||
/// <param name="itemName">Item Name</param>
|
||||
/// <param name="itemText">Item Text</param>
|
||||
public CrumbBarOverflowButton(string itemName, string itemText)
|
||||
: base(itemName, itemText)
|
||||
{
|
||||
this.AutoExpandOnClick = true;
|
||||
this.ShowSubItems = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of ExplorerBarContainerItem item
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
CrumbBarOverflowButton objCopy = new CrumbBarOverflowButton();
|
||||
this.CopyToItem(objCopy);
|
||||
return objCopy;
|
||||
}
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
CrumbBarOverflowButton objCopy = copy as CrumbBarOverflowButton;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
255
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarViewContainer.cs
Normal file
255
PROMS/DotNetBar Source Code/CrumbBar/CrumbBarViewContainer.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents internal CrumbBar view container.
|
||||
/// </summary>
|
||||
internal class CrumbBarViewContainer : ImageItem
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CrumbBarViewContainer class.
|
||||
/// </summary>
|
||||
public CrumbBarViewContainer()
|
||||
: base()
|
||||
{
|
||||
LabelItem imageLabel = new LabelItem("sys_crumbbarimagelabel");
|
||||
this.SubItems.Add(imageLabel);
|
||||
|
||||
CrumbBarOverflowButton overflowButton = new CrumbBarOverflowButton("sys_crumbbaroverflowbutton");
|
||||
this.SubItems.Add(overflowButton);
|
||||
m_IsContainer = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recalculates the size of the item
|
||||
/// </summary>
|
||||
public override void RecalcSize()
|
||||
{
|
||||
if (_InternalRemove) return;
|
||||
|
||||
Point pos = m_Rect.Location;
|
||||
Size containerSize = m_Rect.Size;
|
||||
_CalculatedHeight = 0;
|
||||
|
||||
if (m_SubItems == null)
|
||||
return;
|
||||
|
||||
RestoreOverflowItems();
|
||||
ButtonItem overflowButton = this.OverflowButton;
|
||||
LabelItem imageLabel = this.ImageLabel;
|
||||
|
||||
// Overflow button is hidden by default
|
||||
overflowButton.Visible = false;
|
||||
|
||||
Rectangle itemsRect = m_Rect;
|
||||
|
||||
// Label may be hidden if there is no image assigned to current item
|
||||
if (imageLabel.Visible)
|
||||
{
|
||||
imageLabel.RecalcSize();
|
||||
if (imageLabel.HeightInternal > _CalculatedHeight) _CalculatedHeight = imageLabel.HeightInternal;
|
||||
imageLabel.HeightInternal = containerSize.Height;
|
||||
itemsRect.X += imageLabel.WidthInternal;
|
||||
itemsRect.Width -= imageLabel.WidthInternal;
|
||||
imageLabel.Displayed = true;
|
||||
}
|
||||
Point itemsPos = itemsRect.Location;
|
||||
|
||||
bool overflowState = false;
|
||||
BaseItem[] items = new BaseItem[m_SubItems.Count - 2];
|
||||
if(m_SubItems.Count>2)
|
||||
m_SubItems.CopyToFromIndex(items, 2);
|
||||
|
||||
for (int i = items.Length - 1; i >= 0; i--)
|
||||
{
|
||||
BaseItem item = items[i];
|
||||
if (!item.Visible)
|
||||
{
|
||||
item.Displayed = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!overflowState)
|
||||
{
|
||||
item.LeftInternal = itemsPos.X;
|
||||
item.TopInternal = itemsPos.Y;
|
||||
item.HeightInternal = itemsRect.Height;
|
||||
item.RecalcSize();
|
||||
if (item.HeightInternal > _CalculatedHeight) _CalculatedHeight = item.HeightInternal;
|
||||
item.HeightInternal = itemsRect.Height;
|
||||
if (itemsPos.X + item.WidthInternal > itemsRect.Right || itemsPos.X + item.WidthInternal + 16 > itemsRect.Right && i > 0)
|
||||
{
|
||||
// Overflow mode
|
||||
overflowState = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemsPos.X += item.WidthInternal;
|
||||
item.Displayed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (overflowState)
|
||||
{
|
||||
_InternalRemove = true;
|
||||
m_SubItems.Remove(item);
|
||||
overflowButton.SubItems.Insert(0, item);
|
||||
_InternalRemove = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Now position the items left inside
|
||||
if (overflowState)
|
||||
{
|
||||
overflowButton.Visible = true;
|
||||
overflowButton.Displayed = true;
|
||||
overflowButton.HeightInternal = itemsRect.Height;
|
||||
overflowButton.RecalcSize();
|
||||
overflowButton.LeftInternal = itemsRect.X;
|
||||
overflowButton.TopInternal = itemsRect.Y;
|
||||
overflowButton.HeightInternal = itemsRect.Height;
|
||||
itemsRect.X += overflowButton.WidthInternal;
|
||||
itemsRect.Width -= overflowButton.WidthInternal;
|
||||
}
|
||||
|
||||
itemsPos = itemsRect.Location;
|
||||
for (int i = 2; i < m_SubItems.Count; i++)
|
||||
{
|
||||
BaseItem item = m_SubItems[i];
|
||||
if (!item.Visible)
|
||||
continue;
|
||||
if (item.WidthInternal + itemsPos.X > itemsRect.Right)
|
||||
{
|
||||
item.Displayed = false;
|
||||
itemsPos.X = itemsRect.Right;
|
||||
continue;
|
||||
}
|
||||
|
||||
item.LeftInternal = itemsPos.X;
|
||||
itemsPos.X += item.WidthInternal;
|
||||
}
|
||||
|
||||
base.RecalcSize();
|
||||
}
|
||||
|
||||
private int _CalculatedHeight = 0;
|
||||
internal int CalculatedHeight
|
||||
{
|
||||
get { return _CalculatedHeight; }
|
||||
}
|
||||
|
||||
internal void RestoreOverflowItems()
|
||||
{
|
||||
ButtonItem overflowButton = this.OverflowButton;
|
||||
if (overflowButton.SubItems.Count == 0) return;
|
||||
|
||||
BaseItem[] overflowItems = new BaseItem[overflowButton.SubItems.Count];
|
||||
overflowButton.SubItems.CopyTo(overflowItems, 0);
|
||||
overflowButton.SubItems.Clear();
|
||||
|
||||
for (int i = 0; i < overflowItems.Length; i++)
|
||||
{
|
||||
m_SubItems.Insert(i + 2, overflowItems[i]);
|
||||
}
|
||||
}
|
||||
|
||||
internal LabelItem ImageLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SubItems[0] as LabelItem;
|
||||
}
|
||||
}
|
||||
|
||||
internal CrumbBarOverflowButton OverflowButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return (CrumbBarOverflowButton)m_SubItems[1];
|
||||
}
|
||||
}
|
||||
|
||||
private bool _InternalRemove = false;
|
||||
internal void ClearViewItems()
|
||||
{
|
||||
_InternalRemove = true;
|
||||
while (m_SubItems.Count > 2)
|
||||
m_SubItems.RemoveAt(m_SubItems.Count - 1);
|
||||
_InternalRemove = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paints this base container
|
||||
/// </summary>
|
||||
public override void Paint(ItemPaintArgs pa)
|
||||
{
|
||||
if (this.SuspendLayout)
|
||||
return;
|
||||
System.Drawing.Graphics g = pa.Graphics;
|
||||
if (m_NeedRecalcSize)
|
||||
RecalcSize();
|
||||
|
||||
if (m_SubItems == null)
|
||||
return;
|
||||
|
||||
foreach (BaseItem item in m_SubItems)
|
||||
{
|
||||
if (item.Visible && item.Displayed)
|
||||
{
|
||||
item.Paint(pa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of ExplorerBarContainerItem item
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
CrumbBarViewContainer objCopy = new CrumbBarViewContainer();
|
||||
this.CopyToItem(objCopy);
|
||||
return objCopy;
|
||||
}
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
CrumbBarViewContainer objCopy = copy as CrumbBarViewContainer;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), System.ComponentModel.DefaultValue(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
|
||||
public override bool Expanded
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Expanded;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Expanded = value;
|
||||
if (!value)
|
||||
BaseItem.CollapseSubItems(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when sub item expanded state has changed.
|
||||
/// </summary>
|
||||
/// <param name="item">Sub item affected.</param>
|
||||
protected internal override void OnSubItemExpandChange(BaseItem item)
|
||||
{
|
||||
base.OnSubItemExpandChange(item);
|
||||
if (item.Expanded)
|
||||
this.Expanded = true;
|
||||
else
|
||||
base.Expanded = false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user