Nevron .NET Vision Documentation
Popup Component

Overview
The NPopup is a generic component which "pops" on the screen and has a limited life-time - such as menu windows, tooltips, drop-downs, etc. The popup is completely customizable regarding appearance, behavior, animations, even shadows. Introduced is a completely innovative placement logic allowing for precise positioning and alignment of the popup - either to a target, custom bounds or the mouse.
Appearance

The NPopup component is highly customizable in all aspects of visual representation. Based on the core UI rendering system it exposes an NPalette instance which color values are used to paint the control. The following palette members are used:

 

- Border – used to paint the outer border.

- SecondaryBorder – used to paint the inner border.

- Menu – fills the interior of the popup.

 

You may further extend the appearance by specifying a NUIShape instance as a Background. The following code demonstrates how to create and apply a rounded rectangle as a background: 

C#
Copy Code
NRectShape shape = new NRectShape();
shape.FillStyle = new NColorFillStyle(Color.WhiteSmoke);
shape.StrokeStyle = new NStrokeStyle(1, Color.Gray);
NPopup popup = new NPopup();
popup.Background = shape;
//remove the default border
popup.BorderStyle = PopupBorderStyle.None;
Visual Basic
Copy Code
Dim shape As NRectShape = New NRectShape()
shape.FillStyle = New NColorFillStyle(Color.WhiteSmoke)
shape.StrokeStyle = New NStrokeStyle(1, Color.Gray)
Dim popup As NPopup = New NPopup()
popup.Background = shape
'remove the default border
popup.BorderStyle = PopupBorderStyle.None
Behavior

Since there are many different scenarios where the popup would be in help, provided are many settings controlling the default behavior. Following are the properties which control the behavior of an NPopup instance:

- AnimationInfo – controls the animation of the popup – interval, step, fade-in and fade-out.

- CanActivate – determines whether the popup may be activated (receive keyboard input).

- EnableHook – enables or disables the internal hook used to automatically close the popup when an input event for another control occurs. When this is false the popup will not be closed automatically and you will be responsible for hiding it.

- Layered – an extended control style which makes animations and custom opacity available.

- SizeStyle – specifies whether the popup will be sizable and at which direction.

- TopMost – determines whether the popup will be placed above all other controls on the screen.  

Placement

Although you are able to specify entirely custom placement bounds where the popup will be displayed there are many settings which will cover most of the cases of positioning and aligning an NPopup instance. All of the placement settings are grouped by the NPopupPlacementInfo object. Following is a list all settings:

 

- Bounds – a rectangular area (in screen coordinates) which will be used as an alignment target. Valid when the placement mode is PopupPlacement.Relative.

- HAlign – specifies horizontal edge and flow direction of the popup. For example PopupHAlignment.LeftToLeft value indicates that the popup is aligned with the left edge of the current target and it flows to the left.

- Mode – specifies the current logic to be used when calculating popup’s placement.

- Offset – specifies the amount of offset to be applied when calculating popup’s bounds.

- VAlign – specifies vertical edge and flow direction of the popup. For example PopupVAlignment.TopToTop value indicates that the popup is aligned with the top edge of the current target and it flows to the top.

- ScreenFitMode – specifies whether the popup will fit into the screen (will not overlap any of the screen’s edges).

- PlacementTarget – a Control instance which screen bounds will be used as an alignment box of the popup.

 

The following code demonstrates how to align a popup with the right-bottom edge of a button:

C#
Copy Code
NPopup popup = new NPopup();
popup.PlacementTarget = this.nButton1;
popup.PlacementInfo.HAlign = PopupHAlignment.RightToRight;
popup.PlacementInfo.VAlign = PopupVAlignment.BottomToBottom;
Visual Basic
Copy Code
Dim popup As NPopup = New NPopup()
popup.PlacementTarget = Me.nButton1
popup.PlacementInfo.HAlign = PopupHAlignment.RightToRight
popup.PlacementInfo.VAlign = PopupVAlignment.BottomToBottom
Control Hosting

The NPopup may host any valid Control instance. For example you may have a Panel populated with controls which is hosted on a pop-up.

 

The following code demonstrates how to host a control on an NPopup instance: 

C#
Copy Code
NPopup popup = new NPopup();
popup.HostedControl = this.panel1;
Visual Basic
Copy Code
Dim popup As NPopup = New NPopup()
popup.HostedControl = Me.panel1

At design-time you need to manually update the visibility (make it hidden) of the hosted control since it will be parented by the popup just before the popup is displayed.
See Also

 

 


©2017. Nevron Software LLC.

Send Feedback