Skip to content

Commit f67581c

Browse files
committed
Updated themes
1 parent 3097086 commit f67581c

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

Source/RunActivity/Viewer3D/Debugging/DebugViewerBetaForm.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public partial class DispatchViewerBeta : Form
2727
public readonly Simulator simulator;
2828
private readonly MapDataProvider MapDataProvider;
2929
private readonly MapThemeProvider MapThemeProvider;
30+
private string ThemeName = "light";
3031
private ThemeStyle Theme;
3132
/// <summary>
3233
/// Used to periodically check if we should shift the view when the
@@ -140,7 +141,7 @@ void InitializeForm()
140141
{
141142
MapDataProvider.SetControls();
142143
MapThemeProvider.InitializeThemes();
143-
Theme = MapThemeProvider.LightTheme;
144+
Theme = MapThemeProvider.GetTheme(ThemeName);
144145

145146
float[] dashPattern = { 4, 2 };
146147
ZoomTargetPen.DashPattern = dashPattern;
@@ -1714,7 +1715,12 @@ private void DispatchViewerBeta_Resize(object sender, EventArgs e)
17141715

17151716
private void rotateThemesButton_Click(object sender, EventArgs e)
17161717
{
1717-
Theme = Theme == MapThemeProvider.LightTheme ? MapThemeProvider.DarkTheme : MapThemeProvider.LightTheme;
1718+
// Cycles through the array of available themes
1719+
string[] themes = MapThemeProvider.GetThemes();
1720+
int i = Array.IndexOf(themes, ThemeName);
1721+
ThemeName = i >= 0 && i < themes.Length - 1 ? themes[i + 1] : themes[0];
1722+
1723+
Theme = MapThemeProvider.GetTheme(ThemeName);
17181724

17191725
ApplyThemeRecursively(this);
17201726
MapCanvasColor = Theme.MapCanvasColor;

Source/RunActivity/Viewer3D/Debugging/MapThemeProvider.cs

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
using System.Drawing;
1+
using System.Collections.Generic;
2+
using System.Drawing;
3+
using System.Linq;
24
using System.Windows.Forms;
35

46
namespace Orts.Viewer3D.Debugging
57
{
68
public class MapThemeProvider
79
{
8-
public ThemeStyle LightTheme;
9-
public ThemeStyle DarkTheme;
10-
1110
public void InitializeThemes()
1211
{
13-
LightTheme = new ThemeStyle
12+
ThemeStyle LightTheme = new ThemeStyle
1413
{
1514
BackColor = Color.Transparent,
1615
ForeColor = SystemColors.ControlText,
@@ -20,7 +19,7 @@ public void InitializeThemes()
2019
TrackColor = Color.FromArgb(46, 64, 83),
2120
};
2221

23-
DarkTheme = new ThemeStyle
22+
ThemeStyle DarkTheme = new ThemeStyle
2423
{
2524
BackColor = Color.FromArgb(44, 62, 80),
2625
ForeColor = Color.FromArgb(247, 249, 249),
@@ -29,6 +28,50 @@ public void InitializeThemes()
2928
MapCanvasColor = Color.FromArgb(44, 62, 80),
3029
TrackColor = Color.FromArgb(234, 236, 238),
3130
};
31+
32+
// Reference for "solarized" themes: https://github.com/altercation/solarized?tab=readme-ov-file#the-values
33+
ThemeStyle LightSolarizedTheme = new ThemeStyle
34+
{
35+
BackColor = Color.FromArgb(253, 246, 227),
36+
ForeColor = Color.FromArgb(101, 123, 131),
37+
PanelBackColor = Color.FromArgb(238, 232, 213),
38+
FlatStyle = FlatStyle.Flat,
39+
MapCanvasColor = Color.FromArgb(253, 246, 227),
40+
TrackColor = Color.FromArgb(88, 110, 117),
41+
};
42+
43+
ThemeStyle DarkSolarizedTheme = new ThemeStyle
44+
{
45+
BackColor = Color.FromArgb(0, 43, 54),
46+
ForeColor = Color.FromArgb(131, 148, 150),
47+
PanelBackColor = Color.FromArgb(28, 40, 51),
48+
FlatStyle = FlatStyle.Flat,
49+
MapCanvasColor = Color.FromArgb(0, 43, 54),
50+
TrackColor = Color.FromArgb(147, 161, 161),
51+
};
52+
53+
Themes.Add("light", LightTheme);
54+
Themes.Add("light-solarized", LightSolarizedTheme);
55+
Themes.Add("dark-solarized", DarkSolarizedTheme);
56+
Themes.Add("dark", DarkTheme);
57+
}
58+
59+
private Dictionary<string, ThemeStyle> Themes = new Dictionary<string, ThemeStyle>();
60+
61+
public ThemeStyle GetTheme(string themeName)
62+
{
63+
if (Themes.TryGetValue(themeName, out ThemeStyle theme))
64+
{
65+
return theme;
66+
}
67+
68+
// Handle the case when the theme doesn't exist
69+
return null;
70+
}
71+
72+
public string[] GetThemes()
73+
{
74+
return Themes.Keys.ToArray();
3275
}
3376
}
3477

0 commit comments

Comments
 (0)