Skip to content

Commit

Permalink
minor cleanup and perf. changes
Browse files Browse the repository at this point in the history
- updated theme colors to be more consistent
- added custom panel to apply the same tweaks for double buffering and
transparency as groupboxes
- fixed the naming of tab controls
- updated the themes to support alpha colors
- general cleanup
  • Loading branch information
splintermind committed Dec 23, 2013
1 parent 757aef8 commit 60956a7
Show file tree
Hide file tree
Showing 15 changed files with 2,224 additions and 2,204 deletions.
Binary file modified Masterwork Dwarf Fortress.exe
Binary file not shown.
Binary file modified MasterworkDwarfFortress/System.Windows.Forms.Ribbon35.dll
Binary file not shown.
4,223 changes: 2,112 additions & 2,111 deletions Settings Source/MainForm.Designer.vb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Settings Source/MainForm.vb
Expand Up @@ -139,7 +139,7 @@ Imports System.ComponentModel
setTheme()
Dim frmWait As New frmThemeChange
Me.Opacity = 0
Me.tabMain.SelectedTab = tabSettings2 'choose a tab with few controls as the refresh causes massive flickering
Me.tabMain.SelectedTab = tabSettings 'choose a tab with few controls as the refresh causes massive flickering
frmWait.Show()
Application.DoEvents() 'hurrghh, this is a bad idea
initControls(Me, ToolTipMaker, False, False, True)
Expand Down Expand Up @@ -239,12 +239,12 @@ Imports System.ComponentModel
globals.currentWorldGenIndex = CType(cmbWorldGenIndex.SelectedItem, comboItem).value
'refresh our world gen controls. the internal loading will check the global var
'm_refreshingWorldGen = True
initControls(tabWorldGen2, ToolTipMaker, True, False, False)
initControls(tabWorldGen, ToolTipMaker, True, False, False)
'm_refreshingWorldGen = False
End Sub

Private Sub tabMain_SelectedIndexChanged(sender As Object, e As EventArgs) Handles tabMain.SelectedIndexChanged
If tabMain.SelectedTab Is tabWorldGen2 Then
If tabMain.SelectedTab Is tabWorldGen Then
AddHandler cmbWorldGenIndex.SelectionChangeCommitted, AddressOf refreshWorldGen
Else
RemoveHandler cmbWorldGenIndex.SelectionChangeCommitted, AddressOf refreshWorldGen
Expand Down
6 changes: 6 additions & 0 deletions Settings Source/Masterwork Dwarf Fortress.vbproj
Expand Up @@ -139,6 +139,12 @@
<Compile Include="custom controls\mwGroupBox.vb">
<SubType>Component</SubType>
</Compile>
<Compile Include="custom controls\mwPanel.Designer.vb">
<DependentUpon>mwPanel.vb</DependentUpon>
</Compile>
<Compile Include="custom controls\mwPanel.vb">
<SubType>Component</SubType>
</Compile>
<Compile Include="custom controls\mwTableLayout.Designer.vb">
<DependentUpon>mwTableLayout.vb</DependentUpon>
</Compile>
Expand Down
Expand Up @@ -288,15 +288,10 @@ public string ThemeDateCreated
//internal static Color FromHex(string hex)
static Color FromHexStr(string hex)
{
if (hex.StartsWith("#"))
hex = hex.Substring(1);
if (hex.Length < 7 || hex.Length > 9)
throw new Exception("Invalid color!");

if (hex.Length != 6) throw new Exception("Color not valid");

return Color.FromArgb(
int.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber),
int.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber),
int.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber));
return System.Drawing.ColorTranslator.FromHtml(hex);
}

