Skip to content
This repository has been archived by the owner on Apr 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from ThinkingTransistor/nuget-development
Browse files Browse the repository at this point in the history
(Automatic) nuget integration
  • Loading branch information
plainerman committed Mar 4, 2017
2 parents f218776 + 6a3067e commit e0d110d
Show file tree
Hide file tree
Showing 32 changed files with 572 additions and 106 deletions.
10 changes: 10 additions & 0 deletions Sigma.Core.Monitors.WPF.Tests/Sigma.Core.Monitors.WPF.Tests.csproj
Expand Up @@ -61,6 +61,16 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NugetBuild|AnyCPU'">
<OutputPath>bin\NugetBuild\</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NugetBuild|x64'">
<OutputPath>bin\x64\NugetBuild\</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.7\lib\net45-full\log4net.dll</HintPath>
Expand Down
9 changes: 9 additions & 0 deletions Sigma.Core.Monitors.WPF/Panels/Charts/AccuracyPanel.cs
Expand Up @@ -6,6 +6,11 @@

namespace Sigma.Core.Monitors.WPF.Panels.Charts
{
/// <summary>
/// This panel is specifically designed to display the accuracy.
/// The advantage when using this panel is that multiple accuracies can be
/// added and displayed automatically.
/// </summary>
public class AccuracyPanel : ChartPanel<CartesianChart, LineSeries, double>
{

Expand Down Expand Up @@ -42,6 +47,10 @@ public AccuracyPanel(string title, ITrainer trainer, object headerContent = null
AxisY.MaxValue = 100;
}

/// <summary>
/// This hook is specifically designed to report values to the <see cref="AccuracyPanel"/>.
/// It reports given top accuracies ranging from 0-100%.
/// </summary>
protected class ChartValidationAccuracyReport : ValidationAccuracyReporter
{
private const string PanelIdentifier = "Panel";
Expand Down
9 changes: 6 additions & 3 deletions Sigma.Core.Monitors.WPF/Panels/Charts/ChartPanel.cs
Expand Up @@ -17,7 +17,7 @@ namespace Sigma.Core.Monitors.WPF.Panels.Charts
public class ChartPanel<TChart, TSeries, TData> : GenericPanel<TChart> where TChart : Chart, new() where TSeries : Series, new()
{
/// <summary>
/// The <see cref="SeriesCollection"/> containing the <see cref="Series"/> (of the type <see cref="TSeries"/>).
/// The <see cref="SeriesCollection"/> containing the <see cref="Series"/> (of the type <see ref="TSeries"/>).
/// </summary>
public SeriesCollection SeriesCollection { get; }

Expand All @@ -41,7 +41,7 @@ public class ChartPanel<TChart, TSeries, TData> : GenericPanel<TChart> where TCh
public Axis AxisY { get; }

/// <summary>
/// The maximum of points visible at once (others get removed). This number is only considered when calling <see cref="Add"/> and <see cref="AddRange"/>.
/// The maximum of points visible at once (others get removed). This number is only considered when calling Add and AddRange.
/// If negative (or zero), all points are displayed.
/// </summary>
public int MaxPoints { get; set; } = -1;
Expand Down Expand Up @@ -199,6 +199,9 @@ private void KeepValuesInRange(ICollection<TData> chartValues)
}
}

/// <summary>
/// Clear all <see cref="ChartValues"/> to be able to "restart" the graph.
/// </summary>
public void Clear()
{
foreach (ChartValues<TData> chartValues in ChartValues)
Expand Down Expand Up @@ -259,7 +262,7 @@ public IEnumerable<TSeries> AddSeriesRange(int amount)
}

/// <summary>
/// Adds a range of series. Fastest if given an <see cref="TSeries"/>[].
/// Adds a range of series. Fastest if given an <see ref="TSeries"/>[].
/// </summary>
/// <param name="series">The series that will be added.</param>
public void AddSeriesRange(IEnumerable<TSeries> series)
Expand Down
27 changes: 20 additions & 7 deletions Sigma.Core.Monitors.WPF/Panels/Charts/TrainerChartPanel.cs
Expand Up @@ -90,17 +90,28 @@ private void Init(ITrainer trainer, VisualValueReporterHook hook)
Trainer.AddHook(hook);
}

/// <summary>
/// The hook reports values to a given <see ref="ChartPanel"/>.
/// </summary>
protected class VisualValueReporterHook : ValueReporterHook
{
// TODO: don't keep reference - use ParameterRegistry
public readonly ChartPanel<TChart, TSeries, TData> ChartPanel;
/// <summary>
/// The identifier for the parameter registry that keeps a reference to the chartpanel
/// </summary>
protected const string ChartPanelIdentifier = "panel";

public VisualValueReporterHook(ChartPanel<TChart, TSeries, TData> chartPanel, string valueIdentifier, ITimeStep timestep) : this(chartPanel, new[] { valueIdentifier }, timestep)
{ }
//public VisualValueReporterHook(ChartPanel<TChart, TSeries, TData> chartPanel, string valueIdentifier, ITimeStep timestep) : this(chartPanel, new[] { valueIdentifier }, timestep)
//{ }

/// <summary>
/// Create a new <see ref="VisualValueReportHook"/> fully prepared to report values.
/// </summary>
/// <param name="chartPanel">The chartpanel to which points will get added.</param>
/// <param name="valueIdentifiers">The identifiers for the <see cref="ValueReporterHook"/>; these values will get plotted.</param>
/// <param name="timestep">The <see cref="TimeStep"/> for the hook (i.e. execution definition).</param>
public VisualValueReporterHook(ChartPanel<TChart, TSeries, TData> chartPanel, string[] valueIdentifiers, ITimeStep timestep) : base(valueIdentifiers, timestep)
{
ChartPanel = chartPanel;
ParameterRegistry[ChartPanelIdentifier] = chartPanel;
}

/// <summary>
Expand All @@ -109,8 +120,10 @@ public VisualValueReporterHook(ChartPanel<TChart, TSeries, TData> chartPanel, st
/// <param name="valuesByIdentifier">The values by their identifier.</param>
protected override void ReportValues(IDictionary<string, object> valuesByIdentifier)
{
ChartPanel.Add((TData) valuesByIdentifier.Values.First());
//TODO: multiple values
ChartPanel<TChart, TSeries, TData> chartPanel = (ChartPanel<TChart, TSeries, TData>) ParameterRegistry[ChartPanelIdentifier];
chartPanel.Add((TData) valuesByIdentifier.Values.First());

//TODO: multiple values (in same series)
//ChartPanel.Dispatcher.InvokeAsync(() => ChartPanel.Series.Values.Add(valuesByIdentifier.Values.First()));
}
}
Expand Down
44 changes: 41 additions & 3 deletions Sigma.Core.Monitors.WPF/Panels/Logging/LogDataGridPanel.cs
Expand Up @@ -9,7 +9,6 @@ MIT License
using System;
using System.ComponentModel;
using System.Windows.Data;
using System.Windows.Threading;
using log4net;
using log4net.Appender;
using log4net.Core;
Expand All @@ -19,14 +18,41 @@ MIT License

namespace Sigma.Core.Monitors.WPF.Panels.Logging
{
/// <summary>
/// A container class for a processed <see cref="LoggingEvent"/>.
/// </summary>
public class LogEntry
{
/// <summary>
/// The date and time when the log occurred.
/// </summary>
public DateTime TimeStamp { get; set; }

/// <summary>
/// The severity of the log (i.e log level).
/// </summary>
public Level Level { get; set; }

/// <summary>
/// The thread in which the event occurred.
/// </summary>
public string Thread { get; set; }

/// <summary>
/// The name of the logger (i.e. class name without namespace).
/// </summary>
public string Logger { get; set; }

/// <summary>
/// The message that was passed to the entry.
/// </summary>
public string Message { get; set; }

/// <summary>
/// Create a <see cref="LogEntry"/> that automatically populates its data from a
/// <see cref="LoggingEvent"/>.
/// </summary>
/// <param name="loggingEvent">The event from which the data is processed.</param>
public LogEntry(LoggingEvent loggingEvent)
{
TimeStamp = loggingEvent.TimeStamp;
Expand All @@ -40,10 +66,19 @@ public LogEntry(LoggingEvent loggingEvent)
}
}

/// <summary>
/// A sophisticated log viewer that visualises the data inside a DataGrid.
/// </summary>
public class LogDataGridPanel : SimpleDataGridPanel<LogEntry>, IAppender
{
private readonly IFilter _logfilter;

/// <summary>
/// Create a <see cref="LogDataGridPanel"/>.
/// </summary>
/// <param name="title">The title of the <see cref="SigmaPanel"/>.</param>
/// <param name="logfilter">The filter that decides whether a log is displayed or not.</param>
/// <param name="content">The content that will be displayed instead of the title if not <c>null</c>.</param>
public LogDataGridPanel(string title, IFilter logfilter = null, object content = null) : base(title, content)
{
_logfilter = logfilter;
Expand All @@ -61,12 +96,15 @@ public LogDataGridPanel(string title, IFilter logfilter = null, object content =
AssignToLog();
}

/// <summary>
/// Assign to the log manager.
/// </summary>
protected virtual void AssignToLog()
{
((Hierarchy) LogManager.GetRepository()).Root.AddAppender(this);
}

public void DoAppend(LoggingEvent loggingEvent)
void IAppender.DoAppend(LoggingEvent loggingEvent)
{
if (_logfilter == null || _logfilter.Decide(loggingEvent) == FilterDecision.Accept)
{
Expand All @@ -81,6 +119,6 @@ private void AddItem(object item)
//Content.ScrollIntoView(item);
}

public void Close() { }
void IAppender.Close() { }
}
}
33 changes: 25 additions & 8 deletions Sigma.Core.Monitors.WPF/Panels/Logging/LogTextPanel.cs
Expand Up @@ -6,6 +6,7 @@ MIT License
For full license see LICENSE in the root directory of this project.
*/

using System;
using System.Windows;
using System.Windows.Controls;
using log4net;
Expand All @@ -15,11 +16,20 @@ MIT License

namespace Sigma.Core.Monitors.WPF.Panels.Logging
{
public class LogTextPanel : SigmaPanel, IAppender
/// <summary>
/// This <see cref="LogTextPanel"/> pastes all new log entries in a <see cref="TextBox"/>.
///
/// For a more sophisticated logger see <see cref="LogDataGridPanel"/>.
/// </summary>
public class LogTextPanel : GenericPanel<TextBox>, IAppender
{
public new TextBox Content;

public LogTextPanel(string title) : base(title)
/// <summary>
/// A panel that displays log entries in a <see cref="TextBox"/>. It will automatically assign
/// to the appender list (i.e. receive logs).
/// </summary>
/// <param name="title"></param>
/// <param name="content"></param>
public LogTextPanel(string title, object content = null) : base(title, content)
{
Content = new TextBox
{
Expand All @@ -28,18 +38,25 @@ public LogTextPanel(string title) : base(title)
AcceptsReturn = true,
Margin = new Thickness(10)
};
base.Content = Content;

((Hierarchy) LogManager.GetRepository()).Root.AddAppender(this);
}

public void Close()
void IAppender.Close()
{
}

public void DoAppend(LoggingEvent loggingEvent)
void IAppender.DoAppend(LoggingEvent loggingEvent)
{
Dispatcher.Invoke(() => Content.AppendText($"{loggingEvent.Level.Name}\t{loggingEvent.MessageObject}\n"));
try
{

Dispatcher.Invoke(() => Content.AppendText($"{loggingEvent.Level.Name}\t{loggingEvent.MessageObject}\n"));
}
catch (Exception)
{
((IAppender) this).Close();
}
}
}
}
11 changes: 11 additions & 0 deletions Sigma.Core.Monitors.WPF/Sigma.Core.Monitors.WPF.csproj
Expand Up @@ -53,6 +53,7 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
<DocumentationFile>bin\x64\Release\Sigma.Core.Monitors.WPF.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'TravisBuild|AnyCPU'">
<OutputPath>bin\TravisBuild\</OutputPath>
Expand All @@ -63,6 +64,16 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NugetBuild|AnyCPU'">
<OutputPath>bin\NugetBuild\</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NugetBuild|x64'">
<OutputPath>bin\x64\NugetBuild\</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dragablz, Version=0.0.3.185, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dragablz.0.0.3.185\lib\net45\Dragablz.dll</HintPath>
Expand Down
50 changes: 50 additions & 0 deletions Sigma.Core.Monitors.WPF/Sigma.Core.Monitors.WPF.nuspec
@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<package>
<metadata>
<id>Sigma.Core.Monitors.WPF</id>
<version>$version$</version>
<title>Sigma.Core.Monitors.WPF</title>
<authors>ThinkingTransistor</authors>
<owners>ThinkingTransistor</owners>
<licenseUrl>https://github.com/ThinkingTransistor/Sigma/blob/master/LICENSE</licenseUrl>
<projectUrl>https://sigma.rocks</projectUrl>
<iconUrl>https://sigma.rocks/logo.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>Rocket powered machine learning. Create, compare, adapt, improve - neural networks at the speed of thought.</description>
<releaseNotes>$summary$</releaseNotes>
<copyright>Copyright 2016-2017 (MIT)</copyright>
<tags>machine-learning neural-network artificial-intelligence artificial-neural-networks framework</tags>

<dependencies>
<dependency id="Sigma.Core" version="0.2" />
<dependency id="Dragablz" version="0.0.3.186" />
<dependency id="LiveCharts.Wpf" version="0.9.3.5" />
<dependency id="MahApps.Metro.Resources" version="0.6.1" />
<dependency id="MaterialDesignThemes.MahApps" version="0.0.10" />
</dependencies>

<frameworkAssemblies>
<frameworkAssembly assemblyName="WindowsBase" />
<frameworkAssembly assemblyName="PresentationFramework" />
<frameworkAssembly assemblyName="PresentationCore" />
<frameworkAssembly assemblyName="System.Xaml" />
</frameworkAssemblies>

<!--references>
<reference file="Sigma.Core.Monitors.WPF.dll" />
<reference file="Sigma.Core" />
</references-->
</metadata>

<files>
<file src="build\Sigma.Core.Monitors.WPF.targets" target="build" />

<!-- Language resources -->
<file src="bin\x64\Release\de-DE\Sigma.Core.Monitors.WPF.resources.dll" target="lib\de-DE" />
<file src="bin\x64\Release\en-GB\Sigma.Core.Monitors.WPF.resources.dll" target="lib\en-GB" />
<file src="bin\x64\Release\en-US\Sigma.Core.Monitors.WPF.resources.dll" target="lib\en-US" />

<!-- TODO: dynamic path-->
<file src="bin\x64\Release\Sigma.Core.Monitors.WPF.XML" target="lib" />
</files>
</package>
Empty file.
6 changes: 5 additions & 1 deletion Sigma.Core.Monitors.WPF/View/Colours/ColourManager.cs
Expand Up @@ -15,7 +15,7 @@ MIT License
using Sigma.Core.Monitors.WPF.Model.UI.Resources;
using Sigma.Core.Monitors.WPF.View.Windows;

namespace Sigma.Core.Monitors.WPF.View.Themes
namespace Sigma.Core.Monitors.WPF.View.Colours
{
/// <summary>
/// This <see cref="IColourManager"/> allows to modify the theme for
Expand Down Expand Up @@ -154,6 +154,10 @@ public ColourManager(Swatch defaultPrimary, Swatch defaultSecondary)
/// </summary>
public string CustomDarkPath { get; set; }

/// <summary>
/// A reference to the root window this ColourManager belongs to.
/// This has to be a <see cref="SigmaWindow"/>.
/// </summary>
public Window Window
{
get { return _sigmaWindow; }
Expand Down

0 comments on commit e0d110d

Please sign in to comment.