-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRibbonPageGroupComplexLayoutCalculatorDescendant.vb
61 lines (51 loc) · 2.59 KB
/
RibbonPageGroupComplexLayoutCalculatorDescendant.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Imports System.Collections.Generic
Imports System.Linq
Imports DevExpress.XtraBars.Ribbon.ViewInfo
Imports System.Drawing
Imports DevExpress.XtraBars
Namespace CustomRibbonControl
Public Class RibbonPageGroupComplexLayoutCalculatorDescendant
Inherits RibbonPageGroupComplexLayoutCalculator
Private offsetY As Integer
Private offsetX As Integer
Private widthList As List(Of Integer) = New List(Of Integer)()
Public Sub New(ByVal groupInfo As IRibbonGroupInfo)
MyBase.New(groupInfo)
End Sub
Protected Overrides Sub InsertItemCore(ByVal info As RibbonPageGroupLayoutCalculator.GroupColumnLayoutInfo)
MyBase.InsertItemCore(info)
Dim barItemExtender As BarItemExtender = CType(GroupInfo.ViewInfo.Ribbon, RibbonControlDescendant).BarItemExtender
If barItemExtender IsNot Nothing Then
If TypeOf info.ItemInfo.Item Is BarItemLink Then
Dim Location As Point = barItemExtender.GetLocation(CType(CType(info.ItemInfo.Item, BarItemLink).Item, BarItem))
offsetX = Location.X
offsetY = Location.Y
widthList.Add(offsetX + info.ItemInfo.Bounds.Width)
If offsetY > info.ContentBounds.Height Then offsetY = info.ContentBounds.Height - info.ItemInfo.Bounds.Height
info.ItemInfo.Bounds = New Rectangle(New Point(info.ContentBounds.X + offsetX, info.ContentBounds.Y + offsetY), info.ItemInfo.Bounds.Size)
info.MaxColumnWidth = widthList.Max()
End If
End If
End Sub
Protected Overrides Function UpdateGroupLayout(ByVal contentBounds As Rectangle) As Integer
Dim info As GroupColumnLayoutInfo = New GroupColumnLayoutInfo()
info.Location = contentBounds.Location
info.ContentBounds = contentBounds
GroupInfo.ContentBounds = contentBounds
info.MaxColumnWidth = 0
info.ColumnItemCount = 0
info.Position = 0
While info.Position < GroupInfo.Items.Count
info.ItemInfo = GroupInfo.Items(info.Position)
InsertItem(info)
info.Position += 1
End While
If GroupInfo.ViewInfo.Ribbon.AutoSizeItems Then AutoSizeItems(info)
RelayoutItemsInColumn()
Dim width As Integer = info.Location.X + info.MaxColumnWidth - info.ContentBounds.Left
Return width
End Function
Protected Overrides Sub RelayoutItemsInColumn()
End Sub
End Class
End Namespace