void GetTabbedGroups(DockGroup grp, List <DockGroup> tabbedGroups) { if (grp.Type == DockGroupType.Tabbed) { if (grp.VisibleObjects.Count > 1) { tabbedGroups.Add(grp); } else { grp.ResetNotebook(); } } else { // Make sure it doesn't have a notebook bound to it grp.ResetNotebook(); foreach (DockObject ob in grp.Objects) { if (ob is DockGroup) { GetTabbedGroups((DockGroup)ob, tabbedGroups); } } } }
DockGroupItem AddItemAtLocation(DockGroup grp, DockItem it, string location, bool visible, DockItemStatus status) { string[] positions = location.Split(';'); foreach (string pos in positions) { int i = pos.IndexOf('/'); if (i == -1) { continue; } string id = pos.Substring(0, i).Trim(); DockGroup g = grp.FindGroupContaining(id); if (g != null) { DockPosition dpos; try { dpos = (DockPosition)Enum.Parse(typeof(DockPosition), pos.Substring(i + 1).Trim(), true); } catch { continue; } DockGroupItem dgt = g.AddObject(it, dpos, id); dgt.SetVisible(visible); dgt.Status = status; return(dgt); } } return(null); }
private void UpdateContentAdvancedLayoutProperties() { ViewGroup parent = base.Parent; while (parent != null && !(parent is DockGroup)) { parent = parent.Parent; } DockGroup dockGroup = parent as DockGroup; if (dockGroup == null) { this.DockingOrientation = null; } else { this.DockingOrientation = new Orientation?(dockGroup.Orientation); } IAdvancedLayoutPanel content = base.Content as IAdvancedLayoutPanel; if (content != null) { content.DockingOrientation = this.DockingOrientation; } }
internal bool InRegion(string location, DockGroup objToFindParent, int objToFindIndex, bool insertingPosition) { // Checks if the object is in the specified region. // A region is a collection with the format: "ItemId1/Position1;ItemId2/Position2..." string[] positions = location.Split(';'); foreach (string pos in positions) { // We individually check each entry in the region specification int i = pos.IndexOf('/'); if (i == -1) { continue; } string id = pos.Substring(0, i).Trim(); DockGroup g = container.Layout.FindGroupContaining(id); if (g != null) { DockPosition dpos; try { dpos = (DockPosition)Enum.Parse(typeof(DockPosition), pos.Substring(i + 1).Trim(), true); } catch { continue; } var refItem = g.FindDockGroupItem(id); if (InRegion(g, dpos, refItem, objToFindParent, objToFindIndex, insertingPosition)) { return(true); } } } return(false); }
public virtual void CopyFrom(DockObject ob) { parentGroup = null; frame = ob.frame; rect = ob.rect; size = ob.size; allocSize = ob.allocSize; defaultHorSize = ob.defaultHorSize; defaultVerSize = ob.defaultVerSize; prefSize = ob.prefSize; }
protected override bool ValidateOrReplaceDockGroup(ref DockGroup dockGroup, WindowProfileValidationContext context) { if (!(dockGroup is ExpressionDockGroup) && typeof(DockGroup) == dockGroup.GetType()) { DockGroup dockGroup1 = ViewElementFactory.Current.CreateDockGroup(); if (dockGroup1 == null || !(dockGroup1 is ExpressionDockGroup)) { return(false); } this.CopyDockGroupProperties(dockGroup, dockGroup1); dockGroup = dockGroup1; } return(true); }
/// <summary> /// Gets the style assigned to a specific position of the layout /// </summary> /// <returns> /// The region style for position. /// </returns> /// <param name='parentGroup'> /// Group which contains the position /// </param> /// <param name='childIndex'> /// Index of the position inside the group /// </param> /// <param name='insertingPosition'> /// If true, the position will be inserted (meaning that the objects in childIndex will be shifted 1 position) /// </param> internal DockVisualStyle GetRegionStyleForPosition(DockGroup parentGroup, int childIndex, bool insertingPosition) { DockVisualStyle mergedStyle = null; foreach (var e in regionStyles) { if (InRegion(e.Item1, parentGroup, childIndex, insertingPosition)) { if (mergedStyle == null) { mergedStyle = DefaultVisualStyle.Clone(); } mergedStyle.CopyValuesFrom(e.Item2); } } return(mergedStyle ?? DefaultVisualStyle); }
protected virtual bool ValidateOrReplaceDockGroup(ref DockGroup dockGroup, WindowProfileValidationContext context) { DocumentGroupContainer documentGroupContainer = dockGroup as DocumentGroupContainer; if (documentGroupContainer == null) { return(true); } if (documentGroupContainer.Children.Count == 0) { documentGroupContainer.Children.Add((ViewElement)DocumentGroup.Create()); } bool flag = this.ValidateOrReplaceDocumentGroupContainer(ref documentGroupContainer, context); dockGroup = (DockGroup)documentGroupContainer; return(flag); }
internal void AllocateSplitter(DockGroup grp, int index, Gdk.Rectangle a) { var s = splitters[usedSplitters++]; if (a.Height > a.Width) { a.Width = 5; a.X -= 2; } else { a.Height = 5; a.Y -= 2; } s.SizeAllocate(a); s.Init(grp, index); }
private void GetPreviewSplitterPanel(out SplitterPanel panel, out int targetIndex, DockDirection dockDirection, ViewElement viewElement, FrameworkElement adornedElement, Orientation orientation) { targetIndex = -1; panel = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <SplitterPanel>((Visual)adornedElement); if (panel != null) { SplitterItem ancestor = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <SplitterItem>((Visual)adornedElement); targetIndex = SplitterPanel.GetIndex((UIElement)ancestor); } MainSite mainSite = viewElement as MainSite; if (mainSite == null) { return; } DockGroup dockGroup = mainSite.Child as DockGroup; if (dockGroup == null || dockGroup.Orientation != orientation) { return; } panel = (SplitterPanel)null; DependencyObject reference = (DependencyObject)adornedElement; while (panel == null && reference != null) { reference = VisualTreeHelper.GetChild(reference, 0); panel = reference as SplitterPanel; } if (panel == null) { return; } if (dockDirection == DockDirection.Left || dockDirection == DockDirection.FirstValue) { targetIndex = 0; } else { targetIndex = panel.Children.Count - 1; } }
int CountRequiredSplitters(DockGroup grp) { if (grp.Type == DockGroupType.Tabbed) { return(0); } else { int num = grp.VisibleObjects.Count - 1; if (num < 0) { return(0); } foreach (var c in grp.VisibleObjects.OfType <DockGroup> ()) { num += CountRequiredSplitters(c); } return(num); } }
bool EstimateBarDocPosition(DockGroup grp, DockObject ignoreChild, out PositionType pos, out int size) { foreach (DockObject ob in grp.Objects) { if (ob == ignoreChild) { continue; } if (ob is DockGroup) { if (EstimateBarDocPosition((DockGroup)ob, null, out pos, out size)) { return(true); } } else if (ob is DockGroupItem) { DockGroupItem it = (DockGroupItem)ob; if (it.status == DockItemStatus.AutoHide) { pos = it.barDocPosition; size = it.autoHideSize; return(true); } if (!it.Allocation.IsEmpty) { pos = it.CalcBarDocPosition(); size = it.GetAutoHideSize(pos); return(true); } } } pos = PositionType.Bottom; size = 0; return(false); }
public void Init(DockGroup grp, int index) { dockGroup = grp; dockIndex = index; }
bool InRegion(DockGroup grp, DockPosition pos, DockObject refObject, DockGroup objToFindParent, int objToFindIndex, bool insertingPosition) { if (grp == null) { return(false); } if (grp.Type == DockGroupType.Tabbed) { if (pos != DockPosition.Center && pos != DockPosition.CenterBefore) { return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition)); } } if (grp.Type == DockGroupType.Horizontal) { if (pos != DockPosition.Left && pos != DockPosition.Right) { return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition)); } } if (grp.Type == DockGroupType.Vertical) { if (pos != DockPosition.Top && pos != DockPosition.Bottom) { return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition)); } } bool foundAtLeftSide = true; bool findingLeft = pos == DockPosition.Left || pos == DockPosition.Top || pos == DockPosition.CenterBefore; if (objToFindParent == grp) { // Check positions beyond the current range of items if (objToFindIndex < 0 && findingLeft) { return(true); } if (objToFindIndex >= grp.Objects.Count && !findingLeft) { return(true); } } for (int n = 0; n < grp.Objects.Count; n++) { var ob = grp.Objects[n]; bool foundRefObject = ob == refObject; bool foundTargetObject = objToFindParent == grp && objToFindIndex == n; if (foundRefObject) { // Found the reference object, but if insertingPosition=true it is in the position that the new item will have, // so this position still has to be considered to be at the left side if (foundTargetObject && insertingPosition) { return(foundAtLeftSide == findingLeft); } foundAtLeftSide = false; } else if (foundTargetObject) { return(foundAtLeftSide == findingLeft); } else if (ob is DockGroup) { DockGroup gob = (DockGroup)ob; if (gob == objToFindParent || ObjectHasAncestor(objToFindParent, gob)) { return(foundAtLeftSide == findingLeft); } } } return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition)); }
private void BuildGroupAreas() { switch (InsertType) { case DockInsertType.None: Rectangle dropRect = new() { X = DockGroup.PointToScreen(Point.Empty).X, Y = DockGroup.PointToScreen(Point.Empty).Y, Width = DockGroup.Width, Height = DockGroup.Height }; DropArea = dropRect; HighlightArea = dropRect; break; case DockInsertType.Before: int beforeDropWidth = DockGroup.Width; int beforeDropHeight = DockGroup.Height; switch (DockGroup.DockArea) { case DockArea.Left: case DockArea.Right: beforeDropHeight = DockGroup.Height / 4; break; case DockArea.Bottom: beforeDropWidth = DockGroup.Width / 4; break; } Rectangle beforeDropRect = new() { X = DockGroup.PointToScreen(Point.Empty).X, Y = DockGroup.PointToScreen(Point.Empty).Y, Width = beforeDropWidth, Height = beforeDropHeight }; DropArea = beforeDropRect; HighlightArea = beforeDropRect; break; case DockInsertType.After: int afterDropX = DockGroup.PointToScreen(Point.Empty).X; int afterDropY = DockGroup.PointToScreen(Point.Empty).Y; int afterDropWidth = DockGroup.Width; int afterDropHeight = DockGroup.Height; switch (DockGroup.DockArea) { case DockArea.Left: case DockArea.Right: afterDropHeight = DockGroup.Height / 4; afterDropY = DockGroup.PointToScreen(Point.Empty).Y + DockGroup.Height - afterDropHeight; break; case DockArea.Bottom: afterDropWidth = DockGroup.Width / 4; afterDropX = DockGroup.PointToScreen(Point.Empty).X + DockGroup.Width - afterDropWidth; break; } Rectangle afterDropRect = new() { X = afterDropX, Y = afterDropY, Width = afterDropWidth, Height = afterDropHeight }; DropArea = afterDropRect; HighlightArea = afterDropRect; break; } } #endregion }
private void CopyDockGroupProperties(DockGroup from, DockGroup to) { this.CopyViewGroupProperties((ViewGroup)from, (ViewGroup)to); to.Orientation = from.Orientation; }
void LayoutWidgets() { if (!needsRelayout) { return; } needsRelayout = false; // Create the needed notebooks and place the widgets in there List <DockGroup> tabbedGroups = new List <DockGroup> (); GetTabbedGroups(layout, tabbedGroups); for (int n = 0; n < tabbedGroups.Count; n++) { DockGroup grp = tabbedGroups [n]; TabStrip ts; if (n < notebooks.Count) { ts = notebooks [n]; } else { ts = new TabStrip(frame); ts.Show(); notebooks.Add(ts); ts.Parent = this; } frame.UpdateRegionStyle(grp); ts.VisualStyle = grp.VisualStyle; grp.UpdateNotebook(ts); } // Remove spare tab strips for (int n = notebooks.Count - 1; n >= tabbedGroups.Count; n--) { TabStrip ts = notebooks [n]; notebooks.RemoveAt(n); ts.Clear(); ts.Unparent(); ts.Destroy(); } // Create and add the required splitters int reqSpliters = CountRequiredSplitters(layout); for (int n = 0; n < splitters.Count; n++) { var s = splitters [n]; if (s.Parent != null) { Remove(s); } } // Hide the splitters that are not required for (int n = reqSpliters; n < splitters.Count; n++) { splitters[n].Hide(); } // Add widgets to the container layout.LayoutWidgets(); // Create and add the required splitters for (int n = 0; n < reqSpliters; n++) { if (n < splitters.Count) { var s = splitters [n]; if (!s.Visible) { s.Show(); } Add(s); } else { var s = new SplitterWidget(); splitters.Add(s); s.Show(); Add(s); } } }
protected bool ValidateOrReplaceViewGroup(ref ViewGroup viewGroup, WindowProfileValidationContext context) { DockOperations.TryCollapse((ViewElement)viewGroup); DockGroup dockGroup = viewGroup as DockGroup; if (dockGroup != null) { bool flag = this.ValidateOrReplaceDockGroup(ref dockGroup, context); viewGroup = (ViewGroup)dockGroup; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } NestedGroup nestedGroup = viewGroup as NestedGroup; if (nestedGroup != null) { bool flag = this.ValidateOrReplaceNestedGroup(ref nestedGroup, context); viewGroup = (ViewGroup)nestedGroup; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } AutoHideGroup autoHideGroup = viewGroup as AutoHideGroup; if (autoHideGroup != null) { autoHideGroup.SelectedElement = (ViewElement)null; bool flag = this.ValidateOrReplaceAutoHideGroup(ref autoHideGroup, context); viewGroup = (ViewGroup)autoHideGroup; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } AutoHideChannel autoHideChannel = viewGroup as AutoHideChannel; if (autoHideChannel != null) { bool flag = this.ValidateOrReplaceAutoHideChannel(ref autoHideChannel, context); viewGroup = (ViewGroup)autoHideChannel; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } ViewSite viewSite = viewGroup as ViewSite; if (viewSite != null) { bool flag = this.ValidateOrReplaceViewSite(ref viewSite, context); viewGroup = (ViewGroup)viewSite; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } AutoHideRoot autoHideRoot = viewGroup as AutoHideRoot; if (autoHideRoot != null) { bool flag = this.ValidateOrReplaceAutoHideRoot(ref autoHideRoot, context); viewGroup = (ViewGroup)autoHideRoot; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } DockRoot dockRoot = viewGroup as DockRoot; if (dockRoot == null) { return(this.ValidateOrReplaceCustomViewGroup(ref viewGroup, context)); } bool flag1 = this.ValidateOrReplaceDockRoot(ref dockRoot, context); viewGroup = (ViewGroup)dockRoot; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag1); }
private void BuildGroupAreas() { switch (InsertType) { case DockInsertType.None: var dropRect = new Rectangle { X = DockGroup?.PointToScreen(Point.Empty).X ?? 0, Y = DockGroup?.PointToScreen(Point.Empty).Y ?? 0, Width = DockGroup?.Width ?? 0, Height = DockGroup?.Height ?? 0 }; DropArea = dropRect; HighlightArea = dropRect; break; case DockInsertType.Before: var beforeDropWidth = DockGroup?.Width ?? 0; var beforeDropHeight = DockGroup?.Height ?? 0; switch (DockGroup?.DockArea) { case DarkDockArea.Left: case DarkDockArea.Right: beforeDropHeight = DockGroup.Height / 4; break; case DarkDockArea.Bottom: beforeDropWidth = DockGroup.Width / 4; break; } var beforeDropRect = new Rectangle { X = DockGroup?.PointToScreen(Point.Empty).X ?? 0, Y = DockGroup?.PointToScreen(Point.Empty).Y ?? 0, Width = beforeDropWidth, Height = beforeDropHeight }; DropArea = beforeDropRect; HighlightArea = beforeDropRect; break; case DockInsertType.After: var afterDropX = DockGroup?.PointToScreen(Point.Empty).X ?? 0; var afterDropY = DockGroup?.PointToScreen(Point.Empty).Y ?? 0; var afterDropWidth = DockGroup?.Width ?? 0; var afterDropHeight = DockGroup?.Height ?? 0; switch (DockGroup?.DockArea) { case DarkDockArea.Left: case DarkDockArea.Right: afterDropHeight = DockGroup.Height / 4; afterDropY = DockGroup.PointToScreen(Point.Empty).Y + DockGroup.Height - afterDropHeight; break; case DarkDockArea.Bottom: afterDropWidth = DockGroup.Width / 4; afterDropX = DockGroup.PointToScreen(Point.Empty).X + DockGroup.Width - afterDropWidth; break; } var afterDropRect = new Rectangle { X = afterDropX, Y = afterDropY, Width = afterDropWidth, Height = afterDropHeight }; DropArea = afterDropRect; HighlightArea = afterDropRect; break; } }
DockGroupItem AddDefaultItem(DockGroup grp, DockItem it) { return(AddItemAtLocation(grp, it, it.DefaultLocation, it.DefaultVisible, it.DefaultStatus)); }
bool ObjectHasAncestor(DockObject obj, DockGroup ancestorToFind) { return(obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor(obj.ParentGroup, ancestorToFind))); }
private void BuildGroupAreas() { switch (InsertType) { case DockInsertType.None: var dropRect = new Rectangle { X = DockGroup.PointToScreen(Point.Empty).X, Y = DockGroup.PointToScreen(Point.Empty).Y, Width = DockGroup.Width, Height = DockGroup.Height }; DropArea = dropRect; HighlightArea = dropRect; break; case DockInsertType.Before: var beforeDropWidth = DockGroup.Width; var beforeDropHeight = DockGroup.Height; switch (DockGroup.DockArea) { case DarkDockArea.Left: case DarkDockArea.Right: beforeDropHeight = DockGroup.Height / 4; break; case DarkDockArea.Bottom: beforeDropWidth = DockGroup.Width / 4; break; } var beforeDropRect = new Rectangle { X = DockGroup.PointToScreen(Point.Empty).X, Y = DockGroup.PointToScreen(Point.Empty).Y, Width = beforeDropWidth, Height = beforeDropHeight }; DropArea = beforeDropRect; HighlightArea = beforeDropRect; break; case DockInsertType.After: var afterDropX = DockGroup.PointToScreen(Point.Empty).X; var afterDropY = DockGroup.PointToScreen(Point.Empty).Y; var afterDropWidth = DockGroup.Width; var afterDropHeight = DockGroup.Height; switch (DockGroup.DockArea) { case DarkDockArea.Left: case DarkDockArea.Right: afterDropHeight = DockGroup.Height / 4; afterDropY = DockGroup.PointToScreen(Point.Empty).Y + DockGroup.Height - afterDropHeight; break; case DarkDockArea.Bottom: afterDropWidth = DockGroup.Width / 4; afterDropX = DockGroup.PointToScreen(Point.Empty).X + DockGroup.Width - afterDropWidth; break; } var afterDropRect = new Rectangle { X = afterDropX, Y = afterDropY, Width = afterDropWidth, Height = afterDropHeight }; DropArea = afterDropRect; HighlightArea = afterDropRect; break; } Debug.Assert(DockPanel.ParentForm != null, "DockPanel.ParentForm != null"); DropArea = Rectangle.Intersect(DropArea, DockPanel.ParentForm.Bounds); HighlightArea = Rectangle.Intersect(HighlightArea, DockPanel.ParentForm.Bounds); }
public DockGroupCustomSerializer(DockGroup group) : base((ViewGroup)group) { }