-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from InRule/Add_RuleAppMetricsExtension
Add rule app metrics extension
- Loading branch information
Showing
27 changed files
with
2,267 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26430.16 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RuleAppMetrics", "RuleAppMetrics\RuleAppMetrics.csproj", "{61796E87-E095-49B2-9284-361DEEB1644B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{61796E87-E095-49B2-9284-361DEEB1644B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{61796E87-E095-49B2-9284-361DEEB1644B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{61796E87-E095-49B2-9284-361DEEB1644B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{61796E87-E095-49B2-9284-361DEEB1644B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {65432DB5-F456-40A9-AF22-F2EFA4A90184} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
47 changes: 47 additions & 0 deletions
47
RuleAppMetrics/RuleAppMetrics/Controls/BooleanToHiddenConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace InRuleLabs.AuthoringExtensions.RuleAppMetrics.Controls | ||
{ | ||
public class BooleanToHiddenConverter : IValueConverter | ||
{ | ||
public virtual object Convert(object o, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
bool value; | ||
|
||
if (o is bool? || o is bool) | ||
{ | ||
value = (bool)o; | ||
} | ||
else | ||
{ | ||
throw new NotSupportedException("Only bool and nullable bool are supported."); | ||
} | ||
|
||
Visibility trueValue, falseValue; | ||
|
||
if (!(parameter is string && Enum.TryParse((string)parameter, out trueValue))) | ||
{ | ||
trueValue = Visibility.Collapsed; | ||
} | ||
|
||
if (trueValue == Visibility.Collapsed) | ||
{ | ||
falseValue = Visibility.Visible; | ||
} | ||
else | ||
{ | ||
falseValue = Visibility.Collapsed; | ||
} | ||
|
||
return value ? trueValue : falseValue; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
RuleAppMetrics/RuleAppMetrics/Controls/BooleanToVisibilityConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace InRuleLabs.AuthoringExtensions.RuleAppMetrics.Controls | ||
{ | ||
public class BooleanToVisibilityConverter : IValueConverter | ||
{ | ||
public virtual object Convert(object o, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
bool value; | ||
|
||
if (o is bool? || o is bool) | ||
{ | ||
value = (bool)o; | ||
} | ||
else | ||
{ | ||
throw new NotSupportedException("Only bool and nullable bool are supported."); | ||
} | ||
|
||
Visibility trueValue, falseValue; | ||
|
||
if (!(parameter is string && Enum.TryParse((string)parameter, out trueValue))) | ||
{ | ||
trueValue = Visibility.Visible; | ||
} | ||
|
||
if (trueValue == Visibility.Visible) | ||
{ | ||
falseValue = Visibility.Collapsed; | ||
} | ||
else | ||
{ | ||
falseValue = Visibility.Visible; | ||
} | ||
|
||
return value ? trueValue : falseValue; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
RuleAppMetrics/RuleAppMetrics/Controls/DoubleToGridLengthConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace InRuleLabs.AuthoringExtensions.RuleAppMetrics.Controls | ||
{ | ||
public class DoubleToGridLengthConverter : IValueConverter | ||
{ | ||
public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is double) | ||
{ | ||
return new GridLength((double)value, GridUnitType.Pixel); | ||
} | ||
|
||
if (value == null) | ||
{ | ||
return new GridLength(0); | ||
} | ||
|
||
return new GridLength(0); | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} |
Oops, something went wrong.