BubbleNotification
Namespace: Wisej.Web.Ext.Bubbles
Assembly: Wisej.Web.Ext.Bubbles (4.1.0.0)
Represents a numeric notification bubble that can be displayed next to any control in the Wisej framework.
- C#
- VB.NET
public class BubbleNotification : Component, IExtenderProvider
Public Class BubbleNotification
Inherits Component
Implements IExtenderProvider
This class provides functionality to display numeric notifications, enhancing user interaction by informing users of important updates or statuses associated with a specific control. Since version 3.2.5, it includes support for ToolBarButton components, allowing for greater flexibility in user interface design.
Example:
The following example demonstrates how to create and display a BubbleNotification next to a Button control:
var button = new Button("Click Me");
var bubble = new BubbleNotification();
bubble.SetBubbleValue(button, 7);
this.Controls.Add(button);
Constructors
BubbleNotification()
Initializes a new instance of the BubbleNotification without a specified container.
BubbleNotification(container)
Initializes a new instance of the BubbleNotification class with a specified container.
| Name | Type | Description |
|---|---|---|
| container | IContainer | An IContainercontainer. |
Properties
Alignment
ContentAlignment: Gets or sets the alignment of the bubble notification. (Default: TopRight)
Value: A ContentAlignment value that specifies how the bubble notification is aligned. Possible values include TopLeft, TopRight, BottomLeft, BottomRight, MiddleLeft, MiddleRight, MiddleCenter, etc.
The alignment determines the position of the bubble notification relative to its anchor. Ensure that the chosen alignment fits within the available space of the UI element.
DefaultMargin
Padding: Returns the default value for the Margin property.
Value: A Padding that represents the default space between controls.
The default margin specifies the space between the notification bubble's content and its border, ensuring appropriate separation for visual clarity.
Margin
Padding: Gets or sets the padding margin applied to the bubble notification. This property defines the space between the content of the bubble and its border.
Tag
Object: Gets or sets an object that holds programmer-defined data associated with this BubbleNotification component. (Default: null)
Value: An Object representing the user-defined data. The default value is null.
Any type derived from Object can be assigned to this property. Its value is never read or modified by BubbleNotification; it is provided so that applications can associate arbitrary state with the component without deriving from it.
At design time the property is edited through a StringConverter, so only string values can be entered in the Properties window. Other object types must be assigned in code.
The assigned object is held for the lifetime of the component, so avoid storing values that own unmanaged or otherwise expensive resources.
Methods
CanExtend(target)
Determines whether the BubbleNotification can provide extender properties to the specified target component.
| Parameter | Type | Description |
|---|---|---|
| target | Object | The target object to add an extender property to. |
Returns: Boolean. true if the BubbleNotification class can offer one or more extender properties; otherwise, false.
This method is typically used to verify if the target component is compatible with the extender properties offered by the BubbleNotification class.
Example:
bubbleNotification.CanExtend(new Button()); // true - any Control.
bubbleNotification.CanExtend(new ToolBarButton()); // true - supported since 3.2.5.
bubbleNotification.CanExtend(new Timer()); // false - neither a Control nor a ToolBarButton.
// guard a loosely typed component before assigning a bubble, since
// SetBubbleValue throws when the component is of an unsupported type.
void SetBubble(object component, int value)
{
if (bubbleNotification.CanExtend(component))
bubbleNotification.SetBubbleValue((IWisejComponent)component, value);
}
Clear()
Removes all bubble notifications from the user interface.
This method clears all existing bubble notifications, effectively resetting the notification display. It is useful for scenarios where you want to refresh the notifications or clear old notifications before triggering new ones.
Example:
bubble.Clear();
AlertBox.Show("All bubble notifications have been cleared.");
Dispose(disposing)
Releases the resources used by the BubbleNotification class.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | Indicates whether the method was called directly or indirectly by a user's code (true) or by the runtime (false). |
If disposing is true, the method will release both managed and unmanaged resources. If false, it will only release unmanaged resources.
GetBubbleStyle(component)
Retrieves the BubbleStyle associated with the specified Wisej component. This method returns the bubble style for a given component, which determines the appearance and behavior of the notification bubble. If the bubble style indicates no notification (e.g., a default or hidden style), the return value will reflect this and the notification will not be displayed.
| Parameter | Type | Description |
|---|---|---|
| component | IWisejComponent | The IWisejComponent for which to retrieve the BubbleNotification value. |
Returns: BubbleStyle. A BubbleStyle enum value representing the style of the notification bubble. If the return value corresponds to a hidden state, no bubble will be shown.
Example:
BubbleStyle style = bubble.GetBubbleStyle(myComponent);
AlertBox.Show($"Current bubble style: {style}");
GetBubbleValue(component)
Returns the notification value associated with the specified Wisej component.
| Parameter | Type | Description |
|---|---|---|
| component | IWisejComponent | The IWisejComponent for which to retrieve the BubbleNotification value. |
Returns: Int32. A Int32 containing the value to display in the bubble; when 0, the bubble is hidden.
This method is typically used to update the visual representation of the component's status in the form of a bubble notification based on its value.
Example:
int bubbleValue = bubble.GetBubbleValue(myComponent);
if (bubbleValue > 0)
{
AlertBox.Show($"Bubble value: {bubbleValue}");
}
else
{
AlertBox.Show("Bubble is hidden.");
}
OnClick(e)
Raises the Click event for the Bubble Notification.
| Parameter | Type | Description |
|---|---|---|
| e | BubbleEventArgs | A BubbleEventArgs that contains the event data. |
OnWebEvent(e)
Handles and processes events triggered from the client for the BubbleNotification control. This method receives the event arguments, enabling appropriate responses to client-side actions.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | An instance of WisejEventArgs containing the event data. |
This method is typically invoked in response to user interactions, such as clicks or notifications, and allows for handling logic specific to the event type.
OnWebRender(config)
Renders the client-side component using the specified dynamic configuration. This method updates the BubbleNotification display based on the provided settings.
| Parameter | Type | Description |
|---|---|---|
| config | Object | An object containing dynamic configuration settings for rendering the component. This can include properties such as layout, style, and content to be displayed in the bubble notification. |
SetBubbleStyle(component, style)
Displays a bubble notification for the specified Wisej component using the given bubble style.
| Parameter | Type | Description |
|---|---|---|
| component | IWisejComponent | The IWisejComponent to which the bubble notification is associated. |
| style | BubbleStyle | The BubbleStyle value that defines the appearance of the bubble notification. A value of 0 will hide the bubble. |
SetBubbleValue(component, value)
Displays a bubble notification with a specified value associated with the given Wisej component.
| Parameter | Type | Description |
|---|---|---|
| component | IWisejComponent | The IWisejComponent instance that the bubble notification will be linked to. |
| value | Int32 | The value to show in the bubble notification; Use 0 to hide the bubble notification. |
Events
Click
BubbleEventHandler Fired when the user clicks on a bubble notification.
Implements
| Name | Description |
|---|---|
| IUserData | |
| IWisejComponent | |
| IWisejSerializable |