Skip to content

Commit

Permalink
Update all referenced NuGets.
Browse files Browse the repository at this point in the history
Improve color coding

Issue #9
  • Loading branch information
steffen-wilke committed Jan 13, 2020
1 parent c9ffdf8 commit 79e5bc5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<Import Project="..\..\config\Soloplan.WhatsON.targets" />

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.12" />
<PackageReference Include="NLog" Version="4.6.6" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.17" />
<PackageReference Include="NLog" Version="4.6.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="gong-wpf-dragdrop">
<Version>2.0.4</Version>
<Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="Humanizer.Core">
<Version>2.6.2</Version>
<Version>2.7.9</Version>
</PackageReference>
<PackageReference Include="MaterialDesignThemes">
<Version>2.6.0</Version>
<Version>3.0.1</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>4.6.6</Version>
<Version>4.6.8</Version>
</PackageReference>
<PackageReference Include="System.Windows.Interactivity.WPF">
<Version>2.0.20525</Version>
Expand Down
8 changes: 4 additions & 4 deletions src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Humanizer.Core">
<Version>2.6.2</Version>
<Version>2.7.9</Version>
</PackageReference>
<PackageReference Include="MaterialDesignColors">
<Version>1.2.0</Version>
<Version>1.2.2</Version>
</PackageReference>
<PackageReference Include="MaterialDesignThemes">
<Version>2.6.0</Version>
<Version>3.0.1</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>4.6.6</Version>
<Version>4.6.8</Version>
</PackageReference>
<PackageReference Include="ShowMeTheXAML.MSBuild">
<Version>1.0.12</Version>
Expand Down
80 changes: 10 additions & 70 deletions src/Soloplan.WhatsON.GUI/ThemeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,24 @@ internal class ThemeHelper
{
static ThemeHelper()
{
PrimaryColor = Color.FromRgb(55, 71, 79);
SecondaryColor = Color.FromRgb(196, 80, 143);
PrimaryColor = Color.FromRgb(79, 103, 121);
SecondaryColor = Color.FromRgb(79, 103, 121);
}

public static Color PrimaryColor { get; private set; }

public static Color SecondaryColor { get; private set; }

public static Color ChangeColorBrightness(Color color, float correctionFactor)
{
var red = (float)color.R;
var green = (float)color.G;
var blue = (float)color.B;

if (correctionFactor < 0)
{
correctionFactor = 1 + correctionFactor;
red *= correctionFactor;
green *= correctionFactor;
blue *= correctionFactor;
}
else
{
red = ((255 - red) * correctionFactor) + red;
green = ((255 - green) * correctionFactor) + green;
blue = ((255 - blue) * correctionFactor) + blue;
}

return Color.FromRgb((byte)red, (byte)green, (byte)blue);
}

/// <summary>
/// Initializes this instance.
/// </summary>
public void Initialize(ColorSettings settings)
{
this.ApplySoloplanThemeColors(settings);
if (settings != null)
{
PrimaryColor = settings.Primary.GetColor();
SecondaryColor = settings.Secondary.GetColor();
}
}

/// <summary>
Expand All @@ -69,51 +50,10 @@ public void Initialize(ColorSettings settings)
/// <param name="isDark">if set to <c>true</c> dark mode will be applied.</param>
public void ApplyLightDarkMode(bool isDark)
{
var resourceDictionary = Application.Current.Resources.MergedDictionaries.Where(rd => rd.Source != (Uri)null).SingleOrDefault(rd => Regex.Match(rd.Source.OriginalString, "(\\/MaterialDesignThemes.Wpf;component\\/Themes\\/MaterialDesignTheme\\.)((Light)|(Dark))").Success);
if (resourceDictionary == null)
{
throw new ApplicationException("Unable to find Light/Dark base theme in Application resources.");
}

resourceDictionary["MaterialDesignPaper"] = new SolidColorBrush(isDark ? Color.FromRgb(45, 45, 48) : Color.FromRgb(249, 249, 249));
var paletteHelper = new PaletteHelper();
paletteHelper.SetLightDark(isDark);
}

/// <summary>
/// Applies our favorite colors to current palette.
/// </summary>
private void ApplySoloplanThemeColors(ColorSettings settings)
{
var baseTheme = isDark ? Theme.Dark : Theme.Light;
ITheme theme = isDark ? Theme.Create(baseTheme, PrimaryColor, Color.FromRgb(195, 0, 107)) : Theme.Create(baseTheme, SecondaryColor, Color.FromRgb(195, 0, 107));
var paletteHelper = new PaletteHelper();

var newPrimaryHues = new List<Hue>();
if (settings != null)
{
PrimaryColor = settings.Primary.GetColor();
SecondaryColor = settings.Primary.GetColor();
}

newPrimaryHues.Add(new Hue("Primary50", ChangeColorBrightness(PrimaryColor, 0.5f), Color.FromRgb(255, 255, 255)));
newPrimaryHues.Add(new Hue("Primary100", ChangeColorBrightness(PrimaryColor, 0.4f), Color.FromRgb(255, 255, 255)));
newPrimaryHues.Add(new Hue("Primary200", ChangeColorBrightness(PrimaryColor, 0.3f), Color.FromRgb(255, 255, 255)));
newPrimaryHues.Add(new Hue("Primary300", ChangeColorBrightness(PrimaryColor, 0.2f), Color.FromRgb(255, 255, 255)));
newPrimaryHues.Add(new Hue("Primary400", ChangeColorBrightness(PrimaryColor, 0.1f), Color.FromRgb(255, 255, 255)));
newPrimaryHues.Add(new Hue("Primary500", PrimaryColor, Color.FromRgb(255, 255, 255)));
newPrimaryHues.Add(new Hue("Primary600", ChangeColorBrightness(PrimaryColor, -0.1f), Color.FromRgb(255, 255, 255)));
newPrimaryHues.Add(new Hue("Primary700", ChangeColorBrightness(PrimaryColor, -0.2f), Color.FromRgb(255, 255, 255)));
newPrimaryHues.Add(new Hue("Primary800", ChangeColorBrightness(PrimaryColor, -0.3f), Color.FromRgb(255, 255, 255)));
newPrimaryHues.Add(new Hue("Primary900", ChangeColorBrightness(PrimaryColor, -0.4f), Color.FromRgb(255, 255, 255)));

var newAccentHues = new List<Hue>();
newAccentHues.Add(new Hue("Accent100", ChangeColorBrightness(PrimaryColor, 0.1f), Color.FromRgb(255, 255, 255)));
newAccentHues.Add(new Hue("Accent200", ChangeColorBrightness(SecondaryColor, 0.55f), Color.FromRgb(255, 255, 255)));
newAccentHues.Add(new Hue("Accent400", ChangeColorBrightness(SecondaryColor, -0.1f), Color.FromRgb(255, 255, 255)));
newAccentHues.Add(new Hue("Accent700", ChangeColorBrightness(SecondaryColor, -0.2f), Color.FromRgb(255, 255, 255)));

var swatch = new Swatch("WhatsON", newPrimaryHues, newAccentHues);
var palette = new Palette(swatch, swatch, 3, 5, 4, 2);
paletteHelper.ReplacePalette(palette);
paletteHelper.SetTheme(theme);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog">
<Version>4.6.6</Version>
<Version>4.6.8</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Import Project="..\..\config\Soloplan.WhatsON.targets" />

<ItemGroup>
<PackageReference Include="NLog" Version="4.6.6" />
<PackageReference Include="NLog" Version="4.6.8" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/Soloplan.WhatsON/ObservationScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ private async Task StartObserveSingle(ObservationConnector connector, Cancellati
await Task.Delay(millisecondsToWait, token);
}
}
catch (TaskCanceledException e)
{
}
catch (Exception e)
{
log.Error(e, "Exception occurred when observing connector {connector}", new { Interval = connector.Interval, Name = connector.Connector.Configuration.Name, CurrentStatus = connector.Connector.CurrentStatus });
Expand Down
4 changes: 2 additions & 2 deletions src/Soloplan.WhatsON/Soloplan.WhatsON.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<Import Project="..\..\config\Soloplan.WhatsON.targets" />

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="NLog" Version="4.6.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog" Version="4.6.8" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 79e5bc5

Please sign in to comment.