Skip to content

Commit

Permalink
Read theme name from file and show it in the menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Łaputa authored and Krzysztof Łaputa committed Apr 8, 2019
1 parent a3bbeb7 commit bae6b91
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions DarkTheme/DarkTheme.cs
Expand Up @@ -22,6 +22,11 @@ public bool Enabled
set { SetEnable(value); }
}

public string Name
{
get { return _skin.Name; }
}

public DarkTheme(bool enabled)
{
_defaultSkin = new DefaultSkin();
Expand Down
15 changes: 8 additions & 7 deletions DarkTheme/DarkThemeExt.cs
Expand Up @@ -10,12 +10,12 @@ namespace DarkTheme
{
public sealed class DarkThemeExt : Plugin
{
private const string DarkThemeMenuItemCaption = "Dark theme";
private const string DarkModeOnConfigItem = "DarkTheme.Enabled";

private ControlVisitor _controlVisitor;
private DarkTheme _theme;
private IPluginHost _host;
private ToolStripMenuItem _menuItem;

public override bool Initialize(IPluginHost host)
{
Expand All @@ -40,12 +40,12 @@ public override ToolStripMenuItem GetMenuItem(PluginMenuType t)
{
if (t == PluginMenuType.Main)
{
var menuItem = new ToolStripMenuItem(DarkThemeMenuItemCaption);
menuItem.CheckOnClick = true;
menuItem.Checked = _theme.Enabled;
menuItem.ShortcutKeys = Keys.Control | Keys.T;
menuItem.Click += HandleToggleDarkModeMenuItemClick;
return menuItem;
_menuItem = new ToolStripMenuItem(_theme.Name);
_menuItem.CheckOnClick = true;
_menuItem.Checked = _theme.Enabled;
_menuItem.ShortcutKeys = Keys.Control | Keys.T;
_menuItem.Click += HandleToggleDarkModeMenuItemClick;
return _menuItem;
}

return base.GetMenuItem(t);
Expand All @@ -55,6 +55,7 @@ private void HandleToggleDarkModeMenuItemClick(object sender, EventArgs eventArg
{
_theme.Enabled = !_theme.Enabled;
_host.CustomConfig.SetBool(DarkModeOnConfigItem, _theme.Enabled);
_menuItem.Text = _theme.Name;

ApplyThemeInOpenForms();
}
Expand Down
4 changes: 2 additions & 2 deletions DarkTheme/Properties/AssemblyInfo.cs
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("0.3.0.0")]
2 changes: 2 additions & 0 deletions DarkTheme/Skin/ISkin.cs
Expand Up @@ -5,6 +5,8 @@ namespace DarkTheme.Skin
{
internal interface ISkin
{
string Name { get; }

TreeViewDrawMode TreeViewDrawMode { get; }
Image ListViewBackground { get; }
bool ListViewBackgroundTiled { get; }
Expand Down

0 comments on commit bae6b91

Please sign in to comment.