Skip to content

Commit

Permalink
Fixed bug where only known colors could be used for foreground/backgr…
Browse files Browse the repository at this point in the history
…ound colors. Closes #7.
  • Loading branch information
mitchcapper committed Jan 26, 2017
1 parent 20a2bf8 commit 4b26e49
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions OptionsClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ public class OptionsClass {
internal bool shortcutAltQuick;
internal bool shortcutCntrlQuick;
internal bool shortcutWinQuick;
private Color ColorFromVal(string name) {
if (name != null && name.StartsWith("#"))
return System.Drawing.ColorTranslator.FromHtml(name);
return Color.FromName(name);
}
public void Load() {
try {
RegistryKey Key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\KeePassFloatingPanel");
if (Key == null)
return;
Transparency = (int)Key.GetValue("Transparency", (int)Transparency);
PanelColor = Color.FromName((string)Key.GetValue("PanelColor", PanelColor.Name));
FontColor = Color.FromName((string)Key.GetValue("FontColor", FontColor.Name));
PanelColor = ColorFromVal((string)Key.GetValue("PanelColor", PanelColor.Name));
FontColor = ColorFromVal((string)Key.GetValue("FontColor", FontColor.Name));
URLAction = (int)Key.GetValue("URLAction", URLAction);
sortAlphabetical = Convert.ToBoolean((string)Key.GetValue("SortEntries"));
startGroupUUID = (string)Key.GetValue("startGroupUUID");
Expand Down Expand Up @@ -67,8 +72,8 @@ public void Save() {
if (Key == null)
return;
Key.SetValue("Transparency", (int)Transparency);
Key.SetValue("PanelColor", PanelColor.Name);
Key.SetValue("FontColor", FontColor.Name);
Key.SetValue("PanelColor", PanelColor.IsNamedColor ? PanelColor.Name : "#" + PanelColor.Name);
Key.SetValue("FontColor", FontColor.IsNamedColor ? FontColor.Name : "#" + FontColor.Name);
Key.SetValue("URLAction", URLAction);
Key.SetValue("SortEntries", sortAlphabetical); //s²
Key.SetValue("ShowClock", showClock); //s²
Expand Down

0 comments on commit 4b26e49

Please sign in to comment.