Skip to content

Commit

Permalink
moved repeated code into method
Browse files Browse the repository at this point in the history
  • Loading branch information
A-tG committed May 1, 2022
1 parent a10adba commit 52a79ef
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions VoicemeeterOsdProgram/Options/OsdOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,7 @@ public HashSet<StripElements> AlwaysShowElements
get => m_alwaysShowElements;
set
{
if ((value.Count > 1) && value.Contains(StripElements.None))
{
value.Remove(StripElements.None);
}
if (value.Count == 0)
{
value.Add(StripElements.None);
}

HandleStripElementsCollection(value);
HandlePropertyChange(ref m_alwaysShowElements, ref value, AlwaysShowElementsChanged);
}
}
Expand All @@ -100,15 +92,7 @@ public HashSet<StripElements> NeverShowElements
get => m_neverShowElements;
set
{
if ((value.Count > 1) && value.Contains(StripElements.None))
{
value.Remove(StripElements.None);
}
if (value.Count == 0)
{
value.Add(StripElements.None);
}

HandleStripElementsCollection(value);
HandlePropertyChange(ref m_neverShowElements, ref value, NeverShowElementsChanged);
}
}
Expand Down Expand Up @@ -160,6 +144,18 @@ public override bool TryParseTo(string fromPropertyName, out string toVal)
}
}

private void HandleStripElementsCollection(ICollection<StripElements> elements)
{
if ((elements.Count > 1) && elements.Contains(StripElements.None))
{
elements.Remove(StripElements.None);
}
if (elements.Count == 0)
{
elements.Add(StripElements.None);
}
}

public event EventHandler<bool> DontShowIfVoicemeeterVisibleChanged;
public event EventHandler<bool> IsInteractableChanged;
public event EventHandler<uint> DurationMsChanged;
Expand Down

0 comments on commit 52a79ef

Please sign in to comment.