In This Article

BarCommandLink Class

Provides the base requirements for a bar command link.

public abstract class BarCommandLink : UIElement, IInputElement, IUIElement, ILogicalTreeNode, IDpiAwareElement, IDisposable, IImageListProvider
Inheritance:
object MarshalByRefObject MarshalByRefDisposableObject LogicalTreeNodeBase UIElement object
Derived:
BarButtonLink BarCustomControlLink BarExpanderButtonLink BarLabelLink BarPopupButtonLink BarSplitButtonLink
Implements:
IInputElement IUIElement ILogicalTreeNode IDpiAwareElement IDisposable IImageListProvider

Constructors

Initializes an instance of the class.

public BarCommandLink(BarCommand command)
Parameter Type Description
command BarCommand

The BarCommand upon which the link is based.

Properties

The IBarControl that contains the link.

[Browsable(false)]
public IBarControl? BarControl { get; }

Property Value

IBarControl

Indicates whether the command link begins a group.

public bool BeginAGroup { get; set; }

Property Value

bool:

true if the command link begins a group; otherwise, false.

The BarCommand to link to.

[Browsable(false)]
public BarCommand CommandCore { get; }

Property Value

BarCommand

The default image that is displayed for the bar command link that overrides the default bar command image.

[Browsable(false)]
public Image? DefaultImage { get; set; }

Property Value

Image

The default text of the bar command link that overrides the default bar command text.

[Browsable(false)]
public string? DefaultText { get; set; }

Property Value

string

The display style of the command link.

public BarCommandLinkDisplayStyle DisplayStyle { get; set; }

Property Value

BarCommandLinkDisplayStyle

Indicates whether the command link is enabled.

public DefaultableBoolean Enabled { get; set; }

Property Value

DefaultableBoolean:

A DefaultableBoolean indicating if the command link is enabled. If its value is Default, then the value of the Enabled property is used.

Indicates whether the command link has an image that can be displayed.

[Browsable(false)]
public virtual bool HasImage { get; }

Property Value

bool:

true if the command link has an image that can be displayed; otherwise, false.

The image that is displayed for the bar command link that overrides the default bar command image.

public Image? Image { get; set; }

Property Value

Image

The index of an image within an ImageList that overrides the default bar command image.

[ImageIndex]
[TypeConverter(typeof(ImageIndexConverter))]
public int ImageIndex { get; set; }

Property Value

int:

The default value is -1.

Indicates whether to invalidate the element when mouse events occur.

protected override bool InvalidateOnMouseEvents { get; }

Property Value

bool:

true if the element should be invalidated when mouse events occur; otherwise, false.

Indicates whether the link is clickable in customize mode.

protected virtual bool IsClickableInCustomizeMode { get; }

Property Value

bool:

true if the link is clickable in customize mode; otherwise, false.

Indicates whether the command link has been modified from a merge operation.

[Browsable(false)]
public bool IsMergeModified { get; }

Property Value

bool:

true if the command link has been modified from a merge operation; otherwise, false.

Indicates whether the command link is selected in its parent IBarControl.

[Browsable(false)]
public bool IsSelected { get; }

Property Value

bool:

true if the command link is selected in its parent IBarControl; otherwise, false.

The type of merge action to perform on the link when it is merged onto another IBarControl.

public BarMergeAction MergeAction { get; set; }

Property Value

BarMergeAction

The key to use when merging links, if the command's full name should not be used.

public string? MergeKey { get; set; }

Property Value

string

Remarks

The resolved merge key defaults to the command's full name, unless this property overrides it. If the command link is a merge source command link, the resolved merge key looks for a match on the target command link collection. If the command link is a merge target command link, the resolved merge key is used for matching against source command links.

The mnemonic character that is associated with this command link.

[Browsable(false)]
public char Mnemonic { get; }

Property Value

char:

A character that represents the mnemonic character associated with this command link. Returns the null character '\0' if no mnemonic character is specified in the text of the command link.

The screen bounds of the command link.

[Browsable(false)]
public Rectangle ScreenBounds { get; }

Property Value

Rectangle

The object that contains user-defined data about the object.

[TypeConverter(typeof(StringConverter))]
public object? Tag { get; set; }

Property Value

object

The text of the bar command link that overrides the default bar command text.

public string? Text { get; set; }

Property Value

string

Indicates whether the command link should be visible if space permits.

public bool Visible { get; set; }

Property Value

bool:

true if the command link should be visible if space permits; otherwise, false.

Indicates whether the command link is visible.

protected virtual bool VisibleCore { get; set; }

Property Value

bool:

true if the command link is visible; otherwise, false.

Methods

Creates a copy of the BarCommandLink.

public virtual BarCommandLink Clone()

Returns

BarCommandLink

Returns whether the command link is enabled.

public virtual bool GetEnabled()

Returns

bool:

true if the command link is enabled; otherwise, false.

Remarks

This method resolves Enabled property with the Enabled setting on the bar command.

Returns the Image to use for the command link.

public virtual Image? GetImage()

Returns

Image

Remarks

This method resolves the Image and ImageIndex properties with the Image and ImageIndex settings on the bar command.

Returns the size of the Image to use for the command link.

public virtual Size GetImageSize()

Returns

Size

Returns the mnemonic for this link.

protected virtual char GetMnemonic()

Returns

char:

The upper-case mnemonic character for the text or the null character '\0' if a mnemonic was not found.

Returns the text to use for the command link.

public virtual string? GetText()

Returns

string

Remarks

