Imports System Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Runtime.InteropServices Imports System.Windows.Forms Imports TD.SandBar Public Class Office2003RendererEx Inherits Office2003Renderer Private m_lowColor As Boolean = False Private NotInheritable Class Win32 Const ENUM_CURRENT_SETTINGS As Integer = -1& Public Structure DEVMODE Public dmDeviceName As String Public dmSpecVersion As Short Public dmDriverVersion As Short Public dmSize As Short Public dmDriverExtra As Short Public dmFields As Integer Public dmOrientation As Short Public dmPaperSize As Short Public dmPaperLength As Short Public dmPaperWidth As Short Public dmScale As Short Public dmCopies As Short Public dmDefaultSource As Short Public dmPrintQuality As Short Public dmColor As Short Public dmDuplex As Short Public dmYResolution As Short Public dmTTOption As Short Public dmCollate As Short Public dmFormName As String Public dmUnusedPadding As Short Public dmBitsPerPel As Short Public dmPelsWidth As Integer Public dmPelsHeight As Integer Public dmDisplayFlags As Integer Public dmDisplayFrequency As Integer End Structure Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" _ (ByVal lpszDeviceName As IntPtr, ByVal iModeNum As Integer, ByRef lpDevMode As DEVMODE) As Boolean Public Shared Function GetCurrentDisplaySettings() As DEVMODE Dim DevM As DEVMODE If EnumDisplaySettings(IntPtr.Zero, ENUM_CURRENT_SETTINGS, DevM) Then Return DevM Else Return Nothing End If End Function End Class Public Sub New() LowColor = Win32.GetCurrentDisplaySettings().dmBitsPerPel <= 15 End Sub Public Property LowColor() As Boolean Get Return m_lowColor End Get Set(ByVal Value As Boolean) m_lowColor = Value End Set End Property Protected Overrides Sub DrawToolBarBackground(ByVal graphics As System.Drawing.Graphics, ByVal vertical As Boolean) If Not LowColor Then MyBase.DrawToolBarBackground(graphics, vertical) Else graphics.Clear(SystemColors.Control) If Not TypeOf Me.Toolbar Is TD.SandBar.MenuBar AndAlso Not Me.Toolbar.IsFloating Then Dim rect As Rectangle = ToolBar.ClientRectangle rect.Inflate(-1, -1) Dim x, y, w, h As Integer x = rect.X y = rect.Y - 1 w = rect.Width h = rect.Height + 1 Dim path As New GraphicsPath path.AddLine(x + 2, y, x + w - 2, y) path.AddLine(x + w - 2, y, x + w, y + 2) path.AddLine(x + w, y + 2, x + w, y + h - 2) path.AddLine(x + w, y + h - 2, x + w - 2, y + h) path.AddLine(x + w - 2, y + h, x + 2, y + h) path.AddLine(x + 2, y + h, x, y + h - 2) path.AddLine(x, y + h - 2, x, y + 2) path.AddLine(x, y + 2, x + 2, y) Dim p As New Pen(SystemColors.ControlDark) p.DashStyle = DashStyle.Dot graphics.DrawPath(p, path) End If End If End Sub Protected Overrides Sub DrawButtonHighlight(ByVal graphics As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal state As TD.SandBar.ToolBarItemState, ByVal checked As Boolean, ByVal dropDown As Boolean) If Not LowColor Then MyBase.DrawButtonHighlight(graphics, bounds, state, checked, dropDown) Else Dim back As SolidBrush = Nothing Dim border As Pen = New Pen(SystemColors.Highlight) If state.Pushed AndAlso state.Selected OrElse dropDown OrElse (checked AndAlso state.Selected) Then back = New SolidBrush(SystemColors.Highlight) Else back = New SolidBrush(Color.White) End If If state.Pushed OrElse state.Selected OrElse checked Then graphics.FillRectangle(back, bounds) graphics.DrawRectangle(border, bounds) End If End If End Sub Protected Overrides Sub DrawContainerBackground(ByVal graphics As System.Drawing.Graphics, ByVal container As TD.SandBar.ToolBarContainer, ByVal vertical As Boolean) If LowColor Then graphics.Clear(SystemColors.Control) Else MyBase.DrawContainerBackground(graphics, container, vertical) End If End Sub Protected Overrides Sub DrawToolBarActionsButton(ByVal graphics As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal chevron As Boolean, ByVal state As TD.SandBar.ToolBarItemState, ByVal designMode As Boolean) If LowColor Then Dim points(8) As Point Dim back As Brush Dim border As Pen Dim x, y As Integer If state.Pushed Then back = New SolidBrush(SystemColors.Control) border = New Pen(Color.Black) ElseIf state.Selected Then back = New SolidBrush(Color.White) border = New Pen(SystemColors.Highlight) Else back = New SolidBrush(SystemColors.Control) border = Nothing End If If vertical Then bounds.X += 1 bounds.Width -= 2 bounds.Height -= 3 Else bounds.Y += 1 bounds.X += 1 bounds.Height -= 3 bounds.Width -= 3 End If graphics.FillRectangle(back, bounds) If Not border Is Nothing Then graphics.DrawRectangle(border, bounds) If designMode Then If Vertical Then x = bounds.X + bounds.Width / 2 y = bounds.Y + bounds.Height / 2 - 1 Else x = bounds.X + bounds.Width / 2 + 1 y = bounds.Y + bounds.Height / 2 - 1 End If graphics.DrawLine(Pens.White, x - 1, y + 1, x + 3, y + 1) graphics.DrawLine(Pens.White, x + 1, y - 1, x + 1, y + 3) graphics.DrawLine(Pens.Black, x - 2, y, x + 2, y) graphics.DrawLine(Pens.Black, x, y - 2, x, y + 2) Else If chevron Then DrawChevron(graphics, bounds.X + 2, bounds.Y + 4) If Vertical Then MyBase.DrawVerticalArrowGlyph(graphics, bounds.Right - 6, bounds.Bottom - 6, Color.White) MyBase.DrawVerticalArrowGlyph(graphics, bounds.Right - 7, bounds.Bottom - 7, Color.Black) graphics.DrawLine(Pens.Black, bounds.Right - 10, bounds.Y + 3, bounds.Right - 10, bounds.Bottom - 3) graphics.DrawLine(Pens.White, bounds.Right - 9, bounds.Y + 4, bounds.Right - 9, bounds.Bottom - 2) Else MyBase.DrawArrowGlyph(graphics, bounds.X + 4, bounds.Bottom - 6, Color.White) MyBase.DrawArrowGlyph(graphics, bounds.X + 3, bounds.Bottom - 7, Color.Black) graphics.DrawLine(Pens.Black, bounds.X + 3, bounds.Bottom - 10, bounds.X + 7, bounds.Bottom - 10) graphics.DrawLine(Pens.White, bounds.X + 4, bounds.Bottom - 9, bounds.X + 8, bounds.Bottom - 9) End If End If back.Dispose() If Not border Is Nothing Then border.Dispose() Else MyBase.DrawToolBarActionsButton(graphics, bounds, chevron, state, designMode) End If End Sub Protected Overrides Sub DrawMenuBackground(ByVal graphics As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal marginWidth As Integer, ByVal breakOffset As Integer, ByVal breakSize As Integer, ByVal breakTop As Boolean) If LowColor Then graphics.Clear(Color.White) graphics.DrawRectangle(Pens.Black, bounds) If breakSize > 0 Then If breakTop Then graphics.DrawLine(Pens.White, breakOffset + 1, 0, breakOffset + breakSize - 1, 0) Else graphics.DrawLine(Pens.White, breakOffset + 1, bounds.Bottom, breakOffset + breakSize - 1, bounds.Bottom) End If End If bounds.Inflate(-1, -1) bounds.Y = bounds.Y + 1 bounds.Height = bounds.Height - 1 bounds.Width = marginWidth - 8 graphics.FillRectangle(SystemBrushes.Control, bounds) Else MyBase.DrawMenuBackground(graphics, bounds, marginWidth, breakOffset, breakSize, breakTop) End If End Sub Protected Overrides Sub DrawMenuItemHighlight(ByVal graphics As System.Drawing.Graphics, ByVal item As TD.SandBar.MenuButtonItem, ByVal bounds As System.Drawing.Rectangle) If LowColor Then Dim brush As New SolidBrush(Color.White) graphics.FillRectangle(brush, bounds) brush.Dispose() Dim p As New Pen(HighlightBorderColor) graphics.DrawRectangle(p, bounds) p.Dispose() Else MyBase.DrawMenuItemHighlight(graphics, item, bounds) End If End Sub Protected Overrides Sub PaintMenuBarItem(ByVal graphics As System.Drawing.Graphics, ByVal item As TD.SandBar.MenuBarItem, ByVal state As TD.SandBar.ToolBarItemState) If LowColor Then If state.Pushed Then graphics.FillRectangle(SystemBrushes.Control, item.ButtonBounds) PaintPushedDropDownButton(graphics, item) Dim p As New Pen(SystemColors.ControlDark, 2) graphics.DrawLine(p, item.ButtonBounds.Right + 2, item.ButtonBounds.Top + 2, item.ButtonBounds.Right + 2, item.ButtonBounds.Bottom) p.Dispose() Else DrawButtonHighlight(graphics, item.ButtonBounds, state, False, False) End If DrawText(graphics, item, state, item.ButtonInnerBounds, Me.centreTextFormat) Else MyBase.PaintMenuBarItem(graphics, item, state) End If End Sub Protected Overrides Sub PaintPushedDropDownButton(ByVal graphics As System.Drawing.Graphics, ByVal item As TD.SandBar.TopLevelMenuItemBase) If LowColor Then Dim rect As Rectangle = item.ButtonBounds If item.MenuDirection <> TopLevelMenuItemBase.MenuOffset.Left Then graphics.DrawLine(Pens.Black, rect.Left, rect.Top, rect.Left, rect.Bottom - 1) If item.MenuDirection <> TopLevelMenuItemBase.MenuOffset.Right Then graphics.DrawLine(Pens.Black, rect.Right, rect.Top, rect.Right, rect.Bottom - 1) If item.MenuDirection <> TopLevelMenuItemBase.MenuOffset.Bottom Then graphics.DrawLine(Pens.Black, rect.Left, rect.Bottom, rect.Right, rect.Bottom) If item.MenuDirection <> TopLevelMenuItemBase.MenuOffset.Top Then graphics.DrawLine(Pens.Black, rect.Left, rect.Top, rect.Right, rect.Top) Else MyBase.PaintPushedDropDownButton(graphics, item) End If End Sub Protected Overrides Sub DrawComboBoxButton(ByVal graphics As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal combobox As System.Windows.Forms.ComboBox, ByVal selected As Boolean, ByVal pushed As Boolean) If LowColor Then Dim brush As SolidBrush If pushed Then brush = New SolidBrush(SystemColors.Highlight) ElseIf selected Then brush = New SolidBrush(Color.White) Else bounds.Y -= 1 brush = New SolidBrush(SystemColors.Control) End If graphics.FillRectangle(brush, bounds) brush.Dispose() Else MyBase.DrawComboBoxButton(graphics, bounds, combobox, selected, pushed) End If End Sub Private Sub DrawChevron(ByVal graphics As Graphics, ByVal X As Integer, ByVal y As Integer) graphics.DrawLine(Pens.Black, X, y, X, y + 2) graphics.DrawLine(Pens.Black, X, y + 1, X + 1, y + 1) graphics.DrawLine(Pens.White, X + 1, y + 2, X + 1, y + 3) graphics.DrawLine(Pens.White, X + 1, y + 2, X + 2, y + 2) graphics.DrawLine(Pens.Black, X + 4, y, X + 4, y + 2) graphics.DrawLine(Pens.Black, X + 4, y + 1, X + 5, y + 1) graphics.DrawLine(Pens.White, X + 5, y + 2, X + 5, y + 3) graphics.DrawLine(Pens.White, X + 5, y + 2, X + 6, y + 2) End Sub End Class