public Color FromHex(string hex)
Expand Down
Expand Up @@ -81,7 +81,7 @@ public RibbonProfesionalRendererColorTableBlue()
PanelOverflowBackgroundSelectedNorth = FromHex("#FFFFFF");
PanelOverflowBackgroundSelectedSouth = FromHex("#B8D7FD");
ButtonBgOut = FromHex("#C1D5F1");
ButtonBgCenter = FromHex("#CFE0F7");
ButtonBgCenter = FromHex("#FFFFFF");
ButtonBorderOut = FromHex("#B9D0ED");
ButtonBorderIn = FromHex("#E3EDFB");
ButtonGlossyNorth = FromHex("#DEEBFE");
Expand Down
Expand Up @@ -26,6 +26,7 @@ public class RibbonProfesionalRendererColorTableNormal
string m_lightGray = "#D0D0D0";
string m_medGray = "#757575";
string m_textColor = "#F8F8F2";
string m_transBack = "#82000000";

public RibbonProfesionalRendererColorTableNormal()
{
Expand Down Expand Up @@ -78,7 +79,8 @@ public RibbonProfesionalRendererColorTableNormal()
TabContentNorth = FromHex(m_medGray);
TabContentSouth = FromHex("#B7B7B7");
TabSelectedGlow = FromHex(m_highlight);
PanelDarkBorder = FromHex(m_medGray);

PanelDarkBorder = FromHex(m_transBack);
PanelLightBorder = FromHex(m_lightGray);
PanelTextBackground = FromHex(m_backgroundColor);
PanelTextBackgroundSelected = FromHex(m_medGray);
Expand All @@ -90,7 +92,7 @@ public RibbonProfesionalRendererColorTableNormal()
PanelOverflowBackgroundSelectedSouth = FromHex(m_medGray);

ButtonBgOut = FromHex(m_medGray);
ButtonBgCenter = FromHex(m_backgroundColor);
ButtonBgCenter = FromHex(m_transBack);
ButtonBorderOut = FromHex(m_lightGray);
ButtonBorderIn = FromHex(m_medGray);
ButtonGlossyNorth = FromHex(m_lightGray);
Expand Down
36 changes: 9 additions & 27 deletions Settings Source/custom controls/mwCheckBox.vb
Expand Up @@ -11,11 +11,7 @@
Me.Appearance = Windows.Forms.Appearance.Button
Me.FlatStyle = FlatStyle.Flat
Me.FlatAppearance.BorderSize = 0
'Me.TextAlign = ContentAlignment.MiddleCenter
'Me.ImageAlign = ContentAlignment.MiddleLeft
Me.DoubleBuffered = True


Me.ForeColor = Theme.ColorTable.Text
Me.Image = My.Resources.cross_small
End Sub
Expand All @@ -30,28 +26,15 @@

Public Sub applyTheme() Implements iTheme.applyTheme
If Theme.ThemeColor = RibbonTheme.Normal Then
'Me.BackgroundImage = My.Resources.transp_1
'Me.BackgroundImageLayout = ImageLayout.Tile

'Me.BackColor = Color.Transparent
'Me.FlatAppearance.CheckedBackColor = Color.Transparent
Me.BackColor = Drawing.Color.FromArgb(130, 0, 0, 0)
Me.FlatAppearance.CheckedBackColor = Drawing.Color.FromArgb(130, 0, 0, 0)

Me.FlatAppearance.MouseOverBackColor = Theme.ColorTable.TabSelectedGlow
Me.FlatAppearance.MouseDownBackColor = Theme.ColorTable.TabSelectedGlow
Else
'Me.FlatStyle = Windows.Forms.FlatStyle.Standard
'Me.BackgroundImageLayout = ImageLayout.None
'Me.BackgroundImage = Nothing

Me.BackColor = Theme.ColorTable.RibbonBackground_2013
Me.FlatAppearance.CheckedBackColor = Theme.ColorTable.RibbonBackground_2013
Me.FlatAppearance.MouseDownBackColor = Theme.ColorTable.RibbonBackground_2013

Me.FlatAppearance.MouseOverBackColor = Theme.ColorTable.ButtonSelected_2013
End If

Me.BackColor = Theme.ColorTable.ButtonBgCenter
Me.FlatAppearance.CheckedBackColor = Theme.ColorTable.ButtonBgCenter
Me.FlatAppearance.BorderSize = 0
Me.ForeColor = Theme.ColorTable.Text
End Sub
Expand All @@ -64,12 +47,11 @@
End If
End Function

'Protected Overrides ReadOnly Property CreateParams() As CreateParams
' Get
' Dim parms = MyBase.CreateParams
' parms.Style = parms.Style And Not &H2000000 ' Turn off WS_CLIPCHILDREN
' Return parms
' End Get
'End Property

Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H20
Return cp
End Get
End Property
End Class
7 changes: 7 additions & 0 deletions Settings Source/custom controls/mwComboBox.vb
Expand Up @@ -17,4 +17,11 @@
Me.ForeColor = Theme.ColorTable.Text
End Sub

Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H20
Return cp
End Get
End Property
End Class
28 changes: 28 additions & 0 deletions Settings Source/custom controls/mwPanel.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Settings Source/custom controls/mwPanel.vb
@@ -0,0 +1,21 @@
Public Class mwPanel
Inherits Panel

Public Sub New()

' This call is required by the designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.
Me.DoubleBuffered = True
Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
End Sub

Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H20
Return cp
End Get
End Property
End Class
9 changes: 9 additions & 0 deletions Settings Source/custom controls/mwTableLayout.vb
Expand Up @@ -7,5 +7,14 @@

' Add any initialization after the InitializeComponent() call.
Me.DoubleBuffered = True
Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
End Sub

Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H20
Return cp
End Get
End Property
End Class
1 change: 0 additions & 1 deletion Settings Source/globals.vb
Expand Up @@ -20,5 +20,4 @@
Public Shared m_tokensWorldGen As New Dictionary(Of Integer, Dictionary(Of String, List(Of String)))

Public Shared currentWorldGenIndex As Integer

End Class
72 changes: 21 additions & 51 deletions Settings Source/management classes/utils.vb
@@ -1,6 +1,5 @@
Public Class utils


Public Shared Sub initControls(ByVal parentControl As Control, ByRef toolTipMaker As ToolTip, ByVal loadSetting As Boolean, ByVal loadTooltip As Boolean, ByVal loadTheme As Boolean)
For Each c As Control In parentControl.Controls

Expand All @@ -11,7 +10,6 @@
Else
formatControl(c)
End If

End If

If loadTooltip Then
Expand All @@ -35,17 +33,14 @@
End If
End If

If c.HasChildren Then
initControls(c, toolTipMaker, loadSetting, loadTooltip, loadTheme)
If c.HasChildren Then
initControls(c, toolTipMaker, loadSetting, loadTooltip, loadTheme)
End If
Next
End Sub

Public Shared Sub formatControl(ByVal c As Control)
'this formats any non-custom controls with the ribbon's theme colors
'currently groupboxes and labels only have their forecolor changed,
'since solid backgrounds hides our beautiful background image

'format controls according to the currently applied ribbon theme's colors
Select Case c.GetType
Case GetType(Button)
Dim btn As Button = DirectCast(c, Button)
Expand All @@ -55,68 +50,43 @@
btn.FlatAppearance.MouseDownBackColor = Theme.ColorTable.ButtonSelected_2013
btn.FlatAppearance.BorderSize = 0

If Theme.ThemeColor <> RibbonTheme.Normal Then
'btn.BackgroundImage = Nothing
'btn.BackgroundImageLayout = ImageLayout.None
btn.BackColor = Theme.ColorTable.RibbonBackground_2013
btn.FlatAppearance.CheckedBackColor = Theme.ColorTable.RibbonBackground_2013
Else
'btn.BackgroundImage = My.Resources.transp_1
'btn.BackgroundImageLayout = ImageLayout.Tile
btn.BackColor = Drawing.Color.FromArgb(130, 0, 0, 0) 'Color.Transparent
btn.FlatAppearance.CheckedBackColor = Drawing.Color.FromArgb(130, 0, 0, 0) 'Color.Transparent
End If
btn.BackColor = Theme.ColorTable.ButtonBgCenter
btn.FlatAppearance.CheckedBackColor = Theme.ColorTable.ButtonBgCenter

Case GetType(Label)
'slight exception here in that we want transparent labels for the default theme
'also if a label is not within any groupbox/panel, leave it transparent as well
If Theme.ThemeColor = RibbonTheme.Normal Then
c.BackColor = Drawing.Color.FromArgb(0, 0, 0, 0) 'Color.Transparent
c.BackColor = Color.Transparent
Else
If TypeOf c.Parent Is TabPage Then
c.BackColor = Drawing.Color.FromArgb(0, 0, 0, 0)
c.BackColor = Color.Transparent
Else
c.BackColor = c.Parent.BackColor
End If
End If
c.ForeColor = Theme.ColorTable.Caption1

Case GetType(GroupBox), GetType(Panel), GetType(mwGroupBox)
Case GetType(GroupBox), GetType(Panel), GetType(mwGroupBox), GetType(mwPanel)
c.ForeColor = Theme.ColorTable.Caption1
If Theme.ThemeColor <> RibbonTheme.Normal Then
'c.BackgroundImage = Nothing
'c.BackgroundImageLayout = ImageLayout.None
c.BackColor = Theme.ColorTable.PanelDarkBorder
Else
'c.BackgroundImage = My.Resources.transp_1
c.BackColor = Drawing.Color.FromArgb(130, 0, 0, 0) 'Color.Transparent
'c.BackgroundImageLayout = ImageLayout.Tile
End If
c.BackColor = Theme.ColorTable.PanelDarkBorder

Case GetType(ComboBox)
Dim cb As ComboBox = DirectCast(c, ComboBox)
cb.ForeColor = Theme.ColorTable.Text
cb.BackColor = Theme.ColorTable.DropDownBg
cb.FlatStyle = FlatStyle.Flat
Dim cb As ComboBox = DirectCast(c, ComboBox)
cb.ForeColor = Theme.ColorTable.Text
cb.BackColor = Theme.ColorTable.DropDownBg
cb.FlatStyle = FlatStyle.Flat

Case GetType(KRBTabControl.KRBTabControl)
Dim tabMain As KRBTabControl.KRBTabControl = CType(c, KRBTabControl.KRBTabControl)

If Theme.ThemeColor = RibbonTheme.Normal Then
tabMain.BorderColor = Drawing.Color.FromArgb(0, 0, 0, 0) 'Color.Transparent
tabMain.BackgroundColor = Drawing.Color.FromArgb(0, 0, 0, 0) 'Color.Transparent
tabMain.TabBorderColor = Drawing.Color.FromArgb(0, 0, 0, 0) 'Color.Transparent
Else
tabMain.BorderColor = Theme.ColorTable.PanelBorder_2013
tabMain.BackgroundColor = Theme.ColorTable.RibbonBackground_2013
tabMain.TabBorderColor = Theme.ColorTable.TabText_2013
End If

Dim tabMain As KRBTabControl.KRBTabControl = CType(c, KRBTabControl.KRBTabControl)

tabMain.BackgroundColor = Theme.ColorTable.RibbonBackground_2013

tabMain.TabGradient.ColorStart = Theme.ColorTable.TabActiveBackground_2013
tabMain.TabGradient.ColorEnd = Theme.ColorTable.TabActiveBackground_2013
tabMain.TabGradient.ColorStart = Theme.ColorTable.TabActiveBackground_2013
tabMain.TabGradient.ColorEnd = Theme.ColorTable.TabActiveBackground_2013

tabMain.TabGradient.TabPageSelectedTextColor = Theme.ColorTable.Caption1
tabMain.TabGradient.TabPageTextColor = Theme.ColorTable.TabText_2013
tabMain.TabGradient.TabPageSelectedTextColor = Theme.ColorTable.Caption1
tabMain.TabGradient.TabPageTextColor = Theme.ColorTable.TabText_2013
End Select
End Sub

Expand Down

0 comments on commit 60956a7

Please sign in to comment.