This method resolves Text property with the Text setting on the bar command.

Returns the text to use for the command link tooltips.

public virtual string? GetToolTipText()

Returns

string

Returns whether the command link is different from the specified BarCommandLink.

protected virtual bool IsDifferentFromDefault(BarCommandLink defaultCommandLink)
Parameter Type Description
defaultCommandLink BarCommandLink

The BarCommandLink to examine.

Returns

bool:

true if the command link is different from the specified BarCommandLink.

Measures the size in layout required for child elements and determines a size for the element itself.

protected override Size MeasureOverride(Graphics? g, Size availableSize)
Parameter Type Description
g Graphics

The Graphics object to use for measurement.

availableSize Size

The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.

Returns

Size:

The size that this element determines it needs during layout, based on its calculations of child element sizes.

Remarks

Element authors should override this method, call Measure(Graphics?, Size) on each visible child element and determine the total size required.

Raises the Enabled event.

protected virtual void OnEnabledChanged(EventArgs e)
Parameter Type Description
e EventArgs

The event data.

Occurs when the value of the IsSelected property changes.

protected virtual void OnIsSelectedChanged(EventArgs e)
Parameter Type Description
e EventArgs

The event data.

Raises the MouseEnter event.

protected override void OnMouseEnter(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

The event data.

Raises the MouseLeave event.

protected override void OnMouseLeave(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

The event data.

Invoked when logical parent is changed. This is invoked after the parent has changed, and the purpose is to allow elements to perform actions based on the changed parent.

protected override void OnParentChanged()

Performs processing based on some sort of event.

protected virtual void Process(BarProcessEventArgs e)
Parameter Type Description
e BarProcessEventArgs

The event data.

Process a key that is pressed down.

protected virtual DefaultableBoolean ProcessKeyDown(Keys key)
Parameter Type Description
key Keys

A Keys indicating the key that was pressed.

Returns

DefaultableBoolean:

True if the key was handled. Default if the key was not handled but should be allowed to process to the appropriate control. False if the key was not handled and the BarManager should process the key.

Deserializes the attribute data for the BarCommandLink from XML.

protected virtual void ReadAttributesFromXml(BarLayoutXmlSerializer serializer)
Parameter Type Description
serializer BarLayoutXmlSerializer

The BarLayoutXmlSerializer to use.

Deserializes a child element for the BarCommandLink from XML.

protected virtual void ReadElementFromXml(BarLayoutXmlSerializer serializer)
Parameter Type Description
serializer BarLayoutXmlSerializer

The BarLayoutXmlSerializer to use.

Resets the BeginAGroup property to its default value.

public virtual void ResetBeginAGroup()

Resets the DefaultImage property to its default value.

public virtual void ResetDefaultImage()

Resets the DefaultText property to its default value.

public virtual void ResetDefaultText()

Resets the DisplayStyle property to its default value.

public virtual void ResetDisplayStyle()

Resets the Enabled property to its default value.

public virtual void ResetEnabled()

Resets the Image property to its default value.

public virtual void ResetImage()

Resets the ImageIndex property to its default value.

public virtual void ResetImageIndex()

Resets the MergeAction property to its default value.

public virtual void ResetMergeAction()

Resets the MergeKey property to its default value.

public virtual void ResetMergeKey()

Resets the Text property to its default value.

public virtual void ResetText()

Resets the Visible property to its default value.

public virtual void ResetVisible()

Returns whether an image should be displayed for the item in its current location.

public bool ShouldDisplayImage()

Returns

bool:

true if an image should be displayed; otherwise, false.

Returns whether text should be displayed for the item in its current location.

public bool ShouldDisplayText()

Returns

bool:

true if text should be displayed; otherwise, false.

Indicates whether the BeginAGroup property should be persisted.

public virtual bool ShouldSerializeBeginAGroup()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the DefaultImage property should be persisted.

public virtual bool ShouldSerializeDefaultImage()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the DefaultText property should be persisted.

public virtual bool ShouldSerializeDefaultText()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the DisplayStyle property should be persisted.

public virtual bool ShouldSerializeDisplayStyle()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the Enabled property should be persisted.

public virtual bool ShouldSerializeEnabled()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the Image property should be persisted.

public virtual bool ShouldSerializeImage()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the ImageIndex property should be persisted.

public virtual bool ShouldSerializeImageIndex()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the MergeAction property should be persisted.

public virtual bool ShouldSerializeMergeAction()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the MergeKey property should be persisted.

public virtual bool ShouldSerializeMergeKey()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the Text property should be persisted.

public virtual bool ShouldSerializeText()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Indicates whether the Visible property should be persisted.

public virtual bool ShouldSerializeVisible()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Serializes the attribute data for the BarCommandLink to XML.

protected virtual void WriteAttributesToXml(BarLayoutXmlSerializer serializer, BarCommandLink? defaultCommandLink)
Parameter Type Description
serializer BarLayoutXmlSerializer

The BarLayoutXmlSerializer to use.

defaultCommandLink BarCommandLink

The default BarCommandLink that is used for differential layout comparison.

Serializes the child element data for the BarCommandLink to XML.

protected virtual void WriteElementsToXml(BarLayoutXmlSerializer serializer, BarCommandLink? defaultCommandLink)
Parameter Type Description
serializer BarLayoutXmlSerializer

The BarLayoutXmlSerializer to use.

defaultCommandLink BarCommandLink

The default BarCommandLink that is used for differential layout comparison.

Inherited Members

Extension Methods