-
Notifications
You must be signed in to change notification settings - Fork 20
[Question] Which DockingEdge Page is Docked on? #201
Comments
Any ideas? |
Peter @Wagnerp, Do you have time to help me figure this scenario out? |
Hi @fdncred Is it possible to upload a test project, recreating this issue? |
Thanks for responding @Wagnerp. I don't have an example I can share but perhaps we could use one of the Krypton Examples like "Standard Docking 2019". In this example, if we focus on the "Input 5" page, it appears to be docked at the bottom. When I drag it to the top right docking window like this... I want to know how to tell that "Input 5" is now on DockingEdge.Right. That's really all my code in the original issue is asking. How can I get the DockingEdge after it's docked. I want to know this because I want to change the orientation of my flowlayout panel as demonstrated in my code above. |
Have you tried using the |
@Wagnerp I'd love to. What method checks where the page is located? |
I think I made a small discovery. The code above works sometimes when I dock on the edges. Sometimes it doesn't. Sometimes it works when I dock in the workspace. Sometimes it doesn't. I'm not sure what the magic is to detect where the page is docked exactly. |
I could probably insert a method into the library to do this. I'm not familiar with this part of the toolkit, so can you give me the name of the control that you're using? |
I followed the example in the private KryptonPage NewDocument()
{
KryptonPage page = NewPage("Document ", 0, new ContentDocument());
// Document pages cannot be docked or auto hidden
page.ClearFlags(KryptonPageFlags.DockingAllowAutoHidden | KryptonPageFlags.DockingAllowDocked);
return page;
}
private KryptonPage NewInput()
{
return NewPage("Input ", 1, new ContentInput(), null);
}
private KryptonPage NewPropertyGrid()
{
return NewPage("Properties ", 2, new ContentPropertyGrid(), new Size(300, 300));
}
private KryptonPage NewPage(string name, int image, Control content, Size ?autoHiddenSizeHint = null)
{
// Create new page with title and image
KryptonPage p = new KryptonPage
{
Text = name + _count.ToString(),
TextTitle = name + _count.ToString(),
TextDescription = name + _count.ToString(),
ImageSmall = imageListSmall.Images[image]
};
// Add the control for display inside the page
content.Dock = DockStyle.Fill;
p.Controls.Add(content);
_count++;
if (autoHiddenSizeHint.HasValue)
{
p.AutoHiddenSlideSize = autoHiddenSizeHint.Value;
}
return p;
}
private void Form1_Load(object sender, EventArgs e)
{
// Setup docking functionality
KryptonDockingWorkspace w = kryptonDockingManager.ManageWorkspace(kryptonDockableWorkspace);
kryptonDockingManager.ManageControl(kryptonPanel, w);
kryptonDockingManager.ManageFloating(this);
// Add initial docking pages
kryptonDockingManager.AddToWorkspace("Workspace", new KryptonPage[] { NewDocument(), NewDocument() });
props3 = NewPropertyGrid();
kryptonDockingManager.AddDockspace("Control", DockingEdge.Right, new KryptonPage[] { props3, NewInput() });
kryptonDockingManager.AddDockspace("Control", DockingEdge.Bottom, new KryptonPage[] { NewInput(), NewPropertyGrid() });
// Set correct initial ribbon palette buttons
UpdatePaletteButtons();
} The only thing different is I'm setting up an event so when a page is dropped it fires the code at the top of this issue. kryptonDockingManager.DoDragDropEnd += KryptonDockingManager_DoDragDropEnd; If you're talking about some other control then I'm confused. By my way of thinking you could just modify the Standard Docking example to report where a page is dropped and that would probably suffice. |
|
Yes, that would be ideal but keep in mind that it appears that pages can be docked in a nested fashion. So it could be docked at the bottom of a page that is docked to the right of the form. I'm not sure how this would work exactly but what I'm really trying to learn is if the controls on the page should be drawn left to right or top to bottom. If the page is docked to the bottom of another page and both are docked on the right, then the controls should be drawn top to bottom. If the control is docked to the bottom of a page that is docked to the bottom of the form then the controls should probably be drawn left to right. Does that make sense? BTW - I appreciate your help! |
What I'm thinking of is a method like this: public DockingEdge LocatePage(KryptonPage page)
{
return page.DockingEdge;
} |
That's definitely a start and probably better than what I have now. Is there a way to get the hierarchy of nested pages so I could call that on all of my page's parents to understand where it's docked? Like if it's on the bottom but it's parent is docked at the right? |
There is something called |
Sounds right. I'll do some research. Maybe I can foreach through that collection calling your method to figure out what i need. |
Do you know what property a |
I'm afraid I do not. All I know is how the standard docking does it via the AddDockspace method on kryptonDockingManager. It just passes an edge. So, it may be a property of the docking manager versus the page. I'm not sure if the page knows where it's at. You can see in my code that nearly works that I'm querying the docking manager to figure things out. var kPage = kryptonDockingManager.Pages.Where(x => x.Controls.ContainsKey("IndexingCtrl")).FirstOrDefault();
var edge = kryptonDockingManager.FindDockingEdgeDocked(kPage.UniqueName); |
I figured out why my code sometimes works and sometimes doesn't. It only works when var dockLoc = kryptonDockingManager.FindPageLocation(kPage.UniqueName); |
@Wagnerp Any luck? |
Hi @fdncred I'm away at the moment, so I'm taking a short break from development. Will have a look when I get back. |
Hey @Wagnerp |
Hi @fdncred No, not yet, been really busy dividing up the toolkit into separate NuGet package modules. But I'm sure that there is a variable somewhere to control the location of the page. |
Hi @fdncred It appears to use the // Add three horizontal-stacked pages to bottom edge of the panel
kryptonDockingManager.AddDockspace("Control",
DockingEdge.Bottom,
new KryptonPage[] { NewDocument() },
new KryptonPage[] { NewDocument() },
new KryptonPage[] { NewDocument() }); |
Hey @Wagnerp
|
Hi @fdncred The example seems to use custom user controls that are placed on the workspace, if I recall the unique name returns a random string. |
Hey @Wagnerp |
Hi @fdncred If you look at the example in the IDE, the designer does not show the pages. Instead everything is done via code. I don't think that the |
How do I tell which DockingEdge a Page is docked on? It looks like DoDragDropEnd() is part of the equation but I can't figure out where to go from here. The below code doesn't help because it always shows the edge.Edge as the DockingEdge where the page was created.
The text was updated successfully, but these errors were encountered: