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 DisposableObject LogicalTreeNodeBase UIElement object
Derived:
BarButtonLink BarCustomControlLink BarExpanderButtonLink BarLabelLink BarPopupButtonLink BarSplitButtonLink
Implements:
IInputElement IUIElement ILogicalTreeNode IDpiAwareElement IDisposable IImageListProvider

Constructors

Initializes a new instance of the BarCommandLink class.

public BarCommandLink(BarCommand command)
Parameter Type Description
command BarCommand

The BarCommand upon which the link is based.

Properties

Gets the IBarControl that contains the link.

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

Property Value

IBarControl:

The IBarControl that contains the link.

Gets or sets 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.

Gets the BarCommand to link to.

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

Property Value

BarCommand:

The BarCommand to link to.

Gets or sets 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 Image displayed for the bar command link that overrides the default bar command image. The default value is null.

Gets or sets 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 default text of the bar command link that overrides the default bar command text.

Gets or sets the display style of the command link.

public BarCommandLinkDisplayStyle DisplayStyle { get; set; }

Property Value

BarCommandLinkDisplayStyle:

A BarCommandLinkDisplayStyle specifying the display style of the command link.

Gets or sets 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.

Gets 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.

Gets or sets 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 Image displayed for the bar command link that overrides the default bar command image. The default value is null.

Gets or sets 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 index of an image within an ImageList that overrides the default bar command image. The default value is -1.

Gets 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.

Gets 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.

Gets 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.

Gets 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.

Gets or sets 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:

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

Gets or sets 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:

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

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.

Gets a value indicating 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.

Gets the screen bounds of the command link.

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

Property Value

Rectangle:

The screen bounds of the command link.

Gets or sets the object that contains user-defined data about the object.

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

Property Value

object:

An object that contains user-defined data about the control. The default is null.

Remarks

Any type derived from the object class can be assigned to this property.

Gets or sets the text of the bar command link that overrides the default bar command text.

public string Text { get; set; }

Property Value

string:

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

Gets or sets 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.

Gets or sets 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:

The copy of the BarCommandLink.

Gets the 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.

Gets the Image to use for the command link.

public virtual Image GetImage()

Returns

Image:

The Image to use for the command link.

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

public virtual Size GetImageSize()

Returns

Size:

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

Gets the mnemonic for this link.

protected virtual char GetMnemonic()

Returns

char:

The mnemonic character for this link.

Remarks

This method is called after a command's Text property changes.

Gets the text to use for the command link.

public virtual string GetText()

Returns

string:

The text to use for the command link.

Remarks

This method resolves the text to display in the user interface for the command link.

Gets the text to use for the command link tooltips.

public virtual string GetToolTipText()

Returns

string:

The text to use for the command link tooltips.

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 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

An EventArgs that contains the event data.

Occurs when the value of the IsSelected property changes.

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

An EventArgs that contains the event data.

Raises the MouseEnter event.

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

A MouseEventArgs that contains the event data.

Raises the MouseLeave event.

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

A MouseEventArgs that contains 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

A BarProcessEventArgs that contains 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:

DefaultableBoolean.True if the key was handled. DefaultableBoolean.Default if the key was not handled but should be allowed to process to the appropriate control. DefaultableBoolean.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()

Gets 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.

Gets 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