Create Custom DockManager V1_0_0 Using DevExpress | C# | WPF | Saatody | Amit Padhiyar
In this post, I will try to create simple API structure for DockManager. Actually, The DockManager parent class will derive from DockLayoutManager (DevExpress WPF). But there, I will create simple steps to add DocumentPanel(s). And also, Create some default restrictions like FloatingMode for floating panels, DestroyOnClosingChildren for default DocumentGroup.
This API is for private use only. This is version V1_0_0. And Specially created for DocumentPanel(s) restrictions and for "easy to add" features.
using DevExpress.Xpf.Docking; using DevExpress.Xpf.Layout.Core; namespace Saatody.Core.UI { public class DockManager : DockLayoutManager { private LayoutGroup Root = new LayoutGroup(); private DocumentGroup DocumentGroup = new DocumentGroup(); private DocumentPanel PreviousDocumentPanel = new DocumentPanel(); public DockManager() { // Load Default Dock this.FloatingMode = FloatingMode.Desktop; this.DockController.Dock(Root); this.DockController.Dock(DocumentGroup); // Important DocumentGroup.DestroyOnClosingChildren = false; Event(); } private bool IsFirstDocumentPanel = true; public void AddDocumentPanel(DocumentPanel DocumentPanel) { if (IsFirstDocumentPanel == true) { this.DockController.Dock(DocumentPanel, DocumentGroup, DockType.Fill); PreviousDocumentPanel = DocumentPanel; IsFirstDocumentPanel = false; } else if (IsFirstDocumentPanel == false) { if (DocumentPanel.DockItemState == DockItemState.Undefined || DocumentPanel.DockItemState == DockItemState.Closed) { if (this.ActiveDockItem != null) { if (this.ActiveDockItem.GetType().BaseType == typeof(DocumentPanel)) { if (this.ActiveDockItem.IsFloating == false) { this.DockController.Dock(DocumentPanel, this.ActiveDockItem, DockType.Fill); PreviousDocumentPanel = DocumentPanel; } else if (this.ActiveDockItem.IsFloating == true) { if (PreviousDocumentPanel.IsClosed == false) { if (PreviousDocumentPanel.IsFloating == false) { this.DockController.Dock(DocumentPanel, PreviousDocumentPanel, DockType.Fill); PreviousDocumentPanel = DocumentPanel; } else if (PreviousDocumentPanel.IsFloating == true) { // Any Group To Use For Fill this.DockController.Dock(DocumentPanel, DocumentGroup, DockType.Fill); PreviousDocumentPanel = DocumentPanel; } } else if (PreviousDocumentPanel.IsClosed == true) { // Any Group To Use For Fill this.DockController.Dock(DocumentPanel, DocumentGroup, DockType.Fill); PreviousDocumentPanel = DocumentPanel; } } } else if (this.ActiveDockItem.GetType().BaseType != typeof(DocumentPanel)) { if (PreviousDocumentPanel.IsClosed == false) { if (PreviousDocumentPanel.IsFloating == false) { this.DockController.Dock(DocumentPanel, PreviousDocumentPanel, DockType.Fill); PreviousDocumentPanel = DocumentPanel; } else if (PreviousDocumentPanel.IsFloating == true) { // Any Group To Use For Fill this.DockController.Dock(DocumentPanel, DocumentGroup, DockType.Fill); PreviousDocumentPanel = DocumentPanel; } } else if (PreviousDocumentPanel.IsClosed == true) { // Any Group To Use For Fill this.DockController.Dock(DocumentPanel, DocumentGroup, DockType.Fill); PreviousDocumentPanel = DocumentPanel; } } } else if (this.ActiveDockItem == null) { if (PreviousDocumentPanel.IsClosed == false) { this.DockController.Dock(DocumentPanel, PreviousDocumentPanel, DockType.Fill); PreviousDocumentPanel = DocumentPanel; } else if (PreviousDocumentPanel.IsClosed == true) { // Any Group To Use For Fill this.DockController.Dock(DocumentPanel, DocumentGroup, DockType.Fill); PreviousDocumentPanel = DocumentPanel; } } } else if (DocumentPanel.DockItemState != DockItemState.Undefined && DocumentPanel.DockItemState != DockItemState.Closed) { DocumentPanel.IsActive = true; if (DocumentPanel.IsMinimized == true) { DocumentPanel.MDIState = MDIState.Normal; } } } } private void Event() { this.ShowingDockHints += (sender, e) => { if (e.DraggingSource.GetType().BaseType == typeof(DocumentPanel)) { if ((e.DraggingTarget.GetType() != typeof(DocumentGroup)) && (e.DraggingTarget.GetType().BaseType != typeof(DocumentPanel))) { e.HideAll(); } else if ((e.DraggingTarget.GetType() == typeof(DocumentGroup)) || (e.DraggingTarget.GetType().BaseType == typeof(DocumentPanel))) { e.Hide(DockHint.AutoHideBottom); e.Hide(DockHint.AutoHideLeft); e.Hide(DockHint.AutoHideRight); e.Hide(DockHint.AutoHideTop); //e.Hide(DockHint.Center); //e.Hide(DockHint.CenterBottom); //e.Hide(DockHint.CenterLeft); //e.Hide(DockHint.CenterRight); //e.Hide(DockHint.CenterTop); e.Hide(DockHint.SideBottom); e.Hide(DockHint.SideLeft); e.Hide(DockHint.SideRight); e.Hide(DockHint.SideTop); e.Hide(DockHint.TabBottom); e.Hide(DockHint.TabHeader); e.Hide(DockHint.TabLeft); e.Hide(DockHint.TabRight); e.Hide(DockHint.TabTop); } } }; } } }
Comments
Post a Comment