Profile Picture

Want to add control next to close button

Posted By JSW W. 14 Years Ago
Author
Message
JSW W.
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 127, Visits: 1
Hi on docking Panel title bar right side you have

pin, maximize, minimize, close etc.

How to add custom button or dropdown there?

Angel Chorbadzhiev
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 139, Visits: 184

Hello JSW W.

You can only add a button to the NDockingPanel caption bar.

You can do that with the help of NCaptionButton class.

You need to create an instance of this class, set it's properties and then add it to the Buttons collection of the panel's caption.

To be able to identify the button when the button is clicked you need to set it's ID property.

You can set it to one of the predefined IDs using CaptionButtonId enum.

Depending of the button ID the button has a different functionality and different outlook.

The IDs from 0 to 3 has the following predefined meaning:

0 - None
1 - Close
2 - AutoHide
3 - Maximize / Restore

If you want to implement other functionality of your custom button you have to setup it's ID bigger that 3. Then you need to attach to the CaptionButtonClicked event in order to implement the action when the button is clicked.

If you want to draw the button by yourself instead of using one of the predefined buttons you have to create your renderer class that inherits from NDockingFrameworkRenderer. In this class you should override DrawCaptionButton method and draw your button in the method's body. Then you should create an instance of your renderer and set the NDockManager.Renderer property to it.

Here is one example implementation that might help:

public class MyRenderer : NDockingFrameworkRenderer
{
    public override void DrawCaptionButton(NRenderCaptionContext context, NCaptionButton button)
    {
        
if (button.ID == 5)
        {

            context.Graphics.DrawEllipse(Pens.Red, button.Bounds);
        }
        else
        {
            base.DrawCaptionButton(context, button);
        }
    }
}

...

NCaptionButton button = new NCaptionButton();
button.TooltipText =
"My custom button.";
button.ID = 5;
nDockManager1.Renderer =
new MyRenderer();
nDockingPanel1.Caption.Buttons.Add(button);
nDockingPanel1.CaptionButtonClicked += new CaptionEventHandler(nDockingPanel1_CaptionButtonClicked);

...

private void nDockingPanel1_CaptionButtonClicked(object sender, CaptionEventArgs e)
{
    if (e.ClickedID == 5)
    {
        //The action followed by pressing the custom button.
    }
}

I hope this example will be helpful.

Regards,

Angel Chorbadzhiev.



JSW W.
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 127, Visits: 1
Wonderful support!
I will feedback here soon.



Similar Topics


Reading This Topic